All of lore.kernel.org
 help / color / mirror / Atom feed
From: Trond Myklebust <trond.myklebust@primarydata.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH v4 11/28] pNFS: Files and flexfiles always need to commit before layoutcommit
Date: Wed,  6 Jul 2016 18:29:48 -0400	[thread overview]
Message-ID: <1467844205-76852-12-git-send-email-trond.myklebust@primarydata.com> (raw)
In-Reply-To: <1467844205-76852-11-git-send-email-trond.myklebust@primarydata.com>

So ensure that we mark the layout for commit once the write is done,
and then ensure that the commit to ds is finished before sending
layoutcommit.

Note that by doing this, we're able to optimise away the commit
for the case of servers that don't need layoutcommit in order to
return updated attributes.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
---
 fs/nfs/filelayout/filelayout.c         |  9 ++++++---
 fs/nfs/flexfilelayout/flexfilelayout.c |  7 +++++--
 fs/nfs/nfs4xdr.c                       | 11 ++++++++---
 fs/nfs/pnfs.c                          |  5 ++++-
 fs/nfs/pnfs_nfs.c                      |  7 +++++++
 5 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c
index b4c1407e8fe4..25bd91a6e088 100644
--- a/fs/nfs/filelayout/filelayout.c
+++ b/fs/nfs/filelayout/filelayout.c
@@ -255,13 +255,16 @@ static int filelayout_read_done_cb(struct rpc_task *task,
 static void
 filelayout_set_layoutcommit(struct nfs_pgio_header *hdr)
 {
+	loff_t end_offs = 0;
 
 	if (FILELAYOUT_LSEG(hdr->lseg)->commit_through_mds ||
-	    hdr->res.verf->committed != NFS_DATA_SYNC)
+	    hdr->res.verf->committed == NFS_FILE_SYNC)
 		return;
+	if (hdr->res.verf->committed == NFS_DATA_SYNC)
+		end_offs = hdr->mds_offset + (loff_t)hdr->res.count;
 
-	pnfs_set_layoutcommit(hdr->inode, hdr->lseg,
-			hdr->mds_offset + hdr->res.count);
+	/* Note: if the write is unstable, don't set end_offs until commit */
+	pnfs_set_layoutcommit(hdr->inode, hdr->lseg, end_offs);
 	dprintk("%s inode %lu pls_end_pos %lu\n", __func__, hdr->inode->i_ino,
 		(unsigned long) NFS_I(hdr->inode)->layout->plh_lwb);
 }
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index 14f2ed3f1a5b..e6206eaf2bdf 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -1470,6 +1470,7 @@ static void ff_layout_read_release(void *data)
 static int ff_layout_write_done_cb(struct rpc_task *task,
 				struct nfs_pgio_header *hdr)
 {
+	loff_t end_offs = 0;
 	int err;
 
 	trace_nfs4_pnfs_write(hdr, task->tk_status);
@@ -1495,8 +1496,10 @@ static int ff_layout_write_done_cb(struct rpc_task *task,
 
 	if (hdr->res.verf->committed == NFS_FILE_SYNC ||
 	    hdr->res.verf->committed == NFS_DATA_SYNC)
-		ff_layout_set_layoutcommit(hdr->inode, hdr->lseg,
-				hdr->mds_offset + (loff_t)hdr->res.count);
+		end_offs = hdr->mds_offset + (loff_t)hdr->res.count;
+
+	/* Note: if the write is unstable, don't set end_offs until commit */
+	ff_layout_set_layoutcommit(hdr->inode, hdr->lseg, end_offs);
 
 	/* zero out fattr since we don't care DS attr at all */
 	hdr->fattr.valid = 0;
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 661e753fe1c9..7bd3a5c09d31 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1985,9 +1985,14 @@ encode_layoutcommit(struct xdr_stream *xdr,
 	p = xdr_encode_hyper(p, args->lastbytewritten + 1);	/* length */
 	*p = cpu_to_be32(0); /* reclaim */
 	encode_nfs4_stateid(xdr, &args->stateid);
-	p = reserve_space(xdr, 20);
-	*p++ = cpu_to_be32(1); /* newoffset = TRUE */
-	p = xdr_encode_hyper(p, args->lastbytewritten);
+	if (args->lastbytewritten != U64_MAX) {
+		p = reserve_space(xdr, 20);
+		*p++ = cpu_to_be32(1); /* newoffset = TRUE */
+		p = xdr_encode_hyper(p, args->lastbytewritten);
+	} else {
+		p = reserve_space(xdr, 12);
+		*p++ = cpu_to_be32(0); /* newoffset = FALSE */
+	}
 	*p++ = cpu_to_be32(0); /* Never send time_modify_changed */
 	*p++ = cpu_to_be32(NFS_SERVER(args->inode)->pnfs_curr_ld->id);/* type */
 
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 0c7e0d45a4de..62553182514e 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -2378,7 +2378,10 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync)
 	nfs_fattr_init(&data->fattr);
 	data->args.bitmask = NFS_SERVER(inode)->cache_consistency_bitmask;
 	data->res.fattr = &data->fattr;
-	data->args.lastbytewritten = end_pos - 1;
+	if (end_pos != 0)
+		data->args.lastbytewritten = end_pos - 1;
+	else
+		data->args.lastbytewritten = U64_MAX;
 	data->res.server = NFS_SERVER(inode);
 
 	if (ld->prepare_layoutcommit) {
diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c
index 0dfc476da3e1..0d10cc280a23 100644
--- a/fs/nfs/pnfs_nfs.c
+++ b/fs/nfs/pnfs_nfs.c
@@ -932,6 +932,13 @@ EXPORT_SYMBOL_GPL(pnfs_layout_mark_request_commit);
 int
 pnfs_nfs_generic_sync(struct inode *inode, bool datasync)
 {
+	int ret;
+
+	if (!pnfs_layoutcommit_outstanding(inode))
+		return 0;
+	ret = nfs_commit_inode(inode, FLUSH_SYNC);
+	if (ret < 0)
+		return ret;
 	if (datasync)
 		return 0;
 	return pnfs_layoutcommit_inode(inode, true);
-- 
2.7.4


  reply	other threads:[~2016-07-06 22:30 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-06 22:29 [PATCH v4 00/28] NFS writeback performance patches for v4.8 Trond Myklebust
2016-07-06 22:29 ` [PATCH v4 01/28] NFS: Don't flush caches for a getattr that races with writeback Trond Myklebust
2016-07-06 22:29   ` [PATCH v4 02/28] NFS: Cache access checks more aggressively Trond Myklebust
2016-07-06 22:29     ` [PATCH v4 03/28] NFS: Cache aggressively when file is open for writing Trond Myklebust
2016-07-06 22:29       ` [PATCH v4 04/28] NFS: Kill NFS_INO_NFS_INO_FLUSHING: it is a performance killer Trond Myklebust
2016-07-06 22:29         ` [PATCH v4 05/28] NFS: writepage of a single page should not be synchronous Trond Myklebust
2016-07-06 22:29           ` [PATCH v4 06/28] NFS: Don't hold the inode lock across fsync() Trond Myklebust
2016-07-06 22:29             ` [PATCH v4 07/28] NFS: Don't call COMMIT in ->releasepage() Trond Myklebust
2016-07-06 22:29               ` [PATCH v4 08/28] pNFS/files: Fix layoutcommit after a commit to DS Trond Myklebust
2016-07-06 22:29                 ` [PATCH v4 09/28] pNFS/flexfiles: " Trond Myklebust
2016-07-06 22:29                   ` [PATCH v4 10/28] pNFS/flexfiles: Clean up calls to pnfs_set_layoutcommit() Trond Myklebust
2016-07-06 22:29                     ` Trond Myklebust [this message]
2016-07-06 22:29                       ` [PATCH v4 12/28] pNFS: Ensure we layoutcommit before revalidating attributes Trond Myklebust
2016-07-06 22:29                         ` [PATCH v4 13/28] pNFS: pnfs_layoutcommit_outstanding() is no longer used when !CONFIG_NFS_V4_1 Trond Myklebust
2016-07-06 22:29                           ` [PATCH v4 14/28] NFS: Fix O_DIRECT verifier problems Trond Myklebust
2016-07-06 22:29                             ` [PATCH v4 15/28] NFS: Ensure we reset the write verifier 'committed' value on resend Trond Myklebust
2016-07-06 22:29                               ` [PATCH v4 16/28] NFS: Remove racy size manipulations in O_DIRECT Trond Myklebust
2016-07-06 22:29                                 ` [PATCH v4 17/28] NFS Cleanup: move call to generic_write_checks() into fs/nfs/direct.c Trond Myklebust
2016-07-06 22:29                                   ` [PATCH v4 18/28] NFS: Move buffered I/O locking into nfs_file_write() Trond Myklebust
2016-07-06 22:29                                     ` [PATCH v4 19/28] NFS: Do not serialise O_DIRECT reads and writes Trond Myklebust
2016-07-06 22:29                                       ` [PATCH v4 20/28] NFS: Cleanup nfs_direct_complete() Trond Myklebust
2016-07-06 22:29                                         ` [PATCH v4 21/28] NFS: Remove redundant waits for O_DIRECT in fsync() and write_begin() Trond Myklebust
2016-07-06 22:29                                           ` [PATCH v4 22/28] NFS: Remove unused function nfs_revalidate_mapping_protected() Trond Myklebust
2016-07-06 22:30                                             ` [PATCH v4 23/28] NFS: Do not aggressively cache file attributes in the case of O_DIRECT Trond Myklebust
2016-07-06 22:30                                               ` [PATCH v4 24/28] NFS: Getattr doesn't require data sync semantics Trond Myklebust
2016-07-06 22:30                                                 ` [PATCH v4 25/28] NFSv4.2: Fix a race in nfs42_proc_deallocate() Trond Myklebust
2016-07-06 22:30                                                   ` [PATCH v4 26/28] NFSv4.2: Fix writeback races in nfs4_copy_file_range Trond Myklebust
2016-07-06 22:30                                                     ` [PATCH v4 27/28] NFSv4.2: llseek(SEEK_HOLE) and llseek(SEEK_DATA) don't require data sync Trond Myklebust
2016-07-06 22:30                                                       ` [PATCH v4 28/28] NFS nfs_vm_page_mkwrite: Don't freeze me, Bro Trond Myklebust
2016-07-18  3:48                                                 ` [PATCH v4 24/28] NFS: Getattr doesn't require data sync semantics Christoph Hellwig
2016-07-18  4:32                                                   ` Trond Myklebust
2016-07-18  4:59                                                     ` Trond Myklebust
2016-07-19  3:58                                                       ` hch
2016-07-19 20:00                                                         ` [PATCH v4 24/28] " Benjamin Coddington
2016-07-19 20:06                                                           ` Trond Myklebust
2016-07-20 15:03                                                             ` Benjamin Coddington
2016-07-21  8:22                                                               ` hch
2016-07-21  8:32                                                                 ` Benjamin Coddington
2016-07-21  9:10                                                                   ` Benjamin Coddington
2016-07-21  9:52                                                                     ` Benjamin Coddington
2016-07-21 12:46                                                                       ` Trond Myklebust
2016-07-21 13:05                                                                         ` Benjamin Coddington
2016-07-21 13:20                                                                           ` Trond Myklebust
2016-07-21 14:00                                                                             ` Trond Myklebust
2016-07-21 14:02                                                                             ` Benjamin Coddington
2016-07-25 16:26                                                                             ` Benjamin Coddington
2016-07-25 16:39                                                                               ` Trond Myklebust
2016-07-25 18:26                                                                                 ` Benjamin Coddington
2016-07-25 18:34                                                                                   ` Trond Myklebust
2016-07-25 18:41                                                                                     ` Benjamin Coddington
2016-07-26 16:32                                                                                       ` Benjamin Coddington
2016-07-26 16:35                                                                                         ` Trond Myklebust
2016-07-26 17:57                                                                                           ` Benjamin Coddington
2016-07-26 18:07                                                                                             ` Trond Myklebust
2016-07-27 11:55                                                                                               ` Benjamin Coddington
2016-07-27 12:15                                                                                                 ` Trond Myklebust
2016-07-27 12:31                                                                                                   ` Trond Myklebust
2016-07-27 16:14                                                                                                     ` Benjamin Coddington
2016-07-27 18:05                                                                                                       ` Trond Myklebust
2016-07-28  9:47                                                                                                         ` Benjamin Coddington
2016-07-28 12:31                                                                                                           ` Trond Myklebust
2016-07-28 14:04                                                                                                             ` Trond Myklebust
2016-07-28 15:38                                                                                                               ` Benjamin Coddington
2016-07-28 15:39                                                                                                                 ` Trond Myklebust
2016-07-28 15:33                                                                                                             ` Benjamin Coddington
2016-07-28 15:36                                                                                                               ` Trond Myklebust
2016-07-28 16:40                                                                                                                 ` Benjamin Coddington
2016-07-28 16:41                                                                                                                   ` Trond Myklebust
2016-07-19 20:09                                                           ` Benjamin Coddington

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=1467844205-76852-12-git-send-email-trond.myklebust@primarydata.com \
    --to=trond.myklebust@primarydata.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.