Skip to content

Commit 4738740

Browse files
Tahsin Erdogantytso
authored andcommitted
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: Tahsin Erdogan <[email protected]> Signed-off-by: Theodore Ts'o <[email protected]>
1 parent c07dfcb commit 4738740

File tree

6 files changed

+75
-70
lines changed

6 files changed

+75
-70
lines changed

fs/ext2/ext2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ struct ext2_sb_info {
113113
* of the mount options.
114114
*/
115115
spinlock_t s_lock;
116-
struct mb_cache *s_mb_cache;
116+
struct mb_cache *s_ea_block_cache;
117117
};
118118

119119
static inline spinlock_t *

fs/ext2/super.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ static void ext2_put_super (struct super_block * sb)
147147

148148
ext2_quota_off_umount(sb);
149149

150-
if (sbi->s_mb_cache) {
151-
ext2_xattr_destroy_cache(sbi->s_mb_cache);
152-
sbi->s_mb_cache = NULL;
150+
if (sbi->s_ea_block_cache) {
151+
ext2_xattr_destroy_cache(sbi->s_ea_block_cache);
152+
sbi->s_ea_block_cache = NULL;
153153
}
154154
if (!(sb->s_flags & MS_RDONLY)) {
155155
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)
11311131
}
11321132

11331133
#ifdef CONFIG_EXT2_FS_XATTR
1134-
sbi->s_mb_cache = ext2_xattr_create_cache();
1135-
if (!sbi->s_mb_cache) {
1136-
ext2_msg(sb, KERN_ERR, "Failed to create an mb_cache");
1134+
sbi->s_ea_block_cache = ext2_xattr_create_cache();
1135+
if (!sbi->s_ea_block_cache) {
1136+
ext2_msg(sb, KERN_ERR, "Failed to create ea_block_cache");
11371137
goto failed_mount3;
11381138
}
11391139
#endif
@@ -1182,8 +1182,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
11821182
sb->s_id);
11831183
goto failed_mount;
11841184
failed_mount3:
1185-
if (sbi->s_mb_cache)
1186-
ext2_xattr_destroy_cache(sbi->s_mb_cache);
1185+
if (sbi->s_ea_block_cache)
1186+
ext2_xattr_destroy_cache(sbi->s_ea_block_cache);
11871187
percpu_counter_destroy(&sbi->s_freeblocks_counter);
11881188
percpu_counter_destroy(&sbi->s_freeinodes_counter);
11891189
percpu_counter_destroy(&sbi->s_dirs_counter);

fs/ext2/xattr.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ const struct xattr_handler *ext2_xattr_handlers[] = {
121121
NULL
122122
};
123123

124+
#define EA_BLOCK_CACHE(inode) (EXT2_SB(inode->i_sb)->s_ea_block_cache)
125+
124126
static inline const struct xattr_handler *
125127
ext2_xattr_handler(int name_index)
126128
{
@@ -150,7 +152,7 @@ ext2_xattr_get(struct inode *inode, int name_index, const char *name,
150152
size_t name_len, size;
151153
char *end;
152154
int error;
153-
struct mb_cache *ext2_mb_cache = EXT2_SB(inode->i_sb)->s_mb_cache;
155+
struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
154156

155157
ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
156158
name_index, name, buffer, (long)buffer_size);
@@ -195,7 +197,7 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_get",
195197
goto found;
196198
entry = next;
197199
}
198-
if (ext2_xattr_cache_insert(ext2_mb_cache, bh))
200+
if (ext2_xattr_cache_insert(ea_block_cache, bh))
199201
ea_idebug(inode, "cache insert failed");
200202
error = -ENODATA;
201203
goto cleanup;
@@ -208,7 +210,7 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_get",
208210
le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize)
209211
goto bad_block;
210212

