Linux NFS development
 help / color / mirror / Atom feed
* [PATCH 1/6] NFSv4.1/pnfs: Remove redundant checks in pnfs_layoutgets_blocked()
@ 2015-08-05  2:29 Trond Myklebust
  2015-08-05  2:29 ` [PATCH 2/6] NFSv4.1/pnfs: Fix serialisation of layout return and layoutget Trond Myklebust
  0 siblings, 1 reply; 8+ messages in thread
From: Trond Myklebust @ 2015-08-05  2:29 UTC (permalink / raw)
  To: linux-nfs

If there are no valid layout segments, then we should already have
checked in pnfs_update_layout() whether or not this is the first
layoutget.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
---
 fs/nfs/pnfs.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 70bf706b1090..aa95544123c5 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -829,12 +829,10 @@ pnfs_layout_returning(const struct pnfs_layout_hdr *lo,
 /* lget is set to 1 if called from inside send_layoutget call chain */
 static bool
 pnfs_layoutgets_blocked(const struct pnfs_layout_hdr *lo,
-			struct pnfs_layout_range *range, int lget)
+			struct pnfs_layout_range *range)
 {
 	return lo->plh_block_lgets ||
 		test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags) ||
-		(list_empty(&lo->plh_segs) &&
-		 (atomic_read(&lo->plh_outstanding) > lget)) ||
 		pnfs_layout_returning(lo, range);
 }
 
@@ -847,7 +845,7 @@ pnfs_choose_layoutget_stateid(nfs4_stateid *dst, struct pnfs_layout_hdr *lo,
 
 	dprintk("--> %s\n", __func__);
 	spin_lock(&lo->plh_inode->i_lock);
-	if (pnfs_layoutgets_blocked(lo, range, 1)) {
+	if (pnfs_layoutgets_blocked(lo, range)) {
 		status = -EAGAIN;
 	} else if (!nfs4_valid_open_stateid(open_state)) {
 		status = -EBADF;
@@ -1547,7 +1545,7 @@ lookup_again:
 		goto out_put_layout_hdr;
 	}
 
-	if (pnfs_layoutgets_blocked(lo, &arg, 0))
+	if (pnfs_layoutgets_blocked(lo, &arg))
 		goto out_unlock;
 	atomic_inc(&lo->plh_outstanding);
 	spin_unlock(&ino->i_lock);
@@ -1624,7 +1622,7 @@ pnfs_layout_process(struct nfs4_layoutget *lgp)
 		goto out_forget_reply;
 	}
 
-	if (pnfs_layoutgets_blocked(lo, &lgp->args.range, 1)) {
+	if (pnfs_layoutgets_blocked(lo, &lgp->args.range)) {
 		dprintk("%s forget reply due to state\n", __func__);
 		goto out_forget_reply;
 	}
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/6] NFSv4.1/pnfs: Fix serialisation of layout return and layoutget
  2015-08-05  2:29 [PATCH 1/6] NFSv4.1/pnfs: Remove redundant checks in pnfs_layoutgets_blocked() Trond Myklebust
@ 2015-08-05  2:29 ` Trond Myklebust
  2015-08-05  2:29   ` [PATCH 3/6] NFSv4.1/pnfs: Don't prevent layoutgets when doing return-on-close Trond Myklebust
  0 siblings, 1 reply; 8+ messages in thread
From: Trond Myklebust @ 2015-08-05  2:29 UTC (permalink / raw)
  To: linux-nfs

We should always test for outstanding layout returns, whether or not
pnfs_should_retry_layoutget() is true.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
---
 fs/nfs/pnfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index aa95544123c5..5280def00bc4 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1436,6 +1436,8 @@ static int pnfs_layoutget_retry_bit_wait(struct wait_bit_key *key)
 
 static bool pnfs_prepare_to_retry_layoutget(struct pnfs_layout_hdr *lo)
 {
+	if (!pnfs_should_retry_layoutget(lo))
+		return false;
 	/*
 	 * send layoutcommit as it can hold up layoutreturn due to lseg
 	 * reference
@@ -1531,8 +1533,7 @@ lookup_again:
 	 * Because we free lsegs before sending LAYOUTRETURN, we need to wait
 	 * for LAYOUTRETURN even if first is true.
 	 */
-	if (!lseg && pnfs_should_retry_layoutget(lo) &&
-	    test_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) {
+	if (test_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) {
 		spin_unlock(&ino->i_lock);
 		dprintk("%s wait for layoutreturn\n", __func__);
 		if (pnfs_prepare_to_retry_layoutget(lo)) {
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/6] NFSv4.1/pnfs: Don't prevent layoutgets when doing return-on-close
  2015-08-05  2:29 ` [PATCH 2/6] NFSv4.1/pnfs: Fix serialisation of layout return and layoutget Trond Myklebust
