From patchwork Mon Sep 21 16:30:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "gregkh@linuxfoundation.org" X-Patchwork-Id: 309409 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6038C43466 for ; Mon, 21 Sep 2020 16:48:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8368C2395C for ; Mon, 21 Sep 2020 16:48:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706905; bh=nZmhz7Uay+BXhaZ3w0/AhY7bK+1aE+dQvrdG9JQkNFw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=y7fZYEpbYOlxvULS55WkqyjkbuDDE7+l4m4uLnUvn0ndg9qw9EBsSyL6eBvCV/XJI u8EKpFpJM5jsWalVTuNXIjggHfIKXLBumtlR/6lkyibe0cq505HuP6XYFiBjxC140b +JP8vkxXAwGgn1Mk5QLC9hrbICcuH1DqIkopKQvo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729039AbgIUQsY (ORCPT ); Mon, 21 Sep 2020 12:48:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:55280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728256AbgIUQsD (ORCPT ); Mon, 21 Sep 2020 12:48:03 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BDB97238A1; Mon, 21 Sep 2020 16:48:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706882; bh=nZmhz7Uay+BXhaZ3w0/AhY7bK+1aE+dQvrdG9JQkNFw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WzhHgWKe4I8hSC42wDfVHMg6aON8Ny0/77uuljSEpjRFxB2v93H0jcVUb+1Q3pfWG tYjQeciF2H7+kpOXREUjwmz64DH16PCukHn11JBlGWv8YNPAWIQAdCoE2TlptvBL5f ViUaTIMdB4qpLS7J/YUtxlp7nIsLG4yjuujsWE88= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chuck Lever , Trond Myklebust , Sasha Levin Subject: [PATCH 5.4 14/72] NFS: Zero-stateid SETATTR should first return delegation Date: Mon, 21 Sep 2020 18:30:53 +0200 Message-Id: <20200921163122.552516178@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921163121.870386357@linuxfoundation.org> References: <20200921163121.870386357@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Chuck Lever [ Upstream commit 644c9f40cf71969f29add32f32349e71d4995c0b ] If a write delegation isn't available, the Linux NFS client uses a zero-stateid when performing a SETATTR. NFSv4.0 provides no mechanism for an NFS server to match such a request to a particular client. It recalls all delegations for that file, even delegations held by the client issuing the request. If that client happens to hold a read delegation, the server will recall it immediately, resulting in an NFS4ERR_DELAY/CB_RECALL/ DELEGRETURN sequence. Optimize out this pipeline bubble by having the client return any delegations it may hold on a file before it issues a SETATTR(zero-stateid) on that file. Signed-off-by: Chuck Lever Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- fs/nfs/nfs4proc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 16414ae02c089..00435556db0ce 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3257,8 +3257,10 @@ static int _nfs4_do_setattr(struct inode *inode, /* Servers should only apply open mode checks for file size changes */ truncate = (arg->iap->ia_valid & ATTR_SIZE) ? true : false; - if (!truncate) + if (!truncate) { + nfs4_inode_make_writeable(inode); goto zero_stateid; + } if (nfs4_copy_delegation_stateid(inode, FMODE_WRITE, &arg->stateid, &delegation_cred)) { /* Use that stateid */