From patchwork Fri Jun 20 17:41:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 4391381 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 71C949F314 for ; Fri, 20 Jun 2014 17:41:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 98F582039D for ; Fri, 20 Jun 2014 17:41:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C0F3C20306 for ; Fri, 20 Jun 2014 17:41:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757087AbaFTRlb (ORCPT ); Fri, 20 Jun 2014 13:41:31 -0400 Received: from mail-ig0-f181.google.com ([209.85.213.181]:46839 "EHLO mail-ig0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757085AbaFTRla (ORCPT ); Fri, 20 Jun 2014 13:41:30 -0400 Received: by mail-ig0-f181.google.com with SMTP id h15so776023igd.8 for ; Fri, 20 Jun 2014 10:41:30 -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:in-reply-to :references; bh=+yexLthAcwWmeFwTEZSdv4uEM5jmmX79cTgIcGhrjOc=; b=OZN0i02HfaRrFYDqUjDlMzx/feFyR4HQ4G03/QaGFh38+ZngTlTkSElwTMl74manQK 3aSVY2hxPtOJ9Y5dnGwiI5S6DK/PxRwBiQRLlp3kNLMoge3lbMcr/2g/66UUNRxEX2GL NidUqyABxMEOMmfPmne3X1knF4deHT+fuwHRHDo1JT36StvLI3tEwgnPZggW4lpTUawt I3ej1G++ql4trcLZu6y5S7FAI45FMAyp54dMrIEqxW73926gB+YgWFSFf4YmSJPU4Btq cufFQ2VVMsTVlArtt5X/3e0X5hefMn2fspTZX1nrK+uHjrKNCv8FA4Yprd06FpTPcN4Z 7f1A== X-Gm-Message-State: ALoCoQn18GOydHXM5CQk2s/1BdsHP5XdZZ4JEdGOCBZFss88YI7BtF1ATN8MJ/hO2La0OcgX50JA X-Received: by 10.50.50.141 with SMTP id c13mr6453036igo.0.1403286090196; Fri, 20 Jun 2014 10:41:30 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (50-33-230-70.drr02.mskg.mi.frontiernet.net. [50.33.230.70]) by mx.google.com with ESMTPSA id k5sm6081520igf.5.2014.06.20.10.41.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Jun 2014 10:41:29 -0700 (PDT) From: Trond Myklebust To: Scott Mayhew Cc: Linux NFS Mailing List Subject: [PATCH 3/3] nfs: Fix cache_validity check in nfs_write_pageuptodate() Date: Fri, 20 Jun 2014 13:41:23 -0400 Message-Id: <1403286083-14345-4-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1403286083-14345-3-git-send-email-trond.myklebust@primarydata.com> References: <20140620125140.GH4510@tonberry.usersys.redhat.com> <1403286083-14345-1-git-send-email-trond.myklebust@primarydata.com> <1403286083-14345-2-git-send-email-trond.myklebust@primarydata.com> <1403286083-14345-3-git-send-email-trond.myklebust@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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: Scott Mayhew NFS_INO_INVALID_DATA cannot be ignored, even if we have a delegation. We're still having some problems with data corruption when multiple clients are appending to a file and those clients are being granted write delegations on open. To reproduce: Client A: vi /mnt/`hostname -s` while :; do echo "XXXXXXXXXXXXXXX" >>/mnt/file; sleep $(( $RANDOM % 5 )); done Client B: vi /mnt/`hostname -s` while :; do echo "YYYYYYYYYYYYYYY" >>/mnt/file; sleep $(( $RANDOM % 5 )); done What's happening is that in nfs_update_inode() we're recognizing that the file size has changed and we're setting NFS_INO_INVALID_DATA accordingly, but then we ignore the cache_validity flags in nfs_write_pageuptodate() because we have a delegation. As a result, in nfs_updatepage() we're extending the write to cover the full page even though we've not read in the data to begin with. Signed-off-by: Scott Mayhew Signed-off-by: Trond Myklebust --- fs/nfs/write.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 48cca1a65a4b..8534ee5c207d 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -928,12 +928,14 @@ static bool nfs_write_pageuptodate(struct page *page, struct inode *inode) if (nfs_have_delegated_attributes(inode)) goto out; - if (nfsi->cache_validity & (NFS_INO_INVALID_DATA|NFS_INO_REVAL_PAGECACHE)) + if (nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE) return false; smp_rmb(); if (test_bit(NFS_INO_INVALIDATING, &nfsi->flags)) return false; out: + if (nfsi->cache_validity & NFS_INO_INVALID_DATA) + return false; return PageUptodate(page) != 0; }