@ 2015-08-05  2:29   ` Trond Myklebust
  2015-08-05  2:29     ` [PATCH 4/6] NFSv4.1/pnfs: Remove redundant lo->plh_block_lgets in layoutreturn Trond Myklebust
  2015-08-17 14:42     ` [PATCH 3/6] NFSv4.1/pnfs: Don't prevent layoutgets when doing return-on-close Christoph Hellwig
  0 siblings, 2 replies; 8+ messages in thread
From: Trond Myklebust @ 2015-08-05  2:29 UTC (permalink / raw)
  To: linux-nfs

If there is an outstanding return-on-close, then we just want new
layoutget requests to wait rather than fail.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
---
 fs/nfs/pnfs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 5280def00bc4..9147dcaeb546 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1105,7 +1105,9 @@ bool pnfs_roc(struct inode *ino)
 		}
 	if (!found)
 		goto out_noroc;
-	lo->plh_block_lgets++;
+	if (test_and_set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags))
+		goto out_noroc;
+	lo->plh_return_iomode = IOMODE_ANY;
 	pnfs_get_layout_hdr(lo); /* matched in pnfs_roc_release */
 	spin_unlock(&ino->i_lock);
 	pnfs_free_lseg_list(&tmp_list);
@@ -1133,7 +1135,7 @@ void pnfs_roc_release(struct inode *ino)
 
 	spin_lock(&ino->i_lock);
 	lo = NFS_I(ino)->layout;
-	lo->plh_block_lgets--;
+	pnfs_clear_layoutreturn_waitbit(lo);
 	if (atomic_dec_and_test(&lo->plh_refcount)) {
 		pnfs_detach_layout_hdr(lo);
 		spin_unlock(&ino->i_lock);
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/6] NFSv4.1/pnfs: Remove redundant lo->plh_block_lgets in layoutreturn
  2015-08-05  2:29   ` [PATCH 3/6] NFSv4.1/pnfs: Don't prevent layoutgets when doing return-on-close Trond Myklebust
@ 2015-08-05  2:29     ` Trond Myklebust
  2015-08-05  2:29       ` [PATCH 5/6] NFSv4.1/pnfs: Remove redundant check in pnfs_layoutgets_blocked() Trond Myklebust
  2015-08-17 14:42     ` [PATCH 3/6] NFSv4.1/pnfs: Don't prevent layoutgets when doing return-on-close Christoph Hellwig
  1 sibling, 1 reply; 8+ messages in thread
From: Trond Myklebust @ 2015-08-05  2:29 UTC (permalink / raw)
  To: linux-nfs

The NFS_LAYOUT_RETURN bit already suffices to ensure that layoutget
is blocked.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
---
 fs/nfs/pnfs.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 9147dcaeb546..0c6aa13525e4 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -368,7 +368,6 @@ pnfs_prepare_layoutreturn(struct pnfs_layout_hdr *lo)
 	if (test_and_set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags))
 		return false;
 	lo->plh_return_iomode = 0;
-	lo->plh_block_lgets++;
 	pnfs_get_layout_hdr(lo);
 	clear_bit(NFS_LAYOUT_RETURN_BEFORE_CLOSE, &lo->plh_flags);
 	return true;
@@ -954,7 +953,6 @@ pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo, nfs4_stateid stateid,
 	if (unlikely(lrp == NULL)) {
 		status = -ENOMEM;
 		spin_lock(&ino->i_lock);
-		lo->plh_block_lgets--;
 		pnfs_clear_layoutreturn_waitbit(lo);
 		rpc_wake_up(&NFS_SERVER(ino)->roc_rpcwaitq);
 		spin_unlock(&ino->i_lock);
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/6] NFSv4.1/pnfs: Remove redundant check in pnfs_layoutgets_blocked()
  2015-08-05  2:29     ` [PATCH 4/6] NFSv4.1/pnfs: Remove redundant lo->plh_block_lgets in layoutreturn Trond Myklebust
