From patchwork Sun Oct 17 05:07:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Tao X-Patchwork-Id: 850652 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p564RqPY013322 for ; Mon, 6 Jun 2011 04:27:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755336Ab1FFE1u (ORCPT ); Mon, 6 Jun 2011 00:27:50 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:47628 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755126Ab1FFE1t (ORCPT ); Mon, 6 Jun 2011 00:27:49 -0400 Received: by pzk9 with SMTP id 9so1670644pzk.19 for ; Sun, 05 Jun 2011 21:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer; bh=0xTWirTSCNipzIjAgXwO59abIos8LjgcMmrjJs5adgM=; b=YVYJvWncNS9bNMekFj5qYcS+TrBDSSVWdf4l1lSsWLIKuGNmk1+cHE0jNVkIF2uzxV ioswsegcs9xx6/d32njzskxSVtUXJe1x4HDSJ5IwIQ6InYcNQwDb9+CeUHnXHi2dUf9C gr3Xb4ycni09ecgtmJmagGHptWOmc++dmvrKE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=LgofP9tScbtR/jKnaZWke7l6Kl5tP5wPCf6Cxh80W8Rz3eExanjVG1H9josvqRsHnS ww9c7JDiSXun1g64Xewgvu9v2tME7+K21sHEXvpfe3BTA7xdax9/11NswoO9Bef1IQHV jjigXYnnAQmFkLLNResuRBO7oAfYcJjZmm17k= Received: by 10.68.0.168 with SMTP id 8mr1635703pbf.214.1307334468996; Sun, 05 Jun 2011 21:27:48 -0700 (PDT) Received: from localhost.localdomain ([123.121.79.164]) by mx.google.com with ESMTPS id c5sm3389371pbj.57.2011.06.05.21.27.46 (version=SSLv3 cipher=OTHER); Sun, 05 Jun 2011 21:27:48 -0700 (PDT) From: Peng Tao To: Trond.Myklebust@netapp.com Cc: linux-nfs@vger.kernel.org, Peng Tao Subject: NFS41: do not update isize if inode needs layoutcommit Date: Sat, 16 Oct 2010 22:07:46 -0700 Message-Id: <1287292066-23254-1-git-send-email-bergwolf@gmail.com> X-Mailer: git-send-email 1.7.1.262.g5ef3d Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 06 Jun 2011 04:27:53 +0000 (UTC) nfs_update_inode will update isize if there is no queued pages. For pNFS, layoutcommit is supposed to change file size on server, the same effect as queued pages. nfs_update_inode may be called when dirty pages are written back (nfsi->npages==0) but layoutcommit is not sent, and it will change client file size according to server file size. Then client ends up losing what it just writes back in pNFS path. So we should skip updating client file size if file needs layoutcommit. Signed-off-by: Peng Tao --- fs/nfs/inode.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 144f2a3..3f1eb81 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1294,7 +1294,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) if (new_isize != cur_isize) { /* Do we perhaps have any outstanding writes, or has * the file grown beyond our last write? */ - if (nfsi->npages == 0 || new_isize > cur_isize) { + if ((nfsi->npages == 0 && !test_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) || + new_isize > cur_isize) { i_size_write(inode, new_isize); invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA; }