Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp803049rdh; Thu, 23 Nov 2023 20:20:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZ+Nr1Fk8AD3IRkfFNIN/CIiLhjIvi5cAD361UHtBvYmTGAcLkJF6Ku9U4jsobLhT7yUhT X-Received: by 2002:a05:6a20:160d:b0:138:2fb8:6c48 with SMTP id l13-20020a056a20160d00b001382fb86c48mr1809684pzj.8.1700799620440; Thu, 23 Nov 2023 20:20:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700799620; cv=none; d=google.com; s=arc-20160816; b=FMToKPxIShSdDiAC2hOUeJCBvyXMYuo0jSeZB5T0C71Bh/WCvePuWDfbvH+++EtHXt 8E1w5KOUbCojD+pMnyC0q/JTZPF9yS7mSflXxNB1a26wvbjl1HFiUJweEv58hXe6KrNH 5Vfk95wfpd19899YbcyrlBH885p6bGND3azkitk1dyEHxyEy1rlWXoMAWccz5KesNFwj vs3RHBU8b19f1eErebN8e33u2vNdenLZjHcXamTOkLngSAR+63PoOHqahQSKnYOBk7EY fS2CY++cQjD4p2nlBuJ9krEaP8WGvmY+xOQgrnwDtHzihA/ldI14NnbcxGItJdEQJ3ox k6Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=QdZhyBC92pZxS6OGQnaKqx0d9gukHKlw2xSZwGG3QSw=; fh=oGCWKUgN5rqvEqhxhGaFnCKhx0upqxg87fHnuYmJPFg=; b=HoTqEIXhuwNcfppAoEY1KC7AVZavZKnuApTvN7tP8bh5e6rS4KbH3jHg9QU1xHKU1C oqmiB+Dwdb9r2HoDOgoL2pZCqt/MUOSkf1AwwzNHOkYI6gx3GWfh+sKp3rtFxftMufUR OixTigvEAA3Hul0hSD3ot8q7O6lNj+9HgtP9DzjfLMIVGS0dt12SuCT0jgv8Co5G/nXr TYpefVuXhORa/DbZEYb/+2DvPaCHmsxsQZFqpyxtZvKirmq69ekXT5EQsY1WIYHth00H dZ1sSwyzsQ9/N9zum9QsMyAaj3uio+kfKztLJIZJaX7xesZQPsu5vY1HyNAOyuDpOSgk NjWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs+bounces-45-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-45-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f24-20020a17090aa79800b002839bc84a0esi3169369pjq.139.2023.11.23.20.20.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 20:20:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-45-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs+bounces-45-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-45-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 07758281773 for ; Fri, 24 Nov 2023 04:20:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4644623CF; Fri, 24 Nov 2023 04:20:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none X-Original-To: linux-nfs@vger.kernel.org X-Greylist: delayed 159 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 23 Nov 2023 20:20:12 PST Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BD92D43 for ; Thu, 23 Nov 2023 20:20:11 -0800 (PST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 774F522132; Fri, 24 Nov 2023 00:32:08 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 69ED21340B; Fri, 24 Nov 2023 00:32:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id 1SNaCAbvX2XQegAAD6G6ig (envelope-from ); Fri, 24 Nov 2023 00:32:06 +0000 From: NeilBrown To: Chuck Lever , Jeff Layton Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia , Dai Ngo , Tom Talpey Subject: [PATCH 10/11] nfsd: allow delegation state ids to be revoked and then freed Date: Fri, 24 Nov 2023 11:28:45 +1100 Message-ID: <20231124002925.1816-11-neilb@suse.de> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231124002925.1816-1-neilb@suse.de> References: <20231124002925.1816-1-neilb@suse.de> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Bar: +++++++++++ X-Spam-Score: 11.65 X-Rspamd-Server: rspamd1 X-Rspamd-Queue-Id: 774F522132 Authentication-Results: smtp-out1.suse.de; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=suse.de (policy=none); spf=softfail (smtp-out1.suse.de: 2a07:de40:b281:104:10:150:64:97 is neither permitted nor denied by domain of neilb@suse.de) smtp.mailfrom=neilb@suse.de X-Spamd-Result: default: False [11.65 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; R_SPF_SOFTFAIL(4.60)[~all:c]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_THREE(0.00)[3]; MX_GOOD(-0.01)[]; NEURAL_HAM_SHORT(-0.14)[-0.677]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; DMARC_POLICY_SOFTFAIL(0.10)[suse.de : No valid SPF, No valid DKIM,none] Revoking state through 'unlock_filesystem' now revokes any delegation states found. When the stateids are then freed by the client, the revoked stateids will be cleaned up correctly. As there is already support for revoking delegations, we build on that for admin-revoking. Signed-off-by: NeilBrown --- fs/nfsd/nfs4state.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 8712eb81123f..3d85c88ec4d7 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1340,9 +1340,12 @@ unhash_delegation_locked(struct nfs4_delegation *dp, unsigned short statusmask) if (!delegation_hashed(dp)) return false; - if (dp->dl_stid.sc_client->cl_minorversion == 0) + if (statusmask == NFS4_STID_REVOKED && + dp->dl_stid.sc_client->cl_minorversion == 0) statusmask = NFS4_STID_CLOSED; dp->dl_stid.sc_status |= statusmask; + if (statusmask & NFS4_STID_ADMIN_REVOKED) + atomic_inc(&dp->dl_stid.sc_client->cl_admin_revoked); /* Ensure that deleg break won't try to requeue it */ ++dp->dl_time; @@ -1373,7 +1376,8 @@ static void revoke_delegation(struct nfs4_delegation *dp) trace_nfsd_stid_revoke(&dp->dl_stid); - if (dp->dl_stid.sc_status & NFS4_STID_REVOKED) { + if (dp->dl_stid.sc_status & + (NFS4_STID_REVOKED | NFS4_STID_ADMIN_REVOKED)) { spin_lock(&clp->cl_lock); refcount_inc(&dp->dl_stid.sc_count); list_add(&dp->dl_recall_lru, &clp->cl_revoked); @@ -1708,7 +1712,7 @@ void nfsd4_revoke_states(struct net *net, struct super_block *sb) unsigned int idhashval; unsigned int sc_types; - sc_types = NFS4_OPEN_STID | NFS4_LOCK_STID; + sc_types = NFS4_OPEN_STID | NFS4_LOCK_STID | NFS4_DELEG_STID; spin_lock(&nn->client_lock); for (idhashval = 0; idhashval < CLIENT_HASH_MASK; idhashval++) { @@ -1720,6 +1724,7 @@ void nfsd4_revoke_states(struct net *net, struct super_block *sb) sc_types); if (stid) { struct nfs4_ol_stateid *stp; + struct nfs4_delegation *dp; spin_unlock(&nn->client_lock); switch (stid->sc_type) { @@ -1765,6 +1770,16 @@ void nfsd4_revoke_states(struct net *net, struct super_block *sb) spin_unlock(&clp->cl_lock); mutex_unlock(&stp->st_mutex); break; + case NFS4_DELEG_STID: + dp = delegstateid(stid); + spin_lock(&state_lock); + if (!unhash_delegation_locked( + dp, NFS4_STID_ADMIN_REVOKED)) + dp = NULL; + spin_unlock(&state_lock); + if (dp) + revoke_delegation(dp); + break; } nfs4_put_stid(stid); spin_lock(&nn->client_lock); @@ -4705,6 +4720,7 @@ static void nfsd_drop_revoked_stid(struct nfs4_stid *s) struct nfs4_client *cl = s->sc_client; LIST_HEAD(reaplist); struct nfs4_ol_stateid *stp; + struct nfs4_delegation *dp; bool unhashed; switch (s->sc_type) { @@ -4722,6 +4738,12 @@ static void nfsd_drop_revoked_stid(struct nfs4_stid *s) if (unhashed) nfs4_put_stid(s); break; + case NFS4_DELEG_STID: + dp = delegstateid(s); + list_del_init(&dp->dl_recall_lru); + spin_unlock(&cl->cl_lock); + nfs4_put_stid(s); + break; default: spin_unlock(&cl->cl_lock); } -- 2.42.1