Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp647282rdb; Tue, 31 Oct 2023 19:51:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJ9vp1tG1qOUf8Bp09uzp7wS3KB1XR/tAnuB+Ombn6ZVnF7r/rLbY5wDbj6j0QOZ86AX+X X-Received: by 2002:a05:6358:2608:b0:168:ef9b:6c0d with SMTP id l8-20020a056358260800b00168ef9b6c0dmr16386097rwc.32.1698807087500; Tue, 31 Oct 2023 19:51:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698807087; cv=none; d=google.com; s=arc-20160816; b=MpnsTNVPmBPbMwGd4JmV12nHvMQdgdaCxEj2qIcvSe7wh/1JNjCc9gFiyb+QtpHex/ uX2A0NolKdQsxmOo5xt+UUYLBpNpDbL2LpJDdd9gOG2z6HgnTv5OI+iCDflNlHFPzyMH mIRfUVJkLzukrv4jPNBea9rVSeX9sm5njXCS8dH68MmlJCgYhQJYOCzat5zot57vq3Nz r/FML8tQJkfgFauWDxcAkLKfd/3pPLHmzf5bQH+K78BTxpbzUgS+sJZakA7+6kiYuKlP USHwtARCytqwZBDk7scq2c49HOYLzJ/unsUUivi7eLzJ7sEzPvUoPXTx94lIWzofOvBg jgtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding:dkim-signature :dkim-signature; bh=NvQ2Wh6B6EcokJBMWdAQEi7dVx3oWf8LexKoaJWDdlQ=; fh=yLjDJJsW5hslygGs/rbQ408wfQLi857ZoEWDXCtUCaE=; b=az96+f7CGfK1nwwnIVWpmm3E6+vENo13nXoYBhguZHGO8N13MhXAZjr+vq64/tS21Y OIGFaYO8b7PClhW2CdP069V1rer9CT6LUQ83Zi+67SaI/WeMJjZf/BjQpGqDEyx95/gm wpacat6iBIb07jtHE3YAkrj9xvM+MXyg3jqe17FLwg2uertGEy0jdZSIOIiIjpuL4UB+ c5LUda3AhcuEaWRci21OvhXqzOWt45jwC3/8SKtAXWLEDctSbddg4OjN5OtxxfY5Anko aprQ4tap8rLsw/nfG7uyOmUgU4dcLFk6R54zfakHnLXyLnZTbX/4CjkvsqH96aWNzQJQ Wt4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=HnmYFgmS; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id cm23-20020a056a020a1700b00553800fe4dcsi2152409pgb.583.2023.10.31.19.51.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 19:51:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=HnmYFgmS; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0610E807C872; Tue, 31 Oct 2023 19:50:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345140AbjKACuG (ORCPT + 99 others); Tue, 31 Oct 2023 22:50:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345105AbjKACuF (ORCPT ); Tue, 31 Oct 2023 22:50:05 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F1AFA4 for ; Tue, 31 Oct 2023 19:49:59 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4CE751F74A; Wed, 1 Nov 2023 02:49:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1698806998; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NvQ2Wh6B6EcokJBMWdAQEi7dVx3oWf8LexKoaJWDdlQ=; b=HnmYFgmSF5oTpiSoQDyaweUTMeNU+XMIwaJcRbaoiq/8BGSpm7cu1/B86uHn2Mpe1dIua9 lkXuoSIXHBZDv+fJgA0wwsJVoLZMAxTd5IrflxD5jU5xxnW0fJh6xnoQep9bYlGvtZROMo tYPrmgZqm8WzXbilZKG1mUTtLK/q8R8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1698806998; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NvQ2Wh6B6EcokJBMWdAQEi7dVx3oWf8LexKoaJWDdlQ=; b=CLd09mOQ2o7riD1L6r9I+q04waM1+KyR8m2tRkIOPp3p7Cjix4WbaoHB1Bq76LcNNpQ2XD s1EQlkbq9iD82mBA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3C048138EC; Wed, 1 Nov 2023 02:49:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id n9OuONO8QWU1ZAAAMHmgww (envelope-from ); Wed, 01 Nov 2023 02:49:55 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 From: "NeilBrown" To: "Chuck Lever III" Cc: "Jeff Layton" , "Linux NFS Mailing List" , "Olga Kornievskaia" , "Dai Ngo" , "Tom Talpey" Subject: Re: [PATCH 1/6] nfsd: prepare for supporting admin-revocation of state In-reply-to: References: <20231101010049.27315-1-neilb@suse.de>, <20231101010049.27315-2-neilb@suse.de>, Date: Wed, 01 Nov 2023 13:49:52 +1100 Message-id: <169880699287.24305.9894523784673960041@noble.neil.brown.name> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 31 Oct 2023 19:50:21 -0700 (PDT) On Wed, 01 Nov 2023, Chuck Lever III wrote: > > > On Oct 31, 2023, at 5:57 PM, NeilBrown wrote: > > > > The NFSv4 protocol allows state to be revoked by the admin and has error > > codes which allow this to be communicated to the client. > > > > This patch > > - introduces 3 new state-id types for revoked open, lock, and > > delegation state. This requires the bitmask to be 'short', > > not 'char' > > - reports NFS4ERR_ADMIN_REVOKED when these are accessed > > - introduces a per-client counter of these states and returns > > SEQ4_STATUS_ADMIN_STATE_REVOKED when the counter is not zero. > > Decrement this when freeing any admin-revoked state. > > - introduces stub code to find all interesting states for a given > > superblock so they can be revoked via the 'unlock_filesystem' > > file in /proc/fs/nfsd/ > > No actual states are handled yet. > > > > Signed-off-by: NeilBrown > > --- > > fs/nfsd/nfs4layouts.c | 2 +- > > fs/nfsd/nfs4state.c | 93 +++++++++++++++++++++++++++++++++++++++---- > > fs/nfsd/nfsctl.c | 1 + > > fs/nfsd/nfsd.h | 1 + > > fs/nfsd/state.h | 35 +++++++++++----- > > fs/nfsd/trace.h | 8 +++- > > 6 files changed, 120 insertions(+), 20 deletions(-) > > .... > > > diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h > > index f96eaa8e9413..3af5ab55c978 100644 > > --- a/fs/nfsd/state.h > > +++ b/fs/nfsd/state.h > > @@ -88,17 +88,23 @@ struct nfsd4_callback_ops { > > */ > > struct nfs4_stid { > > refcount_t sc_count; > > -#define NFS4_OPEN_STID 1 > > -#define NFS4_LOCK_STID 2 > > -#define NFS4_DELEG_STID 4 > > + struct list_head sc_cp_list; > > + unsigned short sc_type; > > +#define NFS4_OPEN_STID BIT(0) > > +#define NFS4_LOCK_STID BIT(1) > > +#define NFS4_DELEG_STID BIT(2) > > /* For an open stateid kept around *only* to process close replays: */ > > -#define NFS4_CLOSED_STID 8 > > +#define NFS4_CLOSED_STID BIT(3) > > /* For a deleg stateid kept around only to process free_stateid's: */ > > -#define NFS4_REVOKED_DELEG_STID 16 > > -#define NFS4_CLOSED_DELEG_STID 32 > > -#define NFS4_LAYOUT_STID 64 > > - struct list_head sc_cp_list; > > - unsigned char sc_type; > > +#define NFS4_REVOKED_DELEG_STID BIT(4) > > +#define NFS4_CLOSED_DELEG_STID BIT(5) > > +#define NFS4_LAYOUT_STID BIT(6) > > +#define NFS4_ADMIN_REVOKED_STID BIT(7) > > +#define NFS4_ADMIN_REVOKED_LOCK_STID BIT(8) > > +#define NFS4_ADMIN_REVOKED_DELEG_STID BIT(9) > > +#define NFS4_ALL_ADMIN_REVOKED_STIDS (NFS4_ADMIN_REVOKED_STID | \ > > + NFS4_ADMIN_REVOKED_LOCK_STID | \ > > + NFS4_ADMIN_REVOKED_DELEG_STID) > > stateid_t sc_stateid; > > spinlock_t sc_lock; > > struct nfs4_client *sc_client; > > > > diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h > > index fbc0ccb40424..e359d531402c 100644 > > --- a/fs/nfsd/trace.h > > +++ b/fs/nfsd/trace.h > > @@ -648,6 +648,9 @@ TRACE_DEFINE_ENUM(NFS4_CLOSED_STID); > > TRACE_DEFINE_ENUM(NFS4_REVOKED_DELEG_STID); > > TRACE_DEFINE_ENUM(NFS4_CLOSED_DELEG_STID); > > TRACE_DEFINE_ENUM(NFS4_LAYOUT_STID); > > +TRACE_DEFINE_ENUM(NFS4_ADMIN_REVOKED_STID); > > +TRACE_DEFINE_ENUM(NFS4_ADMIN_REVOKED_LOCK_STID); > > +TRACE_DEFINE_ENUM(NFS4_ADMIN_REVOKED_DELEG_STID); > > This is a bug that pre-dates your change in this patch... > > Since the NFS4_ flags are C macros and not enum symbols, > TRACE_DEFINE_ENUM() is not necessary. All these can be > removed, rather than adding three new ones. > > I can fix this up when I apply the series, or if you > happen to send a v3, you can fix it up first. OK, thanks. I guess this use of "ENUM" for things that aren't enums should have been a red flags :-) NeilBrown > > > > #define show_stid_type(x) \ > > __print_flags(x, "|", \ > > @@ -657,7 +660,10 @@ TRACE_DEFINE_ENUM(NFS4_LAYOUT_STID); > > { NFS4_CLOSED_STID, "CLOSED" }, \ > > { NFS4_REVOKED_DELEG_STID, "REVOKED" }, \ > > { NFS4_CLOSED_DELEG_STID, "CLOSED_DELEG" }, \ > > - { NFS4_LAYOUT_STID, "LAYOUT" }) > > + { NFS4_LAYOUT_STID, "LAYOUT" }, \ > > + { NFS4_ADMIN_REVOKED_STID, "ADMIN_REVOKED" }, \ > > + { NFS4_ADMIN_REVOKED_LOCK_STID, "ADMIN_REVOKED_LOCK" }, \ > > + { NFS4_ADMIN_REVOKED_DELEG_STID,"ADMIN_REVOKED_DELEG" }) > > > > DECLARE_EVENT_CLASS(nfsd_stid_class, > > TP_PROTO( > > -- > > 2.42.0 > > > > -- > Chuck Lever > > >