211-
if (ext2_xattr_cache_insert(ext2_mb_cache, bh))
213+
if (ext2_xattr_cache_insert(ea_block_cache, bh))
212214
ea_idebug(inode, "cache insert failed");
213215
if (buffer) {
214216
error = -ERANGE;
@@ -246,7 +248,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
246248
char *end;
247249
size_t rest = buffer_size;
248250
int error;
249-
struct mb_cache *ext2_mb_cache = EXT2_SB(inode->i_sb)->s_mb_cache;
251+
struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
250252

251253
ea_idebug(inode, "buffer=%p, buffer_size=%ld",
252254
buffer, (long)buffer_size);
@@ -281,7 +283,7 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
281283
goto bad_block;
282284
entry = next;
283285
}
284-
if (ext2_xattr_cache_insert(ext2_mb_cache, bh))
286+
if (ext2_xattr_cache_insert(ea_block_cache, bh))
285287
ea_idebug(inode, "cache insert failed");
286288

287289
/* list the attribute names */
@@ -493,7 +495,7 @@ bad_block: ext2_error(sb, "ext2_xattr_set",
493495
* This must happen under buffer lock for
494496
* ext2_xattr_set2() to reliably detect modified block
495497
*/
496-
mb_cache_entry_delete(EXT2_SB(sb)->s_mb_cache, hash,
498+
mb_cache_entry_delete(EA_BLOCK_CACHE(inode), hash,
497499
bh->b_blocknr);
498500

499501
/* keep the buffer locked while modifying it. */
@@ -627,7 +629,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
627629
struct super_block *sb = inode->i_sb;
628630
struct buffer_head *new_bh = NULL;
629631
int error;
630-
struct mb_cache *ext2_mb_cache = EXT2_SB(sb)->s_mb_cache;
632+
struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
631633

632634
if (header) {
633635
new_bh = ext2_xattr_cache_find(inode, header);
@@ -655,7 +657,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
655657
don't need to change the reference count. */
656658
new_bh = old_bh;
657659
get_bh(new_bh);
658-
ext2_xattr_cache_insert(ext2_mb_cache, new_bh);
660+
ext2_xattr_cache_insert(ea_block_cache, new_bh);
659661
} else {
660662
/* We need to allocate a new block */
661663
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,
676678
memcpy(new_bh->b_data, header, new_bh->b_size);
677679
set_buffer_uptodate(new_bh);
678680
unlock_buffer(new_bh);
679-
ext2_xattr_cache_insert(ext2_mb_cache, new_bh);
681+
ext2_xattr_cache_insert(ea_block_cache, new_bh);
680682

681683
ext2_xattr_update_super_block(sb);
682684
}
@@ -721,7 +723,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
721723
* This must happen under buffer lock for
722724
* ext2_xattr_set2() to reliably detect freed block
723725
*/
724-
mb_cache_entry_delete(ext2_mb_cache, hash,
726+
mb_cache_entry_delete(ea_block_cache, hash,
725727
old_bh->b_blocknr);
726728
/* Free the old block. */
727729
ea_bdebug(old_bh, "freeing");
@@ -795,7 +797,7 @@ ext2_xattr_delete_inode(struct inode *inode)
795797
* This must happen under buffer lock for ext2_xattr_set2() to
796798
* reliably detect freed block
797799
*/
798-
mb_cache_entry_delete(EXT2_SB(inode->i_sb)->s_mb_cache, hash,
800+
mb_cache_entry_delete(EA_BLOCK_CACHE(inode), hash,
799801
bh->b_blocknr);
800802
ext2_free_blocks(inode, EXT2_I(inode)->i_file_acl, 1);
801803
get_bh(bh);
@@ -897,13 +899,13 @@ ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header)
897899
{
898900
__u32 hash = le32_to_cpu(header->h_hash);
899901
struct mb_cache_entry *ce;
900-
struct mb_cache *ext2_mb_cache = EXT2_SB(inode->i_sb)->s_mb_cache;
902+
struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
901903

902904
if (!header->h_hash)
903905
return NULL; /* never share */
904906
ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
905907
again:
906-
ce = mb_cache_entry_find_first(ext2_mb_cache, hash);
908+
ce = mb_cache_entry_find_first(ea_block_cache, hash);
907909
while (ce) {
908910
struct buffer_head *bh;
909911

@@ -924,7 +926,7 @@ ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header)
924926
* entry is still hashed is reliable.
925927
*/
926928
if (hlist_bl_unhashed(&ce->e_hash_list)) {
927-
mb_cache_entry_put(ext2_mb_cache, ce);
929+
mb_cache_entry_put(ea_block_cache, ce);
928930
unlock_buffer(bh);
929931
brelse(bh);
930932
goto again;
@@ -937,14 +939,14 @@ ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header)
937939
} else if (!ext2_xattr_cmp(header, HDR(bh))) {
938940
ea_bdebug(bh, "b_count=%d",
939941
atomic_read(&(bh->b_count)));
940-
mb_cache_entry_touch(ext2_mb_cache, ce);
941-
mb_cache_entry_put(ext2_mb_cache, ce);
942+
mb_cache_entry_touch(ea_block_cache, ce);
943+
mb_cache_entry_put(ea_block_cache, ce);
942944
return bh;
943945
}
944946
unlock_buffer(bh);
945947
brelse(bh);
946948
}
947-
ce = mb_cache_entry_find_next(ext2_mb_cache, ce);
949+
ce = mb_cache_entry_find_next(ea_block_cache, ce);
948950
}
949951
return NULL;
950952
}

