From patchwork Wed Aug 19 20:24:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Tao X-Patchwork-Id: 7039231 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 47D449F358 for ; Wed, 19 Aug 2015 20:26:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0264E207AE for ; Wed, 19 Aug 2015 20:26:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 144FC2078C for ; Wed, 19 Aug 2015 20:26:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750877AbbHSUZx (ORCPT ); Wed, 19 Aug 2015 16:25:53 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:35831 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750926AbbHSUZw (ORCPT ); Wed, 19 Aug 2015 16:25:52 -0400 Received: by pacdd16 with SMTP id dd16so1959266pac.2 for ; Wed, 19 Aug 2015 13:25:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=e/47eL/9PvigZsU62ZTPHM2BKthLO9zDLdBwQfwwUxw=; b=T+MbRwprNJzGvFYQi+GvUn/T06VS78c4iWY+AMbv6mU+6R0/vWW6Uidygn4iEx2Rr/ TRJUjTvw/duB6ApnULN912Urg7Ek9GVSozaWnVdztsdaISM7vPCMDZ7iJrpk+wYCOoG6 A2BcAAKezX8rzGPrjYNnGOu2Yae+fEJctnj5rcM7lPB4yEAvwKhiuz/MWQjXx/bdBAgZ aBEi6fBZXvWW8D32m56YYmowkvs8vSjpz8/Of7GNP1T/7GR/tTr/Acdzk03KDbcI62Z3 l80QLWw1Unh4nmCpzx10BkTzZJnuawz5grOjHXQLZ48s0nuHwBOePRld4G7tloxmx5XX QnIA== X-Gm-Message-State: ALoCoQmoeAqPGDfCitJzmy4+HCX+WJWYIsK+qBEUtw27zwnfjgvmhpF+Tu9Vovs2Y4sUQYpMqovK X-Received: by 10.66.156.196 with SMTP id wg4mr28482790pab.65.1440015951593; Wed, 19 Aug 2015 13:25:51 -0700 (PDT) Received: from lear.localdomain (63-157-6-18.dia.static.qwest.net. [63.157.6.18]) by smtp.gmail.com with ESMTPSA id m2sm1818228pdr.64.2015.08.19.13.25.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Aug 2015 13:25:51 -0700 (PDT) From: Peng Tao To: stable@vger.kernel.org Cc: linux-nfs@vger.kernel.org, Trond Myklebust Subject: [PATCH] NFSv4/pnfs: Ensure we don't miss a file extension Date: Thu, 20 Aug 2015 04:24:50 +0800 Message-Id: <1440015890-28211-1-git-send-email-tao.peng@primarydata.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Trond Myklebust pNFS writes don't return attributes, however that doesn't mean that we should ignore the fact that they may be extending the file. This patch ensures that if a write is seen to extend the file, then we always set an attribute barrier, and update the cached file size. Signed-off-by: Trond Myklebust --- Please apply this to 4.0+ stable releases. It is upstream commit 2b83d3de4c18af49800e0b26ae013db4fcf43a4a. It fixes a08a8cd375db9769588257e7782f6b6b68561b88(NFS: Add attribute update barriers to NFS writebacks) and makes sure we pass fstest read_write/mctime.t test with delegation and inband IO. Without it, users might see mtime not updated after write. Cheers, Tao fs/nfs/write.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 359e9ad..0e6a2b8 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -1378,24 +1378,27 @@ static void nfs_writeback_check_extend(struct nfs_pgio_header *hdr, { struct nfs_pgio_args *argp = &hdr->args; struct nfs_pgio_res *resp = &hdr->res; + u64 size = argp->offset + resp->count; if (!(fattr->valid & NFS_ATTR_FATTR_SIZE)) + fattr->size = size; + if (nfs_size_to_loff_t(fattr->size) < i_size_read(hdr->inode)) { + fattr->valid &= ~NFS_ATTR_FATTR_SIZE; return; - if (argp->offset + resp->count != fattr->size) - return; - if (nfs_size_to_loff_t(fattr->size) < i_size_read(hdr->inode)) + } + if (size != fattr->size) return; /* Set attribute barrier */ nfs_fattr_set_barrier(fattr); + /* ...and update size */ + fattr->valid |= NFS_ATTR_FATTR_SIZE; } void nfs_writeback_update_inode(struct nfs_pgio_header *hdr) { - struct nfs_fattr *fattr = hdr->res.fattr; + struct nfs_fattr *fattr = &hdr->fattr; struct inode *inode = hdr->inode; - if (fattr == NULL) - return; spin_lock(&inode->i_lock); nfs_writeback_check_extend(hdr, fattr); nfs_post_op_update_inode_force_wcc_locked(inode, fattr);