@ 2015-08-05  2:29       ` Trond Myklebust
  2015-08-05  2:29         ` [PATCH 6/6] NFSv4.1/pnfs: Remove redundant wakeup in pnfs_send_layoutreturn() Trond Myklebust
  0 siblings, 1 reply; 8+ messages in thread
From: Trond Myklebust @ 2015-08-05  2:29 UTC (permalink / raw)
  To: linux-nfs

layoutget now should already be serialised w.r.t. layout returns

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
---
 fs/nfs/pnfs.c | 26 +++++---------------------
 1 file changed, 5 insertions(+), 21 deletions(-)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 0c6aa13525e4..b6540cc41f7c 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -816,23 +816,12 @@ pnfs_layout_stateid_blocked(const struct pnfs_layout_hdr *lo,
 	return !pnfs_seqid_is_newer(seqid, lo->plh_barrier);
 }
 
-static bool
-pnfs_layout_returning(const struct pnfs_layout_hdr *lo,
-		      struct pnfs_layout_range *range)
-{
-	return test_bit(NFS_LAYOUT_RETURN, &lo->plh_flags) &&
-		(lo->plh_return_iomode == IOMODE_ANY ||
-		 lo->plh_return_iomode == range->iomode);
-}
-
 /* lget is set to 1 if called from inside send_layoutget call chain */
 static bool
-pnfs_layoutgets_blocked(const struct pnfs_layout_hdr *lo,
-			struct pnfs_layout_range *range)
+pnfs_layoutgets_blocked(const struct pnfs_layout_hdr *lo)
 {
 	return lo->plh_block_lgets ||
-		test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags) ||
-		pnfs_layout_returning(lo, range);
+		test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags);
 }
 
 int
@@ -844,7 +833,7 @@ pnfs_choose_layoutget_stateid(nfs4_stateid *dst, struct pnfs_layout_hdr *lo,
 
 	dprintk("--> %s\n", __func__);
 	spin_lock(&lo->plh_inode->i_lock);
-	if (pnfs_layoutgets_blocked(lo, range)) {
+	if (pnfs_layoutgets_blocked(lo)) {
 		status = -EAGAIN;
 	} else if (!nfs4_valid_open_stateid(open_state)) {
 		status = -EBADF;
@@ -1546,7 +1535,7 @@ lookup_again:
 		goto out_put_layout_hdr;
 	}
 
-	if (pnfs_layoutgets_blocked(lo, &arg))
+	if (pnfs_layoutgets_blocked(lo))
 		goto out_unlock;
 	atomic_inc(&lo->plh_outstanding);
 	spin_unlock(&ino->i_lock);
@@ -1618,12 +1607,7 @@ pnfs_layout_process(struct nfs4_layoutget *lgp)
 	lseg->pls_range = res->range;
 
 	spin_lock(&ino->i_lock);
-	if (test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags)) {
-		dprintk("%s forget reply due to recall\n", __func__);
-		goto out_forget_reply;
-	}
-
-	if (pnfs_layoutgets_blocked(lo, &lgp->args.range)) {
+	if (pnfs_layoutgets_blocked(lo)) {
 		dprintk("%s forget reply due to state\n", __func__);
 		goto out_forget_reply;
 	}
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 6/6] NFSv4.1/pnfs: Remove redundant wakeup in pnfs_send_layoutreturn()
  2015-08-05  2:29       ` [PATCH 5/6] NFSv4.1/pnfs: Remove redundant check in pnfs_layoutgets_blocked() Trond Myklebust
@ 2015-08-05  2:29         ` Trond Myklebust
  0 siblings, 0 replies; 8+ messages in thread
From: Trond Myklebust @ 2015-08-05  2:29 UTC (permalink / raw)
  To: linux-nfs

pnfs_clear_layoutreturn_waitbit() should already be calling
rpc_wake_up(&NFS_SERVER(ino)->roc_rpcwaitq) for us.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
---
 fs/nfs/pnfs.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index b6540cc41f7c..9ca637821bb6 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -943,7 +943,6 @@ pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo, nfs4_stateid stateid,
 		status = -ENOMEM;
 		spin_lock(&ino->i_lock);
 		pnfs_clear_layoutreturn_waitbit(lo);
-		rpc_wake_up(&NFS_SERVER(ino)->roc_rpcwaitq);
 		spin_unlock(&ino->i_lock);
 		pnfs_put_layout_hdr(lo);
 		goto out;
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/6] NFSv4.1/pnfs: Don't prevent layoutgets when doing return-on-close
  2015-08-05  2:29   ` [PATCH 3/6] NFSv4.1/pnfs: Don't prevent layoutgets when doing return-on-close Trond Myklebust
  2015-08-05  2:29     ` [PATCH 4/6] NFSv4.1/pnfs: Remove redundant lo->plh_block_lgets in layoutreturn Trond Myklebust
