diff options
Diffstat (limited to 'fs/ext3/xattr.c')
-rw-r--r-- | fs/ext3/xattr.c | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c index 545e37c4b91e..534a94c3a933 100644 --- a/fs/ext3/xattr.c +++ b/fs/ext3/xattr.c | |||
@@ -99,7 +99,7 @@ static struct buffer_head *ext3_xattr_cache_find(struct inode *, | |||
99 | struct mb_cache_entry **); | 99 | struct mb_cache_entry **); |
100 | static void ext3_xattr_rehash(struct ext3_xattr_header *, | 100 | static void ext3_xattr_rehash(struct ext3_xattr_header *, |
101 | struct ext3_xattr_entry *); | 101 | struct ext3_xattr_entry *); |
102 | static int ext3_xattr_list(struct inode *inode, char *buffer, | 102 | static int ext3_xattr_list(struct dentry *dentry, char *buffer, |
103 | size_t buffer_size); | 103 | size_t buffer_size); |
104 | 104 | ||
105 | static struct mb_cache *ext3_xattr_cache; | 105 | static struct mb_cache *ext3_xattr_cache; |
@@ -147,7 +147,7 @@ ext3_xattr_handler(int name_index) | |||
147 | ssize_t | 147 | ssize_t |
148 | ext3_listxattr(struct dentry *dentry, char *buffer, size_t size) | 148 | ext3_listxattr(struct dentry *dentry, char *buffer, size_t size) |
149 | { | 149 | { |
150 | return ext3_xattr_list(dentry->d_inode, buffer, size); | 150 | return ext3_xattr_list(dentry, buffer, size); |
151 | } | 151 | } |
152 | 152 | ||
153 | static int | 153 | static int |
@@ -274,7 +274,7 @@ ext3_xattr_ibody_get(struct inode *inode, int name_index, const char *name, | |||
274 | void *end; | 274 | void *end; |
275 | int error; | 275 | int error; |
276 | 276 | ||
277 | if (!(EXT3_I(inode)->i_state & EXT3_STATE_XATTR)) | 277 | if (!ext3_test_inode_state(inode, EXT3_STATE_XATTR)) |
278 | return -ENODATA; | 278 | return -ENODATA; |
279 | error = ext3_get_inode_loc(inode, &iloc); | 279 | error = ext3_get_inode_loc(inode, &iloc); |
280 | if (error) | 280 | if (error) |
@@ -332,7 +332,7 @@ ext3_xattr_get(struct inode *inode, int name_index, const char *name, | |||
332 | } | 332 | } |
333 | 333 | ||
334 | static int | 334 | static int |
335 | ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry, | 335 | ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry, |
336 | char *buffer, size_t buffer_size) | 336 | char *buffer, size_t buffer_size) |
337 | { | 337 | { |
338 | size_t rest = buffer_size; | 338 | size_t rest = buffer_size; |
@@ -342,9 +342,10 @@ ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry, | |||
342 | ext3_xattr_handler(entry->e_name_index); | 342 | ext3_xattr_handler(entry->e_name_index); |
343 | 343 | ||
344 | if (handler) { | 344 | if (handler) { |
345 | size_t size = handler->list(inode, buffer, rest, | 345 | size_t size = handler->list(dentry, buffer, rest, |
346 | entry->e_name, | 346 | entry->e_name, |
347 | entry->e_name_len); | 347 | entry->e_name_len, |
348 | handler->flags); | ||
348 | if (buffer) { | 349 | if (buffer) { |
349 | if (size > rest) | 350 | if (size > rest) |
350 | return -ERANGE; | 351 | return -ERANGE; |
@@ -357,8 +358,9 @@ ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry, | |||
357 | } | 358 | } |
358 | 359 | ||
359 | static int | 360 | static int |
360 | ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size) | 361 | ext3_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
361 | { | 362 | { |
363 | struct inode *inode = dentry->d_inode; | ||
362 | struct buffer_head *bh = NULL; | 364 | struct buffer_head *bh = NULL; |
363 | int error; | 365 | int error; |
364 | 366 | ||
@@ -383,7 +385,7 @@ ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
383 | goto cleanup; | 385 | goto cleanup; |
384 | } | 386 | } |
385 | ext3_xattr_cache_insert(bh); | 387 | ext3_xattr_cache_insert(bh); |
386 | error = ext3_xattr_list_entries(inode, BFIRST(bh), buffer, buffer_size); | 388 | error = ext3_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size); |
387 | 389 | ||
388 | cleanup: | 390 | cleanup: |
389 | brelse(bh); | 391 | brelse(bh); |
@@ -392,15 +394,16 @@ cleanup: | |||
392 | } | 394 | } |
393 | 395 | ||
394 | static int | 396 | static int |
395 | ext3_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size) | 397 | ext3_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
396 | { | 398 | { |
399 | struct inode *inode = dentry->d_inode; | ||
397 | struct ext3_xattr_ibody_header *header; | 400 | struct ext3_xattr_ibody_header *header; |
398 | struct ext3_inode *raw_inode; | 401 | struct ext3_inode *raw_inode; |
399 | struct ext3_iloc iloc; | 402 | struct ext3_iloc iloc; |
400 | void *end; | 403 | void *end; |
401 | int error; | 404 | int error; |
402 | 405 | ||
403 | if (!(EXT3_I(inode)->i_state & EXT3_STATE_XATTR)) | 406 | if (!ext3_test_inode_state(inode, EXT3_STATE_XATTR)) |
404 | return 0; | 407 | return 0; |
405 | error = ext3_get_inode_loc(inode, &iloc); | 408 | error = ext3_get_inode_loc(inode, &iloc); |
406 | if (error) | 409 | if (error) |
@@ -411,7 +414,7 @@ ext3_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
411 | error = ext3_xattr_check_names(IFIRST(header), end); | 414 | error = ext3_xattr_check_names(IFIRST(header), end); |
412 | if (error) | 415 | if (error) |
413 | goto cleanup; | 416 | goto cleanup; |
414 | error = ext3_xattr_list_entries(inode, IFIRST(header), | 417 | error = ext3_xattr_list_entries(dentry, IFIRST(header), |
415 | buffer, buffer_size); | 418 | buffer, buffer_size); |
416 | 419 | ||
417 | cleanup: | 420 | cleanup: |
@@ -430,12 +433,12 @@ cleanup: | |||
430 | * used / required on success. | 433 | * used / required on success. |
431 | */ | 434 | */ |
432 | static int | 435 | static int |
433 | ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) | 436 | ext3_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
434 | { | 437 | { |
435 | int i_error, b_error; | 438 | int i_error, b_error; |
436 | 439 | ||
437 | down_read(&EXT3_I(inode)->xattr_sem); | 440 | down_read(&EXT3_I(dentry->d_inode)->xattr_sem); |
438 | i_error = ext3_xattr_ibody_list(inode, buffer, buffer_size); | 441 | i_error = ext3_xattr_ibody_list(dentry, buffer, buffer_size); |
439 | if (i_error < 0) { | 442 | if (i_error < 0) { |
440 | b_error = 0; | 443 | b_error = 0; |
441 | } else { | 444 | } else { |
@@ -443,11 +446,11 @@ ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
443 | buffer += i_error; | 446 | buffer += i_error; |
444 | buffer_size -= i_error; | 447 | buffer_size -= i_error; |
445 | } | 448 | } |
446 | b_error = ext3_xattr_block_list(inode, buffer, buffer_size); | 449 | b_error = ext3_xattr_block_list(dentry, buffer, buffer_size); |
447 | if (b_error < 0) | 450 | if (b_error < 0) |
448 | i_error = 0; | 451 | i_error = 0; |
449 | } | 452 | } |
450 | up_read(&EXT3_I(inode)->xattr_sem); | 453 | up_read(&EXT3_I(dentry->d_inode)->xattr_sem); |
451 | return i_error + b_error; | 454 | return i_error + b_error; |
452 | } | 455 | } |
453 | 456 | ||
@@ -497,7 +500,7 @@ ext3_xattr_release_block(handle_t *handle, struct inode *inode, | |||
497 | error = ext3_journal_dirty_metadata(handle, bh); | 500 | error = ext3_journal_dirty_metadata(handle, bh); |
498 | if (IS_SYNC(inode)) | 501 | if (IS_SYNC(inode)) |
499 | handle->h_sync = 1; | 502 | handle->h_sync = 1; |
500 | vfs_dq_free_block(inode, 1); | 503 | dquot_free_block(inode, 1); |
501 | ea_bdebug(bh, "refcount now=%d; releasing", | 504 | ea_bdebug(bh, "refcount now=%d; releasing", |
502 | le32_to_cpu(BHDR(bh)->h_refcount)); | 505 | le32_to_cpu(BHDR(bh)->h_refcount)); |
503 | if (ce) | 506 | if (ce) |
@@ -772,8 +775,8 @@ inserted: | |||
772 | else { | 775 | else { |
773 | /* The old block is released after updating | 776 | /* The old block is released after updating |
774 | the inode. */ | 777 | the inode. */ |
775 | error = -EDQUOT; | 778 | error = dquot_alloc_block(inode, 1); |
776 | if (vfs_dq_alloc_block(inode, 1)) | 779 | if (error) |
777 | goto cleanup; | 780 | goto cleanup; |
778 | error = ext3_journal_get_write_access(handle, | 781 | error = ext3_journal_get_write_access(handle, |
779 | new_bh); | 782 | new_bh); |
@@ -847,7 +850,7 @@ cleanup: | |||
847 | return error; | 850 | return error; |
848 | 851 | ||
849 | cleanup_dquot: | 852 | cleanup_dquot: |
850 | vfs_dq_free_block(inode, 1); | 853 | dquot_free_block(inode, 1); |
851 | goto cleanup; | 854 | goto cleanup; |
852 | 855 | ||
853 | bad_block: | 856 | bad_block: |
@@ -879,7 +882,7 @@ ext3_xattr_ibody_find(struct inode *inode, struct ext3_xattr_info *i, | |||
879 | is->s.base = is->s.first = IFIRST(header); | 882 | is->s.base = is->s.first = IFIRST(header); |
880 | is->s.here = is->s.first; | 883 | is->s.here = is->s.first; |
881 | is->s.end = (void *)raw_inode + EXT3_SB(inode->i_sb)->s_inode_size; | 884 | is->s.end = (void *)raw_inode + EXT3_SB(inode->i_sb)->s_inode_size; |
882 | if (EXT3_I(inode)->i_state & EXT3_STATE_XATTR) { | 885 | if (ext3_test_inode_state(inode, EXT3_STATE_XATTR)) { |
883 | error = ext3_xattr_check_names(IFIRST(header), is->s.end); | 886 | error = ext3_xattr_check_names(IFIRST(header), is->s.end); |
884 | if (error) | 887 | if (error) |
885 | return error; | 888 | return error; |
@@ -911,10 +914,10 @@ ext3_xattr_ibody_set(handle_t *handle, struct inode *inode, | |||
911 | header = IHDR(inode, ext3_raw_inode(&is->iloc)); | 914 | header = IHDR(inode, ext3_raw_inode(&is->iloc)); |
912 | if (!IS_LAST_ENTRY(s->first)) { | 915 | if (!IS_LAST_ENTRY(s->first)) { |
913 | header->h_magic = cpu_to_le32(EXT3_XATTR_MAGIC); | 916 | header->h_magic = cpu_to_le32(EXT3_XATTR_MAGIC); |
914 | EXT3_I(inode)->i_state |= EXT3_STATE_XATTR; | 917 | ext3_set_inode_state(inode, EXT3_STATE_XATTR); |
915 | } else { | 918 | } else { |
916 | header->h_magic = cpu_to_le32(0); | 919 | header->h_magic = cpu_to_le32(0); |
917 | EXT3_I(inode)->i_state &= ~EXT3_STATE_XATTR; | 920 | ext3_clear_inode_state(inode, EXT3_STATE_XATTR); |
918 | } | 921 | } |
919 | return 0; | 922 | return 0; |
920 | } | 923 | } |
@@ -960,10 +963,14 @@ ext3_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index, | |||
960 | if (error) | 963 | if (error) |
961 | goto cleanup; | 964 | goto cleanup; |
962 | 965 | ||
963 | if (EXT3_I(inode)->i_state & EXT3_STATE_NEW) { | 966 | error = ext3_journal_get_write_access(handle, is.iloc.bh); |
967 | if (error) | ||
968 | goto cleanup; | ||
969 | |||
970 | if (ext3_test_inode_state(inode, EXT3_STATE_NEW)) { | ||
964 | struct ext3_inode *raw_inode = ext3_raw_inode(&is.iloc); | 971 | struct ext3_inode *raw_inode = ext3_raw_inode(&is.iloc); |
965 | memset(raw_inode, 0, EXT3_SB(inode->i_sb)->s_inode_size); | 972 | memset(raw_inode, 0, EXT3_SB(inode->i_sb)->s_inode_size); |
966 | EXT3_I(inode)->i_state &= ~EXT3_STATE_NEW; | 973 | ext3_clear_inode_state(inode, EXT3_STATE_NEW); |
967 | } | 974 | } |
968 | 975 | ||
969 | error = ext3_xattr_ibody_find(inode, &i, &is); | 976 | error = ext3_xattr_ibody_find(inode, &i, &is); |
@@ -985,9 +992,6 @@ ext3_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index, | |||
985 | if (flags & XATTR_CREATE) | 992 | if (flags & XATTR_CREATE) |
986 | goto cleanup; | 993 | goto cleanup; |
987 | } | 994 | } |
988 | error = ext3_journal_get_write_access(handle, is.iloc.bh); | ||
989 | if (error) | ||
990 | goto cleanup; | ||
991 | if (!value) { | 995 | if (!value) { |
992 | if (!is.s.not_found) | 996 | if (!is.s.not_found) |
993 | error = ext3_xattr_ibody_set(handle, inode, &i, &is); | 997 | error = ext3_xattr_ibody_set(handle, inode, &i, &is); |