diff options
Diffstat (limited to 'fs/ext4/xattr.c')
-rw-r--r-- | fs/ext4/xattr.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 16e28c08d1e8..cdc26e54400f 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c | |||
@@ -80,7 +80,7 @@ | |||
80 | # define ea_bdebug(bh, fmt, ...) no_printk(fmt, ##__VA_ARGS__) | 80 | # define ea_bdebug(bh, fmt, ...) no_printk(fmt, ##__VA_ARGS__) |
81 | #endif | 81 | #endif |
82 | 82 | ||
83 | static void ext4_xattr_cache_insert(struct mb_cache *, struct buffer_head *); | 83 | static void ext4_xattr_cache_insert(struct inode *, struct buffer_head *); |
84 | static struct buffer_head *ext4_xattr_cache_find(struct inode *, | 84 | static struct buffer_head *ext4_xattr_cache_find(struct inode *, |
85 | struct ext4_xattr_header *, | 85 | struct ext4_xattr_header *, |
86 | struct mb_cache_entry **); | 86 | struct mb_cache_entry **); |
@@ -278,7 +278,6 @@ ext4_xattr_block_get(struct inode *inode, int name_index, const char *name, | |||
278 | struct ext4_xattr_entry *entry; | 278 | struct ext4_xattr_entry *entry; |
279 | size_t size; | 279 | size_t size; |
280 | int error; | 280 | int error; |
281 | struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode); | ||
282 | 281 | ||
283 | ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld", | 282 | ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld", |
284 | name_index, name, buffer, (long)buffer_size); | 283 | name_index, name, buffer, (long)buffer_size); |
@@ -300,7 +299,7 @@ bad_block: | |||
300 | error = -EIO; | 299 | error = -EIO; |
301 | goto cleanup; | 300 | goto cleanup; |
302 | } | 301 | } |
303 | ext4_xattr_cache_insert(ext4_mb_cache, bh); | 302 | ext4_xattr_cache_insert(inode, bh); |
304 | entry = BFIRST(bh); | 303 | entry = BFIRST(bh); |
305 | error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1); | 304 | error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1); |
306 | if (error == -EIO) | 305 | if (error == -EIO) |
@@ -426,7 +425,6 @@ ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size) | |||
426 | struct inode *inode = d_inode(dentry); | 425 | struct inode *inode = d_inode(dentry); |
427 | struct buffer_head *bh = NULL; | 426 | struct buffer_head *bh = NULL; |
428 | int error; | 427 | int error; |
429 | struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode); | ||
430 | 428 | ||
431 | ea_idebug(inode, "buffer=%p, buffer_size=%ld", | 429 | ea_idebug(inode, "buffer=%p, buffer_size=%ld", |
432 | buffer, (long)buffer_size); | 430 | buffer, (long)buffer_size); |
@@ -448,7 +446,7 @@ ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size) | |||
448 | error = -EIO; | 446 | error = -EIO; |
449 | goto cleanup; | 447 | goto cleanup; |
450 | } | 448 | } |
451 | ext4_xattr_cache_insert(ext4_mb_cache, bh); | 449 | ext4_xattr_cache_insert(inode, bh); |
452 | error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size); | 450 | error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size); |
453 | 451 | ||
454 | cleanup: | 452 | cleanup: |
@@ -547,7 +545,8 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode, | |||
547 | int error = 0; | 545 | int error = 0; |
548 | struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode); | 546 | struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode); |
549 | 547 | ||
550 | ce = mb_cache_entry_get(ext4_mb_cache, bh->b_bdev, bh->b_blocknr); | 548 | if (!test_opt(inode->i_sb, NO_MBCACHE)) |
549 | ce = mb_cache_entry_get(ext4_mb_cache, bh->b_bdev, bh->b_blocknr); | ||
551 | BUFFER_TRACE(bh, "get_write_access"); | 550 | BUFFER_TRACE(bh, "get_write_access"); |
552 | error = ext4_journal_get_write_access(handle, bh); | 551 | error = ext4_journal_get_write_access(handle, bh); |
553 | if (error) | 552 | if (error) |
@@ -788,8 +787,9 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, | |||
788 | if (i->value && i->value_len > sb->s_blocksize) | 787 | if (i->value && i->value_len > sb->s_blocksize) |
789 | return -ENOSPC; | 788 | return -ENOSPC; |
790 | if (s->base) { | 789 | if (s->base) { |
791 | ce = mb_cache_entry_get(ext4_mb_cache, bs->bh->b_bdev, | 790 | if (!test_opt(inode->i_sb, NO_MBCACHE)) |
792 | bs->bh->b_blocknr); | 791 | ce = mb_cache_entry_get(ext4_mb_cache, bs->bh->b_bdev, |
792 | bs->bh->b_blocknr); | ||
793 | BUFFER_TRACE(bs->bh, "get_write_access"); | 793 | BUFFER_TRACE(bs->bh, "get_write_access"); |
794 | error = ext4_journal_get_write_access(handle, bs->bh); | 794 | error = ext4_journal_get_write_access(handle, bs->bh); |
795 | if (error) | 795 | if (error) |
@@ -807,7 +807,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, | |||
807 | if (!IS_LAST_ENTRY(s->first)) | 807 | if (!IS_LAST_ENTRY(s->first)) |
808 | ext4_xattr_rehash(header(s->base), | 808 | ext4_xattr_rehash(header(s->base), |
809 | s->here); | 809 | s->here); |
810 | ext4_xattr_cache_insert(ext4_mb_cache, | 810 | ext4_xattr_cache_insert(inode, |
811 | bs->bh); | 811 | bs->bh); |
812 | } | 812 | } |
813 | unlock_buffer(bs->bh); | 813 | unlock_buffer(bs->bh); |
@@ -892,7 +892,8 @@ inserted: | |||
892 | if (error) | 892 | if (error) |
893 | goto cleanup_dquot; | 893 | goto cleanup_dquot; |
894 | } | 894 | } |
895 | mb_cache_entry_release(ce); | 895 | if (ce) |
896 | mb_cache_entry_release(ce); | ||
896 | ce = NULL; | 897 | ce = NULL; |
897 | } else if (bs->bh && s->base == bs->bh->b_data) { | 898 | } else if (bs->bh && s->base == bs->bh->b_data) { |
898 | /* We were modifying this block in-place. */ | 899 | /* We were modifying this block in-place. */ |
@@ -939,7 +940,7 @@ getblk_failed: | |||
939 | memcpy(new_bh->b_data, s->base, new_bh->b_size); | 940 | memcpy(new_bh->b_data, s->base, new_bh->b_size); |
940 | set_buffer_uptodate(new_bh); | 941 | set_buffer_uptodate(new_bh); |
941 | unlock_buffer(new_bh); | 942 | unlock_buffer(new_bh); |
942 | ext4_xattr_cache_insert(ext4_mb_cache, new_bh); | 943 | ext4_xattr_cache_insert(inode, new_bh); |
943 | error = ext4_handle_dirty_xattr_block(handle, | 944 | error = ext4_handle_dirty_xattr_block(handle, |
944 | inode, new_bh); | 945 | inode, new_bh); |
945 | if (error) | 946 | if (error) |
@@ -1529,12 +1530,17 @@ ext4_xattr_put_super(struct super_block *sb) | |||
1529 | * Returns 0, or a negative error number on failure. | 1530 | * Returns 0, or a negative error number on failure. |
1530 | */ | 1531 | */ |
1531 | static void | 1532 | static void |
1532 | ext4_xattr_cache_insert(struct mb_cache *ext4_mb_cache, struct buffer_head *bh) | 1533 | ext4_xattr_cache_insert(struct inode *inode, struct buffer_head *bh) |
1533 | { | 1534 | { |
1535 | struct super_block *sb = inode->i_sb; | ||
1536 | struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode); | ||
1534 | __u32 hash = le32_to_cpu(BHDR(bh)->h_hash); | 1537 | __u32 hash = le32_to_cpu(BHDR(bh)->h_hash); |
1535 | struct mb_cache_entry *ce; | 1538 | struct mb_cache_entry *ce; |
1536 | int error; | 1539 | int error; |
1537 | 1540 | ||
1541 | if (test_opt(sb, NO_MBCACHE)) | ||
1542 | return; | ||
1543 | |||
1538 | ce = mb_cache_entry_alloc(ext4_mb_cache, GFP_NOFS); | 1544 | ce = mb_cache_entry_alloc(ext4_mb_cache, GFP_NOFS); |
1539 | if (!ce) { | 1545 | if (!ce) { |
1540 | ea_bdebug(bh, "out of memory"); | 1546 | ea_bdebug(bh, "out of memory"); |
@@ -1609,6 +1615,8 @@ ext4_xattr_cache_find(struct inode *inode, struct ext4_xattr_header *header, | |||
1609 | struct mb_cache_entry *ce; | 1615 | struct mb_cache_entry *ce; |
1610 | struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode); | 1616 | struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode); |
1611 | 1617 | ||
1618 | if (test_opt(inode->i_sb, NO_MBCACHE)) | ||
1619 | return NULL; | ||
1612 | if (!header->h_hash) | 1620 | if (!header->h_hash) |
1613 | return NULL; /* never share */ | 1621 | return NULL; /* never share */ |
1614 | ea_idebug(inode, "looking for cached blocks [%x]", (int)hash); | 1622 | ea_idebug(inode, "looking for cached blocks [%x]", (int)hash); |