Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3289408pxk; Mon, 21 Sep 2020 09:47:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0AASr0VGzEeerSxevASZFo/0/mtWSPzMWCeN9UpEKPxY4EXUO/WhUtxmC/+KNglZ76chS X-Received: by 2002:aa7:cf93:: with SMTP id z19mr555682edx.187.1600706874476; Mon, 21 Sep 2020 09:47:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600706874; cv=none; d=google.com; s=arc-20160816; b=YCiNE7T7lLTNxpGzTpLv+mrZZuL9RVkGxuM9Rg5nt/tmUEPhzhKF/m1LH+QFw+/qfl bWs2hYlBf+Z+faLlBzVFV6CY6WpYvGYm7/vgFMBf+ueD4+oVO6lQoEP1a1HhqJTYZgkG Q6b1ATnh2X65r8Bz1AP3rC/Ks/cCcFWcUtjhzQBmeRxqq7mtA1T5UrWJlJdYkHGwn9CT smzskxW6Yr0T63ex6XJSQjfczLQCpnxk9J8QxptN38aWl996Gt7ka9VZGkVmhLagRCg9 YxvKBcX2XYUM7tBbMS3p/dvc+CE4r9g3O+mWM3cCIbUFEtgAedLPegVD5uXln3Wte2Zb jTrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sF6HkGCGfimdMfB9LqSRpe6/rjUZOwDH5SGEbOG5GTU=; b=eZk9Vi6CxVUKgzMA4pD8bTt63Q1lvol8Hv3OQZoAhT6kL+kDqX6G4NwUPhMfu6aZWF 8fXrTtv/r/OsCt/MlIqY0BEnfuGWL3nrVuzHcS2hrPwwFbvveREbQjOeNiu36LowfCZ/ /n8cK6Dknn9SZhVIhc2JWk5T/HS60Sh7ysu8Ov559pF4fey8b7NnwwS1sRFnBLszDeb+ jbvh7v/O40ATqBr6Bmkr8ld7mq0Bs/vIv0e6sqDIQN54QzE0Dt/FZv35ZVymBJBLpiVK YpVM1xh1Op3U3NoSFGiTSiQh3pmVBsSWGteNNa9K1ZqPMXo7pnGG6tRVvO42+ou+EnH8 0bAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Xo9rx4l8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e8si8330539ejj.575.2020.09.21.09.47.30; Mon, 21 Sep 2020 09:47:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Xo9rx4l8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729683AbgIUQob (ORCPT + 99 others); Mon, 21 Sep 2020 12:44:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:48138 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728395AbgIUQna (ORCPT ); Mon, 21 Sep 2020 12:43:30 -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 B31CB235F9; Mon, 21 Sep 2020 16:43:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706610; bh=4VDGPZbOkg6QfLEfi1JhpBbDvYsDwUwHOlmUDXP8ahc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xo9rx4l892Yx+EPr7ySfxbhWWdBWo9IIbI3+M2u/6Qzyv0fTlIZvWXwi0L63oGB23 Gi6dwuA1/T20anAbj76oMw4MWtRFOpYACF6h+LuxU5N+UxXhX+ope/ubclkIYHEKFT F919Enwwv5R9f4IJoiTzujvegS9I+wM35CW+cgFk= 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.8 021/118] NFS: Zero-stateid SETATTR should first return delegation Date: Mon, 21 Sep 2020 18:27:13 +0200 Message-Id: <20200921162037.300996211@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162036.324813383@linuxfoundation.org> References: <20200921162036.324813383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 7f337188a2829..08b1fb0a9225a 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3272,8 +3272,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 */ -- 2.25.1