Return-Path: linux-nfs-owner@vger.kernel.org Received: from mail-pa0-f53.google.com ([209.85.220.53]:46246 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423295Ab3CVV0l (ORCPT ); Fri, 22 Mar 2013 17:26:41 -0400 Received: by mail-pa0-f53.google.com with SMTP id bh2so65866pad.26 for ; Fri, 22 Mar 2013 14:26:40 -0700 (PDT) Date: Fri, 22 Mar 2013 14:21:13 -0700 From: Kent Overstreet To: "J. Bruce Fields" Cc: linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, Al Viro , "Eric W. Biederman" , Zach Brown Subject: Re: [PATCH] nfsd: fix bad offset use Message-ID: <20130322212113.GD19091@google.com> References: <1363976304-26093-1-git-send-email-koverstreet@google.com> <20130322205353.GA14438@fieldses.org> <20130322205434.GB14438@fieldses.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <20130322205434.GB14438@fieldses.org> Sender: linux-nfs-owner@vger.kernel.org List-ID: On Fri, Mar 22, 2013 at 04:54:34PM -0400, J. Bruce Fields wrote: > On Fri, Mar 22, 2013 at 04:53:53PM -0400, J. Bruce Fields wrote: > > On Fri, Mar 22, 2013 at 11:18:24AM -0700, Kent Overstreet wrote: > > > vfs_writev() updates the offset argument - but the code then passes the > > > offset to vfs_fsync_range(). Since offset now points to the offset after > > > what was just written, this is probably not what was intended > > > > Whoops--thanks! Looks like this was introduced by my > > face15025ffdf664de95e86ae831544154d26c9c "nfsd: use vfs_fsync_range(), > > not O_SYNC, for stable writes", in 3.8. > > > > I'll queue up for 3.9 and stable. > > (By the way, out of curiosity: how did you stumble across this?) Just reading code - I've been trying to figure out how to improve the way *pos pointers are passed around everywhere and I was looking at all the users of various vfs code. > --b. > > > > > --b. > > > > > > > > Signed-off-by: Kent Overstreet > > > Cc: "J. Bruce Fields" > > > Cc: Al Viro > > > Cc: "Eric W. Biederman" > > > Cc: Zach Brown > > > --- > > > fs/nfsd/vfs.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c > > > index 2a7eb53..2b2e239 100644 > > > --- a/fs/nfsd/vfs.c > > > +++ b/fs/nfsd/vfs.c > > > @@ -1013,6 +1013,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, > > > int host_err; > > > int stable = *stablep; > > > int use_wgather; > > > + loff_t pos = offset; > > > > > > dentry = file->f_path.dentry; > > > inode = dentry->d_inode; > > > @@ -1025,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, > > > > > > /* Write the data. */ > > > oldfs = get_fs(); set_fs(KERNEL_DS); > > > - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &offset); > > > + host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos); > > > set_fs(oldfs); > > > if (host_err < 0) > > > goto out_nfserr; > > > -- > > > 1.8.1.3 > > >