linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bian Naimeng <biannm@cn.fujitsu.com>
To: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>,
	linux-nfs@vger.kernel.org, Christoph Hellwig <hch@infradead.org>
Subject: [PATCH] Server should allow offset larger than LLONG_MAX at commit procedure
Date: Wed, 18 Aug 2010 16:09:28 +0800	[thread overview]
Message-ID: <4C6B9538.2020608@cn.fujitsu.com> (raw)

When offset larger than LLONG_MAX, it's better to sync all the data of file
than return nfserr_inval.

Signed-off-by: Bian Naimeng <biannm@cn.fujitsu.com>

---
 fs/nfsd/vfs.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 96360a8..f67fe31 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1174,20 +1174,23 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp,
 {
 	struct file	*file;
 	loff_t		end = LLONG_MAX;
-	__be32		err = nfserr_inval;
+	__be32		err;
+
+	if ((u64)count > ~(u64)offset)
+		return nfserr_inval;
 
 	if (offset < 0)
-		goto out;
-	if (count != 0) {
+		offset = 0;
+	else if (count != 0) {
 		end = offset + (loff_t)count - 1;
 		if (end < offset)
-			goto out;
+			end = LLONG_MAX;
 	}
 
 	err = nfsd_open(rqstp, fhp, S_IFREG,
 			NFSD_MAY_WRITE|NFSD_MAY_NOT_BREAK_LEASE, &file);
 	if (err)
-		goto out;
+		return err;
 	if (EX_ISSYNC(fhp->fh_export)) {
 		int err2 = vfs_fsync_range(file, offset, end, 0);
 
@@ -1198,7 +1201,6 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp,
 	}
 
 	nfsd_close(file);
-out:
 	return err;
 }
 #endif /* CONFIG_NFSD_V3 */
-- 
1.6.5.2




-- 
Regards
Bian Naimeng


             reply	other threads:[~2010-08-18  8:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-18  8:09 Bian Naimeng [this message]
2010-08-19  0:16 ` [PATCH] Server should allow offset larger than LLONG_MAX at commit procedure J. Bruce Fields
2010-08-19  3:38   ` Bian Naimeng
2010-08-19 22:19     ` J. Bruce Fields
2010-08-20  7:20       ` Bian Naimeng

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=4C6B9538.2020608@cn.fujitsu.com \
    --to=biannm@cn.fujitsu.com \
    --cc=Trond.Myklebust@netapp.com \
    --cc=bfields@fieldses.org \
    --cc=hch@infradead.org \
    --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 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).