Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp79898ybx; Thu, 31 Oct 2019 16:16:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaBAg+d2jKVVEZyEVi3WIMQC9LizIBCTB9DbwUwfdMkw5inxSTS6eU1n8Hw1XaLrhYeFrW X-Received: by 2002:a17:906:1982:: with SMTP id g2mr6873689ejd.254.1572563811762; Thu, 31 Oct 2019 16:16:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572563811; cv=none; d=google.com; s=arc-20160816; b=FB2VHCllKToowZAKVsdrjmxOKsmUfiabMCtsd8a9KlUqKXWBH6a/Io9wPplC5vX1II FD5qbgqIZk8D4vv0GWb0mHsz6QAnZdQSBKUutojWwYv1T+tFU7y8lOriiDwk+kwg1azg BSq7mwjzAnb4gnuJ9NH5YPKgaIDaSLJUwwkzWsuEeiSgejE6MyNrbPHeAWDWh9KZcSR3 ExqvrXWORU3D0AM5S/pCjYs7j7fLyffZ3RrxfNSMVkyvf2SAHt3HCMWXCOLooAPSvsis tqvuezEddND1e9QOEIKVH86imR3osBOa/s/3rUr/mlAshh4ExJv0qlOWS2XdtQWlyOBc pETA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=miHuqUqWzdE1nbZhl0K85EkExwuSgvBYv/eRMB4N1Ko=; b=wVBxc9cBOGYvaoXTl3xNoC++mv1CteYKWt+xbZsOhACsbJW+sgzY6eeBn/vAsXsqmL BlF6AiPPxuaq+RqAPu94YepfzGwWAAoK9m0H+O11eA5ODZxaMMZEP9WERcRTf7FU5x0M +7EpX8vvVaBI9Edwo2I2IdsxnSB9PWkrcDM4UgY9PTxUEuJQ5K4PACUoFtIXgivF/akh E0bheLcxZzXySisluuzge+eQwQhDEx1xGTYy3P/EdMrfdbzFqlZKzlPJczkCN4nJaKdn pxAIrkzf+dZDxi4G88CFiaminRmTiXTLaQVl4drjEqAB9zVLRLZZCL9uhLic40Hho9pl qThg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Fq4pu+ak; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t52si4718056edd.3.2019.10.31.16.16.28; Thu, 31 Oct 2019 16:16:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Fq4pu+ak; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728057AbfJaWn1 (ORCPT + 99 others); Thu, 31 Oct 2019 18:43:27 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:35426 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727611AbfJaWn0 (ORCPT ); Thu, 31 Oct 2019 18:43:26 -0400 Received: by mail-yw1-f67.google.com with SMTP id r134so2799018ywg.2 for ; Thu, 31 Oct 2019 15:43:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=miHuqUqWzdE1nbZhl0K85EkExwuSgvBYv/eRMB4N1Ko=; b=Fq4pu+akxnGfhPCWfDtr8jOA6vV2beNxDwmzyeU2raiCesZL/4eRlWEGkk5P4o93CA PFwJN+5Wwu2gDhqlj0DGeZUnT2OVoiF+qRWlpW0W83vMczAOYkkIz1iYpmDJsO4VD2gM 8YjmBE6Ze8qTiI7fssjkZ+Zsn7ykkSYY1lfyN/Mb57O5+22bzifDu5yRReMcZQzq3IOm oxZXjvUSF/U6NvTiV7pnmAElS0tqCW8LJw/9heMFVFhYoc3EorxjODX6qIhSRYFQ+jq2 J5jLZY/RKTpXfwY2f3sUrnkNnOIJSalumv+kYiLXquE0B6JFMTjE/fgOzfkOyPT3UoZE Vsmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=miHuqUqWzdE1nbZhl0K85EkExwuSgvBYv/eRMB4N1Ko=; b=gbvBmB+u3pmLI45LUQ4zxz6noRZ6QD5owzzbtLkkw2lR9tzQN7t/QgXD/jAN6YChbj v77SK0gGF4zw6BNyXD+9YpUCK9tCHYJzxsG1oZeNtNj4XDNgLz5d93JM9bAjWGFAueaI i5HQcdGQKZpPBNff1clyRSOqG/FL/I9NJQww7nhogslLFYfzPq2wZs+ND2ey0TMglph7 BxRGDLeEfvAveHmoMQfbuzP+aSSHMG2q8Ud+JO/zC1ClhgJUWjq8nGNYVgKp8bukRyUG MoWF/4698YizA99oIv8WoOiW3GL/gzTRF4+lnzBFeQd04dJS7n128721Xmwks7Z4MaUa 6K9A== X-Gm-Message-State: APjAAAUq7RfJUm6e9PuPKXllNVAKgQrKi/M0gAruXAo0i1yT5toDH66P akODGIvVfdKwticyV6BvIa0Yyms= X-Received: by 2002:a81:61c3:: with SMTP id v186mr6313170ywb.151.1572561805336; Thu, 31 Oct 2019 15:43:25 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:24 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 16/20] NFSv4: Fix nfs4_inode_make_writeable() Date: Thu, 31 Oct 2019 18:40:47 -0400 Message-Id: <20191031224051.8923-17-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-16-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-4-trond.myklebust@hammerspace.com> <20191031224051.8923-5-trond.myklebust@hammerspace.com> <20191031224051.8923-6-trond.myklebust@hammerspace.com> <20191031224051.8923-7-trond.myklebust@hammerspace.com> <20191031224051.8923-8-trond.myklebust@hammerspace.com> <20191031224051.8923-9-trond.myklebust@hammerspace.com> <20191031224051.8923-10-trond.myklebust@hammerspace.com> <20191031224051.8923-11-trond.myklebust@hammerspace.com> <20191031224051.8923-12-trond.myklebust@hammerspace.com> <20191031224051.8923-13-trond.myklebust@hammerspace.com> <20191031224051.8923-14-trond.myklebust@hammerspace.com> <20191031224051.8923-15-trond.myklebust@hammerspace.com> <20191031224051.8923-16-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Fix the checks in nfs4_inode_make_writeable() to ignore the case where we hold no delegations. Currently, in such a case, we automatically flush writes. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 78df1cde286e..e3d8055f0c6d 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -644,10 +644,18 @@ int nfs4_inode_return_delegation(struct inode *inode) */ int nfs4_inode_make_writeable(struct inode *inode) { - if (!nfs4_has_session(NFS_SERVER(inode)->nfs_client) || - !nfs4_check_delegation(inode, FMODE_WRITE)) - return nfs4_inode_return_delegation(inode); - return 0; + struct nfs_delegation *delegation; + + rcu_read_lock(); + delegation = nfs4_get_valid_delegation(inode); + if (delegation == NULL || + (nfs4_has_session(NFS_SERVER(inode)->nfs_client) && + (delegation->type & FMODE_WRITE))) { + rcu_read_unlock(); + return 0; + } + rcu_read_unlock(); + return nfs4_inode_return_delegation(inode); } static void nfs_mark_return_if_closed_delegation(struct nfs_server *server, -- 2.23.0