Linux-NFS Archive on lore.kernel.org
 help / color / Atom feed
From: Trond Myklebust <trondmy@gmail.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 13/19] pnfs: Add barrier to prevent lgopen using LAYOUTGET during recall
Date: Wed, 30 May 2018 14:05:47 -0400
Message-ID: <20180530180553.38769-14-trond.myklebust@hammerspace.com> (raw)
In-Reply-To: <20180530180553.38769-13-trond.myklebust@hammerspace.com>

From: Fred Isaman <fred.isaman@gmail.com>

Since the LAYOUTGET on OPEN can be sent without prior inode information,
existing methods to prevent LAYOUTGET from being sent while processing
CB_LAYOUTRECALL don't work.  Track if a recall occurred while LAYOUTGET
was being sent, and if so ignore the results.

Signed-off-by: Fred Isaman <fred.isaman@gmail.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/callback_proc.c    | 2 ++
 fs/nfs/pnfs.c             | 8 +++++++-
 include/linux/nfs_fs_sb.h | 1 +
 include/linux/nfs_xdr.h   | 1 +
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index a50d7813e3ea..d561161b7c3e 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -322,6 +322,8 @@ static u32 initiate_bulk_draining(struct nfs_client *clp,
 static u32 do_callback_layoutrecall(struct nfs_client *clp,
 				    struct cb_layoutrecallargs *args)
 {
+	write_seqcount_begin(&clp->cl_callback_count);
+	write_seqcount_end(&clp->cl_callback_count);
 	if (args->cbl_recall_type == RETURN_FILE)
 		return initiate_file_draining(clp, args);
 	return initiate_bulk_draining(clp, args);
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index b2158e5bf7f7..5621b85a5c24 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -979,6 +979,7 @@ pnfs_alloc_init_layoutget_args(struct inode *ino,
 	nfs4_stateid_copy(&lgp->args.stateid, stateid);
 	lgp->gfp_flags = gfp_flags;
 	lgp->cred = get_rpccred(ctx->cred);
+	lgp->callback_count = raw_seqcount_begin(&server->nfs_client->cl_callback_count);
 	return lgp;
 }
 
@@ -2051,6 +2052,7 @@ void pnfs_parse_lgopen(struct inode *ino, struct nfs4_layoutget *lgp,
 {
 	struct pnfs_layout_hdr *lo;
 	struct pnfs_layout_segment *lseg;
+	struct nfs_server *srv = NFS_SERVER(ino);
 	u32 iomode;
 
 	if (!lgp)
@@ -2066,7 +2068,7 @@ void pnfs_parse_lgopen(struct inode *ino, struct nfs4_layoutget *lgp,
 			/* FIXME - Any error not listed above permanently
 			 * halts lgopen attempts.
 			 */
-			NFS_SERVER(ino)->caps &= ~NFS_CAP_LGOPEN;
+			srv->caps &= ~NFS_CAP_LGOPEN;
 		}
 		return;
 	}
@@ -2079,6 +2081,9 @@ void pnfs_parse_lgopen(struct inode *ino, struct nfs4_layoutget *lgp,
 		lo = NFS_I(lgp->args.inode)->layout;
 	pnfs_get_layout_hdr(lo);
 
+	if (read_seqcount_retry(&srv->nfs_client->cl_callback_count,
+				lgp->callback_count))
+		goto out;
 	lseg = pnfs_layout_process(lgp);
 	atomic_dec(&lo->plh_outstanding);
 	if (IS_ERR(lseg)) {
@@ -2089,6 +2094,7 @@ void pnfs_parse_lgopen(struct inode *ino, struct nfs4_layoutget *lgp,
 		pnfs_layout_clear_fail_bit(lo, pnfs_iomode_to_fail_bit(iomode));
 		pnfs_put_lseg(lseg);
 	}
+out:
 	pnfs_clear_first_layoutget(lo);
 	pnfs_put_layout_hdr(lo);
 }
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index 2c18d618604e..74ae3e1d19a0 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -28,6 +28,7 @@ struct nfs41_impl_id;
 struct nfs_client {
 	refcount_t		cl_count;
 	atomic_t		cl_mds_count;
+	seqcount_t		cl_callback_count;
 	int			cl_cons_state;	/* current construction state (-ve: init error) */
 #define NFS_CS_READY		0		/* ready to be used */
 #define NFS_CS_INITING		1		/* busy initialising */
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index b36be7a703ea..b777eb7da15e 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -271,6 +271,7 @@ struct nfs4_layoutget {
 	struct nfs4_layoutget_args args;
 	struct nfs4_layoutget_res res;
 	struct rpc_cred *cred;
+	unsigned callback_count;
 	gfp_t gfp_flags;
 };
 
-- 
2.17.0


  reply index

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-30 18:05 [PATCH 00/19] Layoutget on OPEN Trond Myklebust
2018-05-30 18:05 ` [PATCH 01/19] pnfs: Remove redundant assignment from nfs4_proc_layoutget() Trond Myklebust
2018-05-30 18:05   ` [PATCH 02/19] pnfs: Store return value of decode_layoutget for later processing Trond Myklebust
2018-05-30 18:05     ` [PATCH 03/19] NFS4: move ctx into nfs4_run_open_task Trond Myklebust
2018-05-30 18:05       ` [PATCH 04/19] pnfs: Add layout driver flag PNFS_LAYOUTGET_ON_OPEN Trond Myklebust
2018-05-30 18:05         ` [PATCH 05/19] pnfs: refactor send_layoutget Trond Myklebust
2018-05-30 18:05           ` [PATCH 06/19] pnfs: move allocations out of nfs4_proc_layoutget Trond Myklebust
2018-05-30 18:05             ` [PATCH 07/19] pnfs: Add conditional encode/decode of LAYOUTGET within OPEN compound Trond Myklebust
2018-05-30 18:05               ` [PATCH 08/19] pnfs: Move nfs4_opendata into nfs4_fs.h Trond Myklebust
2018-05-30 18:05                 ` [PATCH 09/19] pnfs: Change pnfs_alloc_init_layoutget_args call signature Trond Myklebust
2018-05-30 18:05                   ` [PATCH 10/19] pnfs: Add LAYOUTGET to OPEN of a new file Trond Myklebust
2018-05-30 18:05                     ` [PATCH 11/19] pnfs: Add LAYOUTGET to OPEN of an existing file Trond Myklebust
2018-05-30 18:05                       ` [PATCH 12/19] pnfs: Stop attempting LAYOUTGET on OPEN on failure Trond Myklebust
2018-05-30 18:05                         ` Trond Myklebust [this message]
2018-05-30 18:05                           ` [PATCH 14/19] pnfs: Fix manipulation of NFS_LAYOUT_FIRST_LAYOUTGET Trond Myklebust
2018-05-30 18:05                             ` [PATCH 15/19] NFSv4/pnfs: Ensure pnfs_parse_lgopen() won't try to parse uninitialised data Trond Myklebust
2018-05-30 18:05                               ` [PATCH 16/19] NFSv4/pnfs: Don't switch off layoutget-on-open for transient errors Trond Myklebust
2018-05-30 18:05                                 ` [PATCH 17/19] pNFS: Don't send LAYOUTGET on OPEN for read, if we already have cached data Trond Myklebust
2018-05-30 18:05                                   ` [PATCH 18/19] pnfs: Don't call commit on failed layoutget-on-open Trond Myklebust
2018-05-30 18:05                                     ` [PATCH 19/19] pnfs: Don't release the sequence slot until we've processed layoutget on open Trond Myklebust
2018-05-30 20:10         ` [PATCH 04/19] pnfs: Add layout driver flag PNFS_LAYOUTGET_ON_OPEN Olga Kornievskaia
2018-05-31 12:40           ` Trond Myklebust
2019-09-06 20:17             ` Olga Kornievskaia
2018-05-30 18:25 ` [PATCH 00/19] Layoutget on OPEN Olga Kornievskaia
2018-05-30 18:36   ` Trond Myklebust
2018-05-30 18:37     ` Olga Kornievskaia
2018-05-30 19:27       ` Olga Kornievskaia
2018-05-30 19:29         ` Olga Kornievskaia
2018-05-30 19:47           ` Olga Kornievskaia
2018-05-30 22:33             ` Trond Myklebust
2018-05-31 18:59 ` bfields
2018-06-01  0:28   ` Trond Myklebust

Reply instructions:

You may reply publically 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=20180530180553.38769-14-trond.myklebust@hammerspace.com \
    --to=trondmy@gmail.com \
    --cc=linux-nfs@vger.kernel.org \
    /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

Linux-NFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nfs/0 linux-nfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nfs linux-nfs/ https://lore.kernel.org/linux-nfs \
		linux-nfs@vger.kernel.org linux-nfs@archiver.kernel.org
	public-inbox-index linux-nfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-nfs


AGPL code for this site: git clone https://public-inbox.org/ public-inbox