fs/ext4/ext4.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,7 @@ struct ext4_sb_info {
15161516
struct list_head s_es_list; /* List of inodes with reclaimable extents */
15171517
long s_es_nr_inode;
15181518
struct ext4_es_stats s_es_stats;
1519-
struct mb_cache *s_mb_cache;
1519+
struct mb_cache *s_ea_block_cache;
15201520
spinlock_t s_es_lock ____cacheline_aligned_in_smp;
15211521

15221522
/* Ratelimit ext4 messages. */

fs/ext4/super.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -927,9 +927,9 @@ static void ext4_put_super(struct super_block *sb)
927927
invalidate_bdev(sbi->journal_bdev);
928928
ext4_blkdev_remove(sbi);
929929
}
930-
if (sbi->s_mb_cache) {
931-
ext4_xattr_destroy_cache(sbi->s_mb_cache);
932-
sbi->s_mb_cache = NULL;
930+
if (sbi->s_ea_block_cache) {
931+
ext4_xattr_destroy_cache(sbi->s_ea_block_cache);
932+
sbi->s_ea_block_cache = NULL;
933933
}
934934
if (sbi->s_mmp_tsk)
935935
kthread_stop(sbi->s_mmp_tsk);
@@ -4061,9 +4061,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
40614061
sbi->s_journal->j_commit_callback = ext4_journal_commit_callback;
40624062

40634063
no_journal:
4064-
sbi->s_mb_cache = ext4_xattr_create_cache();
4065-
if (!sbi->s_mb_cache) {
4066-
ext4_msg(sb, KERN_ERR, "Failed to create an mb_cache");
4064+
sbi->s_ea_block_cache = ext4_xattr_create_cache();
4065+
if (!sbi->s_ea_block_cache) {
4066+
ext4_msg(sb, KERN_ERR, "Failed to create ea_block_cache");
40674067
goto failed_mount_wq;
40684068
}
40694069

@@ -4296,9 +4296,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
42964296
if (EXT4_SB(sb)->rsv_conversion_wq)
42974297
destroy_workqueue(EXT4_SB(sb)->rsv_conversion_wq);
42984298
failed_mount_wq:
4299-
if (sbi->s_mb_cache) {
4300-
ext4_xattr_destroy_cache(sbi->s_mb_cache);
4301-
sbi->s_mb_cache = NULL;
4299+
if (sbi->s_ea_block_cache) {
4300+
ext4_xattr_destroy_cache(sbi->s_ea_block_cache);
4301+
sbi->s_ea_block_cache = NULL;
43024302
}
43034303
if (sbi->s_journal) {
43044304
jbd2_journal_destroy(sbi->s_journal);

0 commit comments

Comments
 (0)