@ 2015-08-17 14:42     ` Christoph Hellwig
  2015-08-18 11:33       ` Christoph Hellwig
  1 sibling, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2015-08-17 14:42 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: linux-nfs

This break the block layout client badly.  With this patch applied
it silently hangs in xfstests generic/001.  I'll see if I can
get more details out of my test setup.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/6] NFSv4.1/pnfs: Don't prevent layoutgets when doing return-on-close
  2015-08-17 14:42     ` [PATCH 3/6] NFSv4.1/pnfs: Don't prevent layoutgets when doing return-on-close Christoph Hellwig
@ 2015-08-18 11:33       ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2015-08-18 11:33 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: linux-nfs

On Mon, Aug 17, 2015 at 07:42:56AM -0700, Christoph Hellwig wrote:
> This break the block layout client badly.  With this patch applied
> it silently hangs in xfstests generic/001.  I'll see if I can
> get more details out of my test setup.

Seems like it's waiting either forever or frequently in this
callchain:

[<ffffffff81d30f24>] rpc_wait_bit_killable+0x34/0x80
[<ffffffff81d30ee8>] __rpc_wait_for_completion_task+0x28/0x30
[<ffffffff8138a7cc>] nfs4_do_close+0x1dc/0x2d0
[<ffffffff8139a429>] __nfs4_close+0xd9/0x180
[<ffffffff8139a503>] nfs4_close_sync+0x13/0x20
[<ffffffff81380035>] nfs4_close_context+0x25/0x30
[<ffffffff81363a43>] __put_nfs_open_context+0xc3/0x110
[<ffffffff8136588c>] nfs_release+0x9c/0xb0
[<ffffffff81362581>] nfs_file_release+0x41/0x60
[<ffffffff811dca02>] __fput+0xa2/0x1e0
[<ffffffff811dcb79>] ____fput+0x9/0x10
[<ffffffff810e52b6>] task_work_run+0x96/0xb0
[<ffffffff810c89dc>] do_exit+0x2cc/0xa10
[<ffffffff810c91f7>] do_group_exit+0x47/0xc0
[<ffffffff810c9282>] SyS_exit_group+0x12/0x20
[<ffffffff81d80eae>] entry_SYSCALL_64_fastpath+0x12/0x76
[<ffffffffffffffff>] 0xffffffffffffffff

Trond, does this pass xfstests generic/001 fine with whatever Server
you're testing against?

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-08-18 11:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-05  2:29 [PATCH 1/6] NFSv4.1/pnfs: Remove redundant checks in pnfs_layoutgets_blocked() Trond Myklebust
2015-08-05  2:29 ` [PATCH 2/6] NFSv4.1/pnfs: Fix serialisation of layout return and layoutget Trond Myklebust
2015-08-05  2:29   ` [PATCH 3/6] NFSv4.1/pnfs: Don't prevent layoutgets when doing return-on-close Trond Myklebust
2015-08-05  2:29     ` [PATCH 4/6] NFSv4.1/pnfs: Remove redundant lo->plh_block_lgets in layoutreturn Trond Myklebust
2015-08-05  2:29       ` [PATCH 5/6] NFSv4.1/pnfs: Remove redundant check in pnfs_layoutgets_blocked() Trond Myklebust
2015-08-05  2:29         ` [PATCH 6/6] NFSv4.1/pnfs: Remove redundant wakeup in pnfs_send_layoutreturn() Trond Myklebust
2015-08-17 14:42     ` [PATCH 3/6] NFSv4.1/pnfs: Don't prevent layoutgets when doing return-on-close Christoph Hellwig
2015-08-18 11:33       ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox