Whamcloud - gitweb
- extents patch updated from b1_4:
[fs/lustre-release.git] / lustre / kernel_patches / patches / linux-2.4.18ea-0.8.26.patch
1  fs/ext3/Makefile           |    4 
2  fs/ext3/ext3-exports.c     |   13 
3  fs/ext3/ialloc.c           |    2 
4  fs/ext3/inode.c            |   29 -
5  fs/ext3/namei.c            |   12 
6  fs/ext3/super.c            |   22 
7  fs/ext3/xattr.c            | 1242 +++++++++++++++++++++++++++++++++++++++++++++
8  include/linux/ext3_fs.h    |   46 -
9  include/linux/ext3_jbd.h   |    8 
10  include/linux/ext3_xattr.h |  155 +++++
11  include/linux/xattr.h      |   15 
12  11 files changed, 1496 insertions(+), 52 deletions(-)
13
14 --- linux-2.4.18-p4smp/fs/ext3/ialloc.c~linux-2.4.18ea-0.8.26   2003-07-20 17:12:43.000000000 -0600
15 +++ linux-2.4.18-p4smp-braam/fs/ext3/ialloc.c   2003-07-21 22:49:05.000000000 -0600
16 @@ -17,6 +17,7 @@
17  #include <linux/jbd.h>
18  #include <linux/ext3_fs.h>
19  #include <linux/ext3_jbd.h>
20 +#include <linux/ext3_xattr.h>
21  #include <linux/stat.h>
22  #include <linux/string.h>
23  #include <linux/locks.h>
24 @@ -216,6 +217,7 @@ void ext3_free_inode (handle_t *handle, 
25          * as writing the quota to disk may need the lock as well.
26          */
27         DQUOT_INIT(inode);
28 +       ext3_xattr_drop_inode(handle, inode);
29         DQUOT_FREE_INODE(inode);
30         DQUOT_DROP(inode);
31  
32 --- linux-2.4.18-p4smp/fs/ext3/inode.c~linux-2.4.18ea-0.8.26    2003-07-20 17:12:43.000000000 -0600
33 +++ linux-2.4.18-p4smp-braam/fs/ext3/inode.c    2003-07-21 22:49:05.000000000 -0600
34 @@ -39,6 +39,18 @@
35   */
36  #undef SEARCH_FROM_ZERO
37  
38 +/*
39 + * Test whether an inode is a fast symlink.
40 + */
41 +static inline int ext3_inode_is_fast_symlink(struct inode *inode)
42 +{
43 +       int ea_blocks = EXT3_I(inode)->i_file_acl ?
44 +               (inode->i_sb->s_blocksize >> 9) : 0;
45 +
46 +       return (S_ISLNK(inode->i_mode) &&
47 +               inode->i_blocks - ea_blocks == 0);
48 +}
49 +
50  /* The ext3 forget function must perform a revoke if we are freeing data
51   * which has been journaled.  Metadata (eg. indirect blocks) must be
52   * revoked in all cases. 
53 @@ -48,7 +60,7 @@
54   * still needs to be revoked.
55   */
56  
57 -static int ext3_forget(handle_t *handle, int is_metadata,
58 +int ext3_forget(handle_t *handle, int is_metadata,
59                        struct inode *inode, struct buffer_head *bh,
60                        int blocknr)
61  {
62 @@ -164,9 +176,7 @@ void ext3_delete_inode (struct inode * i
63  {
64         handle_t *handle;
65         
66 -       if (is_bad_inode(inode) ||
67 -           inode->i_ino == EXT3_ACL_IDX_INO ||
68 -           inode->i_ino == EXT3_ACL_DATA_INO)
69 +       if (is_bad_inode(inode))
70                 goto no_delete;
71  
72         lock_kernel();
73 @@ -1877,6 +1887,8 @@ void ext3_truncate(struct inode * inode)
74         if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
75             S_ISLNK(inode->i_mode)))
76                 return;
77 +       if (ext3_inode_is_fast_symlink(inode))
78 +               return;
79         if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
80                 return;
81  
82 @@ -2038,8 +2050,6 @@ int ext3_get_inode_loc (struct inode *in
83         struct ext3_group_desc * gdp;
84                 
85         if ((inode->i_ino != EXT3_ROOT_INO &&
86 -               inode->i_ino != EXT3_ACL_IDX_INO &&
87 -               inode->i_ino != EXT3_ACL_DATA_INO &&
88                 inode->i_ino != EXT3_JOURNAL_INO &&
89                 inode->i_ino < EXT3_FIRST_INO(inode->i_sb)) ||
90                 inode->i_ino > le32_to_cpu(
91 @@ -2166,10 +2176,7 @@ void ext3_read_inode(struct inode * inod
92  
93         brelse (iloc.bh);
94  
95 -       if (inode->i_ino == EXT3_ACL_IDX_INO ||
96 -           inode->i_ino == EXT3_ACL_DATA_INO)
97 -               /* Nothing to do */ ;
98 -       else if (S_ISREG(inode->i_mode)) {
99 +       if (S_ISREG(inode->i_mode)) {
100                 inode->i_op = &ext3_file_inode_operations;
101                 inode->i_fop = &ext3_file_operations;
102                 inode->i_mapping->a_ops = &ext3_aops;
103 @@ -2177,7 +2184,7 @@ void ext3_read_inode(struct inode * inod
104                 inode->i_op = &ext3_dir_inode_operations;
105                 inode->i_fop = &ext3_dir_operations;
106         } else if (S_ISLNK(inode->i_mode)) {
107 -               if (!inode->i_blocks)
108 +               if (ext3_inode_is_fast_symlink(inode))
109                         inode->i_op = &ext3_fast_symlink_inode_operations;
110                 else {
111                         inode->i_op = &page_symlink_inode_operations;
112 --- linux-2.4.18-p4smp/fs/ext3/namei.c~linux-2.4.18ea-0.8.26    2003-07-21 22:29:27.000000000 -0600
113 +++ linux-2.4.18-p4smp-braam/fs/ext3/namei.c    2003-07-21 22:49:05.000000000 -0600
114 @@ -27,6 +27,7 @@
115  #include <linux/sched.h>
116  #include <linux/ext3_fs.h>
117  #include <linux/ext3_jbd.h>
118 +#include <linux/ext3_xattr.h>
119  #include <linux/fcntl.h>
120  #include <linux/stat.h>
121  #include <linux/string.h>
122 @@ -1183,6 +1184,7 @@ static int ext3_add_nondir(handle_t *han
123                 d_instantiate(dentry, inode);
124                 return 0;
125         }
126 +       ext3_xattr_drop_inode(handle, inode);
127         ext3_dec_count(handle, inode);
128         iput(inode);
129         return err;
130 @@ -1268,15 +1270,14 @@ static int ext3_mkdir(struct inode * dir
131         if (IS_SYNC(dir))
132                 handle->h_sync = 1;
133  
134 -       inode = ext3_new_inode (handle, dir, S_IFDIR);
135 +       inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
136         err = PTR_ERR(inode);
137         if (IS_ERR(inode))
138                 goto out_stop;
139  
140         inode->i_op = &ext3_dir_inode_operations;
141         inode->i_fop = &ext3_dir_operations;
142 -       inode->i_size = inode->u.ext3_i.i_disksize = inode->i_sb->s_blocksize;
143 -       inode->i_blocks = 0;    
144 +       inode->i_size = EXT3_I(inode)->i_disksize = inode->i_sb->s_blocksize;
145         dir_block = ext3_bread (handle, inode, 0, 1, &err);
146         if (!dir_block) {
147                 inode->i_nlink--; /* is this nlink == 0? */
148 @@ -1303,9 +1304,6 @@ static int ext3_mkdir(struct inode * dir
149         BUFFER_TRACE(dir_block, "call ext3_journal_dirty_metadata");
150         ext3_journal_dirty_metadata(handle, dir_block);
151         brelse (dir_block);
152 -       inode->i_mode = S_IFDIR | mode;
153 -       if (dir->i_mode & S_ISGID)
154 -               inode->i_mode |= S_ISGID;
155         ext3_mark_inode_dirty(handle, inode);
156         err = ext3_add_entry (handle, dentry, inode);
157         if (err)
158 @@ -1671,7 +1669,7 @@ static int ext3_symlink (struct inode * 
159         if (IS_ERR(inode))
160                 goto out_stop;
161  
162 -       if (l > sizeof (inode->u.ext3_i.i_data)) {
163 +       if (l > sizeof(EXT3_I(inode)->i_data)) {
164                 inode->i_op = &page_symlink_inode_operations;
165                 inode->i_mapping->a_ops = &ext3_aops;
166                 /*
167 --- linux-2.4.18-p4smp/fs/ext3/super.c~linux-2.4.18ea-0.8.26    2003-07-21 22:29:27.000000000 -0600
168 +++ linux-2.4.18-p4smp-braam/fs/ext3/super.c    2003-07-21 22:50:28.000000000 -0600
169 @@ -24,6 +24,7 @@
170  #include <linux/jbd.h>
171  #include <linux/ext3_fs.h>
172  #include <linux/ext3_jbd.h>
173 +#include <linux/ext3_xattr.h>
174  #include <linux/slab.h>
175  #include <linux/init.h>
176  #include <linux/locks.h>
177 @@ -406,6 +407,7 @@ void ext3_put_super (struct super_block 
178         kdev_t j_dev = sbi->s_journal->j_dev;
179         int i;
180  
181 +       ext3_xattr_put_super(sb);
182         journal_destroy(sbi->s_journal);
183         if (!(sb->s_flags & MS_RDONLY)) {
184                 EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER);
185 @@ -1749,17 +1751,27 @@ int ext3_statfs (struct super_block * sb
186  
187  static DECLARE_FSTYPE_DEV(ext3_fs_type, "ext3", ext3_read_super);
188  
189 -static int __init init_ext3_fs(void)
190 +static void exit_ext3_fs(void)
191  {
192 -        return register_filesystem(&ext3_fs_type);
193 +       unregister_filesystem(&ext3_fs_type);
194 +       exit_ext3_xattr_user();
195 +       exit_ext3_xattr();
196  }
197  
198 -static void __exit exit_ext3_fs(void)
199 +static int __init init_ext3_fs(void)
200  {
201 -       unregister_filesystem(&ext3_fs_type);
202 +       int error = init_ext3_xattr();
203 +       if (!error)
204 +               error = init_ext3_xattr_user();
205 +       if (!error)
206 +               error = register_filesystem(&ext3_fs_type);
207 +       if (!error)
208 +               return 0;
209 +
210 +       exit_ext3_fs();
211 +       return error;
212  }
213  
214 -EXPORT_SYMBOL(ext3_bread);
215  
216  MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
217  MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions");
218 --- /dev/null   2003-01-30 03:24:37.000000000 -0700
219 +++ linux-2.4.18-p4smp-braam/fs/ext3/ext3-exports.c     2003-07-21 22:49:05.000000000 -0600
220 @@ -0,0 +1,13 @@
221 +#include <linux/config.h>
222 +#include <linux/module.h>
223 +#include <linux/ext3_fs.h>
224 +#include <linux/ext3_jbd.h>
225 +#include <linux/ext3_xattr.h>
226 +
227 +EXPORT_SYMBOL(ext3_force_commit);
228 +EXPORT_SYMBOL(ext3_bread);
229 +EXPORT_SYMBOL(ext3_xattr_register);
230 +EXPORT_SYMBOL(ext3_xattr_unregister);
231 +EXPORT_SYMBOL(ext3_xattr_get);
232 +EXPORT_SYMBOL(ext3_xattr_list);
233 +EXPORT_SYMBOL(ext3_xattr_set);
234 --- /dev/null   2003-01-30 03:24:37.000000000 -0700
235 +++ linux-2.4.18-p4smp-braam/fs/ext3/xattr.c    2003-07-21 22:50:40.000000000 -0600
236 @@ -0,0 +1,1242 @@
237 +/*
238 + * linux/fs/ext3/xattr.c
239 + *
240 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
241 + *
242 + * Fix by Harrison Xing <harrison@mountainviewdata.com>.
243 + * Ext3 code with a lot of help from Eric Jarman <ejarman@acm.org>.
244 + * Extended attributes for symlinks and special files added per
245 + *  suggestion of Luka Renko <luka.renko@hermes.si>.
246 + */
247 +
248 +/*
249 + * Extended attributes are stored on disk blocks allocated outside of
250 + * any inode. The i_file_acl field is then made to point to this allocated
251 + * block. If all extended attributes of an inode are identical, these
252 + * inodes may share the same extended attribute block. Such situations
253 + * are automatically detected by keeping a cache of recent attribute block
254 + * numbers and hashes over the block's contents in memory.
255 + *
256 + *
257 + * Extended attribute block layout:
258 + *
259 + *   +------------------+
260 + *   | header           |
261 + *   Â¦ entry 1          | |
262 + *   | entry 2          | | growing downwards
263 + *   | entry 3          | v
264 + *   | four null bytes  |
265 + *   | . . .            |
266 + *   | value 1          | ^
267 + *   | value 3          | | growing upwards
268 + *   | value 2          | |
269 + *   +------------------+
270 + *
271 + * The block header is followed by multiple entry descriptors. These entry
272 + * descriptors are variable in size, and alligned to EXT3_XATTR_PAD
273 + * byte boundaries. The entry descriptors are sorted by attribute name,
274 + * so that two extended attribute blocks can be compared efficiently.
275 + *
276 + * Attribute values are aligned to the end of the block, stored in
277 + * no specific order. They are also padded to EXT3_XATTR_PAD byte
278 + * boundaries. No additional gaps are left between them.
279 + *
280 + * Locking strategy
281 + * ----------------
282 + * The VFS already holds the BKL and the inode->i_sem semaphore when any of
283 + * the xattr inode operations are called, so we are guaranteed that only one
284 + * processes accesses extended attributes of an inode at any time.
285 + *
286 + * For writing we also grab the ext3_xattr_sem semaphore. This ensures that
287 + * only a single process is modifying an extended attribute block, even
288 + * if the block is shared among inodes.
289 + *
290 + * Note for porting to 2.5
291 + * -----------------------
292 + * The BKL will no longer be held in the xattr inode operations.
293 + */
294 +
295 +#include <linux/fs.h>
296 +#include <linux/locks.h>
297 +#include <linux/slab.h>
298 +#include <linux/ext3_jbd.h>
299 +#include <linux/ext3_fs.h>
300 +#include <linux/ext3_xattr.h>
301 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
302 +#include <linux/mbcache.h>
303 +#endif
304 +#include <linux/quotaops.h>
305 +#include <asm/semaphore.h>
306 +#include <linux/compatmac.h>
307 +#include <linux/module.h>
308 +
309 +/* These symbols may be needed by a module. */
310 +
311 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
312 +# define mark_buffer_dirty(bh) mark_buffer_dirty(bh, 1)
313 +#endif
314 +
315 +#define HDR(bh) ((struct ext3_xattr_header *)((bh)->b_data))
316 +#define ENTRY(ptr) ((struct ext3_xattr_entry *)(ptr))
317 +#define FIRST_ENTRY(bh) ENTRY(HDR(bh)+1)
318 +#define IS_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)
319 +
320 +#ifdef EXT3_XATTR_DEBUG
321 +# define ea_idebug(inode, f...) do { \
322 +               printk(KERN_DEBUG "inode %s:%ld: ", \
323 +                       kdevname(inode->i_dev), inode->i_ino); \
324 +               printk(f); \
325 +               printk("\n"); \
326 +       } while (0)
327 +# define ea_bdebug(bh, f...) do { \
328 +               printk(KERN_DEBUG "block %s:%ld: ", \
329 +                       kdevname(bh->b_dev), bh->b_blocknr); \
330 +               printk(f); \
331 +               printk("\n"); \
332 +       } while (0)
333 +#else
334 +# define ea_idebug(f...)
335 +# define ea_bdebug(f...)
336 +#endif
337 +
338 +static int ext3_xattr_set2(handle_t *, struct inode *, struct buffer_head *,
339 +                          struct ext3_xattr_header *);
340 +
341 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
342 +
343 +static int ext3_xattr_cache_insert(struct buffer_head *);
344 +static struct buffer_head *ext3_xattr_cache_find(struct inode *,
345 +                                                struct ext3_xattr_header *);
346 +static void ext3_xattr_cache_remove(struct buffer_head *);
347 +static void ext3_xattr_rehash(struct ext3_xattr_header *,
348 +                             struct ext3_xattr_entry *);
349 +
350 +static struct mb_cache *ext3_xattr_cache;
351 +
352 +#else
353 +# define ext3_xattr_cache_insert(bh) 0
354 +# define ext3_xattr_cache_find(inode, header) NULL
355 +# define ext3_xattr_cache_remove(bh) do {} while(0)
356 +# define ext3_xattr_rehash(header, entry) do {} while(0)
357 +#endif
358 +
359 +/*
360 + * If a file system does not share extended attributes among inodes,
361 + * we should not need the ext3_xattr_sem semaphore. However, the
362 + * filesystem may still contain shared blocks, so we always take
363 + * the lock.
364 + */
365 +
366 +DECLARE_MUTEX(ext3_xattr_sem);
367 +
368 +static inline void
369 +ext3_xattr_lock(void)
370 +{
371 +       down(&ext3_xattr_sem);
372 +}
373 +
374 +static inline void
375 +ext3_xattr_unlock(void)
376 +{
377 +       up(&ext3_xattr_sem);
378 +}
379 +
380 +static inline int
381 +ext3_xattr_new_block(handle_t *handle, struct inode *inode,
382 +                    int * errp, int force)
383 +{
384 +       struct super_block *sb = inode->i_sb;
385 +       int goal = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) +
386 +               EXT3_I(inode)->i_block_group * EXT3_BLOCKS_PER_GROUP(sb);
387 +
388 +       /* How can we enforce the allocation? */
389 +       int block = ext3_new_block(handle, inode, goal, 0, 0, errp);
390 +#ifdef OLD_QUOTAS
391 +       if (!*errp)
392 +               inode->i_blocks += inode->i_sb->s_blocksize >> 9;
393 +#endif
394 +       return block;
395 +}
396 +
397 +static inline int
398 +ext3_xattr_quota_alloc(struct inode *inode, int force)
399 +{
400 +       /* How can we enforce the allocation? */
401 +#ifdef OLD_QUOTAS
402 +       int error = DQUOT_ALLOC_BLOCK(inode->i_sb, inode, 1);
403 +       if (!error)
404 +               inode->i_blocks += inode->i_sb->s_blocksize >> 9;
405 +#else
406 +       int error = DQUOT_ALLOC_BLOCK(inode, 1);
407 +#endif
408 +       return error;
409 +}
410 +
411 +#ifdef OLD_QUOTAS
412 +
413 +static inline void
414 +ext3_xattr_quota_free(struct inode *inode)
415 +{
416 +       DQUOT_FREE_BLOCK(inode->i_sb, inode, 1);
417 +       inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
418 +}
419 +
420 +static inline void
421 +ext3_xattr_free_block(handle_t *handle, struct inode * inode,
422 +                     unsigned long block)
423 +{
424 +       ext3_free_blocks(handle, inode, block, 1);
425 +       inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
426 +}
427 +
428 +#else
429 +# define ext3_xattr_quota_free(inode) \
430 +       DQUOT_FREE_BLOCK(inode, 1)
431 +# define ext3_xattr_free_block(handle, inode, block) \
432 +       ext3_free_blocks(handle, inode, block, 1)
433 +#endif
434 +
435 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
436 +
437 +static inline struct buffer_head *
438 +sb_bread(struct super_block *sb, int block)
439 +{
440 +       return bread(sb->s_dev, block, sb->s_blocksize);
441 +}
442 +
443 +static inline struct buffer_head *
444 +sb_getblk(struct super_block *sb, int block)
445 +{
446 +       return getblk(sb->s_dev, block, sb->s_blocksize);
447 +}
448 +
449 +#endif
450 +
451 +struct ext3_xattr_handler *ext3_xattr_handlers[EXT3_XATTR_INDEX_MAX];
452 +rwlock_t ext3_handler_lock = RW_LOCK_UNLOCKED;
453 +
454 +int
455 +ext3_xattr_register(int name_index, struct ext3_xattr_handler *handler)
456 +{
457 +       int error = -EINVAL;
458 +
459 +       if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX) {
460 +               write_lock(&ext3_handler_lock);
461 +               if (!ext3_xattr_handlers[name_index-1]) {
462 +                       ext3_xattr_handlers[name_index-1] = handler;
463 +                       error = 0;
464 +               }
465 +               write_unlock(&ext3_handler_lock);
466 +       }
467 +       return error;
468 +}
469 +
470 +void
471 +ext3_xattr_unregister(int name_index, struct ext3_xattr_handler *handler)
472 +{
473 +       if (name_index > 0 || name_index <= EXT3_XATTR_INDEX_MAX) {
474 +               write_lock(&ext3_handler_lock);
475 +               ext3_xattr_handlers[name_index-1] = NULL;
476 +               write_unlock(&ext3_handler_lock);
477 +       }
478 +}
479 +
480 +static inline const char *
481 +strcmp_prefix(const char *a, const char *a_prefix)
482 +{
483 +       while (*a_prefix && *a == *a_prefix) {
484 +               a++;
485 +               a_prefix++;
486 +       }
487 +       return *a_prefix ? NULL : a;
488 +}
489 +
490 +/*
491 + * Decode the extended attribute name, and translate it into
492 + * the name_index and name suffix.
493 + */
494 +static inline struct ext3_xattr_handler *
495 +ext3_xattr_resolve_name(const char **name)
496 +{
497 +       struct ext3_xattr_handler *handler = NULL;
498 +       int i;
499 +
500 +       if (!*name)
501 +               return NULL;
502 +       read_lock(&ext3_handler_lock);
503 +       for (i=0; i<EXT3_XATTR_INDEX_MAX; i++) {
504 +               if (ext3_xattr_handlers[i]) {
505 +                       const char *n = strcmp_prefix(*name,
506 +                               ext3_xattr_handlers[i]->prefix);
507 +                       if (n) {
508 +                               handler = ext3_xattr_handlers[i];
509 +                               *name = n;
510 +                               break;
511 +                       }
512 +               }
513 +       }
514 +       read_unlock(&ext3_handler_lock);
515 +       return handler;
516 +}
517 +
518 +static inline struct ext3_xattr_handler *
519 +ext3_xattr_handler(int name_index)
520 +{
521 +       struct ext3_xattr_handler *handler = NULL;
522 +       if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX) {
523 +               read_lock(&ext3_handler_lock);
524 +               handler = ext3_xattr_handlers[name_index-1];
525 +               read_unlock(&ext3_handler_lock);
526 +       }
527 +       return handler;
528 +}
529 +
530 +/*
531 + * Inode operation getxattr()
532 + *
533 + * dentry->d_inode->i_sem down
534 + * BKL held [before 2.5.x]
535 + */
536 +ssize_t
537 +ext3_getxattr(struct dentry *dentry, const char *name,
538 +             void *buffer, size_t size)
539 +{
540 +       struct ext3_xattr_handler *handler;
541 +       struct inode *inode = dentry->d_inode;
542 +
543 +       handler = ext3_xattr_resolve_name(&name);
544 +       if (!handler)
545 +               return -ENOTSUP;
546 +       return handler->get(inode, name, buffer, size);
547 +}
548 +
549 +/*
550 + * Inode operation listxattr()
551 + *
552 + * dentry->d_inode->i_sem down
553 + * BKL held [before 2.5.x]
554 + */
555 +ssize_t
556 +ext3_listxattr(struct dentry *dentry, char *buffer, size_t size)
557 +{
558 +       return ext3_xattr_list(dentry->d_inode, buffer, size);
559 +}
560 +
561 +/*
562 + * Inode operation setxattr()
563 + *
564 + * dentry->d_inode->i_sem down
565 + * BKL held [before 2.5.x]
566 + */
567 +int
568 +ext3_setxattr(struct dentry *dentry, const char *name,
569 +             void *value, size_t size, int flags)
570 +{
571 +       struct ext3_xattr_handler *handler;
572 +       struct inode *inode = dentry->d_inode;
573 +
574 +       if (size == 0)
575 +               value = "";  /* empty EA, do not remove */
576 +       handler = ext3_xattr_resolve_name(&name);
577 +       if (!handler)
578 +               return -ENOTSUP;
579 +       return handler->set(inode, name, value, size, flags);
580 +}
581 +
582 +/*
583 + * Inode operation removexattr()
584 + *
585 + * dentry->d_inode->i_sem down
586 + * BKL held [before 2.5.x]
587 + */
588 +int
589 +ext3_removexattr(struct dentry *dentry, const char *name)
590 +{
591 +       struct ext3_xattr_handler *handler;
592 +       struct inode *inode = dentry->d_inode;
593 +
594 +       handler = ext3_xattr_resolve_name(&name);
595 +       if (!handler)
596 +               return -ENOTSUP;
597 +       return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
598 +}
599 +
600 +/*
601 + * ext3_xattr_get()
602 + *
603 + * Copy an extended attribute into the buffer
604 + * provided, or compute the buffer size required.
605 + * Buffer is NULL to compute the size of the buffer required.
606 + *
607 + * Returns a negative error number on failure, or the number of bytes
608 + * used / required on success.
609 + */
610 +int
611 +ext3_xattr_get(struct inode *inode, int name_index, const char *name,
612 +              void *buffer, size_t buffer_size)
613 +{
614 +       struct buffer_head *bh = NULL;
615 +       struct ext3_xattr_entry *entry;
616 +       unsigned int block, size;
617 +       char *end;
618 +       int name_len, error;
619 +
620 +       ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
621 +                 name_index, name, buffer, (long)buffer_size);
622 +
623 +       if (name == NULL)
624 +               return -EINVAL;
625 +       if (!EXT3_I(inode)->i_file_acl)
626 +               return -ENOATTR;
627 +       block = EXT3_I(inode)->i_file_acl;
628 +       ea_idebug(inode, "reading block %d", block);
629 +       bh = sb_bread(inode->i_sb, block);
630 +       if (!bh)
631 +               return -EIO;
632 +       ea_bdebug(bh, "b_count=%d, refcount=%d",
633 +               atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
634 +       end = bh->b_data + bh->b_size;
635 +       if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
636 +           HDR(bh)->h_blocks != cpu_to_le32(1)) {
637 +bad_block:     ext3_error(inode->i_sb, "ext3_xattr_get",
638 +                       "inode %ld: bad block %d", inode->i_ino, block);
639 +               error = -EIO;
640 +               goto cleanup;
641 +       }
642 +       /* find named attribute */
643 +       name_len = strlen(name);
644 +
645 +       error = -ERANGE;
646 +       if (name_len > 255)
647 +               goto cleanup;
648 +       entry = FIRST_ENTRY(bh);
649 +       while (!IS_LAST_ENTRY(entry)) {
650 +               struct ext3_xattr_entry *next =
651 +                       EXT3_XATTR_NEXT(entry);
652 +               if ((char *)next >= end)
653 +                       goto bad_block;
654 +               if (name_index == entry->e_name_index &&
655 +                   name_len == entry->e_name_len &&
656 +                   memcmp(name, entry->e_name, name_len) == 0)
657 +                       goto found;
658 +               entry = next;
659 +       }
660 +       /* Check the remaining name entries */
661 +       while (!IS_LAST_ENTRY(entry)) {
662 +               struct ext3_xattr_entry *next =
663 +                       EXT3_XATTR_NEXT(entry);
664 +               if ((char *)next >= end)
665 +                       goto bad_block;
666 +               entry = next;
667 +       }
668 +       if (ext3_xattr_cache_insert(bh))
669 +               ea_idebug(inode, "cache insert failed");
670 +       error = -ENOATTR;
671 +       goto cleanup;
672 +found:
673 +       /* check the buffer size */
674 +       if (entry->e_value_block != 0)
675 +               goto bad_block;
676 +       size = le32_to_cpu(entry->e_value_size);
677 +       if (size > inode->i_sb->s_blocksize ||
678 +           le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize)
679 +               goto bad_block;
680 +
681 +       if (ext3_xattr_cache_insert(bh))
682 +               ea_idebug(inode, "cache insert failed");
683 +       if (buffer) {
684 +               error = -ERANGE;
685 +               if (size > buffer_size)
686 +                       goto cleanup;
687 +               /* return value of attribute */
688 +               memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs),
689 +                       size);
690 +       }
691 +       error = size;
692 +
693 +cleanup:
694 +       brelse(bh);
695 +
696 +       return error;
697 +}
698 +
699 +/*
700 + * ext3_xattr_list()
701 + *
702 + * Copy a list of attribute names into the buffer
703 + * provided, or compute the buffer size required.
704 + * Buffer is NULL to compute the size of the buffer required.
705 + *
706 + * Returns a negative error number on failure, or the number of bytes
707 + * used / required on success.
708 + */
709 +int
710 +ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
711 +{
712 +       struct buffer_head *bh = NULL;
713 +       struct ext3_xattr_entry *entry;
714 +       unsigned int block, size = 0;
715 +       char *buf, *end;
716 +       int error;
717 +
718 +       ea_idebug(inode, "buffer=%p, buffer_size=%ld",
719 +                 buffer, (long)buffer_size);
720 +
721 +       if (!EXT3_I(inode)->i_file_acl)
722 +               return 0;
723 +       block = EXT3_I(inode)->i_file_acl;
724 +       ea_idebug(inode, "reading block %d", block);
725 +       bh = sb_bread(inode->i_sb, block);
726 +       if (!bh)
727 +               return -EIO;
728 +       ea_bdebug(bh, "b_count=%d, refcount=%d",
729 +               atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
730 +       end = bh->b_data + bh->b_size;
731 +       if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
732 +           HDR(bh)->h_blocks != cpu_to_le32(1)) {
733 +bad_block:     ext3_error(inode->i_sb, "ext3_xattr_list",
734 +                       "inode %ld: bad block %d", inode->i_ino, block);
735 +               error = -EIO;
736 +               goto cleanup;
737 +       }
738 +       /* compute the size required for the list of attribute names */
739 +       for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
740 +            entry = EXT3_XATTR_NEXT(entry)) {
741 +               struct ext3_xattr_handler *handler;
742 +               struct ext3_xattr_entry *next =
743 +                       EXT3_XATTR_NEXT(entry);
744 +               if ((char *)next >= end)
745 +                       goto bad_block;
746 +
747 +               handler = ext3_xattr_handler(entry->e_name_index);
748 +               if (handler) {
749 +                       size += handler->list(NULL, inode, entry->e_name,
750 +                                             entry->e_name_len) + 1;
751 +               }
752 +       }
753 +
754 +       if (ext3_xattr_cache_insert(bh))
755 +               ea_idebug(inode, "cache insert failed");
756 +       if (!buffer) {
757 +               error = size;
758 +               goto cleanup;
759 +       } else {
760 +               error = -ERANGE;
761 +               if (size > buffer_size)
762 +                       goto cleanup;
763 +       }
764 +
765 +       /* list the attribute names */
766 +       buf = buffer;
767 +       for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
768 +            entry = EXT3_XATTR_NEXT(entry)) {
769 +               struct ext3_xattr_handler *handler;
770 +
771 +               handler = ext3_xattr_handler(entry->e_name_index);
772 +               if (handler) {
773 +                       buf += handler->list(buf, inode, entry->e_name,
774 +                                            entry->e_name_len);
775 +                       *buf++ = '\0';
776 +               }
777 +       }
778 +       error = size;
779 +
780 +cleanup:
781 +       brelse(bh);
782 +
783 +       return error;
784 +}
785 +
786 +/*
787 + * If the EXT3_FEATURE_COMPAT_EXT_ATTR feature of this file system is
788 + * not set, set it.
789 + */
790 +static void ext3_xattr_update_super_block(handle_t *handle,
791 +                                         struct super_block *sb)
792 +{
793 +       if (EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_EXT_ATTR))
794 +               return;
795 +
796 +       lock_super(sb);
797 +       ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh);
798 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
799 +       EXT3_SB(sb)->s_feature_compat |= EXT3_FEATURE_COMPAT_EXT_ATTR;
800 +#endif
801 +       EXT3_SB(sb)->s_es->s_feature_compat |=
802 +               cpu_to_le32(EXT3_FEATURE_COMPAT_EXT_ATTR);
803 +       sb->s_dirt = 1;
804 +       ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
805 +       unlock_super(sb);
806 +}
807 +
808 +/*
809 + * ext3_xattr_set()
810 + *
811 + * Create, replace or remove an extended attribute for this inode. Buffer
812 + * is NULL to remove an existing extended attribute, and non-NULL to
813 + * either replace an existing extended attribute, or create a new extended
814 + * attribute. The flags XATTR_REPLACE and XATTR_CREATE
815 + * specify that an extended attribute must exist and must not exist
816 + * previous to the call, respectively.
817 + *
818 + * Returns 0, or a negative error number on failure.
819 + */
820 +int
821 +ext3_xattr_set(handle_t *handle, struct inode *inode, int name_index,
822 +              const char *name, void *value, size_t value_len, int flags)
823 +{
824 +       struct super_block *sb = inode->i_sb;
825 +       struct buffer_head *bh = NULL;
826 +       struct ext3_xattr_header *header = NULL;
827 +       struct ext3_xattr_entry *here, *last;
828 +       unsigned int name_len;
829 +       int min_offs = sb->s_blocksize, not_found = 1, free, error;
830 +       char *end;
831 +       
832 +       /*
833 +        * header -- Points either into bh, or to a temporarily
834 +        *           allocated buffer.
835 +        * here -- The named entry found, or the place for inserting, within
836 +        *         the block pointed to by header.
837 +        * last -- Points right after the last named entry within the block
838 +        *         pointed to by header.
839 +        * min_offs -- The offset of the first value (values are aligned
840 +        *             towards the end of the block).
841 +        * end -- Points right after the block pointed to by header.
842 +        */
843 +       
844 +       ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld",
845 +                 name_index, name, value, (long)value_len);
846 +
847 +       if (IS_RDONLY(inode))
848 +               return -EROFS;
849 +       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
850 +               return -EPERM;
851 +       if (value == NULL)
852 +               value_len = 0;
853 +       if (name == NULL)
854 +               return -EINVAL;
855 +       name_len = strlen(name);
856 +       if (name_len > 255 || value_len > sb->s_blocksize)
857 +               return -ERANGE;
858 +       ext3_xattr_lock();
859 +
860 +       if (EXT3_I(inode)->i_file_acl) {
861 +               /* The inode already has an extended attribute block. */
862 +               int block = EXT3_I(inode)->i_file_acl;
863 +
864 +               bh = sb_bread(sb, block);
865 +               error = -EIO;
866 +               if (!bh)
867 +                       goto cleanup;
868 +               ea_bdebug(bh, "b_count=%d, refcount=%d",
869 +                       atomic_read(&(bh->b_count)),
870 +                       le32_to_cpu(HDR(bh)->h_refcount));
871 +               header = HDR(bh);
872 +               end = bh->b_data + bh->b_size;
873 +               if (header->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
874 +                   header->h_blocks != cpu_to_le32(1)) {
875 +bad_block:             ext3_error(sb, "ext3_xattr_set",
876 +                               "inode %ld: bad block %d", inode->i_ino, block);
877 +                       error = -EIO;
878 +                       goto cleanup;
879 +               }
880 +               /* Find the named attribute. */
881 +               here = FIRST_ENTRY(bh);
882 +               while (!IS_LAST_ENTRY(here)) {
883 +                       struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(here);
884 +                       if ((char *)next >= end)
885 +                               goto bad_block;
886 +                       if (!here->e_value_block && here->e_value_size) {
887 +                               int offs = le16_to_cpu(here->e_value_offs);
888 +                               if (offs < min_offs)
889 +                                       min_offs = offs;
890 +                       }
891 +                       not_found = name_index - here->e_name_index;
892 +                       if (!not_found)
893 +                               not_found = name_len - here->e_name_len;
894 +                       if (!not_found)
895 +                               not_found = memcmp(name, here->e_name,name_len);
896 +                       if (not_found <= 0)
897 +                               break;
898 +                       here = next;
899 +               }
900 +               last = here;
901 +               /* We still need to compute min_offs and last. */
902 +               while (!IS_LAST_ENTRY(last)) {
903 +                       struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(last);
904 +                       if ((char *)next >= end)
905 +                               goto bad_block;
906 +                       if (!last->e_value_block && last->e_value_size) {
907 +                               int offs = le16_to_cpu(last->e_value_offs);
908 +                               if (offs < min_offs)
909 +                                       min_offs = offs;
910 +                       }
911 +                       last = next;
912 +               }
913 +
914 +               /* Check whether we have enough space left. */
915 +               free = min_offs - ((char*)last - (char*)header) - sizeof(__u32);
916 +       } else {
917 +               /* We will use a new extended attribute block. */
918 +               free = sb->s_blocksize -
919 +                       sizeof(struct ext3_xattr_header) - sizeof(__u32);
920 +               here = last = NULL;  /* avoid gcc uninitialized warning. */
921 +       }
922 +
923 +       if (not_found) {
924 +               /* Request to remove a nonexistent attribute? */
925 +               error = -ENOATTR;
926 +               if (flags & XATTR_REPLACE)
927 +                       goto cleanup;
928 +               error = 0;
929 +               if (value == NULL)
930 +                       goto cleanup;
931 +               else
932 +                       free -= EXT3_XATTR_LEN(name_len);
933 +       } else {
934 +               /* Request to create an existing attribute? */
935 +               error = -EEXIST;
936 +               if (flags & XATTR_CREATE)
937 +                       goto cleanup;
938 +               if (!here->e_value_block && here->e_value_size) {
939 +                       unsigned int size = le32_to_cpu(here->e_value_size);
940 +
941 +                       if (le16_to_cpu(here->e_value_offs) + size > 
942 +                           sb->s_blocksize || size > sb->s_blocksize)
943 +                               goto bad_block;
944 +                       free += EXT3_XATTR_SIZE(size);
945 +               }
946 +       }
947 +       free -= EXT3_XATTR_SIZE(value_len);
948 +       error = -ENOSPC;
949 +       if (free < 0)
950 +               goto cleanup;
951 +
952 +       /* Here we know that we can set the new attribute. */
953 +
954 +       if (header) {
955 +               if (header->h_refcount == cpu_to_le32(1)) {
956 +                       ea_bdebug(bh, "modifying in-place");
957 +                       ext3_xattr_cache_remove(bh);
958 +                       error = ext3_journal_get_write_access(handle, bh);
959 +                       if (error)
960 +                               goto cleanup;
961 +               } else {
962 +                       int offset;
963 +
964 +                       ea_bdebug(bh, "cloning");
965 +                       header = kmalloc(bh->b_size, GFP_KERNEL);
966 +                       error = -ENOMEM;
967 +                       if (header == NULL)
968 +                               goto cleanup;
969 +                       memcpy(header, HDR(bh), bh->b_size);
970 +                       header->h_refcount = cpu_to_le32(1);
971 +                       offset = (char *)header - bh->b_data;
972 +                       here = ENTRY((char *)here + offset);
973 +                       last = ENTRY((char *)last + offset);
974 +               }
975 +       } else {
976 +               /* Allocate a buffer where we construct the new block. */
977 +               header = kmalloc(sb->s_blocksize, GFP_KERNEL);
978 +               error = -ENOMEM;
979 +               if (header == NULL)
980 +                       goto cleanup;
981 +               memset(header, 0, sb->s_blocksize);
982 +               end = (char *)header + sb->s_blocksize;
983 +               header->h_magic = cpu_to_le32(EXT3_XATTR_MAGIC);
984 +               header->h_blocks = header->h_refcount = cpu_to_le32(1);
985 +               last = here = ENTRY(header+1);
986 +       }
987 +
988 +       if (not_found) {
989 +               /* Insert the new name. */
990 +               int size = EXT3_XATTR_LEN(name_len);
991 +               int rest = (char *)last - (char *)here;
992 +               memmove((char *)here + size, here, rest);
993 +               memset(here, 0, size);
994 +               here->e_name_index = name_index;
995 +               here->e_name_len = name_len;
996 +               memcpy(here->e_name, name, name_len);
997 +       } else {
998 +               /* Remove the old value. */
999 +               if (!here->e_value_block && here->e_value_size) {
1000 +                       char *first_val = (char *)header + min_offs;
1001 +                       int offs = le16_to_cpu(here->e_value_offs);
1002 +                       char *val = (char *)header + offs;
1003 +                       size_t size = EXT3_XATTR_SIZE(
1004 +                               le32_to_cpu(here->e_value_size));
1005 +                       memmove(first_val + size, first_val, val - first_val);
1006 +                       memset(first_val, 0, size);
1007 +                       here->e_value_offs = 0;
1008 +                       min_offs += size;
1009 +
1010 +                       /* Adjust all value offsets. */
1011 +                       last = ENTRY(header+1);
1012 +                       while (!IS_LAST_ENTRY(last)) {
1013 +                               int o = le16_to_cpu(last->e_value_offs);
1014 +                               if (!last->e_value_block && o < offs)
1015 +                                       last->e_value_offs =
1016 +                                               cpu_to_le16(o + size);
1017 +                               last = EXT3_XATTR_NEXT(last);
1018 +                       }
1019 +               }
1020 +               if (value == NULL) {
1021 +                       /* Remove this attribute. */
1022 +                       if (EXT3_XATTR_NEXT(ENTRY(header+1)) == last) {
1023 +                               /* This block is now empty. */
1024 +                               error = ext3_xattr_set2(handle, inode, bh,NULL);
1025 +                               goto cleanup;
1026 +                       } else {
1027 +                               /* Remove the old name. */
1028 +                               int size = EXT3_XATTR_LEN(name_len);
1029 +                               last = ENTRY((char *)last - size);
1030 +                               memmove(here, (char*)here + size,
1031 +                                       (char*)last - (char*)here);
1032 +                               memset(last, 0, size);
1033 +                       }
1034 +               }
1035 +       }
1036 +
1037 +       if (value != NULL) {
1038 +               /* Insert the new value. */
1039 +               here->e_value_size = cpu_to_le32(value_len);
1040 +               if (value_len) {
1041 +                       size_t size = EXT3_XATTR_SIZE(value_len);
1042 +                       char *val = (char *)header + min_offs - size;
1043 +                       here->e_value_offs =
1044 +                               cpu_to_le16((char *)val - (char *)header);
1045 +                       memset(val + size - EXT3_XATTR_PAD, 0,
1046 +                              EXT3_XATTR_PAD); /* Clear the pad bytes. */
1047 +                       memcpy(val, value, value_len);
1048 +               }
1049 +       }
1050 +       ext3_xattr_rehash(header, here);
1051 +
1052 +       error = ext3_xattr_set2(handle, inode, bh, header);
1053 +
1054 +cleanup:
1055 +       brelse(bh);
1056 +       if (!(bh && header == HDR(bh)))
1057 +               kfree(header);
1058 +       ext3_xattr_unlock();
1059 +
1060 +       return error;
1061 +}
1062 +
1063 +/*
1064 + * Second half of ext3_xattr_set(): Update the file system.
1065 + */
1066 +static int
1067 +ext3_xattr_set2(handle_t *handle, struct inode *inode,
1068 +               struct buffer_head *old_bh, struct ext3_xattr_header *header)
1069 +{
1070 +       struct super_block *sb = inode->i_sb;
1071 +       struct buffer_head *new_bh = NULL;
1072 +       int error;
1073 +
1074 +       if (header) {
1075 +               new_bh = ext3_xattr_cache_find(inode, header);
1076 +               if (new_bh) {
1077 +                       /*
1078 +                        * We found an identical block in the cache.
1079 +                        * The old block will be released after updating
1080 +                        * the inode.
1081 +                        */
1082 +                       ea_bdebug(old_bh, "reusing block %ld",
1083 +                               new_bh->b_blocknr);
1084 +                       
1085 +                       error = -EDQUOT;
1086 +                       if (ext3_xattr_quota_alloc(inode, 1))
1087 +                               goto cleanup;
1088 +                       
1089 +                       error = ext3_journal_get_write_access(handle, new_bh);
1090 +                       if (error)
1091 +                               goto cleanup;
1092 +                       HDR(new_bh)->h_refcount = cpu_to_le32(
1093 +                               le32_to_cpu(HDR(new_bh)->h_refcount) + 1);
1094 +                       ea_bdebug(new_bh, "refcount now=%d",
1095 +                               le32_to_cpu(HDR(new_bh)->h_refcount));
1096 +               } else if (old_bh && header == HDR(old_bh)) {
1097 +                       /* Keep this block. */
1098 +                       new_bh = old_bh;
1099 +                       (void)ext3_xattr_cache_insert(new_bh);
1100 +               } else {
1101 +                       /* We need to allocate a new block */
1102 +                       int force = EXT3_I(inode)->i_file_acl != 0;
1103 +                       int block = ext3_xattr_new_block(handle, inode,
1104 +                                                        &error, force);
1105 +                       if (error)
1106 +                               goto cleanup;
1107 +                       ea_idebug(inode, "creating block %d", block);
1108 +
1109 +                       new_bh = sb_getblk(sb, block);
1110 +                       if (!new_bh) {
1111 +getblk_failed:                 ext3_xattr_free_block(handle, inode, block);
1112 +                               error = -EIO;
1113 +                               goto cleanup;
1114 +                       }
1115 +                       lock_buffer(new_bh);
1116 +                       error = ext3_journal_get_create_access(handle, new_bh);
1117 +                       if (error) {
1118 +                               unlock_buffer(new_bh);
1119 +                               goto getblk_failed;
1120 +                       }
1121 +                       memcpy(new_bh->b_data, header, new_bh->b_size);
1122 +                       mark_buffer_uptodate(new_bh, 1);
1123 +                       unlock_buffer(new_bh);
1124 +                       (void)ext3_xattr_cache_insert(new_bh);
1125 +                       ext3_xattr_update_super_block(handle, sb);
1126 +               }
1127 +               error = ext3_journal_dirty_metadata(handle, new_bh);
1128 +               if (error)
1129 +                       goto cleanup;
1130 +       }
1131 +
1132 +       /* Update the inode. */
1133 +       EXT3_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
1134 +       inode->i_ctime = CURRENT_TIME;
1135 +       ext3_mark_inode_dirty(handle, inode);
1136 +       if (IS_SYNC(inode))
1137 +               handle->h_sync = 1;
1138 +
1139 +       error = 0;
1140 +       if (old_bh && old_bh != new_bh) {
1141 +               /*
1142 +                * If there was an old block, and we are not still using it,
1143 +                * we now release the old block.
1144 +               */
1145 +               unsigned int refcount = le32_to_cpu(HDR(old_bh)->h_refcount);
1146 +
1147 +               error = ext3_journal_get_write_access(handle, old_bh);
1148 +               if (error)
1149 +                       goto cleanup;
1150 +               if (refcount == 1) {
1151 +                       /* Free the old block. */
1152 +                       ea_bdebug(old_bh, "freeing");
1153 +                       ext3_xattr_free_block(handle, inode, old_bh->b_blocknr);
1154 +
1155 +                       /* ext3_forget() calls bforget() for us, but we
1156 +                          let our caller release old_bh, so we need to
1157 +                          duplicate the handle before. */
1158 +                       get_bh(old_bh);
1159 +                       ext3_forget(handle, 1, inode, old_bh,old_bh->b_blocknr);
1160 +               } else {
1161 +                       /* Decrement the refcount only. */
1162 +                       refcount--;
1163 +                       HDR(old_bh)->h_refcount = cpu_to_le32(refcount);
1164 +                       ext3_xattr_quota_free(inode);
1165 +                       ext3_journal_dirty_metadata(handle, old_bh);
1166 +                       ea_bdebug(old_bh, "refcount now=%d", refcount);
1167 +               }
1168 +       }
1169 +
1170 +cleanup:
1171 +       if (old_bh != new_bh)
1172 +               brelse(new_bh);
1173 +
1174 +       return error;
1175 +}
1176 +
1177 +/*
1178 + * ext3_xattr_drop_inode()
1179 + *
1180 + * Free extended attribute resources associated with this inode. This
1181 + * is called immediately before an inode is freed.
1182 + */
1183 +void
1184 +ext3_xattr_drop_inode(handle_t *handle, struct inode *inode)
1185 +{
1186 +       struct buffer_head *bh;
1187 +       unsigned int block = EXT3_I(inode)->i_file_acl;
1188 +
1189 +       if (!block)
1190 +               return;
1191 +       ext3_xattr_lock();
1192 +
1193 +       bh = sb_bread(inode->i_sb, block);
1194 +       if (!bh) {
1195 +               ext3_error(inode->i_sb, "ext3_xattr_drop_inode",
1196 +                       "inode %ld: block %d read error", inode->i_ino, block);
1197 +               goto cleanup;
1198 +       }
1199 +       ea_bdebug(bh, "b_count=%d", atomic_read(&(bh->b_count)));
1200 +       if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
1201 +           HDR(bh)->h_blocks != cpu_to_le32(1)) {
1202 +               ext3_error(inode->i_sb, "ext3_xattr_drop_inode",
1203 +                       "inode %ld: bad block %d", inode->i_ino, block);
1204 +               goto cleanup;
1205 +       }
1206 +       ext3_journal_get_write_access(handle, bh);
1207 +       ea_bdebug(bh, "refcount now=%d", le32_to_cpu(HDR(bh)->h_refcount) - 1);
1208 +       if (HDR(bh)->h_refcount == cpu_to_le32(1)) {
1209 +               ext3_xattr_cache_remove(bh);
1210 +               ext3_xattr_free_block(handle, inode, block);
1211 +               ext3_forget(handle, 1, inode, bh, block);
1212 +               bh = NULL;
1213 +       } else {
1214 +               HDR(bh)->h_refcount = cpu_to_le32(
1215 +                       le32_to_cpu(HDR(bh)->h_refcount) - 1);
1216 +               ext3_journal_dirty_metadata(handle, bh);
1217 +               if (IS_SYNC(inode))
1218 +                       handle->h_sync = 1;
1219 +               ext3_xattr_quota_free(inode);
1220 +       }
1221 +       EXT3_I(inode)->i_file_acl = 0;
1222 +
1223 +cleanup:
1224 +       brelse(bh);
1225 +       ext3_xattr_unlock();
1226 +}
1227 +
1228 +/*
1229 + * ext3_xattr_put_super()
1230 + *
1231 + * This is called when a file system is unmounted.
1232 + */
1233 +void
1234 +ext3_xattr_put_super(struct super_block *sb)
1235 +{
1236 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
1237 +       mb_cache_shrink(ext3_xattr_cache, sb->s_dev);
1238 +#endif
1239 +}
1240 +
1241 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
1242 +
1243 +/*
1244 + * ext3_xattr_cache_insert()
1245 + *
1246 + * Create a new entry in the extended attribute cache, and insert
1247 + * it unless such an entry is already in the cache.
1248 + *
1249 + * Returns 0, or a negative error number on failure.
1250 + */
1251 +static int
1252 +ext3_xattr_cache_insert(struct buffer_head *bh)
1253 +{
1254 +       __u32 hash = le32_to_cpu(HDR(bh)->h_hash);
1255 +       struct mb_cache_entry *ce;
1256 +       int error;
1257 +
1258 +       ce = mb_cache_entry_alloc(ext3_xattr_cache);
1259 +       if (!ce)
1260 +               return -ENOMEM;
1261 +       error = mb_cache_entry_insert(ce, bh->b_dev, bh->b_blocknr, &hash);
1262 +       if (error) {
1263 +               mb_cache_entry_free(ce);
1264 +               if (error == -EBUSY) {
1265 +                       ea_bdebug(bh, "already in cache (%d cache entries)",
1266 +                               atomic_read(&ext3_xattr_cache->c_entry_count));
1267 +                       error = 0;
1268 +               }
1269 +       } else {
1270 +               ea_bdebug(bh, "inserting [%x] (%d cache entries)", (int)hash,
1271 +                         atomic_read(&ext3_xattr_cache->c_entry_count));
1272 +               mb_cache_entry_release(ce);
1273 +       }
1274 +       return error;
1275 +}
1276 +
1277 +/*
1278 + * ext3_xattr_cmp()
1279 + *
1280 + * Compare two extended attribute blocks for equality.
1281 + *
1282 + * Returns 0 if the blocks are equal, 1 if they differ, and
1283 + * a negative error number on errors.
1284 + */
1285 +static int
1286 +ext3_xattr_cmp(struct ext3_xattr_header *header1,
1287 +              struct ext3_xattr_header *header2)
1288 +{
1289 +       struct ext3_xattr_entry *entry1, *entry2;
1290 +
1291 +       entry1 = ENTRY(header1+1);
1292 +       entry2 = ENTRY(header2+1);
1293 +       while (!IS_LAST_ENTRY(entry1)) {
1294 +               if (IS_LAST_ENTRY(entry2))
1295 +                       return 1;
1296 +               if (entry1->e_hash != entry2->e_hash ||
1297 +                   entry1->e_name_len != entry2->e_name_len ||
1298 +                   entry1->e_value_size != entry2->e_value_size ||
1299 +                   memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len))
1300 +                       return 1;
1301 +               if (entry1->e_value_block != 0 || entry2->e_value_block != 0)
1302 +                       return -EIO;
1303 +               if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs),
1304 +                          (char *)header2 + le16_to_cpu(entry2->e_value_offs),
1305 +                          le32_to_cpu(entry1->e_value_size)))
1306 +                       return 1;
1307 +
1308 +               entry1 = EXT3_XATTR_NEXT(entry1);
1309 +               entry2 = EXT3_XATTR_NEXT(entry2);
1310 +       }
1311 +       if (!IS_LAST_ENTRY(entry2))
1312 +               return 1;
1313 +       return 0;
1314 +}
1315 +
1316 +/*
1317 + * ext3_xattr_cache_find()
1318 + *
1319 + * Find an identical extended attribute block.
1320 + *
1321 + * Returns a pointer to the block found, or NULL if such a block was
1322 + * not found or an error occurred.
1323 + */
1324 +static struct buffer_head *
1325 +ext3_xattr_cache_find(struct inode *inode, struct ext3_xattr_header *header)
1326 +{
1327 +       __u32 hash = le32_to_cpu(header->h_hash);
1328 +       struct mb_cache_entry *ce;
1329 +
1330 +       if (!header->h_hash)
1331 +               return NULL;  /* never share */
1332 +       ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
1333 +       ce = mb_cache_entry_find_first(ext3_xattr_cache, 0, inode->i_dev, hash);
1334 +       while (ce) {
1335 +               struct buffer_head *bh = sb_bread(inode->i_sb, ce->e_block);
1336 +
1337 +               if (!bh) {
1338 +                       ext3_error(inode->i_sb, "ext3_xattr_cache_find",
1339 +                               "inode %ld: block %ld read error",
1340 +                               inode->i_ino, ce->e_block);
1341 +               } else if (le32_to_cpu(HDR(bh)->h_refcount) >
1342 +                          EXT3_XATTR_REFCOUNT_MAX) {
1343 +                       ea_idebug(inode, "block %ld refcount %d>%d",ce->e_block,
1344 +                               le32_to_cpu(HDR(bh)->h_refcount),
1345 +                               EXT3_XATTR_REFCOUNT_MAX);
1346 +               } else if (!ext3_xattr_cmp(header, HDR(bh))) {
1347 +                       ea_bdebug(bh, "b_count=%d",atomic_read(&(bh->b_count)));
1348 +                       mb_cache_entry_release(ce);
1349 +                       return bh;
1350 +               }
1351 +               brelse(bh);
1352 +               ce = mb_cache_entry_find_next(ce, 0, inode->i_dev, hash);
1353 +       }
1354 +       return NULL;
1355 +}
1356 +
1357 +/*
1358 + * ext3_xattr_cache_remove()
1359 + *
1360 + * Remove the cache entry of a block from the cache. Called when a
1361 + * block becomes invalid.
1362 + */
1363 +static void
1364 +ext3_xattr_cache_remove(struct buffer_head *bh)
1365 +{
1366 +       struct mb_cache_entry *ce;
1367 +
1368 +       ce = mb_cache_entry_get(ext3_xattr_cache, bh->b_dev, bh->b_blocknr);
1369 +       if (ce) {
1370 +               ea_bdebug(bh, "removing (%d cache entries remaining)",
1371 +                         atomic_read(&ext3_xattr_cache->c_entry_count)-1);
1372 +               mb_cache_entry_free(ce);
1373 +       } else 
1374 +               ea_bdebug(bh, "no cache entry");
1375 +}
1376 +
1377 +#define NAME_HASH_SHIFT 5
1378 +#define VALUE_HASH_SHIFT 16
1379 +
1380 +/*
1381 + * ext3_xattr_hash_entry()
1382 + *
1383 + * Compute the hash of an extended attribute.
1384 + */
1385 +static inline void ext3_xattr_hash_entry(struct ext3_xattr_header *header,
1386 +                                        struct ext3_xattr_entry *entry)
1387 +{
1388 +       __u32 hash = 0;
1389 +       char *name = entry->e_name;
1390 +       int n;
1391 +
1392 +       for (n=0; n < entry->e_name_len; n++) {
1393 +               hash = (hash << NAME_HASH_SHIFT) ^
1394 +                      (hash >> (8*sizeof(hash) - NAME_HASH_SHIFT)) ^
1395 +                      *name++;
1396 +       }
1397 +
1398 +       if (entry->e_value_block == 0 && entry->e_value_size != 0) {
1399 +               __u32 *value = (__u32 *)((char *)header +
1400 +                       le16_to_cpu(entry->e_value_offs));
1401 +               for (n = (le32_to_cpu(entry->e_value_size) +
1402 +                    EXT3_XATTR_ROUND) >> EXT3_XATTR_PAD_BITS; n; n--) {
1403 +                       hash = (hash << VALUE_HASH_SHIFT) ^
1404 +                              (hash >> (8*sizeof(hash) - VALUE_HASH_SHIFT)) ^
1405 +                              le32_to_cpu(*value++);
1406 +               }
1407 +       }
1408 +       entry->e_hash = cpu_to_le32(hash);
1409 +}
1410 +
1411 +#undef NAME_HASH_SHIFT
1412 +#undef VALUE_HASH_SHIFT
1413 +
1414 +#define BLOCK_HASH_SHIFT 16
1415 +
1416 +/*
1417 + * ext3_xattr_rehash()
1418 + *
1419 + * Re-compute the extended attribute hash value after an entry has changed.
1420 + */
1421 +static void ext3_xattr_rehash(struct ext3_xattr_header *header,
1422 +                             struct ext3_xattr_entry *entry)
1423 +{
1424 +       struct ext3_xattr_entry *here;
1425 +       __u32 hash = 0;
1426 +       
1427 +       ext3_xattr_hash_entry(header, entry);
1428 +       here = ENTRY(header+1);
1429 +       while (!IS_LAST_ENTRY(here)) {
1430 +               if (!here->e_hash) {
1431 +                       /* Block is not shared if an entry's hash value == 0 */
1432 +                       hash = 0;
1433 +                       break;
1434 +               }
1435 +               hash = (hash << BLOCK_HASH_SHIFT) ^
1436 +                      (hash >> (8*sizeof(hash) - BLOCK_HASH_SHIFT)) ^
1437 +                      le32_to_cpu(here->e_hash);
1438 +               here = EXT3_XATTR_NEXT(here);
1439 +       }
1440 +       header->h_hash = cpu_to_le32(hash);
1441 +}
1442 +
1443 +#undef BLOCK_HASH_SHIFT
1444 +
1445 +int __init
1446 +init_ext3_xattr(void)
1447 +{
1448 +       ext3_xattr_cache = mb_cache_create("ext3_xattr", NULL,
1449 +               sizeof(struct mb_cache_entry) +
1450 +               sizeof(struct mb_cache_entry_index), 1, 61);
1451 +       if (!ext3_xattr_cache)
1452 +               return -ENOMEM;
1453 +
1454 +       return 0;
1455 +}
1456 +
1457 +void
1458 +exit_ext3_xattr(void)
1459 +{
1460 +       if (ext3_xattr_cache)
1461 +               mb_cache_destroy(ext3_xattr_cache);
1462 +       ext3_xattr_cache = NULL;
1463 +}
1464 +
1465 +#else  /* CONFIG_EXT3_FS_XATTR_SHARING */
1466 +
1467 +int __init
1468 +init_ext3_xattr(void)
1469 +{
1470 +       return 0;
1471 +}
1472 +
1473 +void
1474 +exit_ext3_xattr(void)
1475 +{
1476 +}
1477 +
1478 +#endif  /* CONFIG_EXT3_FS_XATTR_SHARING */
1479 --- linux-2.4.18-p4smp/include/linux/ext3_fs.h~linux-2.4.18ea-0.8.26    2003-07-21 22:29:27.000000000 -0600
1480 +++ linux-2.4.18-p4smp-braam/include/linux/ext3_fs.h    2003-07-21 22:49:05.000000000 -0600
1481 @@ -58,8 +58,6 @@
1482   */
1483  #define        EXT3_BAD_INO             1      /* Bad blocks inode */
1484  #define EXT3_ROOT_INO           2      /* Root inode */
1485 -#define EXT3_ACL_IDX_INO        3      /* ACL inode */
1486 -#define EXT3_ACL_DATA_INO       4      /* ACL inode */
1487  #define EXT3_BOOT_LOADER_INO    5      /* Boot loader inode */
1488  #define EXT3_UNDEL_DIR_INO      6      /* Undelete directory inode */
1489  #define EXT3_RESIZE_INO                 7      /* Reserved group descriptors inode */
1490 @@ -89,7 +87,6 @@
1491  #else
1492  # define EXT3_BLOCK_SIZE(s)            (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size)
1493  #endif
1494 -#define EXT3_ACLE_PER_BLOCK(s)         (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_acl_entry))
1495  #define        EXT3_ADDR_PER_BLOCK(s)          (EXT3_BLOCK_SIZE(s) / sizeof (__u32))
1496  #ifdef __KERNEL__
1497  # define EXT3_BLOCK_SIZE_BITS(s)       ((s)->s_blocksize_bits)
1498 @@ -124,28 +121,6 @@
1499  #endif
1500  
1501  /*
1502 - * ACL structures
1503 - */
1504 -struct ext3_acl_header /* Header of Access Control Lists */
1505 -{
1506 -       __u32   aclh_size;
1507 -       __u32   aclh_file_count;
1508 -       __u32   aclh_acle_count;
1509 -       __u32   aclh_first_acle;
1510 -};
1511 -
1512 -struct ext3_acl_entry  /* Access Control List Entry */
1513 -{
1514 -       __u32   acle_size;
1515 -       __u16   acle_perms;     /* Access permissions */
1516 -       __u16   acle_type;      /* Type of entry */
1517 -       __u16   acle_tag;       /* User or group identity */
1518 -       __u16   acle_pad1;
1519 -       __u32   acle_next;      /* Pointer on next entry for the */
1520 -                                       /* same inode or on next free entry */
1521 -};
1522 -
1523 -/*
1524   * Structure of a blocks group descriptor
1525   */
1526  struct ext3_group_desc
1527 @@ -513,7 +488,7 @@ struct ext3_super_block {
1528  #define EXT3_FEATURE_INCOMPAT_RECOVER          0x0004 /* Needs recovery */
1529  #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV      0x0008 /* Journal device */
1530  
1531 -#define EXT3_FEATURE_COMPAT_SUPP       0
1532 +#define EXT3_FEATURE_COMPAT_SUPP       EXT3_FEATURE_COMPAT_EXT_ATTR
1533  #define EXT3_FEATURE_INCOMPAT_SUPP     (EXT3_FEATURE_INCOMPAT_FILETYPE| \
1534                                          EXT3_FEATURE_INCOMPAT_RECOVER)
1535  #define EXT3_FEATURE_RO_COMPAT_SUPP    (EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
1536 @@ -606,6 +581,24 @@ struct ext3_iloc
1537         unsigned long block_group;
1538  };
1539  
1540 +/* Defined for extended attributes */
1541 +#define CONFIG_EXT3_FS_XATTR y
1542 +#ifndef ENOATTR
1543 +#define ENOATTR ENODATA                /* No such attribute */
1544 +#endif
1545 +#ifndef ENOTSUP
1546 +#define ENOTSUP EOPNOTSUPP     /* Operation not supported */
1547 +#endif
1548 +#ifndef XATTR_NAME_MAX
1549 +#define XATTR_NAME_MAX   255   /* # chars in an extended attribute name */
1550 +#define XATTR_SIZE_MAX 65536   /* size of an extended attribute value (64k) */
1551 +#define XATTR_LIST_MAX 65536   /* size of extended attribute namelist (64k) */
1552 +#endif
1553 +#ifndef XATTR_CREATE
1554 +#define XATTR_CREATE   1       /* set value, fail if attr already exists */
1555 +#define XATTR_REPLACE  2       /* set value, fail if attr does not exist */
1556 +#endif
1557 +
1558  /*
1559   * Function prototypes
1560   */
1561 @@ -647,6 +640,7 @@ extern void ext3_check_inodes_bitmap (st
1562  extern unsigned long ext3_count_free (struct buffer_head *, unsigned);
1563  
1564  /* inode.c */
1565 +extern int ext3_forget(handle_t *, int, struct inode *, struct buffer_head *, int);
1566  extern struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *);
1567  extern struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *);
1568  
1569 --- linux-2.4.18-p4smp/include/linux/ext3_jbd.h~linux-2.4.18ea-0.8.26   2003-07-21 22:29:27.000000000 -0600
1570 +++ linux-2.4.18-p4smp-braam/include/linux/ext3_jbd.h   2003-07-21 22:49:05.000000000 -0600
1571 @@ -30,13 +30,19 @@
1572  
1573  #define EXT3_SINGLEDATA_TRANS_BLOCKS   8
1574  
1575 +/* Extended attributes may touch two data buffers, two bitmap buffers,
1576 + * and two group and summaries. */
1577 +
1578 +#define EXT3_XATTR_TRANS_BLOCKS                8
1579 +
1580  /* Define the minimum size for a transaction which modifies data.  This
1581   * needs to take into account the fact that we may end up modifying two
1582   * quota files too (one for the group, one for the user quota).  The
1583   * superblock only gets updated once, of course, so don't bother
1584   * counting that again for the quota updates. */
1585  
1586 -#define EXT3_DATA_TRANS_BLOCKS         (3 * EXT3_SINGLEDATA_TRANS_BLOCKS - 2)
1587 +#define EXT3_DATA_TRANS_BLOCKS         (3 * EXT3_SINGLEDATA_TRANS_BLOCKS + \
1588 +                                        EXT3_XATTR_TRANS_BLOCKS - 2)
1589  
1590  extern int ext3_writepage_trans_blocks(struct inode *inode);
1591  
1592 --- /dev/null   2003-01-30 03:24:37.000000000 -0700
1593 +++ linux-2.4.18-p4smp-braam/include/linux/ext3_xattr.h 2003-07-21 22:49:05.000000000 -0600
1594 @@ -0,0 +1,155 @@
1595 +/*
1596 +  File: linux/ext3_xattr.h
1597 +
1598 +  On-disk format of extended attributes for the ext3 filesystem.
1599 +
1600 +  (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
1601 +*/
1602 +
1603 +#include <linux/config.h>
1604 +#include <linux/init.h>
1605 +#include <linux/xattr.h>
1606 +
1607 +/* Magic value in attribute blocks */
1608 +#define EXT3_XATTR_MAGIC               0xEA020000
1609 +
1610 +/* Maximum number of references to one attribute block */
1611 +#define EXT3_XATTR_REFCOUNT_MAX                1024
1612 +
1613 +/* Name indexes */
1614 +#define EXT3_XATTR_INDEX_MAX                   10
1615 +#define EXT3_XATTR_INDEX_USER                  1
1616 +
1617 +struct ext3_xattr_header {
1618 +       __u32   h_magic;        /* magic number for identification */
1619 +       __u32   h_refcount;     /* reference count */
1620 +       __u32   h_blocks;       /* number of disk blocks used */
1621 +       __u32   h_hash;         /* hash value of all attributes */
1622 +       __u32   h_reserved[4];  /* zero right now */
1623 +};
1624 +
1625 +struct ext3_xattr_entry {
1626 +       __u8    e_name_len;     /* length of name */
1627 +       __u8    e_name_index;   /* attribute name index */
1628 +       __u16   e_value_offs;   /* offset in disk block of value */
1629 +       __u32   e_value_block;  /* disk block attribute is stored on (n/i) */
1630 +       __u32   e_value_size;   /* size of attribute value */
1631 +       __u32   e_hash;         /* hash value of name and value */
1632 +       char    e_name[0];      /* attribute name */
1633 +};
1634 +
1635 +#define EXT3_XATTR_PAD_BITS            2
1636 +#define EXT3_XATTR_PAD         (1<<EXT3_XATTR_PAD_BITS)
1637 +#define EXT3_XATTR_ROUND               (EXT3_XATTR_PAD-1)
1638 +#define EXT3_XATTR_LEN(name_len) \
1639 +       (((name_len) + EXT3_XATTR_ROUND + \
1640 +       sizeof(struct ext3_xattr_entry)) & ~EXT3_XATTR_ROUND)
1641 +#define EXT3_XATTR_NEXT(entry) \
1642 +       ( (struct ext3_xattr_entry *)( \
1643 +         (char *)(entry) + EXT3_XATTR_LEN((entry)->e_name_len)) )
1644 +#define EXT3_XATTR_SIZE(size) \
1645 +       (((size) + EXT3_XATTR_ROUND) & ~EXT3_XATTR_ROUND)
1646 +
1647 +#ifdef __KERNEL__
1648 +
1649 +# ifdef CONFIG_EXT3_FS_XATTR
1650 +
1651 +struct ext3_xattr_handler {
1652 +       char *prefix;
1653 +       size_t (*list)(char *list, struct inode *inode, const char *name,
1654 +                      int name_len);
1655 +       int (*get)(struct inode *inode, const char *name, void *buffer,
1656 +                  size_t size);
1657 +       int (*set)(struct inode *inode, const char *name, void *buffer,
1658 +                  size_t size, int flags);
1659 +};
1660 +
1661 +extern int ext3_xattr_register(int, struct ext3_xattr_handler *);
1662 +extern void ext3_xattr_unregister(int, struct ext3_xattr_handler *);
1663 +
1664 +extern int ext3_setxattr(struct dentry *, const char *, void *, size_t, int);
1665 +extern ssize_t ext3_getxattr(struct dentry *, const char *, void *, size_t);
1666 +extern ssize_t ext3_listxattr(struct dentry *, char *, size_t);
1667 +extern int ext3_removexattr(struct dentry *, const char *);
1668 +
1669 +extern int ext3_xattr_get(struct inode *, int, const char *, void *, size_t);
1670 +extern int ext3_xattr_list(struct inode *, char *, size_t);
1671 +extern int ext3_xattr_set(handle_t *handle, struct inode *, int, const char *, void *, size_t, int);
1672 +
1673 +extern void ext3_xattr_drop_inode(handle_t *, struct inode *);
1674 +extern void ext3_xattr_put_super(struct super_block *);
1675 +
1676 +extern int init_ext3_xattr(void) __init;
1677 +extern void exit_ext3_xattr(void);
1678 +
1679 +# else  /* CONFIG_EXT3_FS_XATTR */
1680 +#  define ext3_setxattr                NULL
1681 +#  define ext3_getxattr                NULL
1682 +#  define ext3_listxattr       NULL
1683 +#  define ext3_removexattr     NULL
1684 +
1685 +static inline int
1686 +ext3_xattr_get(struct inode *inode, int name_index, const char *name,
1687 +              void *buffer, size_t size, int flags)
1688 +{
1689 +       return -ENOTSUP;
1690 +}
1691 +
1692 +static inline int
1693 +ext3_xattr_list(struct inode *inode, void *buffer, size_t size, int flags)
1694 +{
1695 +       return -ENOTSUP;
1696 +}
1697 +
1698 +static inline int
1699 +ext3_xattr_set(handle_t *handle, struct inode *inode, int name_index,
1700 +              const char *name, void *value, size_t size, int flags)
1701 +{
1702 +       return -ENOTSUP;
1703 +}
1704 +
1705 +static inline void
1706 +ext3_xattr_drop_inode(handle_t *handle, struct inode *inode)
1707 +{
1708 +}
1709 +
1710 +static inline void
1711 +ext3_xattr_put_super(struct super_block *sb)
1712 +{
1713 +}
1714 +
1715 +static inline int
1716 +init_ext3_xattr(void)
1717 +{
1718 +       return 0;
1719 +}
1720 +
1721 +static inline void
1722 +exit_ext3_xattr(void)
1723 +{
1724 +}
1725 +
1726 +# endif  /* CONFIG_EXT3_FS_XATTR */
1727 +
1728 +# ifdef CONFIG_EXT3_FS_XATTR_USER
1729 +
1730 +extern int init_ext3_xattr_user(void) __init;
1731 +extern void exit_ext3_xattr_user(void);
1732 +
1733 +# else  /* CONFIG_EXT3_FS_XATTR_USER */
1734 +
1735 +static inline int
1736 +init_ext3_xattr_user(void)
1737 +{
1738 +       return 0;
1739 +}
1740 +
1741 +static inline void
1742 +exit_ext3_xattr_user(void)
1743 +{
1744 +}
1745 +
1746 +#endif  /* CONFIG_EXT3_FS_XATTR_USER */
1747 +
1748 +#endif  /* __KERNEL__ */
1749 +
1750 --- /dev/null   2003-01-30 03:24:37.000000000 -0700
1751 +++ linux-2.4.18-p4smp-braam/include/linux/xattr.h      2003-07-21 22:49:05.000000000 -0600
1752 @@ -0,0 +1,15 @@
1753 +/*
1754 +  File: linux/xattr.h
1755 +
1756 +  Extended attributes handling.
1757 +
1758 +  Copyright (C) 2001 by Andreas Gruenbacher <a.gruenbacher@computer.org>
1759 +  Copyright (C) 2001 SGI - Silicon Graphics, Inc <linux-xfs@oss.sgi.com>
1760 +*/
1761 +#ifndef _LINUX_XATTR_H
1762 +#define _LINUX_XATTR_H
1763 +
1764 +#define XATTR_CREATE   1       /* set value, fail if attr already exists */
1765 +#define XATTR_REPLACE  2       /* set value, fail if attr does not exist */
1766 +
1767 +#endif /* _LINUX_XATTR_H */
1768 --- linux-2.4.18-p4smp/fs/ext3/Makefile~linux-2.4.18ea-0.8.26   2003-07-21 22:27:37.000000000 -0600
1769 +++ linux-2.4.18-p4smp-braam/fs/ext3/Makefile   2003-07-21 22:51:23.000000000 -0600
1770 @@ -9,10 +9,10 @@
1771  
1772  O_TARGET := ext3.o
1773  
1774 -export-objs := super.o inode.o
1775 +export-objs := ext3-exports.o
1776  
1777  obj-y    := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
1778 -               ioctl.o namei.o super.o symlink.o
1779 +               ioctl.o namei.o super.o symlink.o xattr.o ext3-exports.o
1780  obj-m    := $(O_TARGET)
1781  
1782  include $(TOPDIR)/Rules.make
1783
1784 _