Skip to content

Commit

Permalink
fat: rcu-delay unloading nls and freeing sbi
Browse files Browse the repository at this point in the history
makes ->d_hash() and ->d_compare() safety in RCU mode independent
from vfsmount_lock.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Oct 25, 2013
1 parent 2e32cf5 commit cac45b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions fs/fat/fat.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ struct msdos_sb_info {
struct hlist_head dir_hashtable[FAT_HASH_SIZE];

unsigned int dirty; /* fs state before mount */
struct rcu_head rcu;
};

#define FAT_CACHE_VALID 0 /* special case for valid cache */
Expand Down
19 changes: 11 additions & 8 deletions fs/fat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,16 @@ static void fat_set_state(struct super_block *sb,
brelse(bh);
}

static void delayed_free(struct rcu_head *p)
{
struct msdos_sb_info *sbi = container_of(p, struct msdos_sb_info, rcu);
unload_nls(sbi->nls_disk);
unload_nls(sbi->nls_io);
if (sbi->options.iocharset != fat_default_iocharset)
kfree(sbi->options.iocharset);
kfree(sbi);
}

static void fat_put_super(struct super_block *sb)
{
struct msdos_sb_info *sbi = MSDOS_SB(sb);
Expand All @@ -557,14 +567,7 @@ static void fat_put_super(struct super_block *sb)
iput(sbi->fsinfo_inode);
iput(sbi->fat_inode);

unload_nls(sbi->nls_disk);
unload_nls(sbi->nls_io);

if (sbi->options.iocharset != fat_default_iocharset)
kfree(sbi->options.iocharset);

sb->s_fs_info = NULL;
kfree(sbi);
call_rcu(&sbi->rcu, delayed_free);
}

static struct kmem_cache *fat_inode_cachep;
Expand Down

0 comments on commit cac45b0

Please sign in to comment.