Commit 47387409 authored by Tahsin Erdogan's avatar Tahsin Erdogan Committed by Theodore Ts'o

ext2, ext4: make mb block cache names more explicit

There will be a second mb_cache instance that tracks ea_inodes. Make
existing names more explicit so that it is clear that they refer to
xattr block cache.
Signed-off-by: default avatarTahsin Erdogan <tahsin@google.com>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent c07dfcb4
...@@ -113,7 +113,7 @@ struct ext2_sb_info { ...@@ -113,7 +113,7 @@ struct ext2_sb_info {
* of the mount options. * of the mount options.
*/ */
spinlock_t s_lock; spinlock_t s_lock;
struct mb_cache *s_mb_cache; struct mb_cache *s_ea_block_cache;
}; };
static inline spinlock_t * static inline spinlock_t *
......
...@@ -147,9 +147,9 @@ static void ext2_put_super (struct super_block * sb) ...@@ -147,9 +147,9 @@ static void ext2_put_super (struct super_block * sb)
ext2_quota_off_umount(sb); ext2_quota_off_umount(sb);
if (sbi->s_mb_cache) { if (sbi->s_ea_block_cache) {
ext2_xattr_destroy_cache(sbi->s_mb_cache); ext2_xattr_destroy_cache(sbi->s_ea_block_cache);
sbi->s_mb_cache = NULL; sbi->s_ea_block_cache = NULL;
} }
if (!(sb->s_flags & MS_RDONLY)) { if (!(sb->s_flags & MS_RDONLY)) {
struct ext2_super_block *es = sbi->s_es; struct ext2_super_block *es = sbi->s_es;
...@@ -1131,9 +1131,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1131,9 +1131,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
} }
#ifdef CONFIG_EXT2_FS_XATTR #ifdef CONFIG_EXT2_FS_XATTR
sbi->s_mb_cache = ext2_xattr_create_cache(); sbi->s_ea_block_cache = ext2_xattr_create_cache();
if (!sbi->s_mb_cache) { if (!sbi->s_ea_block_cache) {
ext2_msg(sb, KERN_ERR, "Failed to create an mb_cache"); ext2_msg(sb, KERN_ERR, "Failed to create ea_block_cache");
goto failed_mount3; goto failed_mount3;
} }
#endif #endif
...@@ -1182,8 +1182,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1182,8 +1182,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
sb->s_id); sb->s_id);
goto failed_mount; goto failed_mount;
failed_mount3: failed_mount3:
if (sbi->s_mb_cache) if (sbi->s_ea_block_cache)
ext2_xattr_destroy_cache(sbi->s_mb_cache); ext2_xattr_destroy_cache(sbi->s_ea_block_cache);
percpu_counter_destroy(&sbi->s_freeblocks_counter); percpu_counter_destroy(&sbi->s_freeblocks_counter);
percpu_counter_destroy(&sbi->s_freeinodes_counter); percpu_counter_destroy(&sbi->s_freeinodes_counter);
percpu_counter_destroy(&sbi->s_dirs_counter); percpu_counter_destroy(&sbi->s_dirs_counter);
......
...@@ -121,6 +121,8 @@ const struct xattr_handler *ext2_xattr_handlers[] = { ...@@ -121,6 +121,8 @@ const struct xattr_handler *ext2_xattr_handlers[] = {
NULL NULL
}; };
#define EA_BLOCK_CACHE(inode) (EXT2_SB(inode->i_sb)->s_ea_block_cache)
static inline const struct xattr_handler * static inline const struct xattr_handler *
ext2_xattr_handler(int name_index) ext2_xattr_handler(int name_index)
{ {
...@@ -150,7 +152,7 @@ ext2_xattr_get(struct inode *inode, int name_index, const char *name, ...@@ -150,7 +152,7 @@ ext2_xattr_get(struct inode *inode, int name_index, const char *name,
size_t name_len, size; size_t name_len, size;
char *end; char *end;
int error; int error;
struct mb_cache *ext2_mb_cache = EXT2_SB(inode->i_sb)->s_mb_cache; struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld", ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
name_index, name, buffer, (long)buffer_size); name_index, name, buffer, (long)buffer_size);
...@@ -195,7 +197,7 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_get", ...@@ -195,7 +197,7 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_get",
goto found; goto found;
entry = next; entry = next;
} }
if (ext2_xattr_cache_insert(ext2_mb_cache, bh)) if (ext2_xattr_cache_insert(ea_block_cache, bh))
ea_idebug(inode, "cache insert failed"); ea_idebug(inode, "cache insert failed");
error = -ENODATA; error = -ENODATA;
goto cleanup; goto cleanup;
...@@ -208,7 +210,7 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_get", ...@@ -208,7 +210,7 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_get",
le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize) le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize)
goto bad_block; goto bad_block;
if (ext2_xattr_cache_insert(ext2_mb_cache, bh)) if (ext2_xattr_cache_insert(ea_block_cache, bh))
ea_idebug(inode, "cache insert failed"); ea_idebug(inode, "cache insert failed");
if (buffer) { if (buffer) {
error = -ERANGE; error = -ERANGE;
...@@ -246,7 +248,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) ...@@ -246,7 +248,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
char *end; char *end;
size_t rest = buffer_size; size_t rest = buffer_size;
int error; int error;
struct mb_cache *ext2_mb_cache = EXT2_SB(inode->i_sb)->s_mb_cache; struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
ea_idebug(inode, "buffer=%p, buffer_size=%ld", ea_idebug(inode, "buffer=%p, buffer_size=%ld",
buffer, (long)buffer_size); buffer, (long)buffer_size);
...@@ -281,7 +283,7 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list", ...@@ -281,7 +283,7 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
goto bad_block; goto bad_block;
entry = next; entry = next;
} }
if (ext2_xattr_cache_insert(ext2_mb_cache, bh)) if (ext2_xattr_cache_insert(ea_block_cache, bh))
ea_idebug(inode, "cache insert failed"); ea_idebug(inode, "cache insert failed");
/* list the attribute names */ /* list the attribute names */
...@@ -493,7 +495,7 @@ bad_block: ext2_error(sb, "ext2_xattr_set", ...@@ -493,7 +495,7 @@ bad_block: ext2_error(sb, "ext2_xattr_set",
* This must happen under buffer lock for * This must happen under buffer lock for
* ext2_xattr_set2() to reliably detect modified block * ext2_xattr_set2() to reliably detect modified block
*/ */
mb_cache_entry_delete(EXT2_SB(sb)->s_mb_cache, hash, mb_cache_entry_delete(EA_BLOCK_CACHE(inode), hash,
bh->b_blocknr); bh->b_blocknr);
/* keep the buffer locked while modifying it. */ /* keep the buffer locked while modifying it. */
...@@ -627,7 +629,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, ...@@ -627,7 +629,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
struct super_block *sb = inode->i_sb; struct super_block *sb = inode->i_sb;
struct buffer_head *new_bh = NULL; struct buffer_head *new_bh = NULL;
int error; int error;
struct mb_cache *ext2_mb_cache = EXT2_SB(sb)->s_mb_cache; struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
if (header) { if (header) {
new_bh = ext2_xattr_cache_find(inode, header); new_bh = ext2_xattr_cache_find(inode, header);
...@@ -655,7 +657,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, ...@@ -655,7 +657,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
don't need to change the reference count. */ don't need to change the reference count. */
new_bh = old_bh; new_bh = old_bh;
get_bh(new_bh); get_bh(new_bh);
ext2_xattr_cache_insert(ext2_mb_cache, new_bh); ext2_xattr_cache_insert(ea_block_cache, new_bh);
} else { } else {
/* We need to allocate a new block */ /* We need to allocate a new block */
ext2_fsblk_t goal = ext2_group_first_block_no(sb, ext2_fsblk_t goal = ext2_group_first_block_no(sb,
...@@ -676,7 +678,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, ...@@ -676,7 +678,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
memcpy(new_bh->b_data, header, new_bh->b_size); memcpy(new_bh->b_data, header, new_bh->b_size);
set_buffer_uptodate(new_bh); set_buffer_uptodate(new_bh);
unlock_buffer(new_bh); unlock_buffer(new_bh);
ext2_xattr_cache_insert(ext2_mb_cache, new_bh); ext2_xattr_cache_insert(ea_block_cache, new_bh);
ext2_xattr_update_super_block(sb); ext2_xattr_update_super_block(sb);
} }
...@@ -721,7 +723,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, ...@@ -721,7 +723,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
* This must happen under buffer lock for * This must happen under buffer lock for
* ext2_xattr_set2() to reliably detect freed block * ext2_xattr_set2() to reliably detect freed block
*/ */
mb_cache_entry_delete(ext2_mb_cache, hash, mb_cache_entry_delete(ea_block_cache, hash,
old_bh->b_blocknr); old_bh->b_blocknr);
/* Free the old block. */ /* Free the old block. */
ea_bdebug(old_bh, "freeing"); ea_bdebug(old_bh, "freeing");
...@@ -795,7 +797,7 @@ ext2_xattr_delete_inode(struct inode *inode) ...@@ -795,7 +797,7 @@ ext2_xattr_delete_inode(struct inode *inode)
* This must happen under buffer lock for ext2_xattr_set2() to * This must happen under buffer lock for ext2_xattr_set2() to
* reliably detect freed block * reliably detect freed block
*/ */
mb_cache_entry_delete(EXT2_SB(inode->i_sb)->s_mb_cache, hash, mb_cache_entry_delete(EA_BLOCK_CACHE(inode), hash,
bh->b_blocknr); bh->b_blocknr);
ext2_free_blocks(inode, EXT2_I(inode)->i_file_acl, 1); ext2_free_blocks(inode, EXT2_I(inode)->i_file_acl, 1);
get_bh(bh); get_bh(bh);
...@@ -897,13 +899,13 @@ ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header) ...@@ -897,13 +899,13 @@ ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header)
{ {
__u32 hash = le32_to_cpu(header->h_hash); __u32 hash = le32_to_cpu(header->h_hash);
struct mb_cache_entry *ce; struct mb_cache_entry *ce;
struct mb_cache *ext2_mb_cache = EXT2_SB(inode->i_sb)->s_mb_cache; struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
if (!header->h_hash) if (!header->h_hash)
return NULL; /* never share */ return NULL; /* never share */
ea_idebug(inode, "looking for cached blocks [%x]", (int)hash); ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
again: again:
ce = mb_cache_entry_find_first(ext2_mb_cache, hash); ce = mb_cache_entry_find_first(ea_block_cache, hash);
while (ce) { while (ce) {
struct buffer_head *bh; struct buffer_head *bh;
...@@ -924,7 +926,7 @@ ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header) ...@@ -924,7 +926,7 @@ ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header)
* entry is still hashed is reliable. * entry is still hashed is reliable.
*/ */
if (hlist_bl_unhashed(&ce->e_hash_list)) { if (hlist_bl_unhashed(&ce->e_hash_list)) {
mb_cache_entry_put(ext2_mb_cache, ce); mb_cache_entry_put(ea_block_cache, ce);
unlock_buffer(bh); unlock_buffer(bh);
brelse(bh); brelse(bh);
goto again; goto again;
...@@ -937,14 +939,14 @@ ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header) ...@@ -937,14 +939,14 @@ ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header)
} else if (!ext2_xattr_cmp(header, HDR(bh))) { } else if (!ext2_xattr_cmp(header, HDR(bh))) {
ea_bdebug(bh, "b_count=%d", ea_bdebug(bh, "b_count=%d",
atomic_read(&(bh->b_count))); atomic_read(&(bh->b_count)));
mb_cache_entry_touch(ext2_mb_cache, ce); mb_cache_entry_touch(ea_block_cache, ce);
mb_cache_entry_put(ext2_mb_cache, ce); mb_cache_entry_put(ea_block_cache, ce);
return bh; return bh;
} }
unlock_buffer(bh); unlock_buffer(bh);
brelse(bh); brelse(bh);
} }
ce = mb_cache_entry_find_next(ext2_mb_cache, ce); ce = mb_cache_entry_find_next(ea_block_cache, ce);
} }
return NULL; return NULL;
} }
......
...@@ -1516,7 +1516,7 @@ struct ext4_sb_info { ...@@ -1516,7 +1516,7 @@ struct ext4_sb_info {
struct list_head s_es_list; /* List of inodes with reclaimable extents */ struct list_head s_es_list; /* List of inodes with reclaimable extents */
long s_es_nr_inode; long s_es_nr_inode;
struct ext4_es_stats s_es_stats; struct ext4_es_stats s_es_stats;
struct mb_cache *s_mb_cache; struct mb_cache *s_ea_block_cache;
spinlock_t s_es_lock ____cacheline_aligned_in_smp; spinlock_t s_es_lock ____cacheline_aligned_in_smp;
/* Ratelimit ext4 messages. */ /* Ratelimit ext4 messages. */
......
...@@ -927,9 +927,9 @@ static void ext4_put_super(struct super_block *sb) ...@@ -927,9 +927,9 @@ static void ext4_put_super(struct super_block *sb)
invalidate_bdev(sbi->journal_bdev); invalidate_bdev(sbi->journal_bdev);
ext4_blkdev_remove(sbi); ext4_blkdev_remove(sbi);
} }
if (sbi->s_mb_cache) { if (sbi->s_ea_block_cache) {
ext4_xattr_destroy_cache(sbi->s_mb_cache); ext4_xattr_destroy_cache(sbi->s_ea_block_cache);
sbi->s_mb_cache = NULL; sbi->s_ea_block_cache = NULL;
} }
if (sbi->s_mmp_tsk) if (sbi->s_mmp_tsk)
kthread_stop(sbi->s_mmp_tsk); kthread_stop(sbi->s_mmp_tsk);
...@@ -4061,9 +4061,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) ...@@ -4061,9 +4061,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
sbi->s_journal->j_commit_callback = ext4_journal_commit_callback; sbi->s_journal->j_commit_callback = ext4_journal_commit_callback;
no_journal: no_journal:
sbi->s_mb_cache = ext4_xattr_create_cache(); sbi->s_ea_block_cache = ext4_xattr_create_cache();
if (!sbi->s_mb_cache) { if (!sbi->s_ea_block_cache) {
ext4_msg(sb, KERN_ERR, "Failed to create an mb_cache"); ext4_msg(sb, KERN_ERR, "Failed to create ea_block_cache");
goto failed_mount_wq; goto failed_mount_wq;
} }
...@@ -4296,9 +4296,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) ...@@ -4296,9 +4296,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
if (EXT4_SB(sb)->rsv_conversion_wq) if (EXT4_SB(sb)->rsv_conversion_wq)
destroy_workqueue(EXT4_SB(sb)->rsv_conversion_wq); destroy_workqueue(EXT4_SB(sb)->rsv_conversion_wq);
failed_mount_wq: failed_mount_wq:
if (sbi->s_mb_cache) { if (sbi->s_ea_block_cache) {
ext4_xattr_destroy_cache(sbi->s_mb_cache); ext4_xattr_destroy_cache(sbi->s_ea_block_cache);
sbi->s_mb_cache = NULL; sbi->s_ea_block_cache = NULL;
} }
if (sbi->s_journal) { if (sbi->s_journal) {
jbd2_journal_destroy(sbi->s_journal); jbd2_journal_destroy(sbi->s_journal);
......
...@@ -72,10 +72,11 @@ ...@@ -72,10 +72,11 @@
# define ea_bdebug(bh, fmt, ...) no_printk(fmt, ##__VA_ARGS__) # define ea_bdebug(bh, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
#endif #endif
static void ext4_xattr_cache_insert(struct mb_cache *, struct buffer_head *); static void ext4_xattr_block_cache_insert(struct mb_cache *,
static struct buffer_head *ext4_xattr_cache_find(struct inode *, struct buffer_head *);
struct ext4_xattr_header *, static struct buffer_head *
struct mb_cache_entry **); ext4_xattr_block_cache_find(struct inode *, struct ext4_xattr_header *,
struct mb_cache_entry **);
static void ext4_xattr_rehash(struct ext4_xattr_header *, static void ext4_xattr_rehash(struct ext4_xattr_header *,
struct ext4_xattr_entry *); struct ext4_xattr_entry *);
...@@ -104,8 +105,8 @@ const struct xattr_handler *ext4_xattr_handlers[] = { ...@@ -104,8 +105,8 @@ const struct xattr_handler *ext4_xattr_handlers[] = {
NULL NULL
}; };
#define EXT4_GET_MB_CACHE(inode) (((struct ext4_sb_info *) \ #define EA_BLOCK_CACHE(inode) (((struct ext4_sb_info *) \
inode->i_sb->s_fs_info)->s_mb_cache) inode->i_sb->s_fs_info)->s_ea_block_cache)
#ifdef CONFIG_LOCKDEP #ifdef CONFIG_LOCKDEP
void ext4_xattr_inode_set_class(struct inode *ea_inode) void ext4_xattr_inode_set_class(struct inode *ea_inode)
...@@ -374,7 +375,7 @@ ext4_xattr_block_get(struct inode *inode, int name_index, const char *name, ...@@ -374,7 +375,7 @@ ext4_xattr_block_get(struct inode *inode, int name_index, const char *name,
struct ext4_xattr_entry *entry; struct ext4_xattr_entry *entry;
size_t size; size_t size;
int error; int error;
struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode); struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld", ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
name_index, name, buffer, (long)buffer_size); name_index, name, buffer, (long)buffer_size);
...@@ -395,7 +396,7 @@ ext4_xattr_block_get(struct inode *inode, int name_index, const char *name, ...@@ -395,7 +396,7 @@ ext4_xattr_block_get(struct inode *inode, int name_index, const char *name,
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto cleanup; goto cleanup;
} }
ext4_xattr_cache_insert(ext4_mb_cache, bh); ext4_xattr_block_cache_insert(ea_block_cache, bh);
entry = BFIRST(bh); entry = BFIRST(bh);
error = ext4_xattr_find_entry(&entry, name_index, name, 1); error = ext4_xattr_find_entry(&entry, name_index, name, 1);
if (error) if (error)
...@@ -541,7 +542,6 @@ ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size) ...@@ -541,7 +542,6 @@ ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size)
struct inode *inode = d_inode(dentry); struct inode *inode = d_inode(dentry);
struct buffer_head *bh = NULL; struct buffer_head *bh = NULL;
int error; int error;
struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode);
ea_idebug(inode, "buffer=%p, buffer_size=%ld", ea_idebug(inode, "buffer=%p, buffer_size=%ld",
buffer, (long)buffer_size); buffer, (long)buffer_size);
...@@ -563,7 +563,7 @@ ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size) ...@@ -563,7 +563,7 @@ ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size)
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto cleanup; goto cleanup;
} }
ext4_xattr_cache_insert(ext4_mb_cache, bh); ext4_xattr_block_cache_insert(EA_BLOCK_CACHE(inode), bh);
error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size); error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size);
cleanup: cleanup:
...@@ -660,7 +660,7 @@ static void ...@@ -660,7 +660,7 @@ static void
ext4_xattr_release_block(handle_t *handle, struct inode *inode, ext4_xattr_release_block(handle_t *handle, struct inode *inode,
struct buffer_head *bh) struct buffer_head *bh)
{ {
struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode); struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
u32 hash, ref; u32 hash, ref;
int error = 0; int error = 0;
...@@ -678,7 +678,7 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode, ...@@ -678,7 +678,7 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode,
* This must happen under buffer lock for * This must happen under buffer lock for
* ext4_xattr_block_set() to reliably detect freed block * ext4_xattr_block_set() to reliably detect freed block
*/ */
mb_cache_entry_delete(ext4_mb_cache, hash, bh->b_blocknr); mb_cache_entry_delete(ea_block_cache, hash, bh->b_blocknr);
get_bh(bh); get_bh(bh);
unlock_buffer(bh); unlock_buffer(bh);
ext4_free_blocks(handle, inode, bh, 0, 1, ext4_free_blocks(handle, inode, bh, 0, 1,
...@@ -690,11 +690,11 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode, ...@@ -690,11 +690,11 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode,
if (ref == EXT4_XATTR_REFCOUNT_MAX - 1) { if (ref == EXT4_XATTR_REFCOUNT_MAX - 1) {
struct mb_cache_entry *ce; struct mb_cache_entry *ce;
ce = mb_cache_entry_get(ext4_mb_cache, hash, ce = mb_cache_entry_get(ea_block_cache, hash,
bh->b_blocknr); bh->b_blocknr);
if (ce) { if (ce) {
ce->e_reusable = 1; ce->e_reusable = 1;
mb_cache_entry_put(ext4_mb_cache, ce); mb_cache_entry_put(ea_block_cache, ce);
} }
} }
...@@ -1094,7 +1094,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, ...@@ -1094,7 +1094,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
struct ext4_xattr_search *s = &s_copy; struct ext4_xattr_search *s = &s_copy;
struct mb_cache_entry *ce = NULL; struct mb_cache_entry *ce = NULL;
int error = 0; int error = 0;
struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode); struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
#define header(x) ((struct ext4_xattr_header *)(x)) #define header(x) ((struct ext4_xattr_header *)(x))
...@@ -1113,7 +1113,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, ...@@ -1113,7 +1113,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
* ext4_xattr_block_set() to reliably detect modified * ext4_xattr_block_set() to reliably detect modified
* block * block
*/ */
mb_cache_entry_delete(ext4_mb_cache, hash, mb_cache_entry_delete(ea_block_cache, hash,
bs->bh->b_blocknr); bs->bh->b_blocknr);
ea_bdebug(bs->bh, "modifying in-place"); ea_bdebug(bs->bh, "modifying in-place");
error = ext4_xattr_set_entry(i, s, handle, inode); error = ext4_xattr_set_entry(i, s, handle, inode);
...@@ -1121,8 +1121,8 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, ...@@ -1121,8 +1121,8 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
if (!IS_LAST_ENTRY(s->first)) if (!IS_LAST_ENTRY(s->first))
ext4_xattr_rehash(header(s->base), ext4_xattr_rehash(header(s->base),
s->here); s->here);
ext4_xattr_cache_insert(ext4_mb_cache, ext4_xattr_block_cache_insert(ea_block_cache,
bs->bh); bs->bh);
} }
ext4_xattr_block_csum_set(inode, bs->bh); ext4_xattr_block_csum_set(inode, bs->bh);
unlock_buffer(bs->bh); unlock_buffer(bs->bh);
...@@ -1175,7 +1175,8 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, ...@@ -1175,7 +1175,8 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
inserted: inserted:
if (!IS_LAST_ENTRY(s->first)) { if (!IS_LAST_ENTRY(s->first)) {
new_bh = ext4_xattr_cache_find(inode, header(s->base), &ce); new_bh = ext4_xattr_block_cache_find(inode, header(s->base),
&ce);
if (new_bh) { if (new_bh) {
/* We found an identical block in the cache. */ /* We found an identical block in the cache. */
if (new_bh == bs->bh) if (new_bh == bs->bh)
...@@ -1220,7 +1221,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, ...@@ -1220,7 +1221,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
EXT4_C2B(EXT4_SB(sb), EXT4_C2B(EXT4_SB(sb),
1)); 1));
brelse(new_bh); brelse(new_bh);
mb_cache_entry_put(ext4_mb_cache, ce); mb_cache_entry_put(ea_block_cache, ce);
ce = NULL; ce = NULL;
new_bh = NULL; new_bh = NULL;
goto inserted; goto inserted;
...@@ -1239,8 +1240,8 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, ...@@ -1239,8 +1240,8 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
if (error) if (error)
goto cleanup_dquot; goto cleanup_dquot;
} }
mb_cache_entry_touch(ext4_mb_cache, ce); mb_cache_entry_touch(ea_block_cache, ce);
mb_cache_entry_put(ext4_mb_cache, ce); mb_cache_entry_put(ea_block_cache, ce);
ce = NULL; ce = NULL;
} else if (bs->bh && s->base == bs->bh->b_data) { } else if (bs->bh && s->base == bs->bh->b_data) {
/* We were modifying this block in-place. */ /* We were modifying this block in-place. */
...@@ -1290,7 +1291,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, ...@@ -1290,7 +1291,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
ext4_xattr_block_csum_set(inode, new_bh); ext4_xattr_block_csum_set(inode, new_bh);
set_buffer_uptodate(new_bh); set_buffer_uptodate(new_bh);
unlock_buffer(new_bh); unlock_buffer(new_bh);
ext4_xattr_cache_insert(ext4_mb_cache, new_bh); ext4_xattr_block_cache_insert(ea_block_cache, new_bh);
error = ext4_handle_dirty_metadata(handle, inode, error = ext4_handle_dirty_metadata(handle, inode,
new_bh); new_bh);
if (error) if (error)
...@@ -1308,7 +1309,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, ...@@ -1308,7 +1309,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
cleanup: cleanup:
if (ce) if (ce)
mb_cache_entry_put(ext4_mb_cache, ce); mb_cache_entry_put(ea_block_cache, ce);
brelse(new_bh); brelse(new_bh);
if (!(bs->bh && s->base == bs->bh->b_data)) if (!(bs->bh && s->base == bs->bh->b_data))
kfree(s->base); kfree(s->base);
...@@ -2148,15 +2149,16 @@ void ext4_xattr_inode_array_free(struct ext4_xattr_inode_array *ea_inode_array) ...@@ -2148,15 +2149,16 @@ void ext4_xattr_inode_array_free(struct ext4_xattr_inode_array *ea_inode_array)
} }
/* /*
* ext4_xattr_cache_insert() * ext4_xattr_block_cache_insert()
* *
* Create a new entry in the extended attribute cache, and insert * Create a new entry in the extended attribute block cache, and insert
* it unless such an entry is already in the cache. * it unless such an entry is already in the cache.
* *
* Returns 0, or a negative error number on failure. * Returns 0, or a negative error number on failure.
*/ */
static void static void
ext4_xattr_cache_insert(struct mb_cache *ext4_mb_cache, struct buffer_head *bh) ext4_xattr_block_cache_insert(struct mb_cache *ea_block_cache,
struct buffer_head *bh)
{ {
struct ext4_xattr_header *header = BHDR(bh); struct ext4_xattr_header *header = BHDR(bh);
__u32 hash = le32_to_cpu(header->h_hash); __u32 hash = le32_to_cpu(header->h_hash);
...@@ -2164,7 +2166,7 @@ ext4_xattr_cache_insert(struct mb_cache *ext4_mb_cache, struct buffer_head *bh) ...@@ -2164,7 +2166,7 @@ ext4_xattr_cache_insert(struct mb_cache *ext4_mb_cache, struct buffer_head *bh)
EXT4_XATTR_REFCOUNT_MAX; EXT4_XATTR_REFCOUNT_MAX;
int error; int error;
error = mb_cache_entry_create(ext4_mb_cache, GFP_NOFS, hash, error = mb_cache_entry_create(ea_block_cache, GFP_NOFS, hash,
bh->b_blocknr, reusable); bh->b_blocknr, reusable);
if (error) { if (error) {
if (error == -EBUSY) if (error == -EBUSY)
...@@ -2214,7 +2216,7 @@ ext4_xattr_cmp(struct ext4_xattr_header *header1, ...@@ -2214,7 +2216,7 @@ ext4_xattr_cmp(struct ext4_xattr_header *header1,
} }
/* /*
* ext4_xattr_cache_find() * ext4_xattr_block_cache_find()
* *
* Find an identical extended attribute block. * Find an identical extended attribute block.
* *
...@@ -2222,17 +2224,18 @@ ext4_xattr_cmp(struct ext4_xattr_header *header1, ...@@ -2222,17 +2224,18 @@ ext4_xattr_cmp(struct ext4_xattr_header *header1,
* not found or an error occurred. * not found or an error occurred.
*/ */
static struct buffer_head * static struct buffer_head *
ext4_xattr_cache_find(struct inode *inode, struct ext4_xattr_header *header, ext4_xattr_block_cache_find(struct inode *inode,
struct mb_cache_entry **pce) struct ext4_xattr_header *header,
struct mb_cache_entry **pce)
{ {
__u32 hash = le32_to_cpu(header->h_hash); __u32 hash = le32_to_cpu(header->h_hash);
struct mb_cache_entry *ce; struct mb_cache_entry *ce;
struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode); struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
if (!header->h_hash) if (!header->h_hash)
return NULL; /* never share */ return NULL; /* never share */
ea_idebug(inode, "looking for cached blocks [%x]", (int)hash); ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
ce = mb_cache_entry_find_first(ext4_mb_cache, hash); ce = mb_cache_entry_find_first(ea_block_cache, hash);
while (ce) { while (ce) {
struct buffer_head *bh; struct buffer_head *bh;
...@@ -2245,7 +2248,7 @@ ext4_xattr_cache_find(struct inode *inode, struct ext4_xattr_header *header, ...@@ -2245,7 +2248,7 @@ ext4_xattr_cache_find(struct inode *inode, struct ext4_xattr_header *header,
return bh; return bh;
} }
brelse(bh); brelse(bh);
ce = mb_cache_entry_find_next(ext4_mb_cache, ce); ce = mb_cache_entry_find_next(ea_block_cache, ce);
} }
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment