[v2] nfs: abort delegation in dying VE

Submitted by Stanislav Kinsburskiy on Nov. 15, 2017, 5 p.m.

Details

Message ID 20171115170051.32181.38377.stgit@localhost.localdomain
State New
Series "nfs: abort delegation in dying VE"
Headers show

Commit Message

Stanislav Kinsburskiy Nov. 15, 2017, 5 p.m.
Don't queue delegation request, if ve init is exiting.

https://jira.sw.ru/browse/PSBM-77061

v2: check ve is dying under rcu_lock()

Inspired-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
---
 fs/nfs/delegation.c |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 66af497..1d1500c 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -189,15 +189,31 @@  void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred,
 	nfs_inode_set_delegation(inode, cred, res);
 }
 
+static bool ve_abort_delegation(struct inode *inode)
+{
+	struct nfs_client *clp = NFS_SERVER(inode)->nfs_client;
+	struct rpc_xprt *xprt;
+	bool abort;
+
+	rcu_read_lock();
+	xprt = rcu_dereference(clp->cl_rpcclient->cl_xprt);
+	abort = xprt->xprt_net->owner_ve->ve_netns == NULL;
+	rcu_read_unlock();
+
+	return abort;
+}
+
 static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int issync)
 {
 	int res = 0;
 
-	if (!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags))
+	if (!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) &&
+	    !ve_abort_delegation(inode)) {
 		res = nfs4_proc_delegreturn(inode,
 				delegation->cred,
 				&delegation->stateid,
 				issync);
+	}
 	nfs_free_delegation(delegation);
 	return res;
 }

Comments

Kirill Tkhai Nov. 15, 2017, 5:02 p.m.
On 15.11.2017 20:00, Stanislav Kinsburskiy wrote:
> Don't queue delegation request, if ve init is exiting.
> 
> https://jira.sw.ru/browse/PSBM-77061
> 
> v2: check ve is dying under rcu_lock()
> 
> Inspired-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>

Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>

> ---
>  fs/nfs/delegation.c |   18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
> index 66af497..1d1500c 100644
> --- a/fs/nfs/delegation.c
> +++ b/fs/nfs/delegation.c
> @@ -189,15 +189,31 @@ void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred,
>  	nfs_inode_set_delegation(inode, cred, res);
>  }
>  
> +static bool ve_abort_delegation(struct inode *inode)
> +{
> +	struct nfs_client *clp = NFS_SERVER(inode)->nfs_client;
> +	struct rpc_xprt *xprt;
> +	bool abort;
> +
> +	rcu_read_lock();
> +	xprt = rcu_dereference(clp->cl_rpcclient->cl_xprt);
> +	abort = xprt->xprt_net->owner_ve->ve_netns == NULL;
> +	rcu_read_unlock();
> +
> +	return abort;
> +}
> +
>  static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int issync)
>  {
>  	int res = 0;
>  
> -	if (!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags))
> +	if (!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) &&
> +	    !ve_abort_delegation(inode)) {
>  		res = nfs4_proc_delegreturn(inode,
>  				delegation->cred,
>  				&delegation->stateid,
>  				issync);
> +	}
>  	nfs_free_delegation(delegation);
>  	return res;
>  }
>