1 Index: linux-2.4.20-8/fs/ext3/super.c
2 ===================================================================
3 --- linux-2.4.20-8.orig/fs/ext3/super.c 2004-01-27 19:34:11.000000000 +0800
4 +++ linux-2.4.20-8/fs/ext3/super.c 2004-01-28 05:57:51.000000000 +0800
6 set_opt (*mount_options, EXTENTS);
7 else if (!strcmp (this_char, "extdebug"))
8 set_opt (*mount_options, EXTDEBUG);
9 + else if (!strcmp (this_char, "extents-ea"))
10 + set_opt (*mount_options, EXTENTS_EA);
11 else if (!strcmp (this_char, "grpid") ||
12 !strcmp (this_char, "bsdgroups"))
13 set_opt (*mount_options, GRPID);
14 Index: linux-2.4.20-8/fs/ext3/ialloc.c
15 ===================================================================
16 --- linux-2.4.20-8.orig/fs/ext3/ialloc.c 2004-01-28 01:02:17.000000000 +0800
17 +++ linux-2.4.20-8/fs/ext3/ialloc.c 2004-01-28 07:56:56.000000000 +0800
19 #include <linux/ext3_fs.h>
20 #include <linux/ext3_jbd.h>
21 #include <linux/ext3_xattr.h>
22 +#include <linux/ext3_extents.h>
23 #include <linux/stat.h>
24 #include <linux/string.h>
25 #include <linux/locks.h>
27 EXT3_I(inode)->i_flags |= EXT3_EXTENTS_FL;
28 ext3_extents_initialize_blockmap(handle, inode);
32 err = ext3_mark_iloc_dirty(handle, inode, &iloc);
36 return ERR_PTR(-EDQUOT);
38 ext3_debug ("allocating inode %lu\n", inode->i_ino);
40 + if (test_opt(sb, EXTENTS_EA)) {
41 + EXT3_I(inode)->i_flags |= EXT3_EXTENTS_EA_FL;
42 + ext3_init_extents_tree_in_ea(handle, inode);
48 Index: linux-2.4.20-8/fs/ext3/extents-in-ea.c
49 ===================================================================
50 --- linux-2.4.20-8.orig/fs/ext3/extents-in-ea.c 2004-01-27 20:21:43.000000000 +0800
51 +++ linux-2.4.20-8/fs/ext3/extents-in-ea.c 2004-01-28 06:05:26.000000000 +0800
53 #include <linux/slab.h>
54 #include <asm/uaccess.h>
56 +#define EXTENTS_EA "sparse_extents"
57 +#define EXTENTS_EA_SIZE 64
58 static int ext3_get_ea_write_access(handle_t *handle, void *buffer)
60 struct buffer_head *bh = (struct buffer_head *) buffer;
66 int ext3_init_tree_in_ea(struct inode *inode, int name_index,
67 const char *eaname, int size)
74 +int ext3_init_extents_tree_in_ea(handle_t *handle, struct inode *inode)
76 + return ext3_init_tree_in_ea(inode, EXT3_XATTR_INDEX_EXTENTS,
77 + EXTENTS_EA, EXTENTS_EA_SIZE);
79 +int ext3_insert_extents_in_ea(handle_t *handle, struct inode *inode,
80 + unsigned long from, unsigned long num)
82 + return ext3_ext_in_ea_alloc_space(inode, EXT3_XATTR_INDEX_EXTENTS,
83 + EXTENTS_EA, from, num);
85 +int ext3_remove_extents_in_ea(handle_t *handle, struct inode *inode,
86 + unsigned long from, unsigned long num)
88 + return ext3_ext_in_ea_remove_space(inode, EXT3_XATTR_INDEX_EXTENTS,
89 + EXTENTS_EA, from, num);
94 Index: linux-2.4.20-8/fs/ext3/inode.c
95 ===================================================================
96 --- linux-2.4.20-8.orig/fs/ext3/inode.c 2004-01-27 19:34:11.000000000 +0800
97 +++ linux-2.4.20-8/fs/ext3/inode.c 2004-01-28 06:03:46.000000000 +0800
99 #include <linux/quotaops.h>
100 #include <linux/module.h>
103 +#include <linux/ext3_extents.h>
105 * SEARCH_FROM_ZERO forces each block allocation to search from the start
106 * of the filesystem. This is to force rapid reallocation of recently-freed
108 ext3_get_block_wrap(handle_t *handle, struct inode *inode, long block,
109 struct buffer_head *bh, int create)
111 + int rc1 = 0, rc2 = 0;
113 if (EXT3_I(inode)->i_flags & EXT3_EXTENTS_FL)
114 - return ext3_ext_get_block(handle, inode, block, bh, create);
115 - return ext3_get_block_handle(handle, inode, block, bh, create);
116 + rc1 = ext3_ext_get_block(handle, inode, block, bh, create);
117 + rc1 = ext3_get_block_handle(handle, inode, block, bh, create);
118 + if (EXT3_I(inode)->i_flags & EXT3_EXTENTS_EA_FL) {
120 + rc2 = ext3_insert_extents_in_ea(handle, inode, block, 1);
128 @@ -1897,6 +1906,11 @@
130 ext3_discard_prealloc(inode);
132 + if (EXT3_I(inode)->i_flags & EXT3_EXTENTS_EA_FL) {
133 + last_block = (inode->i_size + inode->i_sb->s_blocksize - 1)
134 + >> EXT3_BLOCK_SIZE_BITS(inode->i_sb);
135 + ext3_remove_extents_in_ea(NULL, inode, last_block, 0xffffffff);
137 if (EXT3_I(inode)->i_flags & EXT3_EXTENTS_FL)
138 return ext3_ext_truncate(inode);
140 Index: linux-2.4.20-8/include/linux/ext3_fs.h
141 ===================================================================
142 --- linux-2.4.20-8.orig/include/linux/ext3_fs.h 2004-01-27 20:21:43.000000000 +0800
143 +++ linux-2.4.20-8/include/linux/ext3_fs.h 2004-01-28 05:57:51.000000000 +0800
145 #define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
146 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
147 #define EXT3_EXTENTS_FL 0x00080000 /* Inode uses extents */
148 +#define EXT3_EXTENTS_EA_FL 0x00100000 /* Inode uses extents */
150 #define EXT3_FL_USER_VISIBLE 0x00005FFF /* User visible flags */
151 #define EXT3_FL_USER_MODIFIABLE 0x000000FF /* User modifiable flags */
153 #define EXT3_MOUNT_ASYNCDEL 0x20000 /* Delayed deletion */
154 #define EXT3_MOUNT_EXTENTS 0x100000/* Extents support */
155 #define EXT3_MOUNT_EXTDEBUG 0x200000/* Extents debug */
156 +#define EXT3_MOUNT_EXTENTS_EA 0x400000/* record sparse Extents */
158 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
159 #ifndef _LINUX_EXT2_FS_H
160 Index: linux-2.4.20-8/include/linux/ext3_xattr.h
161 ===================================================================
162 --- linux-2.4.20-8.orig/include/linux/ext3_xattr.h 2004-01-27 20:21:42.000000000 +0800
163 +++ linux-2.4.20-8/include/linux/ext3_xattr.h 2004-01-28 05:57:51.000000000 +0800
165 #define EXT3_XATTR_INDEX_TRUSTED 4
166 #define EXT3_XATTR_INDEX_LUSTRE 5
167 #define EXT3_XATTR_INDEX_SECURITY 6
168 +#define EXT3_XATTR_INDEX_EXTENTS 7
170 struct ext3_xattr_header {
171 __u32 h_magic; /* magic number for identification */
172 Index: linux-2.4.20-8/include/linux/ext3_extents.h
173 ===================================================================
174 --- linux-2.4.20-8.orig/include/linux/ext3_extents.h 2004-01-28 05:56:02.000000000 +0800
175 +++ linux-2.4.20-8/include/linux/ext3_extents.h 2004-01-28 06:46:15.000000000 +0800
177 extern struct ext3_ext_path * ext3_ext_find_extent(struct ext3_extents_tree *, int, struct ext3_ext_path *);
179 extern int ext3_insert_extents_in_ea(handle_t *handle, struct inode *inode, unsigned long from, unsigned long num);
180 +extern int ext3_remove_extents_in_ea(handle_t *handle, struct inode *inode, unsigned long from, unsigned long num);
181 +extern int ext3_init_extents_tree_in_ea(handle_t *handle, struct inode *inode);
182 #endif /* _LINUX_EXT3_EXTENTS */