From patchwork Thu Aug 27 01:03:43 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhishek Kulkarni X-Patchwork-Id: 44159 X-Patchwork-Delegate: ericvh@gmail.com Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7R14Fsw014149 for ; Thu, 27 Aug 2009 01:04:15 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by 235xhf1.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1MgTPB-0002Mx-Gu; Thu, 27 Aug 2009 01:03:57 +0000 Received: from sfi-mx-2.v28.ch3.sourceforge.com ([172.29.28.122] helo=mx.sourceforge.net) by 235xhf1.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1MgTPA-0002Md-6F for v9fs-developer@lists.sourceforge.net; Thu, 27 Aug 2009 01:03:56 +0000 X-ACL-Warn: Received: from mail-pz0-f192.google.com ([209.85.222.192]) by 72vjzd1.ch3.sourceforge.com with esmtp (Exim 4.69) id 1MgTOz-0008Ev-2d for v9fs-developer@lists.sourceforge.net; Thu, 27 Aug 2009 01:03:53 +0000 Received: by pzk30 with SMTP id 30so711576pzk.4 for ; Wed, 26 Aug 2009 18:03:38 -0700 (PDT) Received: by 10.115.66.9 with SMTP id t9mr10761526wak.56.1251335018778; Wed, 26 Aug 2009 18:03:38 -0700 (PDT) Received: from localhost.localdomain (y-130-55-115-47.lanl.gov [130.55.115.47]) by mx.google.com with ESMTPS id 23sm931524pxi.1.2009.08.26.18.03.37 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 26 Aug 2009 18:03:38 -0700 (PDT) From: Abhishek Kulkarni To: linux-kernel@vger.kernel.org Date: Wed, 26 Aug 2009 19:03:43 -0600 Message-Id: <1251335023-8615-2-git-send-email-adkulkar@umail.iu.edu> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1251335023-8615-1-git-send-email-adkulkar@umail.iu.edu> References: <1251335023-8615-1-git-send-email-adkulkar@umail.iu.edu> X-Spam-Score: 0.0 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. _SUMMARY_ X-Headers-End: 1MgTOz-0008Ev-2d Cc: ericvh@gmail.com, v9fs-developer@lists.sourceforge.net Subject: [V9fs-developer] [PATCH 2/2] 9p: Fix the incorrect update of inode size in v9fs_file_write() X-BeenThere: v9fs-developer@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: v9fs-developer-bounces@lists.sourceforge.net When using the cache=loose flags, the inode's size was not being updated correctly on a remote write. Thus subsequent reads of the whole file resulted in a truncated read. Fix it. Signed-off-by: Abhishek Kulkarni --- fs/9p/vfs_file.c | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index de7690e..cafaa46 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -210,6 +211,7 @@ v9fs_file_write(struct file *filp, const char __user * data, struct p9_client *clnt; struct inode *inode = filp->f_path.dentry->d_inode; int origin = *offset; + unsigned long pg_start, pg_end; P9_DPRINTK(P9_DEBUG_VFS, "data %p count %d offset %x\n", data, (int)count, (int)*offset); @@ -225,7 +227,7 @@ v9fs_file_write(struct file *filp, const char __user * data, if (count < rsize) rsize = count; - n = p9_client_write(fid, NULL, data+total, *offset+total, + n = p9_client_write(fid, NULL, data+total, origin+total, rsize); if (n <= 0) break; @@ -234,13 +236,12 @@ v9fs_file_write(struct file *filp, const char __user * data, } while (count > 0); if (total > 0) { - invalidate_inode_pages2_range(inode->i_mapping, origin, - origin+total); + pg_start = origin >> PAGE_CACHE_SHIFT; + pg_end = (origin + total - 1) >> PAGE_CACHE_SHIFT; + invalidate_inode_pages2_range(inode->i_mapping, pg_start, + pg_end); *offset += total; - } - - if (*offset > i_size_read(inode)) { - i_size_write(inode, *offset); + i_size_write(inode, i_size_read(inode) + total); inode->i_blocks = (i_size_read(inode) + 512 - 1) >> 9; }