From: <andros@netapp.com>
To: <trond.myklebust@netapp.com>
Cc: <linux-nfs@vger.kernel.org>, Andy Adamson <andros@netapp.com>
Subject: [PATCH 1/1] NFSv4.1 fix a kswap nfs4_state_manger race
Date: Mon, 25 Nov 2013 12:57:50 -0500 [thread overview]
Message-ID: <1385402270-14284-2-git-send-email-andros@netapp.com> (raw)
In-Reply-To: <1385402270-14284-1-git-send-email-andros@netapp.com>
From: Andy Adamson <andros@netapp.com>
The state manager is recovering expired state and recovery OPENs are being
processed. If kswapd is pruning inodes at the same time, a deadlock can occur
when kswapd calls evict_inode on an NFSv4.1 inode with a layout, and the
resultant layoutreturn gets an error that the state mangager is to handle,
causing the layoutreturn to wait on the (NFS client) cl_rpcwaitq.
At the same time an open is waiting for the inode deletion to complete in
__wait_on_freeing_inode.
If the open is either the open called by the state manager, or an open from
the same open owner that is holding the NFSv4.0 sequence id which causes the
OPEN from the state manager to wait for the sequence id on the Seqid_waitqueue,
then the state is deadlocked with kswapd.
Do not handle LAYOUTRETURN errors when called from nfs4_evict_inode.
Signed-off-by: Andy Adamson <andros@netapp.com>
---
fs/nfs/nfs4proc.c | 6 ++++++
fs/nfs/pnfs.c | 5 ++++-
include/linux/nfs_xdr.h | 1 +
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index ca36d0d..fbeadf3 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -7596,6 +7596,12 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata)
return;
server = NFS_SERVER(lrp->args.inode);
+
+ /* Error handling can dead lock the state manager running open
+ * recovery when kswapd is also pruning inodes. */
+ if (lrp->ino_freeing)
+ return;
+
if (nfs4_async_handle_error(task, server, NULL) == -EAGAIN) {
rpc_restart_call_prepare(task);
return;
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index d75d938..a55ebf2 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -819,7 +819,7 @@ _pnfs_return_layout(struct inode *ino)
LIST_HEAD(tmp_list);
struct nfs4_layoutreturn *lrp;
nfs4_stateid stateid;
- int status = 0, empty;
+ int status = 0, empty, freeing = 0;
dprintk("NFS: %s for inode %lu\n", __func__, ino->i_ino);
@@ -844,6 +844,8 @@ _pnfs_return_layout(struct inode *ino)
goto out;
}
lo->plh_block_lgets++;
+ if (ino->i_state & I_FREEING)
+ freeing = 1;
spin_unlock(&ino->i_lock);
pnfs_free_lseg_list(&tmp_list);
@@ -863,6 +865,7 @@ _pnfs_return_layout(struct inode *ino)
lrp->args.layout = lo;
lrp->clp = NFS_SERVER(ino)->nfs_client;
lrp->cred = lo->plh_lc_cred;
+ lrp->ino_freeing = freeing;
status = nfs4_proc_layoutreturn(lrp);
out:
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 3ccfcec..b815345 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -316,6 +316,7 @@ struct nfs4_layoutreturn {
struct nfs4_layoutreturn_res res;
struct rpc_cred *cred;
struct nfs_client *clp;
+ int ino_freeing;
int rpc_status;
};
--
1.8.3.1
next prev parent reply other threads:[~2013-11-25 17:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-25 17:57 [PATCH 0/1] NFSv4.1 fix a kswap nfs4_state_manger race andros
2013-11-25 17:57 ` andros [this message]
2013-11-25 18:13 ` [PATCH 1/1] " Myklebust, Trond
2013-11-25 18:17 ` Adamson, Andy
2013-11-25 18:28 ` Myklebust, Trond
2013-11-25 18:31 ` Adamson, Andy
2013-11-25 18:33 ` Myklebust, Trond
2013-11-25 19:27 ` Adamson, Andy
2013-11-25 19:53 ` Myklebust, Trond
2013-11-25 20:10 ` Adamson, Andy
2013-11-25 20:20 ` Myklebust, Trond
2013-11-25 20:29 ` Adamson, Andy
2013-11-25 20:51 ` Adamson, Andy
2013-11-25 20:54 ` Adamson, Andy
2013-11-25 20:57 ` Myklebust, Trond
2013-11-25 21:06 ` Myklebust, Trond
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1385402270-14284-2-git-send-email-andros@netapp.com \
--to=andros@netapp.com \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@netapp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).