Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1073137ybl; Wed, 14 Aug 2019 10:15:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6ghb6Arpoeaq/MDI+mm3I5JqI0G0WHtmociL2qqOrtHNjolZwdfa5VpPvjKdMmyYa863T X-Received: by 2002:a65:56c1:: with SMTP id w1mr176671pgs.395.1565802934851; Wed, 14 Aug 2019 10:15:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802934; cv=none; d=google.com; s=arc-20160816; b=woj8uTVy/LwU28C57P2gt2cR186aImk8VHaVDyApuFS1RgfWGtQtZ33vqwcWflp0Jj W28NYfkgCY0fbDbDyRTHIBRe3SeFJHWFlmBFMCE1xolQ+kcVCdKSKoiGluS2QeuOy+TA vL4O6uv5u9ZZPq2WxabpHe3zsbulwZuWAy+SK/aO4uymCYG5avd/Fqw72oVkuYitmzRU FE31fYZB+Pab65hJDCB2lddJFNSwJapusQsd61ORYVq9brbJ899V6kPRsbulfCuweVwu QJGXpw2j/EhNQJFQ6G6aDO0mHe3r7C7OlIyMB1aUIb8UnnSchZzOiJDCi5K1VBrnXZKr 6bMg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7g7gfhAJm3EchnlgJQnXMQBxDP/84q9gvUOg8Cm9smA=; b=aFy73EmFrjnimWwTPwLtqUh5eSbLS4RPJ2k+rfoj77+zEJJNON9BupCQDI731XA66F OzGsBzIHU3aXrgbUHr4DZys8zK0Ngd9KIVLZ1R6nS8IwKhBkIbWV132epspBfUWIpKAe IyJZMtS/vDF2NMkp6iVVABXE8UZslA4EVCZS5BqihMGrCMvH7/fFkdNvpdum5GJyEIDa VU0IqiH5GWomdLiq5ngqqaeIolQY3DVmAFga8oAzZKjjyvzp7VEb4Zak03iZ+QY2U+/9 2YtGVEKuT3mozojB/i/Sc/bdiBF8FRlGJMW4F6a35VZ8tRzgINrG6gM4obkS6u1uXQFv zHig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wC6Cktva; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n6si180641pgs.333.2019.08.14.10.15.18; Wed, 14 Aug 2019 10:15:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=wC6Cktva; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729361AbfHNROq (ORCPT + 99 others); Wed, 14 Aug 2019 13:14:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:39192 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731122AbfHNROm (ORCPT ); Wed, 14 Aug 2019 13:14:42 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 27AAC20665; Wed, 14 Aug 2019 17:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802881; bh=AprRWtGWuqegUHNLbg31UzWVjF36V4zOA4KIzTA8AtQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wC6CktvafQwfzKgZvDXwWqSlFgyBlBBdpGDXPooYegUTkG7wDtO0nyALT/Y96TzcP BAyF7rgccWizy9HBqy7DXPi1dbKoIoACUtOVYvROtf1J4OHjposggqXGIMw+I03art PeDs4sauwHcVJJ34Kx6avuAj7l2LELLiA66OCmmY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust Subject: [PATCH 4.14 62/69] NFSv4: Only pass the delegation to setattr if were sending a truncate Date: Wed, 14 Aug 2019 19:02:00 +0200 Message-Id: <20190814165750.296357469@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165744.822314328@linuxfoundation.org> References: <20190814165744.822314328@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust commit 991eedb1371dc09b0f9848f59c8898fe63d198c0 upstream. Even then it isn't really necessary. The reason why we may not want to pass in a stateid in other cases is that we cannot use the delegation credential. Signed-off-by: Trond Myklebust Signed-off-by: Greg Kroah-Hartman --- fs/nfs/nfs4proc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -2954,7 +2954,6 @@ static int _nfs4_do_setattr(struct inode }; struct rpc_cred *delegation_cred = NULL; unsigned long timestamp = jiffies; - fmode_t fmode; bool truncate; int status; @@ -2962,11 +2961,12 @@ static int _nfs4_do_setattr(struct inode /* Servers should only apply open mode checks for file size changes */ truncate = (arg->iap->ia_valid & ATTR_SIZE) ? true : false; - fmode = truncate ? FMODE_WRITE : FMODE_READ; + if (!truncate) + goto zero_stateid; - if (nfs4_copy_delegation_stateid(inode, fmode, &arg->stateid, &delegation_cred)) { + if (nfs4_copy_delegation_stateid(inode, FMODE_WRITE, &arg->stateid, &delegation_cred)) { /* Use that stateid */ - } else if (truncate && ctx != NULL) { + } else if (ctx != NULL) { struct nfs_lock_context *l_ctx; if (!nfs4_valid_open_stateid(ctx->state)) return -EBADF; @@ -2978,8 +2978,10 @@ static int _nfs4_do_setattr(struct inode nfs_put_lock_context(l_ctx); if (status == -EIO) return -EBADF; - } else + } else { +zero_stateid: nfs4_stateid_copy(&arg->stateid, &zero_stateid); + } if (delegation_cred) msg.rpc_cred = delegation_cred;