Skip to content

Commit 1dcddd4

Browse files
author
Al Viro
committed
ncpfs: rcu-delay unload_nls() and freeing ncp_server
makes ->d_hash() and ->d_compare() safety in RCU mode independent from vfsmount_lock. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent cac45b0 commit 1dcddd4

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

‎fs/ncpfs/inode.c‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,17 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
782782
return error;
783783
}
784784

785+
static void delayed_free(struct rcu_head *p)
786+
{
787+
struct ncp_server *server = container_of(p, struct ncp_server, rcu);
788+
#ifdef CONFIG_NCPFS_NLS
789+
/* unload the NLS charsets */
790+
unload_nls(server->nls_vol);
791+
unload_nls(server->nls_io);
792+
#endif /* CONFIG_NCPFS_NLS */
793+
kfree(server);
794+
}
795+
785796
static void ncp_put_super(struct super_block *sb)
786797
{
787798
struct ncp_server *server = NCP_SBP(sb);
@@ -792,11 +803,6 @@ static void ncp_put_super(struct super_block *sb)
792803

793804
ncp_stop_tasks(server);
794805

795-
#ifdef CONFIG_NCPFS_NLS
796-
/* unload the NLS charsets */
797-
unload_nls(server->nls_vol);
798-
unload_nls(server->nls_io);
799-
#endif /* CONFIG_NCPFS_NLS */
800806
mutex_destroy(&server->rcv.creq_mutex);
801807
mutex_destroy(&server->root_setup_lock);
802808
mutex_destroy(&server->mutex);
@@ -813,8 +819,7 @@ static void ncp_put_super(struct super_block *sb)
813819
vfree(server->rxbuf);
814820
vfree(server->txbuf);
815821
vfree(server->packet);
816-
sb->s_fs_info = NULL;
817-
kfree(server);
822+
call_rcu(&server->rcu, delayed_free);
818823
}
819824

820825
static int ncp_statfs(struct dentry *dentry, struct kstatfs *buf)

‎fs/ncpfs/ncp_fs_sb.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct ncp_mount_data_kernel {
3838
};
3939

4040
struct ncp_server {
41-
41+
struct rcu_head rcu;
4242
struct ncp_mount_data_kernel m; /* Nearly all of the mount data is of
4343
interest for us later, so we store
4444
it completely. */

0 commit comments

Comments
 (0)