Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp594997pxb; Thu, 21 Jan 2021 15:02:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKG8WyGBOj69+AqxpklFGmIBX50GRygZBQqJ5CEEaHqd/DHdCQx/Ev9NVz/dxCDsJVkfHT X-Received: by 2002:a17:906:4985:: with SMTP id p5mr1118365eju.513.1611270155352; Thu, 21 Jan 2021 15:02:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611270155; cv=none; d=google.com; s=arc-20160816; b=BSm3xDnLAaGjvX6eOYDm//c56LErvNIEM7bUx1XQg2/o7IwKFYYEBAjBHndokbouod PLihhvuxwwnKH1w+dWdT+4WjBIgKQLDfkHZxkPiysSGh1cystbcJy21sPS4A0cUwJGpo KpEY7vEQBDXisuMFPm1+B3kP348Zrz2ay8PNKoTnASae9sHHH9b2YxILKBv9ZVoriZvg F78djZBsuCltQWqZ/DNPtUGuNqyVlLEGJpGQhZXSAdl2PnbN8+XAsM5BJkWiQMsFVaKR 3IQseSF9eh1mRU7xQ9byB+IpdOflnvtxUQrHh9s3juMlVx6hMFxbRep8hoglXOlD26Y1 CvBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-filter; bh=lscifQ6r88dH3+dEBOLTCzjjKE7Sc4rNxLAl63bvmfU=; b=ytN/9ABthaLXVHXCLO3bw6exNFBJHMeh+Q276U3m1BKbrRbwEOjQVMXBHA3TL84FwW 1OgvK39lrxpvVUCBzkgxV9plMC6uACye21uXta4QsIOPV62/QYTnwoCgXQ6jks2zJ8jm AbMOBbnTwQz9rgzly4bmUxVHlnzrzUKSxXyc5rfG2iSl4z/rZw4kYCzSSv6q/+11J7R/ bGwU7F8/xy9YvRH2vW4NTc1rpludEekjnX8hfGbLfZQP8X0oUYrZorzb2dxX3DkXVqCt q7oBCtft3OwVwL/tH9G/yWBNQPA9pfUCA/kAPJtqym9rKpn36P3DYpO4m0LWZAQhrRhN H4hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e5si2936598edc.19.2021.01.21.15.02.12; Thu, 21 Jan 2021 15:02:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727132AbhAUW7O (ORCPT + 99 others); Thu, 21 Jan 2021 17:59:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727111AbhAUW6v (ORCPT ); Thu, 21 Jan 2021 17:58:51 -0500 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 995DAC061797 for ; Thu, 21 Jan 2021 14:57:47 -0800 (PST) Received: by fieldses.org (Postfix, from userid 2815) id BF2D16EA1; Thu, 21 Jan 2021 17:57:46 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org BF2D16EA1 From: "J. Bruce Fields" To: Chuck Lever Cc: linux-nfs@vger.kernel.org, "J. Bruce Fields" Subject: [PATCH v3 6/9] nfsd: find_cpntf_state cleanup Date: Thu, 21 Jan 2021 17:57:42 -0500 Message-Id: <1611269865-30153-6-git-send-email-bfields@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1611269865-30153-1-git-send-email-bfields@redhat.com> References: <20210121204251.GB13298@pick.fieldses.org> <1611269865-30153-1-git-send-email-bfields@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: "J. Bruce Fields" I think this unusual use of struct compound_state could cause confusion. It's not that much more complicated just to open-code this stateid lookup. The only change in behavior should be a different error return in the case the copy is using a source stateid that is a revoked delegation, but I doubt that matters. Signed-off-by: J. Bruce Fields --- fs/nfsd/nfs4state.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index c74bf3b5b0de..db10fef1c1d2 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -5812,21 +5812,27 @@ static __be32 find_cpntf_state(struct nfsd_net *nn, stateid_t *st, { __be32 status; struct nfs4_cpntf_state *cps = NULL; - struct nfsd4_compound_state cstate; + struct nfs4_client *found; status = manage_cpntf_state(nn, st, NULL, &cps); if (status) return status; cps->cpntf_time = ktime_get_boottime_seconds(); - memset(&cstate, 0, sizeof(cstate)); - status = set_client(&cps->cp_p_clid, &cstate, nn, true); - if (status) + + status = nfserr_expired; + found = lookup_clientid(&cps->cp_p_clid, true, nn); + if (!found) goto out; - status = nfsd4_lookup_stateid(&cstate, &cps->cp_p_stateid, - NFS4_DELEG_STID|NFS4_OPEN_STID|NFS4_LOCK_STID, - stid, nn); - put_client_renew(cstate.clp); + + *stid = find_stateid_by_type(found, &cps->cp_p_stateid, + NFS4_DELEG_STID|NFS4_OPEN_STID|NFS4_LOCK_STID); + if (stid) + status = nfs_ok; + else + status = nfserr_bad_stateid; + + put_client_renew(found); out: nfs4_put_cpntf_state(nn, cps); return status; -- 2.29.2