1 Index: linux-2.6.10/fs/ext3/extents-in-ea.c
2 ===================================================================
3 --- linux-2.6.10.orig/fs/ext3/extents-in-ea.c 2005-03-31 19:41:09.471494208 +0800
4 +++ linux-2.6.10/fs/ext3/extents-in-ea.c 2005-03-31 19:41:09.580477640 +0800
6 #include <linux/quotaops.h>
7 #include <linux/string.h>
8 #include <linux/ext3_extents.h>
9 -#include <linux/ext3_xattr.h>
11 #include <linux/slab.h>
12 #include <asm/uaccess.h>
15 err = ext3_extent_tree_init(handle, &tree);
16 ext3_release_tree_in_ea_desc(&tree);
18 - ext3_journal_stop(handle, inode);
19 + ext3_journal_stop(handle);
24 up(&EXT3_I(inode)->truncate_sem);
25 handle = ext3_journal_start(tree->inode, needed + 10);
27 - down_write(&EXT3_I(inode)->truncate_sem);
28 + down(&EXT3_I(inode)->truncate_sem);
29 return PTR_ERR(handle);
32 if (tgen != EXT_GENERATION(tree)) {
33 /* the tree has changed. so path can be invalid at moment */
34 - ext3_journal_stop(handle, inode);
35 - down_write(&EXT3_I(inode)->truncate_sem);
36 + ext3_journal_stop(handle);
37 + down(&EXT3_I(inode)->truncate_sem);
41 - down_write(&EXT3_I(inode)->truncate_sem);
42 + down(&EXT3_I(inode)->truncate_sem);
44 /* insert new extent */
46 err = ext3_ext_insert_extent(handle, tree, path, newex);
48 - ext3_journal_stop(handle, tree->inode);
49 + ext3_journal_stop(handle);
55 err = ext3_init_tree_in_ea_desc(&tree, inode, name_index, eaname);
57 - down_write(&EXT3_I(inode)->truncate_sem);
58 + down(&EXT3_I(inode)->truncate_sem);
59 err = ext3_ext_walk_space(&tree, from, num,
60 ext3_ext_in_ea_new_extent);
61 ext3_release_tree_in_ea_desc(&tree);
62 - up_write(&EXT3_I(inode)->truncate_sem);
63 + up(&EXT3_I(inode)->truncate_sem);
72 +ext3_ext_store_extent_cb(struct ext3_extents_tree *tree,
73 + struct ext3_ext_path *path,
74 + struct ext3_extent *newex, int exist)
76 + struct ext3_extent_buf *buf = (struct ext3_extent_buf *) tree->private;
79 + return EXT_CONTINUE;
82 + if (buf->cur - buf->buffer + sizeof(*newex) > buf->buflen)
85 + if (!copy_to_user(buf->cur, newex, sizeof(*newex))) {
87 + buf->cur += sizeof(*newex);
92 + return EXT_CONTINUE;
96 +ext3_ext_collect_stats_cb(struct ext3_extents_tree *tree,
97 + struct ext3_ext_path *path,
98 + struct ext3_extent *ex, int exist)
100 + struct ext3_extent_tree_stats *buf =
101 + (struct ext3_extent_tree_stats *) tree->private;
105 + return EXT_CONTINUE;
107 + depth = EXT_DEPTH(tree);
108 + buf->extents_num++;
109 + if (path[depth].p_ext == EXT_FIRST_EXTENT(path[depth].p_hdr))
111 + return EXT_CONTINUE;
114 +struct ea_tree_desc {
119 +int ext3_ext_in_ea_ioctl(struct inode *inode, struct file *filp,
120 + unsigned int cmd, unsigned long arg)
124 + if (cmd == EXT3_IOC_EA_TREE_INIT) {
125 + struct ea_tree_desc desc;
127 + if (copy_from_user(&desc, (void *) arg, sizeof(desc)))
129 + err = ext3_init_tree_in_ea(inode, desc.name_index,
131 + } else if (cmd == EXT3_IOC_GET_EA_EXTENTS) {
132 + struct ext3_extents_tree tree;
133 + struct ext3_extent_buf buf;
134 + struct ea_tree_desc desc;
136 + if (copy_from_user(&buf, (void *) arg, sizeof(buf)))
138 + if (copy_from_user(&desc, buf.cur, sizeof(desc)))
140 + err = ext3_init_tree_in_ea_desc(&tree, inode,
141 + desc.name_index, desc.eaname);
144 + buf.cur = buf.buffer;
146 + tree.private = &buf;
147 + err = ext3_ext_walk_space(&tree, buf.start, EXT_MAX_BLOCK,
148 + ext3_ext_store_extent_cb);
151 + ext3_release_tree_in_ea_desc(&tree);
152 + } else if (cmd == EXT3_IOC_EA_TREE_ALLOCATE) {
153 + struct ext3_extent_buf buf;
154 + struct ea_tree_desc desc;
156 + if (copy_from_user(&buf, (void *) arg, sizeof(buf)))
158 + if (copy_from_user(&desc, buf.cur, sizeof(desc)))
160 + err = ext3_ext_in_ea_alloc_space(inode, desc.name_index,
161 + desc.eaname, buf.start,
163 + } else if (cmd == EXT3_IOC_EA_TREE_REMOVE) {
164 + struct ext3_extent_buf buf;
165 + struct ea_tree_desc desc;
167 + if (copy_from_user(&buf, (void *) arg, sizeof(buf)))
169 + if (copy_from_user(&desc, buf.cur, sizeof(desc)))
171 + err = ext3_ext_in_ea_remove_space(inode, desc.name_index,
172 + desc.eaname, buf.start,
180 Index: linux-2.6.10/fs/ext3/ioctl.c
181 ===================================================================
182 --- linux-2.6.10.orig/fs/ext3/ioctl.c 2005-03-31 19:41:09.365510320 +0800
183 +++ linux-2.6.10/fs/ext3/ioctl.c 2005-03-31 19:41:09.580477640 +0800
185 case EXT3_IOC_GET_TREE_STATS:
186 case EXT3_IOC_GET_TREE_DEPTH:
187 return ext3_ext_ioctl(inode, filp, cmd, arg);
189 + case EXT3_IOC_GET_EA_EXTENTS:
190 + case EXT3_IOC_GET_EA_TREE_DEPTH:
191 + case EXT3_IOC_GET_EA_TREE_STATS:
192 + case EXT3_IOC_EA_TREE_INIT:
193 + case EXT3_IOC_EA_TREE_ALLOCATE:
194 + case EXT3_IOC_EA_TREE_REMOVE:
195 + return ext3_ext_in_ea_ioctl(inode, filp, cmd, arg);
199 Index: linux-2.6.10/include/linux/ext3_fs.h
200 ===================================================================
201 --- linux-2.6.10.orig/include/linux/ext3_fs.h 2005-03-31 19:41:09.366510168 +0800
202 +++ linux-2.6.10/include/linux/ext3_fs.h 2005-03-31 19:43:30.539048680 +0800
204 #define EXT3_IOC_GET_EXTENTS _IOR('f', 10, long)
205 #define EXT3_IOC_GET_TREE_DEPTH _IOR('f', 11, long)
206 #define EXT3_IOC_GET_TREE_STATS _IOR('f', 12, long)
208 +#define EXT3_IOC_GET_EA_EXTENTS _IOR('f', 13, long)
209 +#define EXT3_IOC_GET_EA_TREE_DEPTH _IOR('f', 14, long)
210 +#define EXT3_IOC_GET_EA_TREE_STATS _IOR('f', 15, long)
211 +#define EXT3_IOC_EA_TREE_INIT _IOW('f', 16, long)
212 +#define EXT3_IOC_EA_TREE_ALLOCATE _IOW('f', 17, long)
213 +#define EXT3_IOC_EA_TREE_REMOVE _IOW('f', 18, long)
217 * Structure of an inode on the disk
221 extern int ext3_ioctl (struct inode *, struct file *, unsigned int,
224 +extern int ext3_ext_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
225 + unsigned long arg);
226 +extern int ext3_ext_in_ea_ioctl(struct inode *inode, struct file *filp,
227 + unsigned int cmd, unsigned long arg);
229 extern int ext3_orphan_add(handle_t *, struct inode *);
230 extern int ext3_orphan_del(handle_t *, struct inode *);