Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp849999rdh; Thu, 26 Oct 2023 18:56:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFf7tv1LhL8Jx8AYhsD87Oil9TLpcE1MKZSZYZ84hLRLpHp1HdP9j8E1QM5lPjsEr/5z2cq X-Received: by 2002:a81:ad07:0:b0:59b:d872:5ca8 with SMTP id l7-20020a81ad07000000b0059bd8725ca8mr1477900ywh.22.1698371809542; Thu, 26 Oct 2023 18:56:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698371809; cv=none; d=google.com; s=arc-20160816; b=kbBCkY4RQ972zGUO/TisJwhNw7d/eZ6gCSCJGqdh+pgsO0gJZEZOI2iPQkbbHSYRfR nbkGFjVrHBwRPkR5Ooy86GcfOLEe6Pgm9sq+eNxrDgSEEKjmMDOATLcPaLhCvOp5D3YD F4usucvdHQG3kIw8QcKknnzFMevqjHEFhxTl8dZ1MiWMeKbkcXfQ3wd+JO/t0a73sGzg pM8RQlRlIFWB5Sf7lU//kBw85cjfEVs82SLMeHEHJo8tXLAbTllQht4Jk0Rql4wceBOO h5PYxzgfOE0souarWFd69Ds5ppnR1nZc/zgIAUPfTlg60CO7UcEjWTH48V9P+e4kqyge T7+A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=ZoEVGAM/kH9XPvUMzNhmj0SyiXtYsN9ufv+LSfLrSS0=; fh=oGCWKUgN5rqvEqhxhGaFnCKhx0upqxg87fHnuYmJPFg=; b=Ev3Tz06QXZTdSzds8jraQlmbjZQ1zGGAkGkw4wg+f3eoP+VJZTpMf6HkJisF4ykHgr hUO2QKZPEMp9wK7uma/AqNugTT/7y7FkrrTRAtnl60VWmORQivQx9Nzrn39gHdrmnzIQ 2nE1g89w7UMNSpBY3CWib8Oc5Mj4THn1qWut/7vu8kGoBho2NFBAltSah7FaWSZGYazZ E8CafkwSLB9Ea0p/8B1mzb4zeShwyguuGx3wEr+kT/fuKh7Q95qeNhD/i9Q2yGnROKTN jR+H2H5IB5G6ZhEX5F6oy1ce2Q/+2dpBAMj2VWndGU1P4QGMVbeWye+98xV0dK37uNFY lR3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=dN24NfsQ; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=hSNwGx7h; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id a2-20020a0dd802000000b0059f5772c1f3si970783ywe.129.2023.10.26.18.56.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 18:56:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=dN24NfsQ; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=hSNwGx7h; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id DFDA282CFA74; Thu, 26 Oct 2023 18:56:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345097AbjJ0B4m (ORCPT + 99 others); Thu, 26 Oct 2023 21:56:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345102AbjJ0B4l (ORCPT ); Thu, 26 Oct 2023 21:56:41 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D87AEAB for ; Thu, 26 Oct 2023 18:56:38 -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-out1.suse.de (Postfix) with ESMTPS id 702BE21C08; Fri, 27 Oct 2023 01:56:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1698371797; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZoEVGAM/kH9XPvUMzNhmj0SyiXtYsN9ufv+LSfLrSS0=; b=dN24NfsQjLUSxjOzUuwVMZY2wlULQm32j5OfYg3vgDzkEnyfzPqyy659L1sgkyJmyJ5gNx 867Ic58IPo1LuIJrrA+Xm2E36mroqcy74SSuEiLECFkwvpoQv+ASG/wvDHh+Fa1inZoFRe Yv9qQbjeDECuE+GIxb05FeUnmxPGtzQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1698371797; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZoEVGAM/kH9XPvUMzNhmj0SyiXtYsN9ufv+LSfLrSS0=; b=hSNwGx7hcPRkvd4gvsg9rzbGizEcY8w3QyF71CrHOPSgK+nK9dvlm3NyvCb53GHAunWlEn uAdWbnWB7BL01mCQ== 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 EE5B2133F5; Fri, 27 Oct 2023 01:56:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id i2EFKdIYO2X+CQAAMHmgww (envelope-from ); Fri, 27 Oct 2023 01:56:34 +0000 From: NeilBrown To: Chuck Lever , Jeff Layton Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia , Dai Ngo , Tom Talpey Subject: [PATCH 2/6] nfsd: allow admin-revoked state to appear in /proc/fs/nfsd/clients/*/states Date: Fri, 27 Oct 2023 12:45:30 +1100 Message-ID: <20231027015613.26247-3-neilb@suse.de> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231027015613.26247-1-neilb@suse.de> References: <20231027015613.26247-1-neilb@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -2.10 X-Spamd-Result: default: False [-2.10 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[6]; NEURAL_HAM_LONG(-3.00)[-1.000]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Thu, 26 Oct 2023 18:56:45 -0700 (PDT) Change the "show" functions to show some content even if a file cannot be found, and call them for the ADMIN_REVOKED versions of state id. This use primarily useful for debugging - to ensure states are being removed eventually. Signed-off-by: NeilBrown --- fs/nfsd/nfs4state.c | 78 ++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index f3ba53a16105..e15d35c57991 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -2679,17 +2679,10 @@ static int nfs4_show_open(struct seq_file *s, struct nfs4_stid *st) struct nfs4_stateowner *oo; unsigned int access, deny; - if (st->sc_type != NFS4_OPEN_STID && st->sc_type != NFS4_LOCK_STID) - return 0; /* XXX: or SEQ_SKIP? */ ols = openlockstateid(st); oo = ols->st_stateowner; nf = st->sc_file; - spin_lock(&nf->fi_lock); - file = find_any_file_locked(nf); - if (!file) - goto out; - seq_printf(s, "- "); nfs4_show_stateid(s, &st->sc_stateid); seq_printf(s, ": { type: open, "); @@ -2704,14 +2697,17 @@ static int nfs4_show_open(struct seq_file *s, struct nfs4_stid *st) deny & NFS4_SHARE_ACCESS_READ ? "r" : "-", deny & NFS4_SHARE_ACCESS_WRITE ? "w" : "-"); - nfs4_show_superblock(s, file); - seq_printf(s, ", "); - nfs4_show_fname(s, file); - seq_printf(s, ", "); + spin_lock(&nf->fi_lock); + file = find_any_file_locked(nf); + if (file) { + nfs4_show_superblock(s, file); + seq_puts(s, ", "); + nfs4_show_fname(s, file); + seq_puts(s, ", "); + } + spin_unlock(&nf->fi_lock); nfs4_show_owner(s, oo); seq_printf(s, " }\n"); -out: - spin_unlock(&nf->fi_lock); return 0; } @@ -2725,30 +2721,29 @@ static int nfs4_show_lock(struct seq_file *s, struct nfs4_stid *st) ols = openlockstateid(st); oo = ols->st_stateowner; nf = st->sc_file; - spin_lock(&nf->fi_lock); - file = find_any_file_locked(nf); - if (!file) - goto out; seq_printf(s, "- "); nfs4_show_stateid(s, &st->sc_stateid); seq_printf(s, ": { type: lock, "); - /* - * Note: a lock stateid isn't really the same thing as a lock, - * it's the locking state held by one owner on a file, and there - * may be multiple (or no) lock ranges associated with it. - * (Same for the matter is true of open stateids.) - */ + spin_lock(&nf->fi_lock); + file = find_any_file_locked(nf); + if (file) { + /* + * Note: a lock stateid isn't really the same thing as a lock, + * it's the locking state held by one owner on a file, and there + * may be multiple (or no) lock ranges associated with it. + * (Same for the matter is true of open stateids.) + */ - nfs4_show_superblock(s, file); - /* XXX: open stateid? */ - seq_printf(s, ", "); - nfs4_show_fname(s, file); - seq_printf(s, ", "); + nfs4_show_superblock(s, file); + /* XXX: open stateid? */ + seq_puts(s, ", "); + nfs4_show_fname(s, file); + seq_puts(s, ", "); + } nfs4_show_owner(s, oo); seq_printf(s, " }\n"); -out: spin_unlock(&nf->fi_lock); return 0; } @@ -2761,27 +2756,27 @@ static int nfs4_show_deleg(struct seq_file *s, struct nfs4_stid *st) ds = delegstateid(st); nf = st->sc_file; - spin_lock(&nf->fi_lock); - file = nf->fi_deleg_file; - if (!file) - goto out; seq_printf(s, "- "); nfs4_show_stateid(s, &st->sc_stateid); seq_printf(s, ": { type: deleg, "); /* Kinda dead code as long as we only support read delegs: */ - seq_printf(s, "access: %s, ", - ds->dl_type == NFS4_OPEN_DELEGATE_READ ? "r" : "w"); + seq_printf(s, "access: %s", + ds->dl_type == NFS4_OPEN_DELEGATE_READ ? "r" : "w"); /* XXX: lease time, whether it's being recalled. */ - nfs4_show_superblock(s, file); - seq_printf(s, ", "); - nfs4_show_fname(s, file); - seq_printf(s, " }\n"); -out: + spin_lock(&nf->fi_lock); + file = nf->fi_deleg_file; + if (file) { + seq_puts(s, ", "); + nfs4_show_superblock(s, file); + seq_puts(s, ", "); + nfs4_show_fname(s, file); + } spin_unlock(&nf->fi_lock); + seq_puts(s, " }\n"); return 0; } @@ -2813,10 +2808,13 @@ static int states_show(struct seq_file *s, void *v) switch (st->sc_type) { case NFS4_OPEN_STID: + case NFS4_ADMIN_REVOKED_STID: return nfs4_show_open(s, st); case NFS4_LOCK_STID: + case NFS4_ADMIN_REVOKED_LOCK_STID: return nfs4_show_lock(s, st); case NFS4_DELEG_STID: + case NFS4_ADMIN_REVOKED_DELEG_STID: return nfs4_show_deleg(s, st); case NFS4_LAYOUT_STID: return nfs4_show_layout(s, st); -- 2.42.0