Skip to content

Commit

Permalink
ext2: convert to mbcache2
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Theodore Ts'o <[email protected]>
  • Loading branch information
jankara authored and tytso committed Feb 22, 2016
1 parent 82939d7 commit be0726d
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 100 deletions.
3 changes: 3 additions & 0 deletions fs/ext2/ext2.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ struct ext2_block_alloc_info {
#define rsv_start rsv_window._rsv_start
#define rsv_end rsv_window._rsv_end

struct mb2_cache;

/*
* second extended-fs super-block data in memory
*/
Expand Down Expand Up @@ -111,6 +113,7 @@ struct ext2_sb_info {
* of the mount options.
*/
spinlock_t s_lock;
struct mb2_cache *s_mb_cache;
};

static inline spinlock_t *
Expand Down
25 changes: 17 additions & 8 deletions fs/ext2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ static void ext2_put_super (struct super_block * sb)

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

ext2_xattr_put_super(sb);
if (sbi->s_mb_cache) {
ext2_xattr_destroy_cache(sbi->s_mb_cache);
sbi->s_mb_cache = NULL;
}
if (!(sb->s_flags & MS_RDONLY)) {
struct ext2_super_block *es = sbi->s_es;

Expand Down Expand Up @@ -1104,6 +1107,14 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
ext2_msg(sb, KERN_ERR, "error: insufficient memory");
goto failed_mount3;
}

#ifdef CONFIG_EXT2_FS_XATTR
sbi->s_mb_cache = ext2_xattr_create_cache();
if (!sbi->s_mb_cache) {
ext2_msg(sb, KERN_ERR, "Failed to create an mb_cache");
goto failed_mount3;
}
#endif
/*
* set up enough so that it can read an inode
*/
Expand Down Expand Up @@ -1149,6 +1160,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
sb->s_id);
goto failed_mount;
failed_mount3:
if (sbi->s_mb_cache)
ext2_xattr_destroy_cache(sbi->s_mb_cache);
percpu_counter_destroy(&sbi->s_freeblocks_counter);
percpu_counter_destroy(&sbi->s_freeinodes_counter);
percpu_counter_destroy(&sbi->s_dirs_counter);
Expand Down Expand Up @@ -1555,28 +1568,24 @@ MODULE_ALIAS_FS("ext2");

static int __init init_ext2_fs(void)
{
int err = init_ext2_xattr();
if (err)
return err;
int err;

err = init_inodecache();
if (err)
goto out1;
return err;
err = register_filesystem(&ext2_fs_type);
if (err)
goto out;
return 0;
out:
destroy_inodecache();
out1:
exit_ext2_xattr();
return err;
}

static void __exit exit_ext2_fs(void)
{
unregister_filesystem(&ext2_fs_type);
destroy_inodecache();
exit_ext2_xattr();
}

MODULE_AUTHOR("Remy Card and others");
Expand Down
Loading

0 comments on commit be0726d

Please sign in to comment.