Skip to content

Commit be0726d

Browse files
jankaratytso
authored andcommitted
ext2: convert to mbcache2
The conversion is generally straightforward. We convert filesystem from a global cache to per-fs one. Similarly to ext4 the tricky part is that xattr block corresponding to found mbcache entry can get freed before we get buffer lock for that block. So we have to check whether the entry is still valid after getting the buffer lock. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 82939d7 commit be0726d

File tree

4 files changed

+92
-100
lines changed

4 files changed

+92
-100
lines changed

Diff for: fs/ext2/ext2.h

+3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ struct ext2_block_alloc_info {
6161
#define rsv_start rsv_window._rsv_start
6262
#define rsv_end rsv_window._rsv_end
6363

64+
struct mb2_cache;
65+
6466
/*
6567
* second extended-fs super-block data in memory
6668
*/
@@ -111,6 +113,7 @@ struct ext2_sb_info {
111113
* of the mount options.
112114
*/
113115
spinlock_t s_lock;
116+
struct mb2_cache *s_mb_cache;
114117
};
115118

116119
static inline spinlock_t *

Diff for: fs/ext2/super.c

+17-8
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ static void ext2_put_super (struct super_block * sb)
131131

132132
dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);
133133

134-
ext2_xattr_put_super(sb);
134+
if (sbi->s_mb_cache) {
135+
ext2_xattr_destroy_cache(sbi->s_mb_cache);
136+
sbi->s_mb_cache = NULL;
137+
}
135138
if (!(sb->s_flags & MS_RDONLY)) {
136139
struct ext2_super_block *es = sbi->s_es;
137140

@@ -1104,6 +1107,14 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
11041107
ext2_msg(sb, KERN_ERR, "error: insufficient memory");
11051108
goto failed_mount3;
11061109
}
1110+
1111+
#ifdef CONFIG_EXT2_FS_XATTR
1112+
sbi->s_mb_cache = ext2_xattr_create_cache();
1113+
if (!sbi->s_mb_cache) {
1114+
ext2_msg(sb, KERN_ERR, "Failed to create an mb_cache");
1115+
goto failed_mount3;
1116+
}
1117+
#endif
11071118
/*
11081119
* set up enough so that it can read an inode
11091120
*/
@@ -1149,6 +1160,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
11491160
sb->s_id);
11501161
goto failed_mount;
11511162
failed_mount3:
1163+
if (sbi->s_mb_cache)
1164+
ext2_xattr_destroy_cache(sbi->s_mb_cache);
11521165
percpu_counter_destroy(&sbi->s_freeblocks_counter);
11531166
percpu_counter_destroy(&sbi->s_freeinodes_counter);
11541167
percpu_counter_destroy(&sbi->s_dirs_counter);
@@ -1555,28 +1568,24 @@ MODULE_ALIAS_FS("ext2");
15551568

15561569
static int __init init_ext2_fs(void)
15571570
{
1558-
int err = init_ext2_xattr();
1559-
if (err)
1560-
return err;
1571+
int err;
1572+
15611573
err = init_inodecache();
15621574
if (err)
1563-
goto out1;
1575+
return err;
15641576
err = register_filesystem(&ext2_fs_type);
15651577
if (err)
15661578
goto out;
15671579
return 0;
15681580
out:
15691581
destroy_inodecache();
1570-
out1:
1571-
exit_ext2_xattr();
15721582
return err;
15731583
}
15741584

15751585
static void __exit exit_ext2_fs(void)
15761586
{
15771587
unregister_filesystem(&ext2_fs_type);
15781588
destroy_inodecache();
1579-
exit_ext2_xattr();
15801589
}
15811590

15821591
MODULE_AUTHOR("Remy Card and others");

0 commit comments

Comments
 (0)