diff options
Diffstat (limited to 'fs/ext4/xattr.c')
-rw-r--r-- | fs/ext4/xattr.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index e9054c1c7d93..3fbc2c6c3d0e 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c | |||
@@ -53,11 +53,11 @@ | |||
53 | #include <linux/init.h> | 53 | #include <linux/init.h> |
54 | #include <linux/fs.h> | 54 | #include <linux/fs.h> |
55 | #include <linux/slab.h> | 55 | #include <linux/slab.h> |
56 | #include <linux/ext4_jbd2.h> | ||
57 | #include <linux/ext4_fs.h> | ||
58 | #include <linux/mbcache.h> | 56 | #include <linux/mbcache.h> |
59 | #include <linux/quotaops.h> | 57 | #include <linux/quotaops.h> |
60 | #include <linux/rwsem.h> | 58 | #include <linux/rwsem.h> |
59 | #include "ext4_jbd2.h" | ||
60 | #include "ext4.h" | ||
61 | #include "xattr.h" | 61 | #include "xattr.h" |
62 | #include "acl.h" | 62 | #include "acl.h" |
63 | 63 | ||
@@ -92,6 +92,8 @@ static struct buffer_head *ext4_xattr_cache_find(struct inode *, | |||
92 | struct mb_cache_entry **); | 92 | struct mb_cache_entry **); |
93 | static void ext4_xattr_rehash(struct ext4_xattr_header *, | 93 | static void ext4_xattr_rehash(struct ext4_xattr_header *, |
94 | struct ext4_xattr_entry *); | 94 | struct ext4_xattr_entry *); |
95 | static int ext4_xattr_list(struct inode *inode, char *buffer, | ||
96 | size_t buffer_size); | ||
95 | 97 | ||
96 | static struct mb_cache *ext4_xattr_cache; | 98 | static struct mb_cache *ext4_xattr_cache; |
97 | 99 | ||
@@ -225,7 +227,7 @@ ext4_xattr_block_get(struct inode *inode, int name_index, const char *name, | |||
225 | ea_bdebug(bh, "b_count=%d, refcount=%d", | 227 | ea_bdebug(bh, "b_count=%d, refcount=%d", |
226 | atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount)); | 228 | atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount)); |
227 | if (ext4_xattr_check_block(bh)) { | 229 | if (ext4_xattr_check_block(bh)) { |
228 | bad_block: ext4_error(inode->i_sb, __FUNCTION__, | 230 | bad_block: ext4_error(inode->i_sb, __func__, |
229 | "inode %lu: bad block %llu", inode->i_ino, | 231 | "inode %lu: bad block %llu", inode->i_ino, |
230 | EXT4_I(inode)->i_file_acl); | 232 | EXT4_I(inode)->i_file_acl); |
231 | error = -EIO; | 233 | error = -EIO; |
@@ -367,7 +369,7 @@ ext4_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
367 | ea_bdebug(bh, "b_count=%d, refcount=%d", | 369 | ea_bdebug(bh, "b_count=%d, refcount=%d", |
368 | atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount)); | 370 | atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount)); |
369 | if (ext4_xattr_check_block(bh)) { | 371 | if (ext4_xattr_check_block(bh)) { |
370 | ext4_error(inode->i_sb, __FUNCTION__, | 372 | ext4_error(inode->i_sb, __func__, |
371 | "inode %lu: bad block %llu", inode->i_ino, | 373 | "inode %lu: bad block %llu", inode->i_ino, |
372 | EXT4_I(inode)->i_file_acl); | 374 | EXT4_I(inode)->i_file_acl); |
373 | error = -EIO; | 375 | error = -EIO; |
@@ -420,7 +422,7 @@ cleanup: | |||
420 | * Returns a negative error number on failure, or the number of bytes | 422 | * Returns a negative error number on failure, or the number of bytes |
421 | * used / required on success. | 423 | * used / required on success. |
422 | */ | 424 | */ |
423 | int | 425 | static int |
424 | ext4_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) | 426 | ext4_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) |
425 | { | 427 | { |
426 | int i_error, b_error; | 428 | int i_error, b_error; |
@@ -484,8 +486,7 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode, | |||
484 | get_bh(bh); | 486 | get_bh(bh); |
485 | ext4_forget(handle, 1, inode, bh, bh->b_blocknr); | 487 | ext4_forget(handle, 1, inode, bh, bh->b_blocknr); |
486 | } else { | 488 | } else { |
487 | BHDR(bh)->h_refcount = cpu_to_le32( | 489 | le32_add_cpu(&BHDR(bh)->h_refcount, -1); |
488 | le32_to_cpu(BHDR(bh)->h_refcount) - 1); | ||
489 | error = ext4_journal_dirty_metadata(handle, bh); | 490 | error = ext4_journal_dirty_metadata(handle, bh); |
490 | if (IS_SYNC(inode)) | 491 | if (IS_SYNC(inode)) |
491 | handle->h_sync = 1; | 492 | handle->h_sync = 1; |
@@ -660,7 +661,7 @@ ext4_xattr_block_find(struct inode *inode, struct ext4_xattr_info *i, | |||
660 | atomic_read(&(bs->bh->b_count)), | 661 | atomic_read(&(bs->bh->b_count)), |
661 | le32_to_cpu(BHDR(bs->bh)->h_refcount)); | 662 | le32_to_cpu(BHDR(bs->bh)->h_refcount)); |
662 | if (ext4_xattr_check_block(bs->bh)) { | 663 | if (ext4_xattr_check_block(bs->bh)) { |
663 | ext4_error(sb, __FUNCTION__, | 664 | ext4_error(sb, __func__, |
664 | "inode %lu: bad block %llu", inode->i_ino, | 665 | "inode %lu: bad block %llu", inode->i_ino, |
665 | EXT4_I(inode)->i_file_acl); | 666 | EXT4_I(inode)->i_file_acl); |
666 | error = -EIO; | 667 | error = -EIO; |
@@ -738,7 +739,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, | |||
738 | ce = NULL; | 739 | ce = NULL; |
739 | } | 740 | } |
740 | ea_bdebug(bs->bh, "cloning"); | 741 | ea_bdebug(bs->bh, "cloning"); |
741 | s->base = kmalloc(bs->bh->b_size, GFP_KERNEL); | 742 | s->base = kmalloc(bs->bh->b_size, GFP_NOFS); |
742 | error = -ENOMEM; | 743 | error = -ENOMEM; |
743 | if (s->base == NULL) | 744 | if (s->base == NULL) |
744 | goto cleanup; | 745 | goto cleanup; |
@@ -750,7 +751,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, | |||
750 | } | 751 | } |
751 | } else { | 752 | } else { |
752 | /* Allocate a buffer where we construct the new block. */ | 753 | /* Allocate a buffer where we construct the new block. */ |
753 | s->base = kzalloc(sb->s_blocksize, GFP_KERNEL); | 754 | s->base = kzalloc(sb->s_blocksize, GFP_NOFS); |
754 | /* assert(header == s->base) */ | 755 | /* assert(header == s->base) */ |
755 | error = -ENOMEM; | 756 | error = -ENOMEM; |
756 | if (s->base == NULL) | 757 | if (s->base == NULL) |
@@ -789,8 +790,7 @@ inserted: | |||
789 | if (error) | 790 | if (error) |
790 | goto cleanup_dquot; | 791 | goto cleanup_dquot; |
791 | lock_buffer(new_bh); | 792 | lock_buffer(new_bh); |
792 | BHDR(new_bh)->h_refcount = cpu_to_le32(1 + | 793 | le32_add_cpu(&BHDR(new_bh)->h_refcount, 1); |
793 | le32_to_cpu(BHDR(new_bh)->h_refcount)); | ||
794 | ea_bdebug(new_bh, "reusing; refcount now=%d", | 794 | ea_bdebug(new_bh, "reusing; refcount now=%d", |
795 | le32_to_cpu(BHDR(new_bh)->h_refcount)); | 795 | le32_to_cpu(BHDR(new_bh)->h_refcount)); |
796 | unlock_buffer(new_bh); | 796 | unlock_buffer(new_bh); |
@@ -808,10 +808,8 @@ inserted: | |||
808 | get_bh(new_bh); | 808 | get_bh(new_bh); |
809 | } else { | 809 | } else { |
810 | /* We need to allocate a new block */ | 810 | /* We need to allocate a new block */ |
811 | ext4_fsblk_t goal = le32_to_cpu( | 811 | ext4_fsblk_t goal = ext4_group_first_block_no(sb, |
812 | EXT4_SB(sb)->s_es->s_first_data_block) + | 812 | EXT4_I(inode)->i_block_group); |
813 | (ext4_fsblk_t)EXT4_I(inode)->i_block_group * | ||
814 | EXT4_BLOCKS_PER_GROUP(sb); | ||
815 | ext4_fsblk_t block = ext4_new_block(handle, inode, | 813 | ext4_fsblk_t block = ext4_new_block(handle, inode, |
816 | goal, &error); | 814 | goal, &error); |
817 | if (error) | 815 | if (error) |
@@ -863,7 +861,7 @@ cleanup_dquot: | |||
863 | goto cleanup; | 861 | goto cleanup; |
864 | 862 | ||
865 | bad_block: | 863 | bad_block: |
866 | ext4_error(inode->i_sb, __FUNCTION__, | 864 | ext4_error(inode->i_sb, __func__, |
867 | "inode %lu: bad block %llu", inode->i_ino, | 865 | "inode %lu: bad block %llu", inode->i_ino, |
868 | EXT4_I(inode)->i_file_acl); | 866 | EXT4_I(inode)->i_file_acl); |
869 | goto cleanup; | 867 | goto cleanup; |
@@ -1166,7 +1164,7 @@ retry: | |||
1166 | if (!bh) | 1164 | if (!bh) |
1167 | goto cleanup; | 1165 | goto cleanup; |
1168 | if (ext4_xattr_check_block(bh)) { | 1166 | if (ext4_xattr_check_block(bh)) { |
1169 | ext4_error(inode->i_sb, __FUNCTION__, | 1167 | ext4_error(inode->i_sb, __func__, |
1170 | "inode %lu: bad block %llu", inode->i_ino, | 1168 | "inode %lu: bad block %llu", inode->i_ino, |
1171 | EXT4_I(inode)->i_file_acl); | 1169 | EXT4_I(inode)->i_file_acl); |
1172 | error = -EIO; | 1170 | error = -EIO; |
@@ -1341,14 +1339,14 @@ ext4_xattr_delete_inode(handle_t *handle, struct inode *inode) | |||
1341 | goto cleanup; | 1339 | goto cleanup; |
1342 | bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl); | 1340 | bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl); |
1343 | if (!bh) { | 1341 | if (!bh) { |
1344 | ext4_error(inode->i_sb, __FUNCTION__, | 1342 | ext4_error(inode->i_sb, __func__, |
1345 | "inode %lu: block %llu read error", inode->i_ino, | 1343 | "inode %lu: block %llu read error", inode->i_ino, |
1346 | EXT4_I(inode)->i_file_acl); | 1344 | EXT4_I(inode)->i_file_acl); |
1347 | goto cleanup; | 1345 | goto cleanup; |
1348 | } | 1346 | } |
1349 | if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) || | 1347 | if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) || |
1350 | BHDR(bh)->h_blocks != cpu_to_le32(1)) { | 1348 | BHDR(bh)->h_blocks != cpu_to_le32(1)) { |
1351 | ext4_error(inode->i_sb, __FUNCTION__, | 1349 | ext4_error(inode->i_sb, __func__, |
1352 | "inode %lu: bad block %llu", inode->i_ino, | 1350 | "inode %lu: bad block %llu", inode->i_ino, |
1353 | EXT4_I(inode)->i_file_acl); | 1351 | EXT4_I(inode)->i_file_acl); |
1354 | goto cleanup; | 1352 | goto cleanup; |
@@ -1475,7 +1473,7 @@ again: | |||
1475 | } | 1473 | } |
1476 | bh = sb_bread(inode->i_sb, ce->e_block); | 1474 | bh = sb_bread(inode->i_sb, ce->e_block); |
1477 | if (!bh) { | 1475 | if (!bh) { |
1478 | ext4_error(inode->i_sb, __FUNCTION__, | 1476 | ext4_error(inode->i_sb, __func__, |
1479 | "inode %lu: block %lu read error", | 1477 | "inode %lu: block %lu read error", |
1480 | inode->i_ino, (unsigned long) ce->e_block); | 1478 | inode->i_ino, (unsigned long) ce->e_block); |
1481 | } else if (le32_to_cpu(BHDR(bh)->h_refcount) >= | 1479 | } else if (le32_to_cpu(BHDR(bh)->h_refcount) >= |