Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1daef0a8 authored by Trond Myklebust's avatar Trond Myklebust
Browse files

NFS: Clean up nfs_sb_active/nfs_sb_deactive



Instead of causing umount requests to block on server->active_wq while the
asynchronous sillyrename deletes are executing, we can use the sb->s_active
counter to obtain a reference to the super_block, and then release that
reference in nfs_async_unlink_release().

Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent d5e66348
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -850,7 +850,6 @@ static struct nfs_server *nfs_alloc_server(void)
	INIT_LIST_HEAD(&server->client_link);
	INIT_LIST_HEAD(&server->client_link);
	INIT_LIST_HEAD(&server->master_link);
	INIT_LIST_HEAD(&server->master_link);


	init_waitqueue_head(&server->active_wq);
	atomic_set(&server->active, 0);
	atomic_set(&server->active, 0);


	server->io_stats = nfs_alloc_iostats();
	server->io_stats = nfs_alloc_iostats();
+2 −2
Original line number Original line Diff line number Diff line
@@ -163,8 +163,8 @@ extern struct rpc_stat nfs_rpcstat;


extern int __init register_nfs_fs(void);
extern int __init register_nfs_fs(void);
extern void __exit unregister_nfs_fs(void);
extern void __exit unregister_nfs_fs(void);
extern void nfs_sb_active(struct nfs_server *server);
extern void nfs_sb_active(struct super_block *sb);
extern void nfs_sb_deactive(struct nfs_server *server);
extern void nfs_sb_deactive(struct super_block *sb);


/* namespace.c */
/* namespace.c */
extern char *nfs_path(const char *base,
extern char *nfs_path(const char *base,
+8 −16
Original line number Original line Diff line number Diff line
@@ -209,7 +209,6 @@ static int nfs_get_sb(struct file_system_type *, int, const char *, void *, stru
static int nfs_xdev_get_sb(struct file_system_type *fs_type,
static int nfs_xdev_get_sb(struct file_system_type *fs_type,
		int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
		int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
static void nfs_kill_super(struct super_block *);
static void nfs_kill_super(struct super_block *);
static void nfs_put_super(struct super_block *);
static int nfs_remount(struct super_block *sb, int *flags, char *raw_data);
static int nfs_remount(struct super_block *sb, int *flags, char *raw_data);


static struct file_system_type nfs_fs_type = {
static struct file_system_type nfs_fs_type = {
@@ -232,7 +231,6 @@ static const struct super_operations nfs_sops = {
	.alloc_inode	= nfs_alloc_inode,
	.alloc_inode	= nfs_alloc_inode,
	.destroy_inode	= nfs_destroy_inode,
	.destroy_inode	= nfs_destroy_inode,
	.write_inode	= nfs_write_inode,
	.write_inode	= nfs_write_inode,
	.put_super	= nfs_put_super,
	.statfs		= nfs_statfs,
	.statfs		= nfs_statfs,
	.clear_inode	= nfs_clear_inode,
	.clear_inode	= nfs_clear_inode,
	.umount_begin	= nfs_umount_begin,
	.umount_begin	= nfs_umount_begin,
@@ -337,26 +335,20 @@ void __exit unregister_nfs_fs(void)
	unregister_filesystem(&nfs_fs_type);
	unregister_filesystem(&nfs_fs_type);
}
}


void nfs_sb_active(struct nfs_server *server)
void nfs_sb_active(struct super_block *sb)
{
{
	atomic_inc(&server->active);
	struct nfs_server *server = NFS_SB(sb);
}


void nfs_sb_deactive(struct nfs_server *server)
	if (atomic_inc_return(&server->active) == 1)
{
		atomic_inc(&sb->s_active);
	if (atomic_dec_and_test(&server->active))
		wake_up(&server->active_wq);
}
}


static void nfs_put_super(struct super_block *sb)
void nfs_sb_deactive(struct super_block *sb)
{
{
	struct nfs_server *server = NFS_SB(sb);
	struct nfs_server *server = NFS_SB(sb);
	/*

	 * Make sure there are no outstanding ops to this server.
	if (atomic_dec_and_test(&server->active))
	 * If so, wait for them to finish before allowing the
		deactivate_super(sb);
	 * unmount to continue.
	 */
	wait_event(server->active_wq, atomic_read(&server->active) == 0);
}
}


/*
/*
+3 −2
Original line number Original line Diff line number Diff line
@@ -99,7 +99,7 @@ static void nfs_async_unlink_release(void *calldata)


	nfs_dec_sillycount(data->dir);
	nfs_dec_sillycount(data->dir);
	nfs_free_unlinkdata(data);
	nfs_free_unlinkdata(data);
	nfs_sb_deactive(NFS_SB(sb));
	nfs_sb_deactive(sb);
}
}


static const struct rpc_call_ops nfs_unlink_ops = {
static const struct rpc_call_ops nfs_unlink_ops = {
@@ -118,6 +118,7 @@ static int nfs_do_call_unlink(struct dentry *parent, struct inode *dir, struct n
		.rpc_message = &msg,
		.rpc_message = &msg,
		.callback_ops = &nfs_unlink_ops,
		.callback_ops = &nfs_unlink_ops,
		.callback_data = data,
		.callback_data = data,
		.workqueue = nfsiod_workqueue,
		.flags = RPC_TASK_ASYNC,
		.flags = RPC_TASK_ASYNC,
	};
	};
	struct rpc_task *task;
	struct rpc_task *task;
@@ -149,7 +150,7 @@ static int nfs_do_call_unlink(struct dentry *parent, struct inode *dir, struct n
		nfs_dec_sillycount(dir);
		nfs_dec_sillycount(dir);
		return 0;
		return 0;
	}
	}
	nfs_sb_active(NFS_SERVER(dir));
	nfs_sb_active(dir->i_sb);
	data->args.fh = NFS_FH(dir);
	data->args.fh = NFS_FH(dir);
	nfs_fattr_init(&data->res.dir_attr);
	nfs_fattr_init(&data->res.dir_attr);


+0 −1
Original line number Original line Diff line number Diff line
@@ -119,7 +119,6 @@ struct nfs_server {
	void (*destroy)(struct nfs_server *);
	void (*destroy)(struct nfs_server *);


	atomic_t active; /* Keep trace of any activity to this server */
	atomic_t active; /* Keep trace of any activity to this server */
	wait_queue_head_t active_wq;  /* Wait for any activity to stop  */


	/* mountd-related mount options */
	/* mountd-related mount options */
	struct sockaddr_storage	mountd_address;
	struct sockaddr_storage	mountd_address;