1 Documentation/Configure.help | 66 ++
2 arch/alpha/defconfig | 7
3 arch/alpha/kernel/entry.S | 12
5 arch/arm/kernel/calls.S | 24
6 arch/i386/defconfig | 7
7 arch/ia64/defconfig | 7
8 arch/ia64/kernel/entry.S | 24
9 arch/m68k/defconfig | 7
10 arch/mips/defconfig | 7
11 arch/mips64/defconfig | 7
12 arch/ppc/defconfig | 14
13 arch/ppc64/kernel/misc.S | 2
14 arch/s390/defconfig | 7
15 arch/s390/kernel/entry.S | 24
16 arch/s390x/defconfig | 7
17 arch/s390x/kernel/entry.S | 24
18 arch/s390x/kernel/wrapper32.S | 92 +++
19 arch/sparc/defconfig | 7
20 arch/sparc/kernel/systbls.S | 10
21 arch/sparc64/defconfig | 7
22 arch/sparc64/kernel/systbls.S | 20
28 fs/ext2/inode.c | 34 -
31 fs/ext2/symlink.c | 14
32 fs/ext2/xattr.c | 1212 +++++++++++++++++++++++++++++++++++++++++
33 fs/ext2/xattr_user.c | 103 +++
37 fs/ext3/inode.c | 35 -
39 fs/ext3/super.c | 36 +
40 fs/ext3/symlink.c | 14
41 fs/ext3/xattr.c | 1225 ++++++++++++++++++++++++++++++++++++++++++
42 fs/ext3/xattr_user.c | 111 +++
43 fs/jfs/jfs_xattr.h | 6
45 fs/mbcache.c | 648 ++++++++++++++++++++++
46 include/asm-arm/unistd.h | 2
47 include/asm-ia64/unistd.h | 13
48 include/asm-ppc64/unistd.h | 2
49 include/asm-s390/unistd.h | 15
50 include/asm-s390x/unistd.h | 15
51 include/asm-sparc/unistd.h | 24
52 include/asm-sparc64/unistd.h | 24
53 include/linux/cache_def.h | 15
54 include/linux/errno.h | 4
55 include/linux/ext2_fs.h | 31 -
56 include/linux/ext2_xattr.h | 157 +++++
57 include/linux/ext3_fs.h | 31 -
58 include/linux/ext3_jbd.h | 8
59 include/linux/ext3_xattr.h | 157 +++++
60 include/linux/fs.h | 2
61 include/linux/mbcache.h | 69 ++
64 fs/ext3/ext3-exports.c | 14 +
65 64 files changed, 4355 insertions(+), 195 deletions(-)
67 --- linux-2.4.20/Documentation/Configure.help~linux-2.4.20-xattr-0.8.54 2003-05-05 17:43:06.000000000 +0800
68 +++ linux-2.4.20-root/Documentation/Configure.help 2003-05-07 18:08:03.000000000 +0800
69 @@ -15242,6 +15242,39 @@ CONFIG_EXT2_FS
70 be compiled as a module, and so this could be dangerous. Most
71 everyone wants to say Y here.
73 +Ext2 extended attributes
75 + Extended attributes are name:value pairs associated with inodes by
76 + the kernel or by users (see the attr(5) manual page, or visit
77 + <http://acl.bestbits.at/> for details).
81 +Ext2 extended attribute block sharing
82 +CONFIG_EXT2_FS_XATTR_SHARING
83 + This options enables code for sharing identical extended attribute
84 + blocks among multiple inodes.
88 +Ext2 extended user attributes
89 +CONFIG_EXT2_FS_XATTR_USER
90 + This option enables extended user attributes on ext2. Processes can
91 + associate extended user attributes with inodes to store additional
92 + information such as the character encoding of files, etc. (see the
93 + attr(5) manual page, or visit <http://acl.bestbits.at/> for details).
97 +Ext2 trusted extended attributes
98 +CONFIG_EXT2_FS_XATTR_TRUSTED
99 + This option enables extended attributes on ext2 that are accessible
100 + (and visible) only to users capable of CAP_SYS_ADMIN. Usually this
101 + is only the super user. Trusted extended attributes are meant for
102 + implementing system/security services.
106 Ext3 journalling file system support (EXPERIMENTAL)
108 This is the journalling version of the Second extended file system
109 @@ -15274,6 +15307,39 @@ CONFIG_EXT3_FS
110 of your root partition (the one containing the directory /) cannot
111 be compiled as a module, and so this may be dangerous.
113 +Ext3 extended attributes
114 +CONFIG_EXT3_FS_XATTR
115 + Extended attributes are name:value pairs associated with inodes by
116 + the kernel or by users (see the attr(5) manual page, or visit
117 + <http://acl.bestbits.at/> for details).
121 +Ext3 extended attribute block sharing
122 +CONFIG_EXT3_FS_XATTR_SHARING
123 + This options enables code for sharing identical extended attribute
124 + blocks among multiple inodes.
128 +Ext3 extended user attributes
129 +CONFIG_EXT3_FS_XATTR_USER
130 + This option enables extended user attributes on ext3. Processes can
131 + associate extended user attributes with inodes to store additional
132 + information such as the character encoding of files, etc. (see the
133 + attr(5) manual page, or visit <http://acl.bestbits.at/> for details).
137 +Ext3 trusted extended attributes
138 +CONFIG_EXT3_FS_XATTR_TRUSTED
139 + This option enables extended attributes on ext3 that are accessible
140 + (and visible) only to users capable of CAP_SYS_ADMIN. Usually this
141 + is only the super user. Trusted extended attributes are meant for
142 + implementing system/security services.
146 Journal Block Device support (JBD for ext3) (EXPERIMENTAL)
148 This is a generic journalling layer for block devices. It is
149 --- linux-2.4.20/arch/alpha/defconfig~linux-2.4.20-xattr-0.8.54 2001-11-20 07:19:42.000000000 +0800
150 +++ linux-2.4.20-root/arch/alpha/defconfig 2003-05-07 18:08:03.000000000 +0800
153 # Automatically generated make config: don't edit
155 +CONFIG_EXT3_FS_XATTR=y
156 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
157 +# CONFIG_EXT3_FS_XATTR_USER is not set
158 +# CONFIG_EXT2_FS_XATTR is not set
159 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
160 +# CONFIG_EXT2_FS_XATTR_USER is not set
161 +# CONFIG_FS_MBCACHE is not set
163 # CONFIG_UID16 is not set
164 # CONFIG_RWSEM_GENERIC_SPINLOCK is not set
165 --- linux-2.4.20/arch/alpha/kernel/entry.S~linux-2.4.20-xattr-0.8.54 2002-08-03 08:39:42.000000000 +0800
166 +++ linux-2.4.20-root/arch/alpha/kernel/entry.S 2003-05-07 18:08:03.000000000 +0800
167 @@ -1154,6 +1154,18 @@ sys_call_table:
169 .quad sys_ni_syscall /* 380, sys_security */
172 + .quad sys_lsetxattr
173 + .quad sys_fsetxattr
174 + .quad sys_getxattr /* 385 */
175 + .quad sys_lgetxattr
176 + .quad sys_fgetxattr
177 + .quad sys_listxattr
178 + .quad sys_llistxattr
179 + .quad sys_flistxattr /* 390 */
180 + .quad sys_removexattr
181 + .quad sys_lremovexattr
182 + .quad sys_fremovexattr
184 /* Remember to update everything, kids. */
185 .ifne (. - sys_call_table) - (NR_SYSCALLS * 8)
186 --- linux-2.4.20/arch/arm/defconfig~linux-2.4.20-xattr-0.8.54 2001-05-20 08:43:05.000000000 +0800
187 +++ linux-2.4.20-root/arch/arm/defconfig 2003-05-07 18:08:03.000000000 +0800
190 # Automatically generated make config: don't edit
192 +CONFIG_EXT3_FS_XATTR=y
193 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
194 +# CONFIG_EXT3_FS_XATTR_USER is not set
195 +# CONFIG_EXT2_FS_XATTR is not set
196 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
197 +# CONFIG_EXT2_FS_XATTR_USER is not set
198 +# CONFIG_FS_MBCACHE is not set
200 # CONFIG_EISA is not set
201 # CONFIG_SBUS is not set
202 --- linux-2.4.20/arch/arm/kernel/calls.S~linux-2.4.20-xattr-0.8.54 2002-08-03 08:39:42.000000000 +0800
203 +++ linux-2.4.20-root/arch/arm/kernel/calls.S 2003-05-07 18:08:03.000000000 +0800
204 @@ -240,18 +240,18 @@ __syscall_start:
205 .long SYMBOL_NAME(sys_ni_syscall) /* Security */
206 .long SYMBOL_NAME(sys_gettid)
207 /* 225 */ .long SYMBOL_NAME(sys_readahead)
208 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_setxattr */
209 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_lsetxattr */
210 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_fsetxattr */
211 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_getxattr */
212 -/* 230 */ .long SYMBOL_NAME(sys_ni_syscall) /* sys_lgetxattr */
213 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_fgetxattr */
214 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_listxattr */
215 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_llistxattr */
216 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_flistxattr */
217 -/* 235 */ .long SYMBOL_NAME(sys_ni_syscall) /* sys_removexattr */
218 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_lremovexattr */
219 - .long SYMBOL_NAME(sys_ni_syscall) /* sys_fremovexattr */
220 + .long SYMBOL_NAME(sys_setxattr)
221 + .long SYMBOL_NAME(sys_lsetxattr)
222 + .long SYMBOL_NAME(sys_fsetxattr)
223 + .long SYMBOL_NAME(sys_getxattr)
224 +/* 230 */ .long SYMBOL_NAME(sys_lgetxattr)
225 + .long SYMBOL_NAME(sys_fgetxattr)
226 + .long SYMBOL_NAME(sys_listxattr)
227 + .long SYMBOL_NAME(sys_llistxattr)
228 + .long SYMBOL_NAME(sys_flistxattr)
229 +/* 235 */ .long SYMBOL_NAME(sys_removexattr)
230 + .long SYMBOL_NAME(sys_lremovexattr)
231 + .long SYMBOL_NAME(sys_fremovexattr)
232 .long SYMBOL_NAME(sys_tkill)
234 * Please check 2.5 _before_ adding calls here,
235 --- linux-2.4.20/arch/i386/defconfig~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:09.000000000 +0800
236 +++ linux-2.4.20-root/arch/i386/defconfig 2003-05-07 18:08:03.000000000 +0800
239 # Automatically generated make config: don't edit
241 +CONFIG_EXT3_FS_XATTR=y
242 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
243 +# CONFIG_EXT3_FS_XATTR_USER is not set
244 +# CONFIG_EXT2_FS_XATTR is not set
245 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
246 +# CONFIG_EXT2_FS_XATTR_USER is not set
247 +# CONFIG_FS_MBCACHE is not set
250 # CONFIG_SBUS is not set
251 --- linux-2.4.20/arch/ia64/defconfig~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:09.000000000 +0800
252 +++ linux-2.4.20-root/arch/ia64/defconfig 2003-05-07 18:08:03.000000000 +0800
255 # Automatically generated make config: don't edit
257 +CONFIG_EXT3_FS_XATTR=y
258 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
259 +# CONFIG_EXT3_FS_XATTR_USER is not set
260 +# CONFIG_EXT2_FS_XATTR is not set
261 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
262 +# CONFIG_EXT2_FS_XATTR_USER is not set
263 +# CONFIG_FS_MBCACHE is not set
266 # Code maturity level options
267 --- linux-2.4.20/arch/m68k/defconfig~linux-2.4.20-xattr-0.8.54 2000-06-20 03:56:08.000000000 +0800
268 +++ linux-2.4.20-root/arch/m68k/defconfig 2003-05-07 18:08:03.000000000 +0800
271 # Automatically generated make config: don't edit
273 +CONFIG_EXT3_FS_XATTR=y
274 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
275 +# CONFIG_EXT3_FS_XATTR_USER is not set
276 +# CONFIG_EXT2_FS_XATTR is not set
277 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
278 +# CONFIG_EXT2_FS_XATTR_USER is not set
279 +# CONFIG_FS_MBCACHE is not set
283 --- linux-2.4.20/arch/mips/defconfig~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:10.000000000 +0800
284 +++ linux-2.4.20-root/arch/mips/defconfig 2003-05-07 18:08:03.000000000 +0800
287 # Automatically generated make config: don't edit
289 +CONFIG_EXT3_FS_XATTR=y
290 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
291 +# CONFIG_EXT3_FS_XATTR_USER is not set
292 +# CONFIG_EXT2_FS_XATTR is not set
293 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
294 +# CONFIG_EXT2_FS_XATTR_USER is not set
295 +# CONFIG_FS_MBCACHE is not set
298 # CONFIG_MIPS64 is not set
299 --- linux-2.4.20/arch/mips64/defconfig~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:10.000000000 +0800
300 +++ linux-2.4.20-root/arch/mips64/defconfig 2003-05-07 18:08:03.000000000 +0800
303 # Automatically generated make config: don't edit
305 +CONFIG_EXT3_FS_XATTR=y
306 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
307 +# CONFIG_EXT3_FS_XATTR_USER is not set
308 +# CONFIG_EXT2_FS_XATTR is not set
309 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
310 +# CONFIG_EXT2_FS_XATTR_USER is not set
311 +# CONFIG_FS_MBCACHE is not set
313 # CONFIG_MIPS32 is not set
315 --- linux-2.4.20/arch/s390/defconfig~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:11.000000000 +0800
316 +++ linux-2.4.20-root/arch/s390/defconfig 2003-05-07 18:08:03.000000000 +0800
319 # Automatically generated make config: don't edit
321 +CONFIG_EXT3_FS_XATTR=y
322 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
323 +# CONFIG_EXT3_FS_XATTR_USER is not set
324 +# CONFIG_EXT2_FS_XATTR is not set
325 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
326 +# CONFIG_EXT2_FS_XATTR_USER is not set
327 +# CONFIG_FS_MBCACHE is not set
328 # CONFIG_ISA is not set
329 # CONFIG_EISA is not set
330 # CONFIG_MCA is not set
331 --- linux-2.4.20/arch/s390/kernel/entry.S~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:11.000000000 +0800
332 +++ linux-2.4.20-root/arch/s390/kernel/entry.S 2003-05-07 18:08:03.000000000 +0800
333 @@ -558,18 +558,18 @@ sys_call_table:
337 - .long sys_ni_syscall /* 224 - reserved for setxattr */
338 - .long sys_ni_syscall /* 225 - reserved for lsetxattr */
339 - .long sys_ni_syscall /* 226 - reserved for fsetxattr */
340 - .long sys_ni_syscall /* 227 - reserved for getxattr */
341 - .long sys_ni_syscall /* 228 - reserved for lgetxattr */
342 - .long sys_ni_syscall /* 229 - reserved for fgetxattr */
343 - .long sys_ni_syscall /* 230 - reserved for listxattr */
344 - .long sys_ni_syscall /* 231 - reserved for llistxattr */
345 - .long sys_ni_syscall /* 232 - reserved for flistxattr */
346 - .long sys_ni_syscall /* 233 - reserved for removexattr */
347 - .long sys_ni_syscall /* 234 - reserved for lremovexattr */
348 - .long sys_ni_syscall /* 235 - reserved for fremovexattr */
350 + .long sys_lsetxattr /* 225 */
351 + .long sys_fsetxattr
353 + .long sys_lgetxattr
354 + .long sys_fgetxattr
355 + .long sys_listxattr /* 230 */
356 + .long sys_llistxattr
357 + .long sys_flistxattr
358 + .long sys_removexattr
359 + .long sys_lremovexattr
360 + .long sys_fremovexattr /* 235 */
364 --- linux-2.4.20/arch/s390x/defconfig~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:11.000000000 +0800
365 +++ linux-2.4.20-root/arch/s390x/defconfig 2003-05-07 18:08:03.000000000 +0800
368 # Automatically generated make config: don't edit
370 +CONFIG_EXT3_FS_XATTR=y
371 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
372 +# CONFIG_EXT3_FS_XATTR_USER is not set
373 +# CONFIG_EXT2_FS_XATTR is not set
374 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
375 +# CONFIG_EXT2_FS_XATTR_USER is not set
376 +# CONFIG_FS_MBCACHE is not set
377 # CONFIG_ISA is not set
378 # CONFIG_EISA is not set
379 # CONFIG_MCA is not set
380 --- linux-2.4.20/arch/s390x/kernel/entry.S~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:11.000000000 +0800
381 +++ linux-2.4.20-root/arch/s390x/kernel/entry.S 2003-05-07 18:08:03.000000000 +0800
382 @@ -591,18 +591,18 @@ sys_call_table:
383 .long SYSCALL(sys_ni_syscall,sys32_fcntl64_wrapper)
384 .long SYSCALL(sys_ni_syscall,sys_ni_syscall)
385 .long SYSCALL(sys_ni_syscall,sys_ni_syscall)
386 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 224 - reserved for setxattr */
387 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 225 - reserved for lsetxattr */
388 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 226 - reserved for fsetxattr */
389 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 227 - reserved for getxattr */
390 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 228 - reserved for lgetxattr */
391 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 229 - reserved for fgetxattr */
392 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 230 - reserved for listxattr */
393 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 231 - reserved for llistxattr */
394 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 232 - reserved for flistxattr */
395 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 233 - reserved for removexattr */
396 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 234 - reserved for lremovexattr */
397 - .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 235 - reserved for fremovexattr */
398 + .long SYSCALL(sys_setxattr,sys32_setxattr_wrapper)
399 + .long SYSCALL(sys_lsetxattr,sys32_lsetxattr_wrapper) /* 225 */
400 + .long SYSCALL(sys_fsetxattr,sys32_fsetxattr_wrapper)
401 + .long SYSCALL(sys_getxattr,sys32_getxattr_wrapper)
402 + .long SYSCALL(sys_lgetxattr,sys32_lgetxattr_wrapper)
403 + .long SYSCALL(sys_fgetxattr,sys32_fgetxattr_wrapper)
404 + .long SYSCALL(sys_listxattr,sys32_listxattr_wrapper) /* 230 */
405 + .long SYSCALL(sys_llistxattr,sys32_llistxattr_wrapper)
406 + .long SYSCALL(sys_flistxattr,sys32_flistxattr_wrapper)
407 + .long SYSCALL(sys_removexattr,sys32_removexattr_wrapper)
408 + .long SYSCALL(sys_lremovexattr,sys32_lremovexattr_wrapper)
409 + .long SYSCALL(sys_fremovexattr,sys32_fremovexattr_wrapper)/* 235 */
410 .long SYSCALL(sys_gettid,sys_gettid)
411 .long SYSCALL(sys_tkill,sys_tkill)
413 --- linux-2.4.20/arch/s390x/kernel/wrapper32.S~linux-2.4.20-xattr-0.8.54 2002-02-26 03:37:56.000000000 +0800
414 +++ linux-2.4.20-root/arch/s390x/kernel/wrapper32.S 2003-05-07 18:08:03.000000000 +0800
415 @@ -1091,3 +1091,95 @@ sys32_fstat64_wrapper:
416 llgtr %r3,%r3 # struct stat64 *
418 jg sys32_fstat64 # branch to system call
420 + .globl sys32_setxattr_wrapper
421 +sys32_setxattr_wrapper:
422 + llgtr %r2,%r2 # char *
423 + llgtr %r3,%r3 # char *
424 + llgtr %r4,%r4 # void *
425 + llgfr %r5,%r5 # size_t
429 + .globl sys32_lsetxattr_wrapper
430 +sys32_lsetxattr_wrapper:
431 + llgtr %r2,%r2 # char *
432 + llgtr %r3,%r3 # char *
433 + llgtr %r4,%r4 # void *
434 + llgfr %r5,%r5 # size_t
438 + .globl sys32_fsetxattr_wrapper
439 +sys32_fsetxattr_wrapper:
441 + llgtr %r3,%r3 # char *
442 + llgtr %r4,%r4 # void *
443 + llgfr %r5,%r5 # size_t
447 + .globl sys32_getxattr_wrapper
448 +sys32_getxattr_wrapper:
449 + llgtr %r2,%r2 # char *
450 + llgtr %r3,%r3 # char *
451 + llgtr %r4,%r4 # void *
452 + llgfr %r5,%r5 # size_t
455 + .globl sys32_lgetxattr_wrapper
456 +sys32_lgetxattr_wrapper:
457 + llgtr %r2,%r2 # char *
458 + llgtr %r3,%r3 # char *
459 + llgtr %r4,%r4 # void *
460 + llgfr %r5,%r5 # size_t
463 + .globl sys32_fgetxattr_wrapper
464 +sys32_fgetxattr_wrapper:
466 + llgtr %r3,%r3 # char *
467 + llgtr %r4,%r4 # void *
468 + llgfr %r5,%r5 # size_t
471 + .globl sys32_listxattr_wrapper
472 +sys32_listxattr_wrapper:
473 + llgtr %r2,%r2 # char *
474 + llgtr %r3,%r3 # char *
475 + llgfr %r4,%r4 # size_t
478 + .globl sys32_llistxattr_wrapper
479 +sys32_llistxattr_wrapper:
480 + llgtr %r2,%r2 # char *
481 + llgtr %r3,%r3 # char *
482 + llgfr %r4,%r4 # size_t
485 + .globl sys32_flistxattr_wrapper
486 +sys32_flistxattr_wrapper:
488 + llgtr %r3,%r3 # char *
489 + llgfr %r4,%r4 # size_t
492 + .globl sys32_removexattr_wrapper
493 +sys32_removexattr_wrapper:
494 + llgtr %r2,%r2 # char *
495 + llgtr %r3,%r3 # char *
498 + .globl sys32_lremovexattr_wrapper
499 +sys32_lremovexattr_wrapper:
500 + llgtr %r2,%r2 # char *
501 + llgtr %r3,%r3 # char *
502 + jg sys_lremovexattr
504 + .globl sys32_fremovexattr_wrapper
505 +sys32_fremovexattr_wrapper:
507 + llgtr %r3,%r3 # char *
508 + jg sys_fremovexattr
511 --- linux-2.4.20/arch/sparc64/defconfig~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:12.000000000 +0800
512 +++ linux-2.4.20-root/arch/sparc64/defconfig 2003-05-07 18:08:03.000000000 +0800
515 # Automatically generated make config: don't edit
517 +CONFIG_EXT3_FS_XATTR=y
518 +# CONFIG_EXT3_FS_XATTR_SHARING is not set
519 +# CONFIG_EXT3_FS_XATTR_USER is not set
520 +# CONFIG_EXT2_FS_XATTR is not set
521 +# CONFIG_EXT2_FS_XATTR_SHARING is not set
522 +# CONFIG_EXT2_FS_XATTR_USER is not set
523 +# CONFIG_FS_MBCACHE is not set
526 # Code maturity level options
527 --- linux-2.4.20/fs/Config.in~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
528 +++ linux-2.4.20-root/fs/Config.in 2003-05-07 18:08:03.000000000 +0800
529 @@ -25,6 +25,11 @@ dep_mbool ' Debug Befs' CONFIG_BEFS_DEB
530 dep_tristate 'BFS file system support (EXPERIMENTAL)' CONFIG_BFS_FS $CONFIG_EXPERIMENTAL
532 tristate 'Ext3 journalling file system support' CONFIG_EXT3_FS
533 +dep_mbool ' Ext3 extended attributes' CONFIG_EXT3_FS_XATTR $CONFIG_EXT3_FS
534 +dep_bool ' Ext3 extended attribute block sharing' \
535 + CONFIG_EXT3_FS_XATTR_SHARING $CONFIG_EXT3_FS_XATTR
536 +dep_bool ' Ext3 extended user attributes' \
537 + CONFIG_EXT3_FS_XATTR_USER $CONFIG_EXT3_FS_XATTR
538 # CONFIG_JBD could be its own option (even modular), but until there are
539 # other users than ext3, we will simply make it be the same as CONFIG_EXT3_FS
540 # dep_tristate ' Journal Block Device support (JBD for ext3)' CONFIG_JBD $CONFIG_EXT3_FS
541 @@ -84,6 +89,11 @@ dep_mbool ' QNX4FS write support (DANGE
542 tristate 'ROM file system support' CONFIG_ROMFS_FS
544 tristate 'Second extended fs support' CONFIG_EXT2_FS
545 +dep_mbool ' Ext2 extended attributes' CONFIG_EXT2_FS_XATTR $CONFIG_EXT2_FS
546 +dep_bool ' Ext2 extended attribute block sharing' \
547 + CONFIG_EXT2_FS_XATTR_SHARING $CONFIG_EXT2_FS_XATTR
548 +dep_bool ' Ext2 extended user attributes' \
549 + CONFIG_EXT2_FS_XATTR_USER $CONFIG_EXT2_FS_XATTR
551 tristate 'System V/Xenix/V7/Coherent file system support' CONFIG_SYSV_FS
553 @@ -155,6 +165,10 @@ else
554 define_tristate CONFIG_ZISOFS_FS n
557 +# Meta block cache for Extended Attributes (ext2/ext3)
558 +#tristate 'Meta block cache' CONFIG_FS_MBCACHE
559 +define_tristate CONFIG_FS_MBCACHE y
561 mainmenu_option next_comment
562 comment 'Partition Types'
563 source fs/partitions/Config.in
564 --- linux-2.4.20/fs/Makefile~linux-2.4.20-xattr-0.8.54 2003-05-05 19:00:58.000000000 +0800
565 +++ linux-2.4.20-root/fs/Makefile 2003-05-07 18:08:03.000000000 +0800
566 @@ -79,6 +79,9 @@ obj-y += binfmt_script.o
568 obj-$(CONFIG_BINFMT_ELF) += binfmt_elf.o
570 +export-objs += mbcache.o
571 +obj-$(CONFIG_FS_MBCACHE) += mbcache.o
573 # persistent filesystems
574 obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o))
576 --- linux-2.4.20/fs/ext2/Makefile~linux-2.4.20-xattr-0.8.54 2001-10-11 23:05:18.000000000 +0800
577 +++ linux-2.4.20-root/fs/ext2/Makefile 2003-05-07 18:08:03.000000000 +0800
578 @@ -13,4 +13,8 @@ obj-y := balloc.o bitmap.o dir.o file
579 ioctl.o namei.o super.o symlink.o
582 +export-objs += xattr.o
583 +obj-$(CONFIG_EXT2_FS_XATTR) += xattr.o
584 +obj-$(CONFIG_EXT2_FS_XATTR_USER) += xattr_user.o
586 include $(TOPDIR)/Rules.make
587 --- linux-2.4.20/fs/ext2/file.c~linux-2.4.20-xattr-0.8.54 2001-10-11 23:05:18.000000000 +0800
588 +++ linux-2.4.20-root/fs/ext2/file.c 2003-05-07 18:08:03.000000000 +0800
591 #include <linux/fs.h>
592 #include <linux/ext2_fs.h>
593 +#include <linux/ext2_xattr.h>
594 #include <linux/sched.h>
597 @@ -51,4 +52,8 @@ struct file_operations ext2_file_operati
599 struct inode_operations ext2_file_inode_operations = {
600 truncate: ext2_truncate,
601 + setxattr: ext2_setxattr,
602 + getxattr: ext2_getxattr,
603 + listxattr: ext2_listxattr,
604 + removexattr: ext2_removexattr,
606 --- linux-2.4.20/fs/ext2/ialloc.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
607 +++ linux-2.4.20-root/fs/ext2/ialloc.c 2003-05-07 18:08:03.000000000 +0800
609 #include <linux/config.h>
610 #include <linux/fs.h>
611 #include <linux/ext2_fs.h>
612 +#include <linux/ext2_xattr.h>
613 #include <linux/locks.h>
614 #include <linux/quotaops.h>
616 @@ -167,6 +168,7 @@ void ext2_free_inode (struct inode * ino
618 if (!is_bad_inode(inode)) {
619 /* Quota is already initialized in iput() */
620 + ext2_xattr_delete_inode(inode);
621 DQUOT_FREE_INODE(inode);
624 --- linux-2.4.20/fs/ext2/inode.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
625 +++ linux-2.4.20-root/fs/ext2/inode.c 2003-05-07 18:08:03.000000000 +0800
626 @@ -39,6 +39,18 @@ MODULE_LICENSE("GPL");
627 static int ext2_update_inode(struct inode * inode, int do_sync);
630 + * Test whether an inode is a fast symlink.
632 +static inline int ext2_inode_is_fast_symlink(struct inode *inode)
634 + int ea_blocks = inode->u.ext2_i.i_file_acl ?
635 + (inode->i_sb->s_blocksize >> 9) : 0;
637 + return (S_ISLNK(inode->i_mode) &&
638 + inode->i_blocks - ea_blocks == 0);
642 * Called at each iput()
644 void ext2_put_inode (struct inode * inode)
645 @@ -53,9 +65,7 @@ void ext2_delete_inode (struct inode * i
649 - if (is_bad_inode(inode) ||
650 - inode->i_ino == EXT2_ACL_IDX_INO ||
651 - inode->i_ino == EXT2_ACL_DATA_INO)
652 + if (is_bad_inode(inode))
654 inode->u.ext2_i.i_dtime = CURRENT_TIME;
655 mark_inode_dirty(inode);
656 @@ -801,6 +811,8 @@ void ext2_truncate (struct inode * inode
657 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
658 S_ISLNK(inode->i_mode)))
660 + if (ext2_inode_is_fast_symlink(inode))
662 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
665 @@ -888,8 +900,7 @@ void ext2_read_inode (struct inode * ino
666 unsigned long offset;
667 struct ext2_group_desc * gdp;
669 - if ((inode->i_ino != EXT2_ROOT_INO && inode->i_ino != EXT2_ACL_IDX_INO &&
670 - inode->i_ino != EXT2_ACL_DATA_INO &&
671 + if ((inode->i_ino != EXT2_ROOT_INO &&
672 inode->i_ino < EXT2_FIRST_INO(inode->i_sb)) ||
673 inode->i_ino > le32_to_cpu(inode->i_sb->u.ext2_sb.s_es->s_inodes_count)) {
674 ext2_error (inode->i_sb, "ext2_read_inode",
675 @@ -974,10 +985,7 @@ void ext2_read_inode (struct inode * ino
676 for (block = 0; block < EXT2_N_BLOCKS; block++)
677 inode->u.ext2_i.i_data[block] = raw_inode->i_block[block];
679 - if (inode->i_ino == EXT2_ACL_IDX_INO ||
680 - inode->i_ino == EXT2_ACL_DATA_INO)
681 - /* Nothing to do */ ;
682 - else if (S_ISREG(inode->i_mode)) {
683 + if (S_ISREG(inode->i_mode)) {
684 inode->i_op = &ext2_file_inode_operations;
685 inode->i_fop = &ext2_file_operations;
686 inode->i_mapping->a_ops = &ext2_aops;
687 @@ -986,15 +994,17 @@ void ext2_read_inode (struct inode * ino
688 inode->i_fop = &ext2_dir_operations;
689 inode->i_mapping->a_ops = &ext2_aops;
690 } else if (S_ISLNK(inode->i_mode)) {
691 - if (!inode->i_blocks)
692 + if (ext2_inode_is_fast_symlink(inode))
693 inode->i_op = &ext2_fast_symlink_inode_operations;
695 - inode->i_op = &page_symlink_inode_operations;
696 + inode->i_op = &ext2_symlink_inode_operations;
697 inode->i_mapping->a_ops = &ext2_aops;
701 + inode->i_op = &ext2_special_inode_operations;
702 init_special_inode(inode, inode->i_mode,
703 le32_to_cpu(raw_inode->i_block[0]));
706 inode->i_attr_flags = 0;
707 if (inode->u.ext2_i.i_flags & EXT2_SYNC_FL) {
708 --- linux-2.4.20/fs/ext2/namei.c~linux-2.4.20-xattr-0.8.54 2001-10-04 13:57:36.000000000 +0800
709 +++ linux-2.4.20-root/fs/ext2/namei.c 2003-05-07 18:08:03.000000000 +0800
712 #include <linux/fs.h>
713 #include <linux/ext2_fs.h>
714 +#include <linux/ext2_xattr.h>
715 #include <linux/pagemap.h>
718 @@ -136,7 +137,7 @@ static int ext2_symlink (struct inode *
720 if (l > sizeof (inode->u.ext2_i.i_data)) {
722 - inode->i_op = &page_symlink_inode_operations;
723 + inode->i_op = &ext2_symlink_inode_operations;
724 inode->i_mapping->a_ops = &ext2_aops;
725 err = block_symlink(inode, symname, l);
727 @@ -345,4 +346,15 @@ struct inode_operations ext2_dir_inode_o
731 + setxattr: ext2_setxattr,
732 + getxattr: ext2_getxattr,
733 + listxattr: ext2_listxattr,
734 + removexattr: ext2_removexattr,
737 +struct inode_operations ext2_special_inode_operations = {
738 + setxattr: ext2_setxattr,
739 + getxattr: ext2_getxattr,
740 + listxattr: ext2_listxattr,
741 + removexattr: ext2_removexattr,
743 --- linux-2.4.20/fs/ext2/super.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
744 +++ linux-2.4.20-root/fs/ext2/super.c 2003-05-07 18:08:03.000000000 +0800
746 #include <linux/string.h>
747 #include <linux/fs.h>
748 #include <linux/ext2_fs.h>
749 +#include <linux/ext2_xattr.h>
750 #include <linux/slab.h>
751 #include <linux/init.h>
752 #include <linux/locks.h>
753 @@ -125,6 +126,7 @@ void ext2_put_super (struct super_block
757 + ext2_xattr_put_super(sb);
758 if (!(sb->s_flags & MS_RDONLY)) {
759 struct ext2_super_block *es = EXT2_SB(sb)->s_es;
761 @@ -175,6 +177,13 @@ static int parse_options (char * options
762 this_char = strtok (NULL, ",")) {
763 if ((value = strchr (this_char, '=')) != NULL)
765 +#ifdef CONFIG_EXT2_FS_XATTR_USER
766 + if (!strcmp (this_char, "user_xattr"))
767 + set_opt (*mount_options, XATTR_USER);
768 + else if (!strcmp (this_char, "nouser_xattr"))
769 + clear_opt (*mount_options, XATTR_USER);
772 if (!strcmp (this_char, "bsddf"))
773 clear_opt (*mount_options, MINIX_DF);
774 else if (!strcmp (this_char, "nouid32")) {
775 @@ -424,6 +433,9 @@ struct super_block * ext2_read_super (st
776 blocksize = BLOCK_SIZE;
778 sb->u.ext2_sb.s_mount_opt = 0;
779 +#ifdef CONFIG_EXT2_FS_XATTR_USER
780 + /* set_opt (sb->u.ext2_sb.s_mount_opt, XATTR_USER); */
782 if (!parse_options ((char *) data, &sb_block, &resuid, &resgid,
783 &sb->u.ext2_sb.s_mount_opt)) {
785 @@ -813,12 +825,27 @@ static DECLARE_FSTYPE_DEV(ext2_fs_type,
787 static int __init init_ext2_fs(void)
789 - return register_filesystem(&ext2_fs_type);
790 + int error = init_ext2_xattr();
793 + error = init_ext2_xattr_user();
796 + error = register_filesystem(&ext2_fs_type);
800 + exit_ext2_xattr_user();
806 static void __exit exit_ext2_fs(void)
808 unregister_filesystem(&ext2_fs_type);
809 + exit_ext2_xattr_user();
814 --- linux-2.4.20/fs/ext2/symlink.c~linux-2.4.20-xattr-0.8.54 2000-09-28 04:41:33.000000000 +0800
815 +++ linux-2.4.20-root/fs/ext2/symlink.c 2003-05-07 18:08:03.000000000 +0800
818 #include <linux/fs.h>
819 #include <linux/ext2_fs.h>
820 +#include <linux/ext2_xattr.h>
822 static int ext2_readlink(struct dentry *dentry, char *buffer, int buflen)
824 @@ -32,7 +33,20 @@ static int ext2_follow_link(struct dentr
825 return vfs_follow_link(nd, s);
828 +struct inode_operations ext2_symlink_inode_operations = {
829 + readlink: page_readlink,
830 + follow_link: page_follow_link,
831 + setxattr: ext2_setxattr,
832 + getxattr: ext2_getxattr,
833 + listxattr: ext2_listxattr,
834 + removexattr: ext2_removexattr,
837 struct inode_operations ext2_fast_symlink_inode_operations = {
838 readlink: ext2_readlink,
839 follow_link: ext2_follow_link,
840 + setxattr: ext2_setxattr,
841 + getxattr: ext2_getxattr,
842 + listxattr: ext2_listxattr,
843 + removexattr: ext2_removexattr,
845 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
846 +++ linux-2.4.20-root/fs/ext2/xattr.c 2003-05-07 18:08:03.000000000 +0800
849 + * linux/fs/ext2/xattr.c
851 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
853 + * Fix by Harrison Xing <harrison@mountainviewdata.com>.
854 + * Extended attributes for symlinks and special files added per
855 + * suggestion of Luka Renko <luka.renko@hermes.si>.
859 + * Extended attributes are stored on disk blocks allocated outside of
860 + * any inode. The i_file_acl field is then made to point to this allocated
861 + * block. If all extended attributes of an inode are identical, these
862 + * inodes may share the same extended attribute block. Such situations
863 + * are automatically detected by keeping a cache of recent attribute block
864 + * numbers and hashes over the block's contents in memory.
867 + * Extended attribute block layout:
869 + * +------------------+
872 + * | entry 2 | | growing downwards
874 + * | four null bytes |
877 + * | value 3 | | growing upwards
879 + * +------------------+
881 + * The block header is followed by multiple entry descriptors. These entry
882 + * descriptors are variable in size, and alligned to EXT2_XATTR_PAD
883 + * byte boundaries. The entry descriptors are sorted by attribute name,
884 + * so that two extended attribute blocks can be compared efficiently.
886 + * Attribute values are aligned to the end of the block, stored in
887 + * no specific order. They are also padded to EXT2_XATTR_PAD byte
888 + * boundaries. No additional gaps are left between them.
892 + * The VFS already holds the BKL and the inode->i_sem semaphore when any of
893 + * the xattr inode operations are called, so we are guaranteed that only one
894 + * processes accesses extended attributes of an inode at any time.
896 + * For writing we also grab the ext2_xattr_sem semaphore. This ensures that
897 + * only a single process is modifying an extended attribute block, even
898 + * if the block is shared among inodes.
900 + * Note for porting to 2.5
901 + * -----------------------
902 + * The BKL will no longer be held in the xattr inode operations.
905 +#include <linux/module.h>
906 +#include <linux/locks.h>
907 +#include <linux/slab.h>
908 +#include <linux/fs.h>
909 +#include <linux/ext2_fs.h>
910 +#include <linux/ext2_xattr.h>
911 +#include <linux/mbcache.h>
912 +#include <linux/quotaops.h>
913 +#include <asm/semaphore.h>
914 +#include <linux/compatmac.h>
916 +/* These symbols may be needed by a module. */
917 +EXPORT_SYMBOL(ext2_xattr_register);
918 +EXPORT_SYMBOL(ext2_xattr_unregister);
919 +EXPORT_SYMBOL(ext2_xattr_get);
920 +EXPORT_SYMBOL(ext2_xattr_list);
921 +EXPORT_SYMBOL(ext2_xattr_set);
923 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
924 +# define mark_buffer_dirty(bh) mark_buffer_dirty(bh, 1)
927 +#define HDR(bh) ((struct ext2_xattr_header *)((bh)->b_data))
928 +#define ENTRY(ptr) ((struct ext2_xattr_entry *)(ptr))
929 +#define FIRST_ENTRY(bh) ENTRY(HDR(bh)+1)
930 +#define IS_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)
932 +#ifdef EXT2_XATTR_DEBUG
933 +# define ea_idebug(inode, f...) do { \
934 + printk(KERN_DEBUG "inode %s:%ld: ", \
935 + kdevname(inode->i_dev), inode->i_ino); \
939 +# define ea_bdebug(bh, f...) do { \
940 + printk(KERN_DEBUG "block %s:%ld: ", \
941 + kdevname(bh->b_dev), bh->b_blocknr); \
946 +# define ea_idebug(f...)
947 +# define ea_bdebug(f...)
950 +static int ext2_xattr_set2(struct inode *, struct buffer_head *,
951 + struct ext2_xattr_header *);
953 +#ifdef CONFIG_EXT2_FS_XATTR_SHARING
955 +static int ext2_xattr_cache_insert(struct buffer_head *);
956 +static struct buffer_head *ext2_xattr_cache_find(struct inode *,
957 + struct ext2_xattr_header *);
958 +static void ext2_xattr_cache_remove(struct buffer_head *);
959 +static void ext2_xattr_rehash(struct ext2_xattr_header *,
960 + struct ext2_xattr_entry *);
962 +static struct mb_cache *ext2_xattr_cache;
965 +# define ext2_xattr_cache_insert(bh) 0
966 +# define ext2_xattr_cache_find(inode, header) NULL
967 +# define ext2_xattr_cache_remove(bh) while(0) {}
968 +# define ext2_xattr_rehash(header, entry) while(0) {}
972 + * If a file system does not share extended attributes among inodes,
973 + * we should not need the ext2_xattr_sem semaphore. However, the
974 + * filesystem may still contain shared blocks, so we always take
978 +DECLARE_MUTEX(ext2_xattr_sem);
981 +ext2_xattr_new_block(struct inode *inode, int * errp, int force)
983 + struct super_block *sb = inode->i_sb;
984 + int goal = le32_to_cpu(EXT2_SB(sb)->s_es->s_first_data_block) +
985 + EXT2_I(inode)->i_block_group * EXT2_BLOCKS_PER_GROUP(sb);
987 + /* How can we enforce the allocation? */
988 + int block = ext2_new_block(inode, goal, 0, 0, errp);
991 + inode->i_blocks += inode->i_sb->s_blocksize >> 9;
997 +ext2_xattr_quota_alloc(struct inode *inode, int force)
999 + /* How can we enforce the allocation? */
1001 + int error = DQUOT_ALLOC_BLOCK(inode->i_sb, inode, 1);
1003 + inode->i_blocks += inode->i_sb->s_blocksize >> 9;
1005 + int error = DQUOT_ALLOC_BLOCK(inode, 1);
1013 +ext2_xattr_quota_free(struct inode *inode)
1015 + DQUOT_FREE_BLOCK(inode->i_sb, inode, 1);
1016 + inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
1020 +ext2_xattr_free_block(struct inode * inode, unsigned long block)
1022 + ext2_free_blocks(inode, block, 1);
1023 + inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
1027 +# define ext2_xattr_quota_free(inode) \
1028 + DQUOT_FREE_BLOCK(inode, 1)
1029 +# define ext2_xattr_free_block(inode, block) \
1030 + ext2_free_blocks(inode, block, 1)
1033 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
1035 +static inline struct buffer_head *
1036 +sb_bread(struct super_block *sb, int block)
1038 + return bread(sb->s_dev, block, sb->s_blocksize);
1041 +static inline struct buffer_head *
1042 +sb_getblk(struct super_block *sb, int block)
1044 + return getblk(sb->s_dev, block, sb->s_blocksize);
1049 +struct ext2_xattr_handler *ext2_xattr_handlers[EXT2_XATTR_INDEX_MAX];
1050 +rwlock_t ext2_handler_lock = RW_LOCK_UNLOCKED;
1053 +ext2_xattr_register(int name_index, struct ext2_xattr_handler *handler)
1055 + int error = -EINVAL;
1057 + if (name_index > 0 && name_index <= EXT2_XATTR_INDEX_MAX) {
1058 + write_lock(&ext2_handler_lock);
1059 + if (!ext2_xattr_handlers[name_index-1]) {
1060 + ext2_xattr_handlers[name_index-1] = handler;
1063 + write_unlock(&ext2_handler_lock);
1069 +ext2_xattr_unregister(int name_index, struct ext2_xattr_handler *handler)
1071 + if (name_index > 0 || name_index <= EXT2_XATTR_INDEX_MAX) {
1072 + write_lock(&ext2_handler_lock);
1073 + ext2_xattr_handlers[name_index-1] = NULL;
1074 + write_unlock(&ext2_handler_lock);
1078 +static inline const char *
1079 +strcmp_prefix(const char *a, const char *a_prefix)
1081 + while (*a_prefix && *a == *a_prefix) {
1085 + return *a_prefix ? NULL : a;
1089 + * Decode the extended attribute name, and translate it into
1090 + * the name_index and name suffix.
1092 +static struct ext2_xattr_handler *
1093 +ext2_xattr_resolve_name(const char **name)
1095 + struct ext2_xattr_handler *handler = NULL;
1100 + read_lock(&ext2_handler_lock);
1101 + for (i=0; i<EXT2_XATTR_INDEX_MAX; i++) {
1102 + if (ext2_xattr_handlers[i]) {
1103 + const char *n = strcmp_prefix(*name,
1104 + ext2_xattr_handlers[i]->prefix);
1106 + handler = ext2_xattr_handlers[i];
1112 + read_unlock(&ext2_handler_lock);
1116 +static inline struct ext2_xattr_handler *
1117 +ext2_xattr_handler(int name_index)
1119 + struct ext2_xattr_handler *handler = NULL;
1120 + if (name_index > 0 && name_index <= EXT2_XATTR_INDEX_MAX) {
1121 + read_lock(&ext2_handler_lock);
1122 + handler = ext2_xattr_handlers[name_index-1];
1123 + read_unlock(&ext2_handler_lock);
1129 + * Inode operation getxattr()
1131 + * dentry->d_inode->i_sem down
1132 + * BKL held [before 2.5.x]
1135 +ext2_getxattr(struct dentry *dentry, const char *name,
1136 + void *buffer, size_t size)
1138 + struct ext2_xattr_handler *handler;
1139 + struct inode *inode = dentry->d_inode;
1141 + handler = ext2_xattr_resolve_name(&name);
1144 + return handler->get(inode, name, buffer, size);
1148 + * Inode operation listxattr()
1150 + * dentry->d_inode->i_sem down
1151 + * BKL held [before 2.5.x]
1154 +ext2_listxattr(struct dentry *dentry, char *buffer, size_t size)
1156 + return ext2_xattr_list(dentry->d_inode, buffer, size);
1160 + * Inode operation setxattr()
1162 + * dentry->d_inode->i_sem down
1163 + * BKL held [before 2.5.x]
1166 +ext2_setxattr(struct dentry *dentry, const char *name,
1167 + const void *value, size_t size, int flags)
1169 + struct ext2_xattr_handler *handler;
1170 + struct inode *inode = dentry->d_inode;
1173 + value = ""; /* empty EA, do not remove */
1174 + handler = ext2_xattr_resolve_name(&name);
1177 + return handler->set(inode, name, value, size, flags);
1181 + * Inode operation removexattr()
1183 + * dentry->d_inode->i_sem down
1184 + * BKL held [before 2.5.x]
1187 +ext2_removexattr(struct dentry *dentry, const char *name)
1189 + struct ext2_xattr_handler *handler;
1190 + struct inode *inode = dentry->d_inode;
1192 + handler = ext2_xattr_resolve_name(&name);
1195 + return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
1199 + * ext2_xattr_get()
1201 + * Copy an extended attribute into the buffer
1202 + * provided, or compute the buffer size required.
1203 + * Buffer is NULL to compute the size of the buffer required.
1205 + * Returns a negative error number on failure, or the number of bytes
1206 + * used / required on success.
1209 +ext2_xattr_get(struct inode *inode, int name_index, const char *name,
1210 + void *buffer, size_t buffer_size)
1212 + struct buffer_head *bh = NULL;
1213 + struct ext2_xattr_entry *entry;
1214 + unsigned int block, size;
1216 + int name_len, error;
1218 + ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
1219 + name_index, name, buffer, (long)buffer_size);
1223 + if (!EXT2_I(inode)->i_file_acl)
1225 + block = EXT2_I(inode)->i_file_acl;
1226 + ea_idebug(inode, "reading block %d", block);
1227 + bh = sb_bread(inode->i_sb, block);
1230 + ea_bdebug(bh, "b_count=%d, refcount=%d",
1231 + atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
1232 + end = bh->b_data + bh->b_size;
1233 + if (HDR(bh)->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
1234 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
1235 +bad_block: ext2_error(inode->i_sb, "ext2_xattr_get",
1236 + "inode %ld: bad block %d", inode->i_ino, block);
1240 + /* find named attribute */
1241 + name_len = strlen(name);
1244 + if (name_len > 255)
1246 + entry = FIRST_ENTRY(bh);
1247 + while (!IS_LAST_ENTRY(entry)) {
1248 + struct ext2_xattr_entry *next =
1249 + EXT2_XATTR_NEXT(entry);
1250 + if ((char *)next >= end)
1252 + if (name_index == entry->e_name_index &&
1253 + name_len == entry->e_name_len &&
1254 + memcmp(name, entry->e_name, name_len) == 0)
1258 + /* Check the remaining name entries */
1259 + while (!IS_LAST_ENTRY(entry)) {
1260 + struct ext2_xattr_entry *next =
1261 + EXT2_XATTR_NEXT(entry);
1262 + if ((char *)next >= end)
1266 + if (ext2_xattr_cache_insert(bh))
1267 + ea_idebug(inode, "cache insert failed");
1271 + /* check the buffer size */
1272 + if (entry->e_value_block != 0)
1274 + size = le32_to_cpu(entry->e_value_size);
1275 + if (size > inode->i_sb->s_blocksize ||
1276 + le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize)
1279 + if (ext2_xattr_cache_insert(bh))
1280 + ea_idebug(inode, "cache insert failed");
1283 + if (size > buffer_size)
1285 + /* return value of attribute */
1286 + memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs),
1298 + * ext2_xattr_list()
1300 + * Copy a list of attribute names into the buffer
1301 + * provided, or compute the buffer size required.
1302 + * Buffer is NULL to compute the size of the buffer required.
1304 + * Returns a negative error number on failure, or the number of bytes
1305 + * used / required on success.
1308 +ext2_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
1310 + struct buffer_head *bh = NULL;
1311 + struct ext2_xattr_entry *entry;
1312 + unsigned int block, size = 0;
1316 + ea_idebug(inode, "buffer=%p, buffer_size=%ld",
1317 + buffer, (long)buffer_size);
1319 + if (!EXT2_I(inode)->i_file_acl)
1321 + block = EXT2_I(inode)->i_file_acl;
1322 + ea_idebug(inode, "reading block %d", block);
1323 + bh = sb_bread(inode->i_sb, block);
1326 + ea_bdebug(bh, "b_count=%d, refcount=%d",
1327 + atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
1328 + end = bh->b_data + bh->b_size;
1329 + if (HDR(bh)->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
1330 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
1331 +bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
1332 + "inode %ld: bad block %d", inode->i_ino, block);
1336 + /* compute the size required for the list of attribute names */
1337 + for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
1338 + entry = EXT2_XATTR_NEXT(entry)) {
1339 + struct ext2_xattr_handler *handler;
1340 + struct ext2_xattr_entry *next =
1341 + EXT2_XATTR_NEXT(entry);
1342 + if ((char *)next >= end)
1345 + handler = ext2_xattr_handler(entry->e_name_index);
1347 + size += handler->list(NULL, inode, entry->e_name,
1348 + entry->e_name_len);
1351 + if (ext2_xattr_cache_insert(bh))
1352 + ea_idebug(inode, "cache insert failed");
1358 + if (size > buffer_size)
1362 + /* list the attribute names */
1364 + for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
1365 + entry = EXT2_XATTR_NEXT(entry)) {
1366 + struct ext2_xattr_handler *handler;
1368 + handler = ext2_xattr_handler(entry->e_name_index);
1370 + buf += handler->list(buf, inode, entry->e_name,
1371 + entry->e_name_len);
1382 + * If the EXT2_FEATURE_COMPAT_EXT_ATTR feature of this file system is
1383 + * not set, set it.
1385 +static void ext2_xattr_update_super_block(struct super_block *sb)
1387 + if (EXT2_HAS_COMPAT_FEATURE(sb, EXT2_FEATURE_COMPAT_EXT_ATTR))
1391 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
1392 + EXT2_SB(sb)->s_feature_compat |= EXT2_FEATURE_COMPAT_EXT_ATTR;
1394 + EXT2_SB(sb)->s_es->s_feature_compat |=
1395 + cpu_to_le32(EXT2_FEATURE_COMPAT_EXT_ATTR);
1397 + mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
1402 + * ext2_xattr_set()
1404 + * Create, replace or remove an extended attribute for this inode. Buffer
1405 + * is NULL to remove an existing extended attribute, and non-NULL to
1406 + * either replace an existing extended attribute, or create a new extended
1407 + * attribute. The flags XATTR_REPLACE and XATTR_CREATE
1408 + * specify that an extended attribute must exist and must not exist
1409 + * previous to the call, respectively.
1411 + * Returns 0, or a negative error number on failure.
1414 +ext2_xattr_set(struct inode *inode, int name_index, const char *name,
1415 + const void *value, size_t value_len, int flags)
1417 + struct super_block *sb = inode->i_sb;
1418 + struct buffer_head *bh = NULL;
1419 + struct ext2_xattr_header *header = NULL;
1420 + struct ext2_xattr_entry *here, *last;
1421 + unsigned int name_len;
1422 + int block = EXT2_I(inode)->i_file_acl;
1423 + int min_offs = sb->s_blocksize, not_found = 1, free, error;
1427 + * header -- Points either into bh, or to a temporarily
1428 + * allocated buffer.
1429 + * here -- The named entry found, or the place for inserting, within
1430 + * the block pointed to by header.
1431 + * last -- Points right after the last named entry within the block
1432 + * pointed to by header.
1433 + * min_offs -- The offset of the first value (values are aligned
1434 + * towards the end of the block).
1435 + * end -- Points right after the block pointed to by header.
1438 + ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld",
1439 + name_index, name, value, (long)value_len);
1441 + if (IS_RDONLY(inode))
1443 + if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1445 + if (value == NULL)
1449 + name_len = strlen(name);
1450 + if (name_len > 255 || value_len > sb->s_blocksize)
1452 + down(&ext2_xattr_sem);
1455 + /* The inode already has an extended attribute block. */
1457 + bh = sb_bread(sb, block);
1461 + ea_bdebug(bh, "b_count=%d, refcount=%d",
1462 + atomic_read(&(bh->b_count)),
1463 + le32_to_cpu(HDR(bh)->h_refcount));
1465 + end = bh->b_data + bh->b_size;
1466 + if (header->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
1467 + header->h_blocks != cpu_to_le32(1)) {
1468 +bad_block: ext2_error(sb, "ext2_xattr_set",
1469 + "inode %ld: bad block %d", inode->i_ino, block);
1473 + /* Find the named attribute. */
1474 + here = FIRST_ENTRY(bh);
1475 + while (!IS_LAST_ENTRY(here)) {
1476 + struct ext2_xattr_entry *next = EXT2_XATTR_NEXT(here);
1477 + if ((char *)next >= end)
1479 + if (!here->e_value_block && here->e_value_size) {
1480 + int offs = le16_to_cpu(here->e_value_offs);
1481 + if (offs < min_offs)
1484 + not_found = name_index - here->e_name_index;
1486 + not_found = name_len - here->e_name_len;
1488 + not_found = memcmp(name, here->e_name,name_len);
1489 + if (not_found <= 0)
1494 + /* We still need to compute min_offs and last. */
1495 + while (!IS_LAST_ENTRY(last)) {
1496 + struct ext2_xattr_entry *next = EXT2_XATTR_NEXT(last);
1497 + if ((char *)next >= end)
1499 + if (!last->e_value_block && last->e_value_size) {
1500 + int offs = le16_to_cpu(last->e_value_offs);
1501 + if (offs < min_offs)
1507 + /* Check whether we have enough space left. */
1508 + free = min_offs - ((char*)last - (char*)header) - sizeof(__u32);
1510 + /* We will use a new extended attribute block. */
1511 + free = sb->s_blocksize -
1512 + sizeof(struct ext2_xattr_header) - sizeof(__u32);
1513 + here = last = NULL; /* avoid gcc uninitialized warning. */
1517 + /* Request to remove a nonexistent attribute? */
1519 + if (flags & XATTR_REPLACE)
1522 + if (value == NULL)
1525 + free -= EXT2_XATTR_LEN(name_len);
1527 + /* Request to create an existing attribute? */
1529 + if (flags & XATTR_CREATE)
1531 + if (!here->e_value_block && here->e_value_size) {
1532 + unsigned int size = le32_to_cpu(here->e_value_size);
1534 + if (le16_to_cpu(here->e_value_offs) + size >
1535 + sb->s_blocksize || size > sb->s_blocksize)
1537 + free += EXT2_XATTR_SIZE(size);
1540 + free -= EXT2_XATTR_SIZE(value_len);
1545 + /* Here we know that we can set the new attribute. */
1548 + if (header->h_refcount == cpu_to_le32(1)) {
1549 + ea_bdebug(bh, "modifying in-place");
1550 + ext2_xattr_cache_remove(bh);
1554 + ea_bdebug(bh, "cloning");
1555 + header = kmalloc(bh->b_size, GFP_KERNEL);
1557 + if (header == NULL)
1559 + memcpy(header, HDR(bh), bh->b_size);
1560 + header->h_refcount = cpu_to_le32(1);
1561 + offset = (char *)header - bh->b_data;
1562 + here = ENTRY((char *)here + offset);
1563 + last = ENTRY((char *)last + offset);
1566 + /* Allocate a buffer where we construct the new block. */
1567 + header = kmalloc(sb->s_blocksize, GFP_KERNEL);
1569 + if (header == NULL)
1571 + memset(header, 0, sb->s_blocksize);
1572 + end = (char *)header + sb->s_blocksize;
1573 + header->h_magic = cpu_to_le32(EXT2_XATTR_MAGIC);
1574 + header->h_blocks = header->h_refcount = cpu_to_le32(1);
1575 + last = here = ENTRY(header+1);
1579 + /* Insert the new name. */
1580 + int size = EXT2_XATTR_LEN(name_len);
1581 + int rest = (char *)last - (char *)here;
1582 + memmove((char *)here + size, here, rest);
1583 + memset(here, 0, size);
1584 + here->e_name_index = name_index;
1585 + here->e_name_len = name_len;
1586 + memcpy(here->e_name, name, name_len);
1588 + /* Remove the old value. */
1589 + if (!here->e_value_block && here->e_value_size) {
1590 + char *first_val = (char *)header + min_offs;
1591 + int offs = le16_to_cpu(here->e_value_offs);
1592 + char *val = (char *)header + offs;
1593 + size_t size = EXT2_XATTR_SIZE(
1594 + le32_to_cpu(here->e_value_size));
1595 + memmove(first_val + size, first_val, val - first_val);
1596 + memset(first_val, 0, size);
1597 + here->e_value_offs = 0;
1600 + /* Adjust all value offsets. */
1601 + last = ENTRY(header+1);
1602 + while (!IS_LAST_ENTRY(last)) {
1603 + int o = le16_to_cpu(last->e_value_offs);
1604 + if (!last->e_value_block && o < offs)
1605 + last->e_value_offs =
1606 + cpu_to_le16(o + size);
1607 + last = EXT2_XATTR_NEXT(last);
1610 + if (value == NULL) {
1611 + /* Remove this attribute. */
1612 + if (EXT2_XATTR_NEXT(ENTRY(header+1)) == last) {
1613 + /* This block is now empty. */
1614 + error = ext2_xattr_set2(inode, bh, NULL);
1617 + /* Remove the old name. */
1618 + int size = EXT2_XATTR_LEN(name_len);
1619 + last = ENTRY((char *)last - size);
1620 + memmove(here, (char*)here + size,
1621 + (char*)last - (char*)here);
1622 + memset(last, 0, size);
1627 + if (value != NULL) {
1628 + /* Insert the new value. */
1629 + here->e_value_size = cpu_to_le32(value_len);
1631 + size_t size = EXT2_XATTR_SIZE(value_len);
1632 + char *val = (char *)header + min_offs - size;
1633 + here->e_value_offs =
1634 + cpu_to_le16((char *)val - (char *)header);
1635 + memset(val + size - EXT2_XATTR_PAD, 0,
1636 + EXT2_XATTR_PAD); /* Clear the pad bytes. */
1637 + memcpy(val, value, value_len);
1640 + ext2_xattr_rehash(header, here);
1642 + error = ext2_xattr_set2(inode, bh, header);
1646 + if (!(bh && header == HDR(bh)))
1648 + up(&ext2_xattr_sem);
1654 + * Second half of ext2_xattr_set(): Update the file system.
1657 +ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
1658 + struct ext2_xattr_header *header)
1660 + struct super_block *sb = inode->i_sb;
1661 + struct buffer_head *new_bh = NULL;
1665 + new_bh = ext2_xattr_cache_find(inode, header);
1668 + * We found an identical block in the cache.
1669 + * The old block will be released after updating
1672 + ea_bdebug(old_bh, "reusing block %ld",
1673 + new_bh->b_blocknr);
1676 + if (ext2_xattr_quota_alloc(inode, 1))
1679 + HDR(new_bh)->h_refcount = cpu_to_le32(
1680 + le32_to_cpu(HDR(new_bh)->h_refcount) + 1);
1681 + ea_bdebug(new_bh, "refcount now=%d",
1682 + le32_to_cpu(HDR(new_bh)->h_refcount));
1683 + } else if (old_bh && header == HDR(old_bh)) {
1684 + /* Keep this block. */
1686 + (void)ext2_xattr_cache_insert(new_bh);
1688 + /* We need to allocate a new block */
1689 + int force = EXT2_I(inode)->i_file_acl != 0;
1690 + int block = ext2_xattr_new_block(inode, &error, force);
1693 + ea_idebug(inode, "creating block %d", block);
1695 + new_bh = sb_getblk(sb, block);
1697 + ext2_xattr_free_block(inode, block);
1701 + lock_buffer(new_bh);
1702 + memcpy(new_bh->b_data, header, new_bh->b_size);
1703 + mark_buffer_uptodate(new_bh, 1);
1704 + unlock_buffer(new_bh);
1705 + (void)ext2_xattr_cache_insert(new_bh);
1707 + ext2_xattr_update_super_block(sb);
1709 + mark_buffer_dirty(new_bh);
1710 + if (IS_SYNC(inode)) {
1711 + ll_rw_block(WRITE, 1, &new_bh);
1712 + wait_on_buffer(new_bh);
1714 + if (buffer_req(new_bh) && !buffer_uptodate(new_bh))
1719 + /* Update the inode. */
1720 + EXT2_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
1721 + inode->i_ctime = CURRENT_TIME;
1722 + if (IS_SYNC(inode)) {
1723 + error = ext2_sync_inode (inode);
1727 + mark_inode_dirty(inode);
1730 + if (old_bh && old_bh != new_bh) {
1732 + * If there was an old block, and we are not still using it,
1733 + * we now release the old block.
1735 + unsigned int refcount = le32_to_cpu(HDR(old_bh)->h_refcount);
1737 + if (refcount == 1) {
1738 + /* Free the old block. */
1739 + ea_bdebug(old_bh, "freeing");
1740 + ext2_xattr_free_block(inode, old_bh->b_blocknr);
1741 + mark_buffer_clean(old_bh);
1743 + /* Decrement the refcount only. */
1745 + HDR(old_bh)->h_refcount = cpu_to_le32(refcount);
1746 + ext2_xattr_quota_free(inode);
1747 + mark_buffer_dirty(old_bh);
1748 + ea_bdebug(old_bh, "refcount now=%d", refcount);
1753 + if (old_bh != new_bh)
1760 + * ext2_xattr_delete_inode()
1762 + * Free extended attribute resources associated with this inode. This
1763 + * is called immediately before an inode is freed.
1766 +ext2_xattr_delete_inode(struct inode *inode)
1768 + struct buffer_head *bh;
1769 + unsigned int block = EXT2_I(inode)->i_file_acl;
1773 + down(&ext2_xattr_sem);
1775 + bh = sb_bread(inode->i_sb, block);
1777 + ext2_error(inode->i_sb, "ext2_xattr_delete_inode",
1778 + "inode %ld: block %d read error", inode->i_ino, block);
1781 + ea_bdebug(bh, "b_count=%d", atomic_read(&(bh->b_count)));
1782 + if (HDR(bh)->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
1783 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
1784 + ext2_error(inode->i_sb, "ext2_xattr_delete_inode",
1785 + "inode %ld: bad block %d", inode->i_ino, block);
1788 + ea_bdebug(bh, "refcount now=%d", le32_to_cpu(HDR(bh)->h_refcount) - 1);
1789 + if (HDR(bh)->h_refcount == cpu_to_le32(1)) {
1790 + ext2_xattr_cache_remove(bh);
1791 + ext2_xattr_free_block(inode, block);
1795 + HDR(bh)->h_refcount = cpu_to_le32(
1796 + le32_to_cpu(HDR(bh)->h_refcount) - 1);
1797 + mark_buffer_dirty(bh);
1798 + if (IS_SYNC(inode)) {
1799 + ll_rw_block(WRITE, 1, &bh);
1800 + wait_on_buffer(bh);
1802 + ext2_xattr_quota_free(inode);
1804 + EXT2_I(inode)->i_file_acl = 0;
1808 + up(&ext2_xattr_sem);
1812 + * ext2_xattr_put_super()
1814 + * This is called when a file system is unmounted.
1817 +ext2_xattr_put_super(struct super_block *sb)
1819 +#ifdef CONFIG_EXT2_FS_XATTR_SHARING
1820 + mb_cache_shrink(ext2_xattr_cache, sb->s_dev);
1824 +#ifdef CONFIG_EXT2_FS_XATTR_SHARING
1827 + * ext2_xattr_cache_insert()
1829 + * Create a new entry in the extended attribute cache, and insert
1830 + * it unless such an entry is already in the cache.
1832 + * Returns 0, or a negative error number on failure.
1835 +ext2_xattr_cache_insert(struct buffer_head *bh)
1837 + __u32 hash = le32_to_cpu(HDR(bh)->h_hash);
1838 + struct mb_cache_entry *ce;
1841 + ce = mb_cache_entry_alloc(ext2_xattr_cache);
1844 + error = mb_cache_entry_insert(ce, bh->b_dev, bh->b_blocknr, &hash);
1846 + mb_cache_entry_free(ce);
1847 + if (error == -EBUSY) {
1848 + ea_bdebug(bh, "already in cache (%d cache entries)",
1849 + atomic_read(&ext2_xattr_cache->c_entry_count));
1853 + ea_bdebug(bh, "inserting [%x] (%d cache entries)", (int)hash,
1854 + atomic_read(&ext2_xattr_cache->c_entry_count));
1855 + mb_cache_entry_release(ce);
1861 + * ext2_xattr_cmp()
1863 + * Compare two extended attribute blocks for equality.
1865 + * Returns 0 if the blocks are equal, 1 if they differ, and
1866 + * a negative error number on errors.
1869 +ext2_xattr_cmp(struct ext2_xattr_header *header1,
1870 + struct ext2_xattr_header *header2)
1872 + struct ext2_xattr_entry *entry1, *entry2;
1874 + entry1 = ENTRY(header1+1);
1875 + entry2 = ENTRY(header2+1);
1876 + while (!IS_LAST_ENTRY(entry1)) {
1877 + if (IS_LAST_ENTRY(entry2))
1879 + if (entry1->e_hash != entry2->e_hash ||
1880 + entry1->e_name_len != entry2->e_name_len ||
1881 + entry1->e_value_size != entry2->e_value_size ||
1882 + memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len))
1884 + if (entry1->e_value_block != 0 || entry2->e_value_block != 0)
1886 + if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs),
1887 + (char *)header2 + le16_to_cpu(entry2->e_value_offs),
1888 + le32_to_cpu(entry1->e_value_size)))
1891 + entry1 = EXT2_XATTR_NEXT(entry1);
1892 + entry2 = EXT2_XATTR_NEXT(entry2);
1894 + if (!IS_LAST_ENTRY(entry2))
1900 + * ext2_xattr_cache_find()
1902 + * Find an identical extended attribute block.
1904 + * Returns a pointer to the block found, or NULL if such a block was
1905 + * not found or an error occurred.
1907 +static struct buffer_head *
1908 +ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header)
1910 + __u32 hash = le32_to_cpu(header->h_hash);
1911 + struct mb_cache_entry *ce;
1913 + if (!header->h_hash)
1914 + return NULL; /* never share */
1915 + ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
1916 + ce = mb_cache_entry_find_first(ext2_xattr_cache, 0, inode->i_dev, hash);
1918 + struct buffer_head *bh = sb_bread(inode->i_sb, ce->e_block);
1921 + ext2_error(inode->i_sb, "ext2_xattr_cache_find",
1922 + "inode %ld: block %ld read error",
1923 + inode->i_ino, ce->e_block);
1924 + } else if (le32_to_cpu(HDR(bh)->h_refcount) >
1925 + EXT2_XATTR_REFCOUNT_MAX) {
1926 + ea_idebug(inode, "block %ld refcount %d>%d",ce->e_block,
1927 + le32_to_cpu(HDR(bh)->h_refcount),
1928 + EXT2_XATTR_REFCOUNT_MAX);
1929 + } else if (!ext2_xattr_cmp(header, HDR(bh))) {
1930 + ea_bdebug(bh, "b_count=%d",atomic_read(&(bh->b_count)));
1931 + mb_cache_entry_release(ce);
1935 + ce = mb_cache_entry_find_next(ce, 0, inode->i_dev, hash);
1941 + * ext2_xattr_cache_remove()
1943 + * Remove the cache entry of a block from the cache. Called when a
1944 + * block becomes invalid.
1947 +ext2_xattr_cache_remove(struct buffer_head *bh)
1949 + struct mb_cache_entry *ce;
1951 + ce = mb_cache_entry_get(ext2_xattr_cache, bh->b_dev, bh->b_blocknr);
1953 + ea_bdebug(bh, "removing (%d cache entries remaining)",
1954 + atomic_read(&ext2_xattr_cache->c_entry_count)-1);
1955 + mb_cache_entry_free(ce);
1957 + ea_bdebug(bh, "no cache entry");
1960 +#define NAME_HASH_SHIFT 5
1961 +#define VALUE_HASH_SHIFT 16
1964 + * ext2_xattr_hash_entry()
1966 + * Compute the hash of an extended attribute.
1968 +static inline void ext2_xattr_hash_entry(struct ext2_xattr_header *header,
1969 + struct ext2_xattr_entry *entry)
1972 + char *name = entry->e_name;
1975 + for (n=0; n < entry->e_name_len; n++) {
1976 + hash = (hash << NAME_HASH_SHIFT) ^
1977 + (hash >> (8*sizeof(hash) - NAME_HASH_SHIFT)) ^
1981 + if (entry->e_value_block == 0 && entry->e_value_size != 0) {
1982 + __u32 *value = (__u32 *)((char *)header +
1983 + le16_to_cpu(entry->e_value_offs));
1984 + for (n = (le32_to_cpu(entry->e_value_size) +
1985 + EXT2_XATTR_ROUND) >> EXT2_XATTR_PAD_BITS; n; n--) {
1986 + hash = (hash << VALUE_HASH_SHIFT) ^
1987 + (hash >> (8*sizeof(hash) - VALUE_HASH_SHIFT)) ^
1988 + le32_to_cpu(*value++);
1991 + entry->e_hash = cpu_to_le32(hash);
1994 +#undef NAME_HASH_SHIFT
1995 +#undef VALUE_HASH_SHIFT
1997 +#define BLOCK_HASH_SHIFT 16
2000 + * ext2_xattr_rehash()
2002 + * Re-compute the extended attribute hash value after an entry has changed.
2004 +static void ext2_xattr_rehash(struct ext2_xattr_header *header,
2005 + struct ext2_xattr_entry *entry)
2007 + struct ext2_xattr_entry *here;
2010 + ext2_xattr_hash_entry(header, entry);
2011 + here = ENTRY(header+1);
2012 + while (!IS_LAST_ENTRY(here)) {
2013 + if (!here->e_hash) {
2014 + /* Block is not shared if an entry's hash value == 0 */
2018 + hash = (hash << BLOCK_HASH_SHIFT) ^
2019 + (hash >> (8*sizeof(hash) - BLOCK_HASH_SHIFT)) ^
2020 + le32_to_cpu(here->e_hash);
2021 + here = EXT2_XATTR_NEXT(here);
2023 + header->h_hash = cpu_to_le32(hash);
2026 +#undef BLOCK_HASH_SHIFT
2029 +init_ext2_xattr(void)
2031 + ext2_xattr_cache = mb_cache_create("ext2_xattr", NULL,
2032 + sizeof(struct mb_cache_entry) +
2033 + sizeof(struct mb_cache_entry_index), 1, 61);
2034 + if (!ext2_xattr_cache)
2041 +exit_ext2_xattr(void)
2043 + mb_cache_destroy(ext2_xattr_cache);
2046 +#else /* CONFIG_EXT2_FS_XATTR_SHARING */
2049 +init_ext2_xattr(void)
2055 +exit_ext2_xattr(void)
2059 +#endif /* CONFIG_EXT2_FS_XATTR_SHARING */
2060 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
2061 +++ linux-2.4.20-root/fs/ext2/xattr_user.c 2003-05-07 18:08:03.000000000 +0800
2064 + * linux/fs/ext2/xattr_user.c
2065 + * Handler for extended user attributes.
2067 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
2070 +#include <linux/module.h>
2071 +#include <linux/string.h>
2072 +#include <linux/fs.h>
2073 +#include <linux/ext2_fs.h>
2074 +#include <linux/ext2_xattr.h>
2076 +#ifdef CONFIG_EXT2_FS_POSIX_ACL
2077 +# include <linux/ext2_acl.h>
2080 +#define XATTR_USER_PREFIX "user."
2083 +ext2_xattr_user_list(char *list, struct inode *inode,
2084 + const char *name, int name_len)
2086 + const int prefix_len = sizeof(XATTR_USER_PREFIX)-1;
2088 + if (!test_opt(inode->i_sb, XATTR_USER))
2092 + memcpy(list, XATTR_USER_PREFIX, prefix_len);
2093 + memcpy(list+prefix_len, name, name_len);
2094 + list[prefix_len + name_len] = '\0';
2096 + return prefix_len + name_len + 1;
2100 +ext2_xattr_user_get(struct inode *inode, const char *name,
2101 + void *buffer, size_t size)
2105 + if (strcmp(name, "") == 0)
2107 + if (!test_opt(inode->i_sb, XATTR_USER))
2109 +#ifdef CONFIG_EXT2_FS_POSIX_ACL
2110 + error = ext2_permission_locked(inode, MAY_READ);
2112 + error = permission(inode, MAY_READ);
2117 + return ext2_xattr_get(inode, EXT2_XATTR_INDEX_USER, name,
2122 +ext2_xattr_user_set(struct inode *inode, const char *name,
2123 + const void *value, size_t size, int flags)
2127 + if (strcmp(name, "") == 0)
2129 + if (!test_opt(inode->i_sb, XATTR_USER))
2131 + if ( !S_ISREG(inode->i_mode) &&
2132 + (!S_ISDIR(inode->i_mode) || inode->i_mode & S_ISVTX))
2134 +#ifdef CONFIG_EXT2_FS_POSIX_ACL
2135 + error = ext2_permission_locked(inode, MAY_WRITE);
2137 + error = permission(inode, MAY_WRITE);
2142 + return ext2_xattr_set(inode, EXT2_XATTR_INDEX_USER, name,
2143 + value, size, flags);
2146 +struct ext2_xattr_handler ext2_xattr_user_handler = {
2147 + prefix: XATTR_USER_PREFIX,
2148 + list: ext2_xattr_user_list,
2149 + get: ext2_xattr_user_get,
2150 + set: ext2_xattr_user_set,
2154 +init_ext2_xattr_user(void)
2156 + return ext2_xattr_register(EXT2_XATTR_INDEX_USER,
2157 + &ext2_xattr_user_handler);
2161 +exit_ext2_xattr_user(void)
2163 + ext2_xattr_unregister(EXT2_XATTR_INDEX_USER,
2164 + &ext2_xattr_user_handler);
2166 --- linux-2.4.20/fs/ext3/Makefile~linux-2.4.20-xattr-0.8.54 2003-05-05 19:01:02.000000000 +0800
2167 +++ linux-2.4.20-root/fs/ext3/Makefile 2003-05-07 18:10:33.000000000 +0800
2170 -# Makefile for the linux ext2-filesystem routines.
2171 +# Makefile for the linux ext3-filesystem routines.
2173 # Note! Dependencies are done automagically by 'make dep', which also
2174 # removes any old dependencies. DON'T put your own dependencies here
2179 -export-objs := super.o inode.o
2180 +export-objs := ext3-exports.o
2182 obj-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
2183 - ioctl.o namei.o super.o symlink.o hash.o
2184 + ioctl.o namei.o super.o symlink.o hash.o ext3-exports.o
2185 obj-m := $(O_TARGET)
2187 +export-objs += xattr.o
2188 +obj-$(CONFIG_EXT3_FS_XATTR) += xattr.o
2189 +obj-$(CONFIG_EXT3_FS_XATTR_USER) += xattr_user.o
2191 include $(TOPDIR)/Rules.make
2192 --- linux-2.4.20/fs/ext3/file.c~linux-2.4.20-xattr-0.8.54 2003-05-05 19:01:02.000000000 +0800
2193 +++ linux-2.4.20-root/fs/ext3/file.c 2003-05-07 18:08:03.000000000 +0800
2195 #include <linux/locks.h>
2196 #include <linux/jbd.h>
2197 #include <linux/ext3_fs.h>
2198 +#include <linux/ext3_xattr.h>
2199 #include <linux/ext3_jbd.h>
2200 #include <linux/smp_lock.h>
2202 @@ -126,5 +127,9 @@ struct file_operations ext3_file_operati
2203 struct inode_operations ext3_file_inode_operations = {
2204 truncate: ext3_truncate, /* BKL held */
2205 setattr: ext3_setattr, /* BKL held */
2206 + setxattr: ext3_setxattr, /* BKL held */
2207 + getxattr: ext3_getxattr, /* BKL held */
2208 + listxattr: ext3_listxattr, /* BKL held */
2209 + removexattr: ext3_removexattr, /* BKL held */
2212 --- linux-2.4.20/fs/ext3/ialloc.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
2213 +++ linux-2.4.20-root/fs/ext3/ialloc.c 2003-05-07 18:08:03.000000000 +0800
2215 #include <linux/jbd.h>
2216 #include <linux/ext3_fs.h>
2217 #include <linux/ext3_jbd.h>
2218 +#include <linux/ext3_xattr.h>
2219 #include <linux/stat.h>
2220 #include <linux/string.h>
2221 #include <linux/locks.h>
2222 @@ -216,6 +217,7 @@ void ext3_free_inode (handle_t *handle,
2223 * as writing the quota to disk may need the lock as well.
2226 + ext3_xattr_delete_inode(handle, inode);
2227 DQUOT_FREE_INODE(inode);
2230 --- linux-2.4.20/fs/ext3/inode.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
2231 +++ linux-2.4.20-root/fs/ext3/inode.c 2003-05-07 18:08:03.000000000 +0800
2234 #undef SEARCH_FROM_ZERO
2237 + * Test whether an inode is a fast symlink.
2239 +static inline int ext3_inode_is_fast_symlink(struct inode *inode)
2241 + int ea_blocks = inode->u.ext3_i.i_file_acl ?
2242 + (inode->i_sb->s_blocksize >> 9) : 0;
2244 + return (S_ISLNK(inode->i_mode) &&
2245 + inode->i_blocks - ea_blocks == 0);
2248 /* The ext3 forget function must perform a revoke if we are freeing data
2249 * which has been journaled. Metadata (eg. indirect blocks) must be
2250 * revoked in all cases.
2252 * still needs to be revoked.
2255 -static int ext3_forget(handle_t *handle, int is_metadata,
2256 +int ext3_forget(handle_t *handle, int is_metadata,
2257 struct inode *inode, struct buffer_head *bh,
2260 @@ -164,9 +176,7 @@ void ext3_delete_inode (struct inode * i
2264 - if (is_bad_inode(inode) ||
2265 - inode->i_ino == EXT3_ACL_IDX_INO ||
2266 - inode->i_ino == EXT3_ACL_DATA_INO)
2267 + if (is_bad_inode(inode))
2271 @@ -1855,6 +1865,8 @@ void ext3_truncate(struct inode * inode)
2272 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
2273 S_ISLNK(inode->i_mode)))
2275 + if (ext3_inode_is_fast_symlink(inode))
2277 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2280 @@ -2002,8 +2014,6 @@ int ext3_get_inode_loc (struct inode *in
2281 struct ext3_group_desc * gdp;
2283 if ((inode->i_ino != EXT3_ROOT_INO &&
2284 - inode->i_ino != EXT3_ACL_IDX_INO &&
2285 - inode->i_ino != EXT3_ACL_DATA_INO &&
2286 inode->i_ino != EXT3_JOURNAL_INO &&
2287 inode->i_ino < EXT3_FIRST_INO(inode->i_sb)) ||
2288 inode->i_ino > le32_to_cpu(
2289 @@ -2130,10 +2140,7 @@ void ext3_read_inode(struct inode * inod
2293 - if (inode->i_ino == EXT3_ACL_IDX_INO ||
2294 - inode->i_ino == EXT3_ACL_DATA_INO)
2295 - /* Nothing to do */ ;
2296 - else if (S_ISREG(inode->i_mode)) {
2297 + if (S_ISREG(inode->i_mode)) {
2298 inode->i_op = &ext3_file_inode_operations;
2299 inode->i_fop = &ext3_file_operations;
2300 inode->i_mapping->a_ops = &ext3_aops;
2301 @@ -2141,15 +2148,17 @@ void ext3_read_inode(struct inode * inod
2302 inode->i_op = &ext3_dir_inode_operations;
2303 inode->i_fop = &ext3_dir_operations;
2304 } else if (S_ISLNK(inode->i_mode)) {
2305 - if (!inode->i_blocks)
2306 + if (ext3_inode_is_fast_symlink(inode))
2307 inode->i_op = &ext3_fast_symlink_inode_operations;
2309 - inode->i_op = &page_symlink_inode_operations;
2310 + inode->i_op = &ext3_symlink_inode_operations;
2311 inode->i_mapping->a_ops = &ext3_aops;
2315 + inode->i_op = &ext3_special_inode_operations;
2316 init_special_inode(inode, inode->i_mode,
2317 le32_to_cpu(iloc.raw_inode->i_block[0]));
2319 ext3_set_inode_flags(inode);
2322 --- linux-2.4.20/fs/ext3/namei.c~linux-2.4.20-xattr-0.8.54 2003-05-05 19:01:05.000000000 +0800
2323 +++ linux-2.4.20-root/fs/ext3/namei.c 2003-05-07 18:08:03.000000000 +0800
2325 #include <linux/sched.h>
2326 #include <linux/ext3_fs.h>
2327 #include <linux/ext3_jbd.h>
2328 +#include <linux/ext3_xattr.h>
2329 #include <linux/fcntl.h>
2330 #include <linux/stat.h>
2331 #include <linux/string.h>
2332 @@ -1611,7 +1612,7 @@ static int ext3_mkdir(struct inode * dir
2336 - inode = ext3_new_inode (handle, dir, S_IFDIR);
2337 + inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
2338 err = PTR_ERR(inode);
2341 @@ -1619,7 +1620,6 @@ static int ext3_mkdir(struct inode * dir
2342 inode->i_op = &ext3_dir_inode_operations;
2343 inode->i_fop = &ext3_dir_operations;
2344 inode->i_size = EXT3_I(inode)->i_disksize = inode->i_sb->s_blocksize;
2345 - inode->i_blocks = 0;
2346 dir_block = ext3_bread (handle, inode, 0, 1, &err);
2348 inode->i_nlink--; /* is this nlink == 0? */
2349 @@ -1646,9 +1646,6 @@ static int ext3_mkdir(struct inode * dir
2350 BUFFER_TRACE(dir_block, "call ext3_journal_dirty_metadata");
2351 ext3_journal_dirty_metadata(handle, dir_block);
2353 - inode->i_mode = S_IFDIR | mode;
2354 - if (dir->i_mode & S_ISGID)
2355 - inode->i_mode |= S_ISGID;
2356 ext3_mark_inode_dirty(handle, inode);
2357 err = ext3_add_entry (handle, dentry, inode);
2359 @@ -2017,7 +2014,7 @@ static int ext3_symlink (struct inode *
2362 if (l > sizeof (EXT3_I(inode)->i_data)) {
2363 - inode->i_op = &page_symlink_inode_operations;
2364 + inode->i_op = &ext3_symlink_inode_operations;
2365 inode->i_mapping->a_ops = &ext3_aops;
2367 * block_symlink() calls back into ext3_prepare/commit_write.
2368 @@ -2244,4 +2241,16 @@ struct inode_operations ext3_dir_inode_o
2369 rmdir: ext3_rmdir, /* BKL held */
2370 mknod: ext3_mknod, /* BKL held */
2371 rename: ext3_rename, /* BKL held */
2372 + setxattr: ext3_setxattr, /* BKL held */
2373 + getxattr: ext3_getxattr, /* BKL held */
2374 + listxattr: ext3_listxattr, /* BKL held */
2375 + removexattr: ext3_removexattr, /* BKL held */
2378 +struct inode_operations ext3_special_inode_operations = {
2379 + setxattr: ext3_setxattr, /* BKL held */
2380 + getxattr: ext3_getxattr, /* BKL held */
2381 + listxattr: ext3_listxattr, /* BKL held */
2382 + removexattr: ext3_removexattr, /* BKL held */
2385 --- linux-2.4.20/fs/ext3/super.c~linux-2.4.20-xattr-0.8.54 2003-05-05 19:01:02.000000000 +0800
2386 +++ linux-2.4.20-root/fs/ext3/super.c 2003-05-07 18:08:39.000000000 +0800
2388 #include <linux/jbd.h>
2389 #include <linux/ext3_fs.h>
2390 #include <linux/ext3_jbd.h>
2391 +#include <linux/ext3_xattr.h>
2392 #include <linux/slab.h>
2393 #include <linux/init.h>
2394 #include <linux/locks.h>
2395 @@ -404,6 +405,7 @@ void ext3_put_super (struct super_block
2396 kdev_t j_dev = sbi->s_journal->j_dev;
2399 + ext3_xattr_put_super(sb);
2400 journal_destroy(sbi->s_journal);
2401 if (!(sb->s_flags & MS_RDONLY)) {
2402 EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER);
2403 @@ -499,6 +501,7 @@ static int parse_options (char * options
2406 unsigned long *mount_options = &sbi->s_mount_opt;
2408 uid_t *resuid = &sbi->s_resuid;
2409 gid_t *resgid = &sbi->s_resgid;
2411 @@ -511,6 +514,13 @@ static int parse_options (char * options
2412 this_char = strtok (NULL, ",")) {
2413 if ((value = strchr (this_char, '=')) != NULL)
2415 +#ifdef CONFIG_EXT3_FS_XATTR_USER
2416 + if (!strcmp (this_char, "user_xattr"))
2417 + set_opt (*mount_options, XATTR_USER);
2418 + else if (!strcmp (this_char, "nouser_xattr"))
2419 + clear_opt (*mount_options, XATTR_USER);
2422 if (!strcmp (this_char, "bsddf"))
2423 clear_opt (*mount_options, MINIX_DF);
2424 else if (!strcmp (this_char, "nouid32")) {
2425 @@ -928,6 +938,12 @@ struct super_block * ext3_read_super (st
2426 sbi->s_mount_opt = 0;
2427 sbi->s_resuid = EXT3_DEF_RESUID;
2428 sbi->s_resgid = EXT3_DEF_RESGID;
2430 + /* Default extended attribute flags */
2431 +#ifdef CONFIG_EXT3_FS_XATTR_USER
2432 + /* set_opt(sbi->s_mount_opt, XATTR_USER); */
2435 if (!parse_options ((char *) data, &sb_block, sbi, &journal_inum, 0)) {
2438 @@ -1767,17 +1783,29 @@ static DECLARE_FSTYPE_DEV(ext3_fs_type,
2440 static int __init init_ext3_fs(void)
2442 - return register_filesystem(&ext3_fs_type);
2443 + int error = init_ext3_xattr();
2446 + error = init_ext3_xattr_user();
2449 + error = register_filesystem(&ext3_fs_type);
2453 + exit_ext3_xattr_user();
2455 + exit_ext3_xattr();
2459 static void __exit exit_ext3_fs(void)
2461 unregister_filesystem(&ext3_fs_type);
2462 + exit_ext3_xattr_user();
2463 + exit_ext3_xattr();
2466 -EXPORT_SYMBOL(ext3_force_commit);
2467 -EXPORT_SYMBOL(ext3_bread);
2469 MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
2470 MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions");
2471 MODULE_LICENSE("GPL");
2472 --- linux-2.4.20/fs/ext3/symlink.c~linux-2.4.20-xattr-0.8.54 2001-11-10 06:25:04.000000000 +0800
2473 +++ linux-2.4.20-root/fs/ext3/symlink.c 2003-05-07 18:08:03.000000000 +0800
2475 #include <linux/fs.h>
2476 #include <linux/jbd.h>
2477 #include <linux/ext3_fs.h>
2478 +#include <linux/ext3_xattr.h>
2480 static int ext3_readlink(struct dentry *dentry, char *buffer, int buflen)
2482 @@ -33,7 +34,20 @@ static int ext3_follow_link(struct dentr
2483 return vfs_follow_link(nd, s);
2486 +struct inode_operations ext3_symlink_inode_operations = {
2487 + readlink: page_readlink, /* BKL not held. Don't need */
2488 + follow_link: page_follow_link, /* BKL not held. Don't need */
2489 + setxattr: ext3_setxattr, /* BKL held */
2490 + getxattr: ext3_getxattr, /* BKL held */
2491 + listxattr: ext3_listxattr, /* BKL held */
2492 + removexattr: ext3_removexattr, /* BKL held */
2495 struct inode_operations ext3_fast_symlink_inode_operations = {
2496 readlink: ext3_readlink, /* BKL not held. Don't need */
2497 follow_link: ext3_follow_link, /* BKL not held. Don't need */
2498 + setxattr: ext3_setxattr, /* BKL held */
2499 + getxattr: ext3_getxattr, /* BKL held */
2500 + listxattr: ext3_listxattr, /* BKL held */
2501 + removexattr: ext3_removexattr, /* BKL held */
2503 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
2504 +++ linux-2.4.20-root/fs/ext3/xattr.c 2003-05-07 18:09:23.000000000 +0800
2507 + * linux/fs/ext3/xattr.c
2509 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
2511 + * Fix by Harrison Xing <harrison@mountainviewdata.com>.
2512 + * Ext3 code with a lot of help from Eric Jarman <ejarman@acm.org>.
2513 + * Extended attributes for symlinks and special files added per
2514 + * suggestion of Luka Renko <luka.renko@hermes.si>.
2518 + * Extended attributes are stored on disk blocks allocated outside of
2519 + * any inode. The i_file_acl field is then made to point to this allocated
2520 + * block. If all extended attributes of an inode are identical, these
2521 + * inodes may share the same extended attribute block. Such situations
2522 + * are automatically detected by keeping a cache of recent attribute block
2523 + * numbers and hashes over the block's contents in memory.
2526 + * Extended attribute block layout:
2528 + * +------------------+
2531 + * | entry 2 | | growing downwards
2533 + * | four null bytes |
2536 + * | value 3 | | growing upwards
2538 + * +------------------+
2540 + * The block header is followed by multiple entry descriptors. These entry
2541 + * descriptors are variable in size, and alligned to EXT3_XATTR_PAD
2542 + * byte boundaries. The entry descriptors are sorted by attribute name,
2543 + * so that two extended attribute blocks can be compared efficiently.
2545 + * Attribute values are aligned to the end of the block, stored in
2546 + * no specific order. They are also padded to EXT3_XATTR_PAD byte
2547 + * boundaries. No additional gaps are left between them.
2549 + * Locking strategy
2550 + * ----------------
2551 + * The VFS already holds the BKL and the inode->i_sem semaphore when any of
2552 + * the xattr inode operations are called, so we are guaranteed that only one
2553 + * processes accesses extended attributes of an inode at any time.
2555 + * For writing we also grab the ext3_xattr_sem semaphore. This ensures that
2556 + * only a single process is modifying an extended attribute block, even
2557 + * if the block is shared among inodes.
2559 + * Note for porting to 2.5
2560 + * -----------------------
2561 + * The BKL will no longer be held in the xattr inode operations.
2564 +#include <linux/module.h>
2565 +#include <linux/fs.h>
2566 +#include <linux/locks.h>
2567 +#include <linux/slab.h>
2568 +#include <linux/ext3_jbd.h>
2569 +#include <linux/ext3_fs.h>
2570 +#include <linux/ext3_xattr.h>
2571 +#include <linux/mbcache.h>
2572 +#include <linux/quotaops.h>
2573 +#include <asm/semaphore.h>
2574 +#include <linux/compatmac.h>
2576 +#define EXT3_EA_USER "user."
2578 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
2579 +# define mark_buffer_dirty(bh) mark_buffer_dirty(bh, 1)
2582 +#define HDR(bh) ((struct ext3_xattr_header *)((bh)->b_data))
2583 +#define ENTRY(ptr) ((struct ext3_xattr_entry *)(ptr))
2584 +#define FIRST_ENTRY(bh) ENTRY(HDR(bh)+1)
2585 +#define IS_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)
2587 +#ifdef EXT3_XATTR_DEBUG
2588 +# define ea_idebug(inode, f...) do { \
2589 + printk(KERN_DEBUG "inode %s:%ld: ", \
2590 + kdevname(inode->i_dev), inode->i_ino); \
2594 +# define ea_bdebug(bh, f...) do { \
2595 + printk(KERN_DEBUG "block %s:%ld: ", \
2596 + kdevname(bh->b_dev), bh->b_blocknr); \
2601 +# define ea_idebug(f...)
2602 +# define ea_bdebug(f...)
2605 +static int ext3_xattr_set2(handle_t *, struct inode *, struct buffer_head *,
2606 + struct ext3_xattr_header *);
2608 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
2610 +static int ext3_xattr_cache_insert(struct buffer_head *);
2611 +static struct buffer_head *ext3_xattr_cache_find(struct inode *,
2612 + struct ext3_xattr_header *);
2613 +static void ext3_xattr_cache_remove(struct buffer_head *);
2614 +static void ext3_xattr_rehash(struct ext3_xattr_header *,
2615 + struct ext3_xattr_entry *);
2617 +static struct mb_cache *ext3_xattr_cache;
2620 +# define ext3_xattr_cache_insert(bh) 0
2621 +# define ext3_xattr_cache_find(inode, header) NULL
2622 +# define ext3_xattr_cache_remove(bh) while(0) {}
2623 +# define ext3_xattr_rehash(header, entry) while(0) {}
2627 + * If a file system does not share extended attributes among inodes,
2628 + * we should not need the ext3_xattr_sem semaphore. However, the
2629 + * filesystem may still contain shared blocks, so we always take
2633 +DECLARE_MUTEX(ext3_xattr_sem);
2636 +ext3_xattr_new_block(handle_t *handle, struct inode *inode,
2637 + int * errp, int force)
2639 + struct super_block *sb = inode->i_sb;
2640 + int goal = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) +
2641 + EXT3_I(inode)->i_block_group * EXT3_BLOCKS_PER_GROUP(sb);
2643 + /* How can we enforce the allocation? */
2644 + int block = ext3_new_block(handle, inode, goal, 0, 0, errp);
2647 + inode->i_blocks += inode->i_sb->s_blocksize >> 9;
2653 +ext3_xattr_quota_alloc(struct inode *inode, int force)
2655 + /* How can we enforce the allocation? */
2657 + int error = DQUOT_ALLOC_BLOCK(inode->i_sb, inode, 1);
2659 + inode->i_blocks += inode->i_sb->s_blocksize >> 9;
2661 + int error = DQUOT_ALLOC_BLOCK(inode, 1);
2669 +ext3_xattr_quota_free(struct inode *inode)
2671 + DQUOT_FREE_BLOCK(inode->i_sb, inode, 1);
2672 + inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
2676 +ext3_xattr_free_block(handle_t *handle, struct inode * inode,
2677 + unsigned long block)
2679 + ext3_free_blocks(handle, inode, block, 1);
2680 + inode->i_blocks -= inode->i_sb->s_blocksize >> 9;
2684 +# define ext3_xattr_quota_free(inode) \
2685 + DQUOT_FREE_BLOCK(inode, 1)
2686 +# define ext3_xattr_free_block(handle, inode, block) \
2687 + ext3_free_blocks(handle, inode, block, 1)
2690 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
2692 +static inline struct buffer_head *
2693 +sb_bread(struct super_block *sb, int block)
2695 + return bread(sb->s_dev, block, sb->s_blocksize);
2698 +static inline struct buffer_head *
2699 +sb_getblk(struct super_block *sb, int block)
2701 + return getblk(sb->s_dev, block, sb->s_blocksize);
2706 +struct ext3_xattr_handler *ext3_xattr_handlers[EXT3_XATTR_INDEX_MAX];
2707 +rwlock_t ext3_handler_lock = RW_LOCK_UNLOCKED;
2710 +ext3_xattr_register(int name_index, struct ext3_xattr_handler *handler)
2712 + int error = -EINVAL;
2714 + if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX) {
2715 + write_lock(&ext3_handler_lock);
2716 + if (!ext3_xattr_handlers[name_index-1]) {
2717 + ext3_xattr_handlers[name_index-1] = handler;
2720 + write_unlock(&ext3_handler_lock);
2726 +ext3_xattr_unregister(int name_index, struct ext3_xattr_handler *handler)
2728 + if (name_index > 0 || name_index <= EXT3_XATTR_INDEX_MAX) {
2729 + write_lock(&ext3_handler_lock);
2730 + ext3_xattr_handlers[name_index-1] = NULL;
2731 + write_unlock(&ext3_handler_lock);
2735 +static inline const char *
2736 +strcmp_prefix(const char *a, const char *a_prefix)
2738 + while (*a_prefix && *a == *a_prefix) {
2742 + return *a_prefix ? NULL : a;
2746 + * Decode the extended attribute name, and translate it into
2747 + * the name_index and name suffix.
2749 +static inline struct ext3_xattr_handler *
2750 +ext3_xattr_resolve_name(const char **name)
2752 + struct ext3_xattr_handler *handler = NULL;
2757 + read_lock(&ext3_handler_lock);
2758 + for (i=0; i<EXT3_XATTR_INDEX_MAX; i++) {
2759 + if (ext3_xattr_handlers[i]) {
2760 + const char *n = strcmp_prefix(*name,
2761 + ext3_xattr_handlers[i]->prefix);
2763 + handler = ext3_xattr_handlers[i];
2769 + read_unlock(&ext3_handler_lock);
2773 +static inline struct ext3_xattr_handler *
2774 +ext3_xattr_handler(int name_index)
2776 + struct ext3_xattr_handler *handler = NULL;
2777 + if (name_index > 0 && name_index <= EXT3_XATTR_INDEX_MAX) {
2778 + read_lock(&ext3_handler_lock);
2779 + handler = ext3_xattr_handlers[name_index-1];
2780 + read_unlock(&ext3_handler_lock);
2786 + * Inode operation getxattr()
2788 + * dentry->d_inode->i_sem down
2789 + * BKL held [before 2.5.x]
2792 +ext3_getxattr(struct dentry *dentry, const char *name,
2793 + void *buffer, size_t size)
2795 + struct ext3_xattr_handler *handler;
2796 + struct inode *inode = dentry->d_inode;
2798 + handler = ext3_xattr_resolve_name(&name);
2801 + return handler->get(inode, name, buffer, size);
2805 + * Inode operation listxattr()
2807 + * dentry->d_inode->i_sem down
2808 + * BKL held [before 2.5.x]
2811 +ext3_listxattr(struct dentry *dentry, char *buffer, size_t size)
2813 + return ext3_xattr_list(dentry->d_inode, buffer, size);
2817 + * Inode operation setxattr()
2819 + * dentry->d_inode->i_sem down
2820 + * BKL held [before 2.5.x]
2823 +ext3_setxattr(struct dentry *dentry, const char *name,
2824 + const void *value, size_t size, int flags)
2826 + struct ext3_xattr_handler *handler;
2827 + struct inode *inode = dentry->d_inode;
2830 + value = ""; /* empty EA, do not remove */
2831 + handler = ext3_xattr_resolve_name(&name);
2834 + return handler->set(inode, name, value, size, flags);
2838 + * Inode operation removexattr()
2840 + * dentry->d_inode->i_sem down
2841 + * BKL held [before 2.5.x]
2844 +ext3_removexattr(struct dentry *dentry, const char *name)
2846 + struct ext3_xattr_handler *handler;
2847 + struct inode *inode = dentry->d_inode;
2849 + handler = ext3_xattr_resolve_name(&name);
2852 + return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
2856 + * ext3_xattr_get()
2858 + * Copy an extended attribute into the buffer
2859 + * provided, or compute the buffer size required.
2860 + * Buffer is NULL to compute the size of the buffer required.
2862 + * Returns a negative error number on failure, or the number of bytes
2863 + * used / required on success.
2866 +ext3_xattr_get(struct inode *inode, int name_index, const char *name,
2867 + void *buffer, size_t buffer_size)
2869 + struct buffer_head *bh = NULL;
2870 + struct ext3_xattr_entry *entry;
2871 + unsigned int block, size;
2873 + int name_len, error;
2875 + ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
2876 + name_index, name, buffer, (long)buffer_size);
2880 + if (!EXT3_I(inode)->i_file_acl)
2882 + block = EXT3_I(inode)->i_file_acl;
2883 + ea_idebug(inode, "reading block %d", block);
2884 + bh = sb_bread(inode->i_sb, block);
2887 + ea_bdebug(bh, "b_count=%d, refcount=%d",
2888 + atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
2889 + end = bh->b_data + bh->b_size;
2890 + if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
2891 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
2892 +bad_block: ext3_error(inode->i_sb, "ext3_xattr_get",
2893 + "inode %ld: bad block %d", inode->i_ino, block);
2897 + /* find named attribute */
2898 + name_len = strlen(name);
2901 + if (name_len > 255)
2903 + entry = FIRST_ENTRY(bh);
2904 + while (!IS_LAST_ENTRY(entry)) {
2905 + struct ext3_xattr_entry *next =
2906 + EXT3_XATTR_NEXT(entry);
2907 + if ((char *)next >= end)
2909 + if (name_index == entry->e_name_index &&
2910 + name_len == entry->e_name_len &&
2911 + memcmp(name, entry->e_name, name_len) == 0)
2915 + /* Check the remaining name entries */
2916 + while (!IS_LAST_ENTRY(entry)) {
2917 + struct ext3_xattr_entry *next =
2918 + EXT3_XATTR_NEXT(entry);
2919 + if ((char *)next >= end)
2923 + if (ext3_xattr_cache_insert(bh))
2924 + ea_idebug(inode, "cache insert failed");
2928 + /* check the buffer size */
2929 + if (entry->e_value_block != 0)
2931 + size = le32_to_cpu(entry->e_value_size);
2932 + if (size > inode->i_sb->s_blocksize ||
2933 + le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize)
2936 + if (ext3_xattr_cache_insert(bh))
2937 + ea_idebug(inode, "cache insert failed");
2940 + if (size > buffer_size)
2942 + /* return value of attribute */
2943 + memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs),
2955 + * ext3_xattr_list()
2957 + * Copy a list of attribute names into the buffer
2958 + * provided, or compute the buffer size required.
2959 + * Buffer is NULL to compute the size of the buffer required.
2961 + * Returns a negative error number on failure, or the number of bytes
2962 + * used / required on success.
2965 +ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
2967 + struct buffer_head *bh = NULL;
2968 + struct ext3_xattr_entry *entry;
2969 + unsigned int block, size = 0;
2973 + ea_idebug(inode, "buffer=%p, buffer_size=%ld",
2974 + buffer, (long)buffer_size);
2976 + if (!EXT3_I(inode)->i_file_acl)
2978 + block = EXT3_I(inode)->i_file_acl;
2979 + ea_idebug(inode, "reading block %d", block);
2980 + bh = sb_bread(inode->i_sb, block);
2983 + ea_bdebug(bh, "b_count=%d, refcount=%d",
2984 + atomic_read(&(bh->b_count)), le32_to_cpu(HDR(bh)->h_refcount));
2985 + end = bh->b_data + bh->b_size;
2986 + if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
2987 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
2988 +bad_block: ext3_error(inode->i_sb, "ext3_xattr_list",
2989 + "inode %ld: bad block %d", inode->i_ino, block);
2993 + /* compute the size required for the list of attribute names */
2994 + for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
2995 + entry = EXT3_XATTR_NEXT(entry)) {
2996 + struct ext3_xattr_handler *handler;
2997 + struct ext3_xattr_entry *next =
2998 + EXT3_XATTR_NEXT(entry);
2999 + if ((char *)next >= end)
3002 + handler = ext3_xattr_handler(entry->e_name_index);
3004 + size += handler->list(NULL, inode, entry->e_name,
3005 + entry->e_name_len);
3008 + if (ext3_xattr_cache_insert(bh))
3009 + ea_idebug(inode, "cache insert failed");
3015 + if (size > buffer_size)
3019 + /* list the attribute names */
3021 + for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
3022 + entry = EXT3_XATTR_NEXT(entry)) {
3023 + struct ext3_xattr_handler *handler;
3025 + handler = ext3_xattr_handler(entry->e_name_index);
3027 + buf += handler->list(buf, inode, entry->e_name,
3028 + entry->e_name_len);
3039 + * If the EXT3_FEATURE_COMPAT_EXT_ATTR feature of this file system is
3040 + * not set, set it.
3042 +static void ext3_xattr_update_super_block(handle_t *handle,
3043 + struct super_block *sb)
3045 + if (EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_EXT_ATTR))
3049 + ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh);
3050 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
3051 + EXT3_SB(sb)->s_feature_compat |= EXT3_FEATURE_COMPAT_EXT_ATTR;
3053 + EXT3_SB(sb)->s_es->s_feature_compat |=
3054 + cpu_to_le32(EXT3_FEATURE_COMPAT_EXT_ATTR);
3056 + ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
3061 + * ext3_xattr_set()
3063 + * Create, replace or remove an extended attribute for this inode. Buffer
3064 + * is NULL to remove an existing extended attribute, and non-NULL to
3065 + * either replace an existing extended attribute, or create a new extended
3066 + * attribute. The flags XATTR_REPLACE and XATTR_CREATE
3067 + * specify that an extended attribute must exist and must not exist
3068 + * previous to the call, respectively.
3070 + * Returns 0, or a negative error number on failure.
3073 +ext3_xattr_set(handle_t *handle, struct inode *inode, int name_index,
3074 + const char *name, const void *value, size_t value_len, int flags)
3076 + struct super_block *sb = inode->i_sb;
3077 + struct buffer_head *bh = NULL;
3078 + struct ext3_xattr_header *header = NULL;
3079 + struct ext3_xattr_entry *here, *last;
3080 + unsigned int name_len;
3081 + int block = EXT3_I(inode)->i_file_acl;
3082 + int min_offs = sb->s_blocksize, not_found = 1, free, error;
3086 + * header -- Points either into bh, or to a temporarily
3087 + * allocated buffer.
3088 + * here -- The named entry found, or the place for inserting, within
3089 + * the block pointed to by header.
3090 + * last -- Points right after the last named entry within the block
3091 + * pointed to by header.
3092 + * min_offs -- The offset of the first value (values are aligned
3093 + * towards the end of the block).
3094 + * end -- Points right after the block pointed to by header.
3097 + ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld",
3098 + name_index, name, value, (long)value_len);
3100 + if (IS_RDONLY(inode))
3102 + if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
3104 + if (value == NULL)
3108 + name_len = strlen(name);
3109 + if (name_len > 255 || value_len > sb->s_blocksize)
3111 + down(&ext3_xattr_sem);
3114 + /* The inode already has an extended attribute block. */
3115 + bh = sb_bread(sb, block);
3119 + ea_bdebug(bh, "b_count=%d, refcount=%d",
3120 + atomic_read(&(bh->b_count)),
3121 + le32_to_cpu(HDR(bh)->h_refcount));
3123 + end = bh->b_data + bh->b_size;
3124 + if (header->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
3125 + header->h_blocks != cpu_to_le32(1)) {
3126 +bad_block: ext3_error(sb, "ext3_xattr_set",
3127 + "inode %ld: bad block %d", inode->i_ino, block);
3131 + /* Find the named attribute. */
3132 + here = FIRST_ENTRY(bh);
3133 + while (!IS_LAST_ENTRY(here)) {
3134 + struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(here);
3135 + if ((char *)next >= end)
3137 + if (!here->e_value_block && here->e_value_size) {
3138 + int offs = le16_to_cpu(here->e_value_offs);
3139 + if (offs < min_offs)
3142 + not_found = name_index - here->e_name_index;
3144 + not_found = name_len - here->e_name_len;
3146 + not_found = memcmp(name, here->e_name,name_len);
3147 + if (not_found <= 0)
3152 + /* We still need to compute min_offs and last. */
3153 + while (!IS_LAST_ENTRY(last)) {
3154 + struct ext3_xattr_entry *next = EXT3_XATTR_NEXT(last);
3155 + if ((char *)next >= end)
3157 + if (!last->e_value_block && last->e_value_size) {
3158 + int offs = le16_to_cpu(last->e_value_offs);
3159 + if (offs < min_offs)
3165 + /* Check whether we have enough space left. */
3166 + free = min_offs - ((char*)last - (char*)header) - sizeof(__u32);
3168 + /* We will use a new extended attribute block. */
3169 + free = sb->s_blocksize -
3170 + sizeof(struct ext3_xattr_header) - sizeof(__u32);
3171 + here = last = NULL; /* avoid gcc uninitialized warning. */
3175 + /* Request to remove a nonexistent attribute? */
3177 + if (flags & XATTR_REPLACE)
3180 + if (value == NULL)
3183 + free -= EXT3_XATTR_LEN(name_len);
3185 + /* Request to create an existing attribute? */
3187 + if (flags & XATTR_CREATE)
3189 + if (!here->e_value_block && here->e_value_size) {
3190 + unsigned int size = le32_to_cpu(here->e_value_size);
3192 + if (le16_to_cpu(here->e_value_offs) + size >
3193 + sb->s_blocksize || size > sb->s_blocksize)
3195 + free += EXT3_XATTR_SIZE(size);
3198 + free -= EXT3_XATTR_SIZE(value_len);
3203 + /* Here we know that we can set the new attribute. */
3206 + if (header->h_refcount == cpu_to_le32(1)) {
3207 + ea_bdebug(bh, "modifying in-place");
3208 + ext3_xattr_cache_remove(bh);
3209 + error = ext3_journal_get_write_access(handle, bh);
3215 + ea_bdebug(bh, "cloning");
3216 + header = kmalloc(bh->b_size, GFP_KERNEL);
3218 + if (header == NULL)
3220 + memcpy(header, HDR(bh), bh->b_size);
3221 + header->h_refcount = cpu_to_le32(1);
3222 + offset = (char *)header - bh->b_data;
3223 + here = ENTRY((char *)here + offset);
3224 + last = ENTRY((char *)last + offset);
3227 + /* Allocate a buffer where we construct the new block. */
3228 + header = kmalloc(sb->s_blocksize, GFP_KERNEL);
3230 + if (header == NULL)
3232 + memset(header, 0, sb->s_blocksize);
3233 + end = (char *)header + sb->s_blocksize;
3234 + header->h_magic = cpu_to_le32(EXT3_XATTR_MAGIC);
3235 + header->h_blocks = header->h_refcount = cpu_to_le32(1);
3236 + last = here = ENTRY(header+1);
3240 + /* Insert the new name. */
3241 + int size = EXT3_XATTR_LEN(name_len);
3242 + int rest = (char *)last - (char *)here;
3243 + memmove((char *)here + size, here, rest);
3244 + memset(here, 0, size);
3245 + here->e_name_index = name_index;
3246 + here->e_name_len = name_len;
3247 + memcpy(here->e_name, name, name_len);
3249 + /* Remove the old value. */
3250 + if (!here->e_value_block && here->e_value_size) {
3251 + char *first_val = (char *)header + min_offs;
3252 + int offs = le16_to_cpu(here->e_value_offs);
3253 + char *val = (char *)header + offs;
3254 + size_t size = EXT3_XATTR_SIZE(
3255 + le32_to_cpu(here->e_value_size));
3256 + memmove(first_val + size, first_val, val - first_val);
3257 + memset(first_val, 0, size);
3258 + here->e_value_offs = 0;
3261 + /* Adjust all value offsets. */
3262 + last = ENTRY(header+1);
3263 + while (!IS_LAST_ENTRY(last)) {
3264 + int o = le16_to_cpu(last->e_value_offs);
3265 + if (!last->e_value_block && o < offs)
3266 + last->e_value_offs =
3267 + cpu_to_le16(o + size);
3268 + last = EXT3_XATTR_NEXT(last);
3271 + if (value == NULL) {
3272 + /* Remove this attribute. */
3273 + if (EXT3_XATTR_NEXT(ENTRY(header+1)) == last) {
3274 + /* This block is now empty. */
3275 + error = ext3_xattr_set2(handle, inode, bh,NULL);
3278 + /* Remove the old name. */
3279 + int size = EXT3_XATTR_LEN(name_len);
3280 + last = ENTRY((char *)last - size);
3281 + memmove(here, (char*)here + size,
3282 + (char*)last - (char*)here);
3283 + memset(last, 0, size);
3288 + if (value != NULL) {
3289 + /* Insert the new value. */
3290 + here->e_value_size = cpu_to_le32(value_len);
3292 + size_t size = EXT3_XATTR_SIZE(value_len);
3293 + char *val = (char *)header + min_offs - size;
3294 + here->e_value_offs =
3295 + cpu_to_le16((char *)val - (char *)header);
3296 + memset(val + size - EXT3_XATTR_PAD, 0,
3297 + EXT3_XATTR_PAD); /* Clear the pad bytes. */
3298 + memcpy(val, value, value_len);
3301 + ext3_xattr_rehash(header, here);
3303 + error = ext3_xattr_set2(handle, inode, bh, header);
3307 + if (!(bh && header == HDR(bh)))
3309 + up(&ext3_xattr_sem);
3315 + * Second half of ext3_xattr_set(): Update the file system.
3318 +ext3_xattr_set2(handle_t *handle, struct inode *inode,
3319 + struct buffer_head *old_bh, struct ext3_xattr_header *header)
3321 + struct super_block *sb = inode->i_sb;
3322 + struct buffer_head *new_bh = NULL;
3326 + new_bh = ext3_xattr_cache_find(inode, header);
3329 + * We found an identical block in the cache.
3330 + * The old block will be released after updating
3333 + ea_bdebug(old_bh, "reusing block %ld",
3334 + new_bh->b_blocknr);
3337 + if (ext3_xattr_quota_alloc(inode, 1))
3340 + error = ext3_journal_get_write_access(handle, new_bh);
3343 + HDR(new_bh)->h_refcount = cpu_to_le32(
3344 + le32_to_cpu(HDR(new_bh)->h_refcount) + 1);
3345 + ea_bdebug(new_bh, "refcount now=%d",
3346 + le32_to_cpu(HDR(new_bh)->h_refcount));
3347 + } else if (old_bh && header == HDR(old_bh)) {
3348 + /* Keep this block. */
3350 + (void)ext3_xattr_cache_insert(new_bh);
3352 + /* We need to allocate a new block */
3353 + int force = EXT3_I(inode)->i_file_acl != 0;
3354 + int block = ext3_xattr_new_block(handle, inode,
3358 + ea_idebug(inode, "creating block %d", block);
3360 + new_bh = sb_getblk(sb, block);
3362 +getblk_failed: ext3_xattr_free_block(handle, inode, block);
3366 + lock_buffer(new_bh);
3367 + error = ext3_journal_get_create_access(handle, new_bh);
3369 + unlock_buffer(new_bh);
3370 + goto getblk_failed;
3372 + memcpy(new_bh->b_data, header, new_bh->b_size);
3373 + mark_buffer_uptodate(new_bh, 1);
3374 + unlock_buffer(new_bh);
3375 + (void)ext3_xattr_cache_insert(new_bh);
3377 + ext3_xattr_update_super_block(handle, sb);
3379 + error = ext3_journal_dirty_metadata(handle, new_bh);
3384 + /* Update the inode. */
3385 + EXT3_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
3386 + inode->i_ctime = CURRENT_TIME;
3387 + ext3_mark_inode_dirty(handle, inode);
3388 + if (IS_SYNC(inode))
3389 + handle->h_sync = 1;
3392 + if (old_bh && old_bh != new_bh) {
3394 + * If there was an old block, and we are not still using it,
3395 + * we now release the old block.
3397 + unsigned int refcount = le32_to_cpu(HDR(old_bh)->h_refcount);
3399 + error = ext3_journal_get_write_access(handle, old_bh);
3402 + if (refcount == 1) {
3403 + /* Free the old block. */
3404 + ea_bdebug(old_bh, "freeing");
3405 + ext3_xattr_free_block(handle, inode, old_bh->b_blocknr);
3407 + /* ext3_forget() calls bforget() for us, but we
3408 + let our caller release old_bh, so we need to
3409 + duplicate the handle before. */
3411 + ext3_forget(handle, 1, inode, old_bh,old_bh->b_blocknr);
3413 + /* Decrement the refcount only. */
3415 + HDR(old_bh)->h_refcount = cpu_to_le32(refcount);
3416 + ext3_xattr_quota_free(inode);
3417 + ext3_journal_dirty_metadata(handle, old_bh);
3418 + ea_bdebug(old_bh, "refcount now=%d", refcount);
3423 + if (old_bh != new_bh)
3430 + * ext3_xattr_delete_inode()
3432 + * Free extended attribute resources associated with this inode. This
3433 + * is called immediately before an inode is freed.
3436 +ext3_xattr_delete_inode(handle_t *handle, struct inode *inode)
3438 + struct buffer_head *bh;
3439 + unsigned int block = EXT3_I(inode)->i_file_acl;
3443 + down(&ext3_xattr_sem);
3445 + bh = sb_bread(inode->i_sb, block);
3447 + ext3_error(inode->i_sb, "ext3_xattr_delete_inode",
3448 + "inode %ld: block %d read error", inode->i_ino, block);
3451 + ea_bdebug(bh, "b_count=%d", atomic_read(&(bh->b_count)));
3452 + if (HDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
3453 + HDR(bh)->h_blocks != cpu_to_le32(1)) {
3454 + ext3_error(inode->i_sb, "ext3_xattr_delete_inode",
3455 + "inode %ld: bad block %d", inode->i_ino, block);
3458 + ext3_journal_get_write_access(handle, bh);
3459 + ea_bdebug(bh, "refcount now=%d", le32_to_cpu(HDR(bh)->h_refcount) - 1);
3460 + if (HDR(bh)->h_refcount == cpu_to_le32(1)) {
3461 + ext3_xattr_cache_remove(bh);
3462 + ext3_xattr_free_block(handle, inode, block);
3463 + ext3_forget(handle, 1, inode, bh, block);
3466 + HDR(bh)->h_refcount = cpu_to_le32(
3467 + le32_to_cpu(HDR(bh)->h_refcount) - 1);
3468 + ext3_journal_dirty_metadata(handle, bh);
3469 + if (IS_SYNC(inode))
3470 + handle->h_sync = 1;
3471 + ext3_xattr_quota_free(inode);
3473 + EXT3_I(inode)->i_file_acl = 0;
3477 + up(&ext3_xattr_sem);
3481 + * ext3_xattr_put_super()
3483 + * This is called when a file system is unmounted.
3486 +ext3_xattr_put_super(struct super_block *sb)
3488 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
3489 + mb_cache_shrink(ext3_xattr_cache, sb->s_dev);
3493 +#ifdef CONFIG_EXT3_FS_XATTR_SHARING
3496 + * ext3_xattr_cache_insert()
3498 + * Create a new entry in the extended attribute cache, and insert
3499 + * it unless such an entry is already in the cache.
3501 + * Returns 0, or a negative error number on failure.
3504 +ext3_xattr_cache_insert(struct buffer_head *bh)
3506 + __u32 hash = le32_to_cpu(HDR(bh)->h_hash);
3507 + struct mb_cache_entry *ce;
3510 + ce = mb_cache_entry_alloc(ext3_xattr_cache);
3513 + error = mb_cache_entry_insert(ce, bh->b_dev, bh->b_blocknr, &hash);
3515 + mb_cache_entry_free(ce);
3516 + if (error == -EBUSY) {
3517 + ea_bdebug(bh, "already in cache (%d cache entries)",
3518 + atomic_read(&ext3_xattr_cache->c_entry_count));
3522 + ea_bdebug(bh, "inserting [%x] (%d cache entries)", (int)hash,
3523 + atomic_read(&ext3_xattr_cache->c_entry_count));
3524 + mb_cache_entry_release(ce);
3530 + * ext3_xattr_cmp()
3532 + * Compare two extended attribute blocks for equality.
3534 + * Returns 0 if the blocks are equal, 1 if they differ, and
3535 + * a negative error number on errors.
3538 +ext3_xattr_cmp(struct ext3_xattr_header *header1,
3539 + struct ext3_xattr_header *header2)
3541 + struct ext3_xattr_entry *entry1, *entry2;
3543 + entry1 = ENTRY(header1+1);
3544 + entry2 = ENTRY(header2+1);
3545 + while (!IS_LAST_ENTRY(entry1)) {
3546 + if (IS_LAST_ENTRY(entry2))
3548 + if (entry1->e_hash != entry2->e_hash ||
3549 + entry1->e_name_len != entry2->e_name_len ||
3550 + entry1->e_value_size != entry2->e_value_size ||
3551 + memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len))
3553 + if (entry1->e_value_block != 0 || entry2->e_value_block != 0)
3555 + if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs),
3556 + (char *)header2 + le16_to_cpu(entry2->e_value_offs),
3557 + le32_to_cpu(entry1->e_value_size)))
3560 + entry1 = EXT3_XATTR_NEXT(entry1);
3561 + entry2 = EXT3_XATTR_NEXT(entry2);
3563 + if (!IS_LAST_ENTRY(entry2))
3569 + * ext3_xattr_cache_find()
3571 + * Find an identical extended attribute block.
3573 + * Returns a pointer to the block found, or NULL if such a block was
3574 + * not found or an error occurred.
3576 +static struct buffer_head *
3577 +ext3_xattr_cache_find(struct inode *inode, struct ext3_xattr_header *header)
3579 + __u32 hash = le32_to_cpu(header->h_hash);
3580 + struct mb_cache_entry *ce;
3582 + if (!header->h_hash)
3583 + return NULL; /* never share */
3584 + ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
3585 + ce = mb_cache_entry_find_first(ext3_xattr_cache, 0, inode->i_dev, hash);
3587 + struct buffer_head *bh = sb_bread(inode->i_sb, ce->e_block);
3590 + ext3_error(inode->i_sb, "ext3_xattr_cache_find",
3591 + "inode %ld: block %ld read error",
3592 + inode->i_ino, ce->e_block);
3593 + } else if (le32_to_cpu(HDR(bh)->h_refcount) >
3594 + EXT3_XATTR_REFCOUNT_MAX) {
3595 + ea_idebug(inode, "block %ld refcount %d>%d",ce->e_block,
3596 + le32_to_cpu(HDR(bh)->h_refcount),
3597 + EXT3_XATTR_REFCOUNT_MAX);
3598 + } else if (!ext3_xattr_cmp(header, HDR(bh))) {
3599 + ea_bdebug(bh, "b_count=%d",atomic_read(&(bh->b_count)));
3600 + mb_cache_entry_release(ce);
3604 + ce = mb_cache_entry_find_next(ce, 0, inode->i_dev, hash);
3610 + * ext3_xattr_cache_remove()
3612 + * Remove the cache entry of a block from the cache. Called when a
3613 + * block becomes invalid.
3616 +ext3_xattr_cache_remove(struct buffer_head *bh)
3618 + struct mb_cache_entry *ce;
3620 + ce = mb_cache_entry_get(ext3_xattr_cache, bh->b_dev, bh->b_blocknr);
3622 + ea_bdebug(bh, "removing (%d cache entries remaining)",
3623 + atomic_read(&ext3_xattr_cache->c_entry_count)-1);
3624 + mb_cache_entry_free(ce);
3626 + ea_bdebug(bh, "no cache entry");
3629 +#define NAME_HASH_SHIFT 5
3630 +#define VALUE_HASH_SHIFT 16
3633 + * ext3_xattr_hash_entry()
3635 + * Compute the hash of an extended attribute.
3637 +static inline void ext3_xattr_hash_entry(struct ext3_xattr_header *header,
3638 + struct ext3_xattr_entry *entry)
3641 + char *name = entry->e_name;
3644 + for (n=0; n < entry->e_name_len; n++) {
3645 + hash = (hash << NAME_HASH_SHIFT) ^
3646 + (hash >> (8*sizeof(hash) - NAME_HASH_SHIFT)) ^
3650 + if (entry->e_value_block == 0 && entry->e_value_size != 0) {
3651 + __u32 *value = (__u32 *)((char *)header +
3652 + le16_to_cpu(entry->e_value_offs));
3653 + for (n = (le32_to_cpu(entry->e_value_size) +
3654 + EXT3_XATTR_ROUND) >> EXT3_XATTR_PAD_BITS; n; n--) {
3655 + hash = (hash << VALUE_HASH_SHIFT) ^
3656 + (hash >> (8*sizeof(hash) - VALUE_HASH_SHIFT)) ^
3657 + le32_to_cpu(*value++);
3660 + entry->e_hash = cpu_to_le32(hash);
3663 +#undef NAME_HASH_SHIFT
3664 +#undef VALUE_HASH_SHIFT
3666 +#define BLOCK_HASH_SHIFT 16
3669 + * ext3_xattr_rehash()
3671 + * Re-compute the extended attribute hash value after an entry has changed.
3673 +static void ext3_xattr_rehash(struct ext3_xattr_header *header,
3674 + struct ext3_xattr_entry *entry)
3676 + struct ext3_xattr_entry *here;
3679 + ext3_xattr_hash_entry(header, entry);
3680 + here = ENTRY(header+1);
3681 + while (!IS_LAST_ENTRY(here)) {
3682 + if (!here->e_hash) {
3683 + /* Block is not shared if an entry's hash value == 0 */
3687 + hash = (hash << BLOCK_HASH_SHIFT) ^
3688 + (hash >> (8*sizeof(hash) - BLOCK_HASH_SHIFT)) ^
3689 + le32_to_cpu(here->e_hash);
3690 + here = EXT3_XATTR_NEXT(here);
3692 + header->h_hash = cpu_to_le32(hash);
3695 +#undef BLOCK_HASH_SHIFT
3698 +init_ext3_xattr(void)
3700 + ext3_xattr_cache = mb_cache_create("ext3_xattr", NULL,
3701 + sizeof(struct mb_cache_entry) +
3702 + sizeof(struct mb_cache_entry_index), 1, 61);
3703 + if (!ext3_xattr_cache)
3710 +exit_ext3_xattr(void)
3712 + if (ext3_xattr_cache)
3713 + mb_cache_destroy(ext3_xattr_cache);
3714 + ext3_xattr_cache = NULL;
3717 +#else /* CONFIG_EXT3_FS_XATTR_SHARING */
3720 +init_ext3_xattr(void)
3726 +exit_ext3_xattr(void)
3730 +#endif /* CONFIG_EXT3_FS_XATTR_SHARING */
3731 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
3732 +++ linux-2.4.20-root/fs/ext3/xattr_user.c 2003-05-07 18:08:03.000000000 +0800
3735 + * linux/fs/ext3/xattr_user.c
3736 + * Handler for extended user attributes.
3738 + * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
3741 +#include <linux/module.h>
3742 +#include <linux/string.h>
3743 +#include <linux/fs.h>
3744 +#include <linux/ext3_jbd.h>
3745 +#include <linux/ext3_fs.h>
3746 +#include <linux/ext3_xattr.h>
3748 +#ifdef CONFIG_EXT3_FS_POSIX_ACL
3749 +# include <linux/ext3_acl.h>
3752 +#define XATTR_USER_PREFIX "user."
3755 +ext3_xattr_user_list(char *list, struct inode *inode,
3756 + const char *name, int name_len)
3758 + const int prefix_len = sizeof(XATTR_USER_PREFIX)-1;
3760 + if (!test_opt(inode->i_sb, XATTR_USER))
3764 + memcpy(list, XATTR_USER_PREFIX, prefix_len);
3765 + memcpy(list+prefix_len, name, name_len);
3766 + list[prefix_len + name_len] = '\0';
3768 + return prefix_len + name_len + 1;
3772 +ext3_xattr_user_get(struct inode *inode, const char *name,
3773 + void *buffer, size_t size)
3777 + if (strcmp(name, "") == 0)
3779 + if (!test_opt(inode->i_sb, XATTR_USER))
3781 +#ifdef CONFIG_EXT3_FS_POSIX_ACL
3782 + error = ext3_permission_locked(inode, MAY_READ);
3784 + error = permission(inode, MAY_READ);
3789 + return ext3_xattr_get(inode, EXT3_XATTR_INDEX_USER, name,
3794 +ext3_xattr_user_set(struct inode *inode, const char *name,
3795 + const void *value, size_t size, int flags)
3800 + if (strcmp(name, "") == 0)
3802 + if (!test_opt(inode->i_sb, XATTR_USER))
3804 + if ( !S_ISREG(inode->i_mode) &&
3805 + (!S_ISDIR(inode->i_mode) || inode->i_mode & S_ISVTX))
3807 +#ifdef CONFIG_EXT3_FS_POSIX_ACL
3808 + error = ext3_permission_locked(inode, MAY_WRITE);
3810 + error = permission(inode, MAY_WRITE);
3815 + handle = ext3_journal_start(inode, EXT3_XATTR_TRANS_BLOCKS);
3816 + if (IS_ERR(handle))
3817 + return PTR_ERR(handle);
3818 + error = ext3_xattr_set(handle, inode, EXT3_XATTR_INDEX_USER, name,
3819 + value, size, flags);
3820 + ext3_journal_stop(handle, inode);
3825 +struct ext3_xattr_handler ext3_xattr_user_handler = {
3826 + prefix: XATTR_USER_PREFIX,
3827 + list: ext3_xattr_user_list,
3828 + get: ext3_xattr_user_get,
3829 + set: ext3_xattr_user_set,
3833 +init_ext3_xattr_user(void)
3835 + return ext3_xattr_register(EXT3_XATTR_INDEX_USER,
3836 + &ext3_xattr_user_handler);
3840 +exit_ext3_xattr_user(void)
3842 + ext3_xattr_unregister(EXT3_XATTR_INDEX_USER,
3843 + &ext3_xattr_user_handler);
3845 --- linux-2.4.20/fs/jfs/jfs_xattr.h~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
3846 +++ linux-2.4.20-root/fs/jfs/jfs_xattr.h 2003-05-07 18:08:03.000000000 +0800
3847 @@ -52,8 +52,10 @@ struct jfs_ea_list {
3848 #define END_EALIST(ealist) \
3849 ((struct jfs_ea *) (((char *) (ealist)) + EALIST_SIZE(ealist)))
3851 -extern int __jfs_setxattr(struct inode *, const char *, void *, size_t, int);
3852 -extern int jfs_setxattr(struct dentry *, const char *, void *, size_t, int);
3853 +extern int __jfs_setxattr(struct inode *, const char *, const void *, size_t,
3855 +extern int jfs_setxattr(struct dentry *, const char *, const void *, size_t,
3857 extern ssize_t __jfs_getxattr(struct inode *, const char *, void *, size_t);
3858 extern ssize_t jfs_getxattr(struct dentry *, const char *, void *, size_t);
3859 extern ssize_t jfs_listxattr(struct dentry *, char *, size_t);
3860 --- linux-2.4.20/fs/jfs/xattr.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
3861 +++ linux-2.4.20-root/fs/jfs/xattr.c 2003-05-07 18:08:03.000000000 +0800
3862 @@ -641,7 +641,7 @@ static int ea_put(struct inode *inode, s
3865 static int can_set_xattr(struct inode *inode, const char *name,
3866 - void *value, size_t value_len)
3867 + const void *value, size_t value_len)
3869 if (IS_RDONLY(inode))
3871 @@ -660,7 +660,7 @@ static int can_set_xattr(struct inode *i
3872 return permission(inode, MAY_WRITE);
3875 -int __jfs_setxattr(struct inode *inode, const char *name, void *value,
3876 +int __jfs_setxattr(struct inode *inode, const char *name, const void *value,
3877 size_t value_len, int flags)
3879 struct jfs_ea_list *ealist;
3880 @@ -799,7 +799,7 @@ int __jfs_setxattr(struct inode *inode,
3884 -int jfs_setxattr(struct dentry *dentry, const char *name, void *value,
3885 +int jfs_setxattr(struct dentry *dentry, const char *name, const void *value,
3886 size_t value_len, int flags)
3888 if (value == NULL) { /* empty EA, do not remove */
3889 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
3890 +++ linux-2.4.20-root/fs/mbcache.c 2003-05-07 18:08:03.000000000 +0800
3893 + * linux/fs/mbcache.c
3894 + * (C) 2001-2002 Andreas Gruenbacher, <a.gruenbacher@computer.org>
3898 + * Filesystem Meta Information Block Cache (mbcache)
3900 + * The mbcache caches blocks of block devices that need to be located
3901 + * by their device/block number, as well as by other criteria (such
3902 + * as the block's contents).
3904 + * There can only be one cache entry in a cache per device and block number.
3905 + * Additional indexes need not be unique in this sense. The number of
3906 + * additional indexes (=other criteria) can be hardwired at compile time
3907 + * or specified at cache create time.
3909 + * Each cache entry is of fixed size. An entry may be `valid' or `invalid'
3910 + * in the cache. A valid entry is in the main hash tables of the cache,
3911 + * and may also be in the lru list. An invalid entry is not in any hashes
3914 + * A valid cache entry is only in the lru list if no handles refer to it.
3915 + * Invalid cache entries will be freed when the last handle to the cache
3916 + * entry is released. Entries that cannot be freed immediately are put
3917 + * back on the lru list.
3920 +#include <linux/kernel.h>
3921 +#include <linux/module.h>
3923 +#include <linux/fs.h>
3924 +#include <linux/slab.h>
3925 +#include <linux/sched.h>
3926 +#include <linux/cache_def.h>
3927 +#include <linux/version.h>
3928 +#include <linux/init.h>
3929 +#include <linux/mbcache.h>
3932 +#ifdef MB_CACHE_DEBUG
3933 +# define mb_debug(f...) do { \
3934 + printk(KERN_DEBUG f); \
3937 +#define mb_assert(c) do { if (!(c)) \
3938 + printk(KERN_ERR "assertion " #c " failed\n"); \
3941 +# define mb_debug(f...) do { } while(0)
3942 +# define mb_assert(c) do { } while(0)
3944 +#define mb_error(f...) do { \
3945 + printk(KERN_ERR f); \
3949 +MODULE_AUTHOR("Andreas Gruenbacher <a.gruenbacher@computer.org>");
3950 +MODULE_DESCRIPTION("Meta block cache (for extended attributes)");
3951 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
3952 +MODULE_LICENSE("GPL");
3955 +EXPORT_SYMBOL(mb_cache_create);
3956 +EXPORT_SYMBOL(mb_cache_shrink);
3957 +EXPORT_SYMBOL(mb_cache_destroy);
3958 +EXPORT_SYMBOL(mb_cache_entry_alloc);
3959 +EXPORT_SYMBOL(mb_cache_entry_insert);
3960 +EXPORT_SYMBOL(mb_cache_entry_release);
3961 +EXPORT_SYMBOL(mb_cache_entry_takeout);
3962 +EXPORT_SYMBOL(mb_cache_entry_free);
3963 +EXPORT_SYMBOL(mb_cache_entry_dup);
3964 +EXPORT_SYMBOL(mb_cache_entry_get);
3965 +#if !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0)
3966 +EXPORT_SYMBOL(mb_cache_entry_find_first);
3967 +EXPORT_SYMBOL(mb_cache_entry_find_next);
3972 + * Global data: list of all mbcache's, lru list, and a spinlock for
3973 + * accessing cache data structures on SMP machines. The lru list is
3974 + * global across all mbcaches.
3977 +static LIST_HEAD(mb_cache_list);
3978 +static LIST_HEAD(mb_cache_lru_list);
3979 +static spinlock_t mb_cache_spinlock = SPIN_LOCK_UNLOCKED;
3982 +mb_cache_indexes(struct mb_cache *cache)
3984 +#ifdef MB_CACHE_INDEXES_COUNT
3985 + return MB_CACHE_INDEXES_COUNT;
3987 + return cache->c_indexes_count;
3992 + * What the mbcache registers as to get shrunk dynamically.
3996 +mb_cache_memory_pressure(int priority, unsigned int gfp_mask);
3998 +static struct cache_definition mb_cache_definition = {
4000 + mb_cache_memory_pressure
4005 +__mb_cache_entry_is_hashed(struct mb_cache_entry *ce)
4007 + return !list_empty(&ce->e_block_list);
4012 +__mb_cache_entry_unhash(struct mb_cache_entry *ce)
4016 + if (__mb_cache_entry_is_hashed(ce)) {
4017 + list_del_init(&ce->e_block_list);
4018 + for (n=0; n<mb_cache_indexes(ce->e_cache); n++)
4019 + list_del(&ce->e_indexes[n].o_list);
4025 +__mb_cache_entry_forget(struct mb_cache_entry *ce, int gfp_mask)
4027 + struct mb_cache *cache = ce->e_cache;
4029 + mb_assert(atomic_read(&ce->e_used) == 0);
4030 + if (cache->c_op.free && cache->c_op.free(ce, gfp_mask)) {
4031 + /* free failed -- put back on the lru list
4032 + for freeing later. */
4033 + spin_lock(&mb_cache_spinlock);
4034 + list_add(&ce->e_lru_list, &mb_cache_lru_list);
4035 + spin_unlock(&mb_cache_spinlock);
4037 + kmem_cache_free(cache->c_entry_cache, ce);
4038 + atomic_dec(&cache->c_entry_count);
4044 +__mb_cache_entry_release_unlock(struct mb_cache_entry *ce)
4046 + if (atomic_dec_and_test(&ce->e_used)) {
4047 + if (__mb_cache_entry_is_hashed(ce))
4048 + list_add_tail(&ce->e_lru_list, &mb_cache_lru_list);
4050 + spin_unlock(&mb_cache_spinlock);
4051 + __mb_cache_entry_forget(ce, GFP_KERNEL);
4055 + spin_unlock(&mb_cache_spinlock);
4060 + * mb_cache_memory_pressure() memory pressure callback
4062 + * This function is called by the kernel memory management when memory
4065 + * @priority: Amount by which to shrink the cache (0 = highes priority)
4066 + * @gfp_mask: (ignored)
4069 +mb_cache_memory_pressure(int priority, unsigned int gfp_mask)
4071 + LIST_HEAD(free_list);
4072 + struct list_head *l, *ltmp;
4075 + spin_lock(&mb_cache_spinlock);
4076 + list_for_each(l, &mb_cache_list) {
4077 + struct mb_cache *cache =
4078 + list_entry(l, struct mb_cache, c_cache_list);
4079 + mb_debug("cache %s (%d)", cache->c_name,
4080 + atomic_read(&cache->c_entry_count));
4081 + count += atomic_read(&cache->c_entry_count);
4083 + mb_debug("trying to free %d of %d entries",
4084 + count / (priority ? priority : 1), count);
4086 + count /= priority;
4087 + while (count-- && !list_empty(&mb_cache_lru_list)) {
4088 + struct mb_cache_entry *ce =
4089 + list_entry(mb_cache_lru_list.next,
4090 + struct mb_cache_entry, e_lru_list);
4091 + list_del(&ce->e_lru_list);
4092 + __mb_cache_entry_unhash(ce);
4093 + list_add_tail(&ce->e_lru_list, &free_list);
4095 + spin_unlock(&mb_cache_spinlock);
4096 + list_for_each_safe(l, ltmp, &free_list) {
4097 + __mb_cache_entry_forget(list_entry(l, struct mb_cache_entry,
4098 + e_lru_list), gfp_mask);
4104 + * mb_cache_create() create a new cache
4106 + * All entries in one cache are equal size. Cache entries may be from
4107 + * multiple devices. If this is the first mbcache created, registers
4108 + * the cache with kernel memory management. Returns NULL if no more
4109 + * memory was available.
4111 + * @name: name of the cache (informal)
4112 + * @cache_op: contains the callback called when freeing a cache entry
4113 + * @entry_size: The size of a cache entry, including
4114 + * struct mb_cache_entry
4115 + * @indexes_count: number of additional indexes in the cache. Must equal
4116 + * MB_CACHE_INDEXES_COUNT if the number of indexes is
4118 + * @bucket_count: number of hash buckets
4121 +mb_cache_create(const char *name, struct mb_cache_op *cache_op,
4122 + size_t entry_size, int indexes_count, int bucket_count)
4125 + struct mb_cache *cache = NULL;
4127 + if(entry_size < sizeof(struct mb_cache_entry) +
4128 + indexes_count * sizeof(struct mb_cache_entry_index))
4131 + MOD_INC_USE_COUNT;
4132 + cache = kmalloc(sizeof(struct mb_cache) +
4133 + indexes_count * sizeof(struct list_head), GFP_KERNEL);
4136 + cache->c_name = name;
4137 + cache->c_op.free = NULL;
4139 + cache->c_op.free = cache_op->free;
4140 + atomic_set(&cache->c_entry_count, 0);
4141 + cache->c_bucket_count = bucket_count;
4142 +#ifdef MB_CACHE_INDEXES_COUNT
4143 + mb_assert(indexes_count == MB_CACHE_INDEXES_COUNT);
4145 + cache->c_indexes_count = indexes_count;
4147 + cache->c_block_hash = kmalloc(bucket_count * sizeof(struct list_head),
4149 + if (!cache->c_block_hash)
4151 + for (n=0; n<bucket_count; n++)
4152 + INIT_LIST_HEAD(&cache->c_block_hash[n]);
4153 + for (m=0; m<indexes_count; m++) {
4154 + cache->c_indexes_hash[m] = kmalloc(bucket_count *
4155 + sizeof(struct list_head),
4157 + if (!cache->c_indexes_hash[m])
4159 + for (n=0; n<bucket_count; n++)
4160 + INIT_LIST_HEAD(&cache->c_indexes_hash[m][n]);
4162 + cache->c_entry_cache = kmem_cache_create(name, entry_size, 0,
4163 + 0 /*SLAB_POISON | SLAB_RED_ZONE*/, NULL, NULL);
4164 + if (!cache->c_entry_cache)
4167 + spin_lock(&mb_cache_spinlock);
4168 + list_add(&cache->c_cache_list, &mb_cache_list);
4169 + spin_unlock(&mb_cache_spinlock);
4175 + kfree(cache->c_indexes_hash[m]);
4176 + if (cache->c_block_hash)
4177 + kfree(cache->c_block_hash);
4180 + MOD_DEC_USE_COUNT;
4186 + * mb_cache_shrink()
4188 + * Removes all cache entires of a device from the cache. All cache entries
4189 + * currently in use cannot be freed, and thus remain in the cache.
4191 + * @cache: which cache to shrink
4192 + * @dev: which device's cache entries to shrink
4195 +mb_cache_shrink(struct mb_cache *cache, kdev_t dev)
4197 + LIST_HEAD(free_list);
4198 + struct list_head *l, *ltmp;
4200 + spin_lock(&mb_cache_spinlock);
4201 + list_for_each_safe(l, ltmp, &mb_cache_lru_list) {
4202 + struct mb_cache_entry *ce =
4203 + list_entry(l, struct mb_cache_entry, e_lru_list);
4204 + if (ce->e_dev == dev) {
4205 + list_del(&ce->e_lru_list);
4206 + list_add_tail(&ce->e_lru_list, &free_list);
4207 + __mb_cache_entry_unhash(ce);
4210 + spin_unlock(&mb_cache_spinlock);
4211 + list_for_each_safe(l, ltmp, &free_list) {
4212 + __mb_cache_entry_forget(list_entry(l, struct mb_cache_entry,
4213 + e_lru_list), GFP_KERNEL);
4219 + * mb_cache_destroy()
4221 + * Shrinks the cache to its minimum possible size (hopefully 0 entries),
4222 + * and then destroys it. If this was the last mbcache, un-registers the
4223 + * mbcache from kernel memory management.
4226 +mb_cache_destroy(struct mb_cache *cache)
4228 + LIST_HEAD(free_list);
4229 + struct list_head *l, *ltmp;
4232 + spin_lock(&mb_cache_spinlock);
4233 + list_for_each_safe(l, ltmp, &mb_cache_lru_list) {
4234 + struct mb_cache_entry *ce =
4235 + list_entry(l, struct mb_cache_entry, e_lru_list);
4236 + if (ce->e_cache == cache) {
4237 + list_del(&ce->e_lru_list);
4238 + list_add_tail(&ce->e_lru_list, &free_list);
4239 + __mb_cache_entry_unhash(ce);
4242 + list_del(&cache->c_cache_list);
4243 + spin_unlock(&mb_cache_spinlock);
4244 + list_for_each_safe(l, ltmp, &free_list) {
4245 + __mb_cache_entry_forget(list_entry(l, struct mb_cache_entry,
4246 + e_lru_list), GFP_KERNEL);
4249 + if (atomic_read(&cache->c_entry_count) > 0) {
4250 + mb_error("cache %s: %d orphaned entries",
4252 + atomic_read(&cache->c_entry_count));
4255 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
4256 + /* We don't have kmem_cache_destroy() in 2.2.x */
4257 + kmem_cache_shrink(cache->c_entry_cache);
4259 + kmem_cache_destroy(cache->c_entry_cache);
4261 + for (n=0; n < mb_cache_indexes(cache); n++)
4262 + kfree(cache->c_indexes_hash[n]);
4263 + kfree(cache->c_block_hash);
4266 + MOD_DEC_USE_COUNT;
4271 + * mb_cache_entry_alloc()
4273 + * Allocates a new cache entry. The new entry will not be valid initially,
4274 + * and thus cannot be looked up yet. It should be filled with data, and
4275 + * then inserted into the cache using mb_cache_entry_insert(). Returns NULL
4276 + * if no more memory was available.
4278 +struct mb_cache_entry *
4279 +mb_cache_entry_alloc(struct mb_cache *cache)
4281 + struct mb_cache_entry *ce;
4283 + atomic_inc(&cache->c_entry_count);
4284 + ce = kmem_cache_alloc(cache->c_entry_cache, GFP_KERNEL);
4286 + INIT_LIST_HEAD(&ce->e_lru_list);
4287 + INIT_LIST_HEAD(&ce->e_block_list);
4288 + ce->e_cache = cache;
4289 + atomic_set(&ce->e_used, 1);
4296 + * mb_cache_entry_insert()
4298 + * Inserts an entry that was allocated using mb_cache_entry_alloc() into
4299 + * the cache. After this, the cache entry can be looked up, but is not yet
4300 + * in the lru list as the caller still holds a handle to it. Returns 0 on
4301 + * success, or -EBUSY if a cache entry for that device + inode exists
4302 + * already (this may happen after a failed lookup, if another process has
4303 + * inserted the same cache entry in the meantime).
4305 + * @dev: device the cache entry belongs to
4306 + * @block: block number
4307 + * @keys: array of additional keys. There must be indexes_count entries
4308 + * in the array (as specified when creating the cache).
4311 +mb_cache_entry_insert(struct mb_cache_entry *ce, kdev_t dev,
4312 + unsigned long block, unsigned int keys[])
4314 + struct mb_cache *cache = ce->e_cache;
4315 + unsigned int bucket = (HASHDEV(dev) + block) % cache->c_bucket_count;
4316 + struct list_head *l;
4317 + int error = -EBUSY, n;
4319 + spin_lock(&mb_cache_spinlock);
4320 + list_for_each(l, &cache->c_block_hash[bucket]) {
4321 + struct mb_cache_entry *ce =
4322 + list_entry(l, struct mb_cache_entry, e_block_list);
4323 + if (ce->e_dev == dev && ce->e_block == block)
4326 + __mb_cache_entry_unhash(ce);
4328 + ce->e_block = block;
4329 + list_add(&ce->e_block_list, &cache->c_block_hash[bucket]);
4330 + for (n=0; n<mb_cache_indexes(cache); n++) {
4331 + ce->e_indexes[n].o_key = keys[n];
4332 + bucket = keys[n] % cache->c_bucket_count;
4333 + list_add(&ce->e_indexes[n].o_list,
4334 + &cache->c_indexes_hash[n][bucket]);
4337 + spin_unlock(&mb_cache_spinlock);
4343 + * mb_cache_entry_release()
4345 + * Release a handle to a cache entry. When the last handle to a cache entry
4346 + * is released it is either freed (if it is invalid) or otherwise inserted
4347 + * in to the lru list.
4350 +mb_cache_entry_release(struct mb_cache_entry *ce)
4352 + spin_lock(&mb_cache_spinlock);
4353 + __mb_cache_entry_release_unlock(ce);
4358 + * mb_cache_entry_takeout()
4360 + * Take a cache entry out of the cache, making it invalid. The entry can later
4361 + * be re-inserted using mb_cache_entry_insert(), or released using
4362 + * mb_cache_entry_release().
4365 +mb_cache_entry_takeout(struct mb_cache_entry *ce)
4367 + spin_lock(&mb_cache_spinlock);
4368 + mb_assert(list_empty(&ce->e_lru_list));
4369 + __mb_cache_entry_unhash(ce);
4370 + spin_unlock(&mb_cache_spinlock);
4375 + * mb_cache_entry_free()
4377 + * This is equivalent to the sequence mb_cache_entry_takeout() --
4378 + * mb_cache_entry_release().
4381 +mb_cache_entry_free(struct mb_cache_entry *ce)
4383 + spin_lock(&mb_cache_spinlock);
4384 + mb_assert(list_empty(&ce->e_lru_list));
4385 + __mb_cache_entry_unhash(ce);
4386 + __mb_cache_entry_release_unlock(ce);
4391 + * mb_cache_entry_dup()
4393 + * Duplicate a handle to a cache entry (does not duplicate the cache entry
4394 + * itself). After the call, both the old and the new handle must be released.
4396 +struct mb_cache_entry *
4397 +mb_cache_entry_dup(struct mb_cache_entry *ce)
4399 + atomic_inc(&ce->e_used);
4405 + * mb_cache_entry_get()
4407 + * Get a cache entry by device / block number. (There can only be one entry
4408 + * in the cache per device and block.) Returns NULL if no such cache entry
4411 +struct mb_cache_entry *
4412 +mb_cache_entry_get(struct mb_cache *cache, kdev_t dev, unsigned long block)
4414 + unsigned int bucket = (HASHDEV(dev) + block) % cache->c_bucket_count;
4415 + struct list_head *l;
4416 + struct mb_cache_entry *ce;
4418 + spin_lock(&mb_cache_spinlock);
4419 + list_for_each(l, &cache->c_block_hash[bucket]) {
4420 + ce = list_entry(l, struct mb_cache_entry, e_block_list);
4421 + if (ce->e_dev == dev && ce->e_block == block) {
4422 + if (!list_empty(&ce->e_lru_list))
4423 + list_del_init(&ce->e_lru_list);
4424 + atomic_inc(&ce->e_used);
4431 + spin_unlock(&mb_cache_spinlock);
4435 +#if !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0)
4437 +static struct mb_cache_entry *
4438 +__mb_cache_entry_find(struct list_head *l, struct list_head *head,
4439 + int index, kdev_t dev, unsigned int key)
4441 + while (l != head) {
4442 + struct mb_cache_entry *ce =
4443 + list_entry(l, struct mb_cache_entry,
4444 + e_indexes[index].o_list);
4445 + if (ce->e_dev == dev && ce->e_indexes[index].o_key == key) {
4446 + if (!list_empty(&ce->e_lru_list))
4447 + list_del_init(&ce->e_lru_list);
4448 + atomic_inc(&ce->e_used);
4458 + * mb_cache_entry_find_first()
4460 + * Find the first cache entry on a given device with a certain key in
4461 + * an additional index. Additonal matches can be found with
4462 + * mb_cache_entry_find_next(). Returns NULL if no match was found.
4464 + * @cache: the cache to search
4465 + * @index: the number of the additonal index to search (0<=index<indexes_count)
4466 + * @dev: the device the cache entry should belong to
4467 + * @key: the key in the index
4469 +struct mb_cache_entry *
4470 +mb_cache_entry_find_first(struct mb_cache *cache, int index, kdev_t dev,
4473 + unsigned int bucket = key % cache->c_bucket_count;
4474 + struct list_head *l;
4475 + struct mb_cache_entry *ce;
4477 + mb_assert(index < mb_cache_indexes(cache));
4478 + spin_lock(&mb_cache_spinlock);
4479 + l = cache->c_indexes_hash[index][bucket].next;
4480 + ce = __mb_cache_entry_find(l, &cache->c_indexes_hash[index][bucket],
4482 + spin_unlock(&mb_cache_spinlock);
4488 + * mb_cache_entry_find_next()
4490 + * Find the next cache entry on a given device with a certain key in an
4491 + * additional index. Returns NULL if no match could be found. The previous
4492 + * entry is atomatically released, so that mb_cache_entry_find_next() can
4493 + * be called like this:
4495 + * entry = mb_cache_entry_find_first();
4498 + * entry = mb_cache_entry_find_next(entry, ...);
4501 + * @prev: The previous match
4502 + * @index: the number of the additonal index to search (0<=index<indexes_count)
4503 + * @dev: the device the cache entry should belong to
4504 + * @key: the key in the index
4506 +struct mb_cache_entry *
4507 +mb_cache_entry_find_next(struct mb_cache_entry *prev, int index, kdev_t dev,
4510 + struct mb_cache *cache = prev->e_cache;
4511 + unsigned int bucket = key % cache->c_bucket_count;
4512 + struct list_head *l;
4513 + struct mb_cache_entry *ce;
4515 + mb_assert(index < mb_cache_indexes(cache));
4516 + spin_lock(&mb_cache_spinlock);
4517 + l = prev->e_indexes[index].o_list.next;
4518 + ce = __mb_cache_entry_find(l, &cache->c_indexes_hash[index][bucket],
4520 + __mb_cache_entry_release_unlock(prev);
4524 +#endif /* !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0) */
4526 +static int __init init_mbcache(void)
4528 + register_cache(&mb_cache_definition);
4532 +static void __exit exit_mbcache(void)
4534 + unregister_cache(&mb_cache_definition);
4537 +module_init(init_mbcache)
4538 +module_exit(exit_mbcache)
4540 --- linux-2.4.20/include/asm-arm/unistd.h~linux-2.4.20-xattr-0.8.54 2002-08-03 08:39:45.000000000 +0800
4541 +++ linux-2.4.20-root/include/asm-arm/unistd.h 2003-05-07 18:08:03.000000000 +0800
4543 #define __NR_security (__NR_SYSCALL_BASE+223)
4544 #define __NR_gettid (__NR_SYSCALL_BASE+224)
4545 #define __NR_readahead (__NR_SYSCALL_BASE+225)
4546 -#if 0 /* allocated in 2.5 */
4547 #define __NR_setxattr (__NR_SYSCALL_BASE+226)
4548 #define __NR_lsetxattr (__NR_SYSCALL_BASE+227)
4549 #define __NR_fsetxattr (__NR_SYSCALL_BASE+228)
4551 #define __NR_removexattr (__NR_SYSCALL_BASE+235)
4552 #define __NR_lremovexattr (__NR_SYSCALL_BASE+236)
4553 #define __NR_fremovexattr (__NR_SYSCALL_BASE+237)
4555 #define __NR_tkill (__NR_SYSCALL_BASE+238)
4557 * Please check 2.5 _before_ adding calls here,
4558 --- linux-2.4.20/include/asm-ppc64/unistd.h~linux-2.4.20-xattr-0.8.54 2002-08-03 08:39:45.000000000 +0800
4559 +++ linux-2.4.20-root/include/asm-ppc64/unistd.h 2003-05-07 18:08:03.000000000 +0800
4561 #define __NR_gettid 207
4562 #if 0 /* Reserved syscalls */
4563 #define __NR_tkill 208
4565 #define __NR_setxattr 209
4566 #define __NR_lsetxattr 210
4567 #define __NR_fsetxattr 211
4569 #define __NR_removexattr 218
4570 #define __NR_lremovexattr 219
4571 #define __NR_fremovexattr 220
4572 +#if 0 /* Reserved syscalls */
4573 #define __NR_futex 221
4576 --- linux-2.4.20/include/asm-s390/unistd.h~linux-2.4.20-xattr-0.8.54 2002-08-03 08:39:45.000000000 +0800
4577 +++ linux-2.4.20-root/include/asm-s390/unistd.h 2003-05-07 18:08:03.000000000 +0800
4578 @@ -212,9 +212,18 @@
4579 #define __NR_getdents64 220
4580 #define __NR_fcntl64 221
4581 #define __NR_readahead 222
4583 - * Numbers 224-235 are reserved for posix acl
4585 +#define __NR_setxattr 224
4586 +#define __NR_lsetxattr 225
4587 +#define __NR_fsetxattr 226
4588 +#define __NR_getxattr 227
4589 +#define __NR_lgetxattr 228
4590 +#define __NR_fgetxattr 229
4591 +#define __NR_listxattr 230
4592 +#define __NR_llistxattr 231
4593 +#define __NR_flistxattr 232
4594 +#define __NR_removexattr 233
4595 +#define __NR_lremovexattr 234
4596 +#define __NR_fremovexattr 235
4597 #define __NR_gettid 236
4598 #define __NR_tkill 237
4600 --- linux-2.4.20/include/asm-s390x/unistd.h~linux-2.4.20-xattr-0.8.54 2002-08-03 08:39:45.000000000 +0800
4601 +++ linux-2.4.20-root/include/asm-s390x/unistd.h 2003-05-07 18:08:03.000000000 +0800
4602 @@ -180,9 +180,18 @@
4603 #define __NR_mincore 218
4604 #define __NR_madvise 219
4605 #define __NR_readahead 222
4607 - * Numbers 224-235 are reserved for posix acl
4609 +#define __NR_setxattr 224
4610 +#define __NR_lsetxattr 225
4611 +#define __NR_fsetxattr 226
4612 +#define __NR_getxattr 227
4613 +#define __NR_lgetxattr 228
4614 +#define __NR_fgetxattr 229
4615 +#define __NR_listxattr 230
4616 +#define __NR_llistxattr 231
4617 +#define __NR_flistxattr 232
4618 +#define __NR_removexattr 233
4619 +#define __NR_lremovexattr 234
4620 +#define __NR_fremovexattr 235
4621 #define __NR_gettid 236
4622 #define __NR_tkill 237
4624 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
4625 +++ linux-2.4.20-root/include/linux/cache_def.h 2003-05-07 18:08:03.000000000 +0800
4628 + * linux/cache_def.h
4629 + * Handling of caches defined in drivers, filesystems, ...
4631 + * Copyright (C) 2002 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
4634 +struct cache_definition {
4636 + void (*shrink)(int, unsigned int);
4637 + struct list_head link;
4640 +extern void register_cache(struct cache_definition *);
4641 +extern void unregister_cache(struct cache_definition *);
4642 --- linux-2.4.20/include/linux/errno.h~linux-2.4.20-xattr-0.8.54 2003-04-14 16:39:03.000000000 +0800
4643 +++ linux-2.4.20-root/include/linux/errno.h 2003-05-07 18:08:03.000000000 +0800
4648 +/* Defined for extended attributes */
4649 +#define ENOATTR ENODATA /* No such attribute */
4650 +#define ENOTSUP EOPNOTSUPP /* Operation not supported */
4653 --- linux-2.4.20/include/linux/ext2_fs.h~linux-2.4.20-xattr-0.8.54 2003-04-14 16:39:08.000000000 +0800
4654 +++ linux-2.4.20-root/include/linux/ext2_fs.h 2003-05-07 18:08:03.000000000 +0800
4657 #define EXT2_BAD_INO 1 /* Bad blocks inode */
4658 #define EXT2_ROOT_INO 2 /* Root inode */
4659 -#define EXT2_ACL_IDX_INO 3 /* ACL inode */
4660 -#define EXT2_ACL_DATA_INO 4 /* ACL inode */
4661 #define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
4662 #define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
4666 # define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
4668 -#define EXT2_ACLE_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry))
4669 #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
4671 # define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
4672 @@ -121,28 +118,6 @@
4678 -struct ext2_acl_header /* Header of Access Control Lists */
4681 - __u32 aclh_file_count;
4682 - __u32 aclh_acle_count;
4683 - __u32 aclh_first_acle;
4686 -struct ext2_acl_entry /* Access Control List Entry */
4689 - __u16 acle_perms; /* Access permissions */
4690 - __u16 acle_type; /* Type of entry */
4691 - __u16 acle_tag; /* User or group identity */
4693 - __u32 acle_next; /* Pointer on next entry for the */
4694 - /* same inode or on next free entry */
4698 * Structure of a blocks group descriptor
4700 struct ext2_group_desc
4701 @@ -314,6 +289,7 @@ struct ext2_inode {
4702 #define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
4703 #define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
4704 #define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */
4705 +#define EXT2_MOUNT_XATTR_USER 0x4000 /* Extended user attributes */
4707 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
4708 #define set_opt(o, opt) o |= EXT2_MOUNT_##opt
4709 @@ -397,6 +373,7 @@ struct ext2_super_block {
4712 #define EXT2_SB(sb) (&((sb)->u.ext2_sb))
4713 +#define EXT2_I(inode) (&((inode)->u.ext2_i))
4715 /* Assume that user mode programs are passing in an ext2fs superblock, not
4716 * a kernel struct super_block. This will allow us to call the feature-test
4717 @@ -466,7 +443,7 @@ struct ext2_super_block {
4718 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
4719 #define EXT2_FEATURE_INCOMPAT_ANY 0xffffffff
4721 -#define EXT2_FEATURE_COMPAT_SUPP 0
4722 +#define EXT2_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
4723 #define EXT2_FEATURE_INCOMPAT_SUPP EXT2_FEATURE_INCOMPAT_FILETYPE
4724 #define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
4725 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
4726 @@ -623,8 +600,10 @@ extern struct address_space_operations e
4729 extern struct inode_operations ext2_dir_inode_operations;
4730 +extern struct inode_operations ext2_special_inode_operations;
4733 +extern struct inode_operations ext2_symlink_inode_operations;
4734 extern struct inode_operations ext2_fast_symlink_inode_operations;
4736 #endif /* __KERNEL__ */
4737 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
4738 +++ linux-2.4.20-root/include/linux/ext2_xattr.h 2003-05-07 18:08:03.000000000 +0800
4741 + File: linux/ext2_xattr.h
4743 + On-disk format of extended attributes for the ext2 filesystem.
4745 + (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
4748 +#include <linux/config.h>
4749 +#include <linux/init.h>
4750 +#include <linux/xattr.h>
4752 +/* Magic value in attribute blocks */
4753 +#define EXT2_XATTR_MAGIC 0xEA020000
4755 +/* Maximum number of references to one attribute block */
4756 +#define EXT2_XATTR_REFCOUNT_MAX 1024
4759 +#define EXT2_XATTR_INDEX_MAX 10
4760 +#define EXT2_XATTR_INDEX_USER 1
4761 +#define EXT2_XATTR_INDEX_POSIX_ACL_ACCESS 2
4762 +#define EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT 3
4764 +struct ext2_xattr_header {
4765 + __u32 h_magic; /* magic number for identification */
4766 + __u32 h_refcount; /* reference count */
4767 + __u32 h_blocks; /* number of disk blocks used */
4768 + __u32 h_hash; /* hash value of all attributes */
4769 + __u32 h_reserved[4]; /* zero right now */
4772 +struct ext2_xattr_entry {
4773 + __u8 e_name_len; /* length of name */
4774 + __u8 e_name_index; /* attribute name index */
4775 + __u16 e_value_offs; /* offset in disk block of value */
4776 + __u32 e_value_block; /* disk block attribute is stored on (n/i) */
4777 + __u32 e_value_size; /* size of attribute value */
4778 + __u32 e_hash; /* hash value of name and value */
4779 + char e_name[0]; /* attribute name */
4782 +#define EXT2_XATTR_PAD_BITS 2
4783 +#define EXT2_XATTR_PAD (1<<EXT2_XATTR_PAD_BITS)
4784 +#define EXT2_XATTR_ROUND (EXT2_XATTR_PAD-1)
4785 +#define EXT2_XATTR_LEN(name_len) \
4786 + (((name_len) + EXT2_XATTR_ROUND + \
4787 + sizeof(struct ext2_xattr_entry)) & ~EXT2_XATTR_ROUND)
4788 +#define EXT2_XATTR_NEXT(entry) \
4789 + ( (struct ext2_xattr_entry *)( \
4790 + (char *)(entry) + EXT2_XATTR_LEN((entry)->e_name_len)) )
4791 +#define EXT2_XATTR_SIZE(size) \
4792 + (((size) + EXT2_XATTR_ROUND) & ~EXT2_XATTR_ROUND)
4796 +# ifdef CONFIG_EXT2_FS_XATTR
4798 +struct ext2_xattr_handler {
4800 + size_t (*list)(char *list, struct inode *inode, const char *name,
4802 + int (*get)(struct inode *inode, const char *name, void *buffer,
4804 + int (*set)(struct inode *inode, const char *name, const void *buffer,
4805 + size_t size, int flags);
4808 +extern int ext2_xattr_register(int, struct ext2_xattr_handler *);
4809 +extern void ext2_xattr_unregister(int, struct ext2_xattr_handler *);
4811 +extern int ext2_setxattr(struct dentry *, const char *, const void *, size_t, int);
4812 +extern ssize_t ext2_getxattr(struct dentry *, const char *, void *, size_t);
4813 +extern ssize_t ext2_listxattr(struct dentry *, char *, size_t);
4814 +extern int ext2_removexattr(struct dentry *, const char *);
4816 +extern int ext2_xattr_get(struct inode *, int, const char *, void *, size_t);
4817 +extern int ext2_xattr_list(struct inode *, char *, size_t);
4818 +extern int ext2_xattr_set(struct inode *, int, const char *, const void *, size_t, int);
4820 +extern void ext2_xattr_delete_inode(struct inode *);
4821 +extern void ext2_xattr_put_super(struct super_block *);
4823 +extern int init_ext2_xattr(void) __init;
4824 +extern void exit_ext2_xattr(void);
4826 +# else /* CONFIG_EXT2_FS_XATTR */
4827 +# define ext2_setxattr NULL
4828 +# define ext2_getxattr NULL
4829 +# define ext2_listxattr NULL
4830 +# define ext2_removexattr NULL
4833 +ext2_xattr_get(struct inode *inode, int name_index,
4834 + const char *name, void *buffer, size_t size)
4840 +ext2_xattr_list(struct inode *inode, char *buffer, size_t size)
4846 +ext2_xattr_set(struct inode *inode, int name_index, const char *name,
4847 + const void *value, size_t size, int flags)
4853 +ext2_xattr_delete_inode(struct inode *inode)
4858 +ext2_xattr_put_super(struct super_block *sb)
4863 +init_ext2_xattr(void)
4869 +exit_ext2_xattr(void)
4873 +# endif /* CONFIG_EXT2_FS_XATTR */
4875 +# ifdef CONFIG_EXT2_FS_XATTR_USER
4877 +extern int init_ext2_xattr_user(void) __init;
4878 +extern void exit_ext2_xattr_user(void);
4880 +# else /* CONFIG_EXT2_FS_XATTR_USER */
4883 +init_ext2_xattr_user(void)
4889 +exit_ext2_xattr_user(void)
4893 +# endif /* CONFIG_EXT2_FS_XATTR_USER */
4895 +#endif /* __KERNEL__ */
4897 --- linux-2.4.20/include/linux/ext3_fs.h~linux-2.4.20-xattr-0.8.54 2003-05-05 19:01:04.000000000 +0800
4898 +++ linux-2.4.20-root/include/linux/ext3_fs.h 2003-05-07 18:08:03.000000000 +0800
4901 #define EXT3_BAD_INO 1 /* Bad blocks inode */
4902 #define EXT3_ROOT_INO 2 /* Root inode */
4903 -#define EXT3_ACL_IDX_INO 3 /* ACL inode */
4904 -#define EXT3_ACL_DATA_INO 4 /* ACL inode */
4905 #define EXT3_BOOT_LOADER_INO 5 /* Boot loader inode */
4906 #define EXT3_UNDEL_DIR_INO 6 /* Undelete directory inode */
4907 #define EXT3_RESIZE_INO 7 /* Reserved group descriptors inode */
4910 # define EXT3_BLOCK_SIZE(s) (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size)
4912 -#define EXT3_ACLE_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_acl_entry))
4913 #define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (__u32))
4915 # define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
4916 @@ -129,28 +126,6 @@
4922 -struct ext3_acl_header /* Header of Access Control Lists */
4925 - __u32 aclh_file_count;
4926 - __u32 aclh_acle_count;
4927 - __u32 aclh_first_acle;
4930 -struct ext3_acl_entry /* Access Control List Entry */
4933 - __u16 acle_perms; /* Access permissions */
4934 - __u16 acle_type; /* Type of entry */
4935 - __u16 acle_tag; /* User or group identity */
4937 - __u32 acle_next; /* Pointer on next entry for the */
4938 - /* same inode or on next free entry */
4942 * Structure of a blocks group descriptor
4944 struct ext3_group_desc
4945 @@ -344,6 +319,7 @@ struct ext3_inode {
4946 #define EXT3_MOUNT_WRITEBACK_DATA 0x0C00 /* No data ordering */
4947 #define EXT3_MOUNT_UPDATE_JOURNAL 0x1000 /* Update the journal format */
4948 #define EXT3_MOUNT_NO_UID32 0x2000 /* Disable 32-bit UIDs */
4949 +#define EXT3_MOUNT_XATTR_USER 0x4000 /* Extended user attributes */
4951 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
4952 #ifndef _LINUX_EXT2_FS_H
4953 @@ -520,7 +496,7 @@ struct ext3_super_block {
4954 #define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
4955 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
4957 -#define EXT3_FEATURE_COMPAT_SUPP 0
4958 +#define EXT3_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
4959 #define EXT3_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_FILETYPE| \
4960 EXT3_FEATURE_INCOMPAT_RECOVER)
4961 #define EXT3_FEATURE_RO_COMPAT_SUPP (EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
4962 @@ -703,6 +679,7 @@ extern void ext3_check_inodes_bitmap (st
4963 extern unsigned long ext3_count_free (struct buffer_head *, unsigned);
4966 +extern int ext3_forget(handle_t *, int, struct inode *, struct buffer_head *, int);
4967 extern struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *);
4968 extern struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *);
4970 @@ -771,8 +748,10 @@ extern struct address_space_operations e
4973 extern struct inode_operations ext3_dir_inode_operations;
4974 +extern struct inode_operations ext3_special_inode_operations;
4977 +extern struct inode_operations ext3_symlink_inode_operations;
4978 extern struct inode_operations ext3_fast_symlink_inode_operations;
4981 --- linux-2.4.20/include/linux/ext3_jbd.h~linux-2.4.20-xattr-0.8.54 2003-05-05 19:01:02.000000000 +0800
4982 +++ linux-2.4.20-root/include/linux/ext3_jbd.h 2003-05-07 18:08:03.000000000 +0800
4985 #define EXT3_SINGLEDATA_TRANS_BLOCKS 8
4987 +/* Extended attributes may touch two data buffers, two bitmap buffers,
4988 + * and two group and summaries. */
4990 +#define EXT3_XATTR_TRANS_BLOCKS 8
4992 /* Define the minimum size for a transaction which modifies data. This
4993 * needs to take into account the fact that we may end up modifying two
4994 * quota files too (one for the group, one for the user quota). The
4995 * superblock only gets updated once, of course, so don't bother
4996 * counting that again for the quota updates. */
4998 -#define EXT3_DATA_TRANS_BLOCKS (3 * EXT3_SINGLEDATA_TRANS_BLOCKS - 2)
4999 +#define EXT3_DATA_TRANS_BLOCKS (3 * EXT3_SINGLEDATA_TRANS_BLOCKS + \
5000 + EXT3_XATTR_TRANS_BLOCKS - 2)
5002 extern int ext3_writepage_trans_blocks(struct inode *inode);
5004 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
5005 +++ linux-2.4.20-root/include/linux/ext3_xattr.h 2003-05-07 18:08:03.000000000 +0800
5008 + File: linux/ext3_xattr.h
5010 + On-disk format of extended attributes for the ext3 filesystem.
5012 + (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
5015 +#include <linux/config.h>
5016 +#include <linux/init.h>
5017 +#include <linux/xattr.h>
5019 +/* Magic value in attribute blocks */
5020 +#define EXT3_XATTR_MAGIC 0xEA020000
5022 +/* Maximum number of references to one attribute block */
5023 +#define EXT3_XATTR_REFCOUNT_MAX 1024
5026 +#define EXT3_XATTR_INDEX_MAX 10
5027 +#define EXT3_XATTR_INDEX_USER 1
5028 +#define EXT3_XATTR_INDEX_POSIX_ACL_ACCESS 2
5029 +#define EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT 3
5031 +struct ext3_xattr_header {
5032 + __u32 h_magic; /* magic number for identification */
5033 + __u32 h_refcount; /* reference count */
5034 + __u32 h_blocks; /* number of disk blocks used */
5035 + __u32 h_hash; /* hash value of all attributes */
5036 + __u32 h_reserved[4]; /* zero right now */
5039 +struct ext3_xattr_entry {
5040 + __u8 e_name_len; /* length of name */
5041 + __u8 e_name_index; /* attribute name index */
5042 + __u16 e_value_offs; /* offset in disk block of value */
5043 + __u32 e_value_block; /* disk block attribute is stored on (n/i) */
5044 + __u32 e_value_size; /* size of attribute value */
5045 + __u32 e_hash; /* hash value of name and value */
5046 + char e_name[0]; /* attribute name */
5049 +#define EXT3_XATTR_PAD_BITS 2
5050 +#define EXT3_XATTR_PAD (1<<EXT3_XATTR_PAD_BITS)
5051 +#define EXT3_XATTR_ROUND (EXT3_XATTR_PAD-1)
5052 +#define EXT3_XATTR_LEN(name_len) \
5053 + (((name_len) + EXT3_XATTR_ROUND + \
5054 + sizeof(struct ext3_xattr_entry)) & ~EXT3_XATTR_ROUND)
5055 +#define EXT3_XATTR_NEXT(entry) \
5056 + ( (struct ext3_xattr_entry *)( \
5057 + (char *)(entry) + EXT3_XATTR_LEN((entry)->e_name_len)) )
5058 +#define EXT3_XATTR_SIZE(size) \
5059 + (((size) + EXT3_XATTR_ROUND) & ~EXT3_XATTR_ROUND)
5063 +# ifdef CONFIG_EXT3_FS_XATTR
5065 +struct ext3_xattr_handler {
5067 + size_t (*list)(char *list, struct inode *inode, const char *name,
5069 + int (*get)(struct inode *inode, const char *name, void *buffer,
5071 + int (*set)(struct inode *inode, const char *name, const void *buffer,
5072 + size_t size, int flags);
5075 +extern int ext3_xattr_register(int, struct ext3_xattr_handler *);
5076 +extern void ext3_xattr_unregister(int, struct ext3_xattr_handler *);
5078 +extern int ext3_setxattr(struct dentry *, const char *, const void *, size_t, int);
5079 +extern ssize_t ext3_getxattr(struct dentry *, const char *, void *, size_t);
5080 +extern ssize_t ext3_listxattr(struct dentry *, char *, size_t);
5081 +extern int ext3_removexattr(struct dentry *, const char *);
5083 +extern int ext3_xattr_get(struct inode *, int, const char *, void *, size_t);
5084 +extern int ext3_xattr_list(struct inode *, char *, size_t);
5085 +extern int ext3_xattr_set(handle_t *handle, struct inode *, int, const char *, const void *, size_t, int);
5087 +extern void ext3_xattr_delete_inode(handle_t *, struct inode *);
5088 +extern void ext3_xattr_put_super(struct super_block *);
5090 +extern int init_ext3_xattr(void) __init;
5091 +extern void exit_ext3_xattr(void);
5093 +# else /* CONFIG_EXT3_FS_XATTR */
5094 +# define ext3_setxattr NULL
5095 +# define ext3_getxattr NULL
5096 +# define ext3_listxattr NULL
5097 +# define ext3_removexattr NULL
5100 +ext3_xattr_get(struct inode *inode, int name_index, const char *name,
5101 + void *buffer, size_t size)
5107 +ext3_xattr_list(struct inode *inode, void *buffer, size_t size)
5113 +ext3_xattr_set(handle_t *handle, struct inode *inode, int name_index,
5114 + const char *name, const void *value, size_t size, int flags)
5120 +ext3_xattr_delete_inode(handle_t *handle, struct inode *inode)
5125 +ext3_xattr_put_super(struct super_block *sb)
5130 +init_ext3_xattr(void)
5136 +exit_ext3_xattr(void)
5140 +# endif /* CONFIG_EXT3_FS_XATTR */
5142 +# ifdef CONFIG_EXT3_FS_XATTR_USER
5144 +extern int init_ext3_xattr_user(void) __init;
5145 +extern void exit_ext3_xattr_user(void);
5147 +# else /* CONFIG_EXT3_FS_XATTR_USER */
5150 +init_ext3_xattr_user(void)
5156 +exit_ext3_xattr_user(void)
5160 +#endif /* CONFIG_EXT3_FS_XATTR_USER */
5162 +#endif /* __KERNEL__ */
5164 --- linux-2.4.20/include/linux/fs.h~linux-2.4.20-xattr-0.8.54 2003-05-05 19:00:55.000000000 +0800
5165 +++ linux-2.4.20-root/include/linux/fs.h 2003-05-07 18:08:03.000000000 +0800
5166 @@ -888,7 +888,7 @@ struct inode_operations {
5167 int (*setattr) (struct dentry *, struct iattr *);
5168 int (*setattr_raw) (struct inode *, struct iattr *);
5169 int (*getattr) (struct dentry *, struct iattr *);
5170 - int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
5171 + int (*setxattr) (struct dentry *, const char *, const void *, size_t, int);
5172 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
5173 ssize_t (*listxattr) (struct dentry *, char *, size_t);
5174 int (*removexattr) (struct dentry *, const char *);
5175 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
5176 +++ linux-2.4.20-root/include/linux/mbcache.h 2003-05-07 18:08:03.000000000 +0800
5179 + File: linux/mbcache.h
5181 + (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
5184 +/* Hardwire the number of additional indexes */
5185 +#define MB_CACHE_INDEXES_COUNT 1
5187 +struct mb_cache_entry;
5189 +struct mb_cache_op {
5190 + int (*free)(struct mb_cache_entry *, int);
5194 + struct list_head c_cache_list;
5195 + const char *c_name;
5196 + struct mb_cache_op c_op;
5197 + atomic_t c_entry_count;
5198 + int c_bucket_count;
5199 +#ifndef MB_CACHE_INDEXES_COUNT
5200 + int c_indexes_count;
5202 + kmem_cache_t *c_entry_cache;
5203 + struct list_head *c_block_hash;
5204 + struct list_head *c_indexes_hash[0];
5207 +struct mb_cache_entry_index {
5208 + struct list_head o_list;
5209 + unsigned int o_key;
5212 +struct mb_cache_entry {
5213 + struct list_head e_lru_list;
5214 + struct mb_cache *e_cache;
5217 + unsigned long e_block;
5218 + struct list_head e_block_list;
5219 + struct mb_cache_entry_index e_indexes[0];
5222 +/* Functions on caches */
5224 +struct mb_cache * mb_cache_create(const char *, struct mb_cache_op *, size_t,
5226 +void mb_cache_shrink(struct mb_cache *, kdev_t);
5227 +void mb_cache_destroy(struct mb_cache *);
5229 +/* Functions on cache entries */
5231 +struct mb_cache_entry *mb_cache_entry_alloc(struct mb_cache *);
5232 +int mb_cache_entry_insert(struct mb_cache_entry *, kdev_t, unsigned long,
5234 +void mb_cache_entry_rehash(struct mb_cache_entry *, unsigned int[]);
5235 +void mb_cache_entry_release(struct mb_cache_entry *);
5236 +void mb_cache_entry_takeout(struct mb_cache_entry *);
5237 +void mb_cache_entry_free(struct mb_cache_entry *);
5238 +struct mb_cache_entry *mb_cache_entry_dup(struct mb_cache_entry *);
5239 +struct mb_cache_entry *mb_cache_entry_get(struct mb_cache *, kdev_t,
5241 +#if !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0)
5242 +struct mb_cache_entry *mb_cache_entry_find_first(struct mb_cache *cache, int,
5243 + kdev_t, unsigned int);
5244 +struct mb_cache_entry *mb_cache_entry_find_next(struct mb_cache_entry *, int,
5245 + kdev_t, unsigned int);
5247 --- linux-2.4.20/kernel/ksyms.c~linux-2.4.20-xattr-0.8.54 2003-05-05 17:43:15.000000000 +0800
5248 +++ linux-2.4.20-root/kernel/ksyms.c 2003-05-07 18:08:03.000000000 +0800
5251 #include <linux/config.h>
5252 #include <linux/slab.h>
5253 +#include <linux/cache_def.h>
5254 #include <linux/module.h>
5255 #include <linux/blkdev.h>
5256 #include <linux/cdrom.h>
5257 @@ -89,6 +90,7 @@ EXPORT_SYMBOL(exit_mm);
5258 EXPORT_SYMBOL(exit_files);
5259 EXPORT_SYMBOL(exit_fs);
5260 EXPORT_SYMBOL(exit_sighand);
5261 +EXPORT_SYMBOL(copy_fs_struct);
5263 /* internal kernel memory management */
5264 EXPORT_SYMBOL(_alloc_pages);
5265 @@ -107,6 +109,8 @@ EXPORT_SYMBOL(kmem_cache_validate);
5266 EXPORT_SYMBOL(kmem_cache_alloc);
5267 EXPORT_SYMBOL(kmem_cache_free);
5268 EXPORT_SYMBOL(kmem_cache_size);
5269 +EXPORT_SYMBOL(register_cache);
5270 +EXPORT_SYMBOL(unregister_cache);
5271 EXPORT_SYMBOL(kmalloc);
5272 EXPORT_SYMBOL(kfree);
5273 EXPORT_SYMBOL(vfree);
5274 --- linux-2.4.20/mm/vmscan.c~linux-2.4.20-xattr-0.8.54 2002-11-29 07:53:15.000000000 +0800
5275 +++ linux-2.4.20-root/mm/vmscan.c 2003-05-07 18:08:03.000000000 +0800
5277 #include <linux/kernel_stat.h>
5278 #include <linux/swap.h>
5279 #include <linux/swapctl.h>
5280 +#include <linux/cache_def.h>
5281 #include <linux/smp_lock.h>
5282 #include <linux/pagemap.h>
5283 #include <linux/init.h>
5286 #define DEF_PRIORITY (6)
5288 +static DECLARE_MUTEX(other_caches_sem);
5289 +static LIST_HEAD(cache_definitions);
5291 +void register_cache(struct cache_definition *cache)
5293 + down(&other_caches_sem);
5294 + list_add(&cache->link, &cache_definitions);
5295 + up(&other_caches_sem);
5298 +void unregister_cache(struct cache_definition *cache)
5300 + down(&other_caches_sem);
5301 + list_del(&cache->link);
5302 + up(&other_caches_sem);
5305 +static void shrink_other_caches(unsigned int priority, int gfp_mask)
5307 + struct list_head *p;
5309 + if (down_trylock(&other_caches_sem))
5312 + list_for_each_prev(p, &cache_definitions) {
5313 + struct cache_definition *cache =
5314 + list_entry(p, struct cache_definition, link);
5316 + cache->shrink(priority, gfp_mask);
5318 + up(&other_caches_sem);
5322 * The swap-out function returns 1 if it successfully
5323 * scanned all the pages it was asked to (`count').
5324 @@ -577,6 +611,7 @@ static int shrink_caches(zone_t * classz
5326 shrink_dcache_memory(priority, gfp_mask);
5327 shrink_icache_memory(priority, gfp_mask);
5328 + shrink_other_caches(priority, gfp_mask);
5330 shrink_dqcache_memory(DEF_PRIORITY, gfp_mask);
5332 --- /dev/null 2003-01-30 18:24:37.000000000 +0800
5333 +++ linux-root/fs/ext3/ext3-exports.c 2003-05-05 18:19:11.000000000 +0800
5335 +#include <linux/config.h>
5336 +#include <linux/module.h>
5337 +#include <linux/ext3_fs.h>
5338 +#include <linux/ext3_jbd.h>
5339 +#include <linux/ext3_xattr.h>
5341 +EXPORT_SYMBOL(ext3_force_commit);
5342 +EXPORT_SYMBOL(ext3_bread);
5343 +EXPORT_SYMBOL(ext3_xattr_register);
5344 +EXPORT_SYMBOL(ext3_xattr_unregister);
5345 +EXPORT_SYMBOL(ext3_xattr_get);
5346 +EXPORT_SYMBOL(ext3_xattr_list);
5347 +EXPORT_SYMBOL(ext3_xattr_set);