Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp612145rdb; Tue, 31 Oct 2023 18:01:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzcWjLlaBQp45dX51WNrjJvkUqjTk3lbE5Ji2IEeHRDOaYd64h8+96ljvEZbAP9qp7D39P X-Received: by 2002:a05:6358:899:b0:169:8c27:6528 with SMTP id m25-20020a056358089900b001698c276528mr3770020rwj.6.1698800482985; Tue, 31 Oct 2023 18:01:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698800482; cv=none; d=google.com; s=arc-20160816; b=G2yFqysNy1ZeFZ/mJ8x8FzUDVOmBJRNiqBlXto+p/dYhxasYJo/Zc20dAKl+NblqlN rBuYrFPftzw9dzSgxI0YHMClc7i3FpLTEUmSf8AwqdlaCCgmUfblHDRnPCiPAmb9kv2w umuobWDSSLQiDquxL16H1IwIzt/Bzns7VAL1bFtR+M1OFEfPZtUeiAKux+0UoN1uOxlZ uGNn72pjO+AyGMV8C36FoFrct/0ajfIrN/iN8ptj+K882Jcg15WgSU/csNa3yjEyfkau pvghonrjvgoqfsOWI7pvDGZuMEq7pnyTpmsJHMK1LfddhCaBFOYy1UZ60hYH+s69rxb/ 8bIw== 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=Y+S8panHCmjseCaDD5c5Yp41AhAQE6VmMNINs06LfuXM9Jf+tpE0lki387UAeksBQs j4mcuFgxMwvBlRqfGo+e8Y6yzrpSO3MTJ/J/qXYWi6XLHmFPdIOP045y6jX9VZTygk/a 02jQAqQFbZ1tWtv5MwSy7kq40PBjrct9yb/RljbcgXSYf8P4BGILUN/b/4ZCUi/hehTM lW4YfRs8CeofYBpMHW4SIJVjetcQWOKGMMPdWOm4ryYThoYgR58U1lU4nGdzJoFnpOhq 4CwZ4zMLTlEEksC4ubOHXFCUFistnufyKFurebLt9q6icVAzkfc4RtKpLLWp6laXJOqA twEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=2Pvx3fnu; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=WdzE0qo9; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id b7-20020a63d807000000b005859c81f1f0si1868709pgh.137.2023.10.31.18.01.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 18:01:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=2Pvx3fnu; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=WdzE0qo9; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 07E3E80FC15D; Tue, 31 Oct 2023 18:01:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376925AbjKABBN (ORCPT + 99 others); Tue, 31 Oct 2023 21:01:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376924AbjKABBM (ORCPT ); Tue, 31 Oct 2023 21:01:12 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24A15C9 for ; Tue, 31 Oct 2023 18:01:10 -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 D717C1F460; Wed, 1 Nov 2023 01:01:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1698800468; 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=2Pvx3fnuLFJovqqW+vuO0rwJru8xsIYjIw/81hTDhLyDP1K9nF9ZtT8fIUcIR2cImcMGjQ X/lO0WvnCeYedPJplSbYqTKbcK2IHut98hsC7apfFnzEUSCgxZ83jOa1cuCEZTX/V7AswL ArPRJShuVr8j/PgPT7CGTYWvXlrs2yU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1698800468; 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=WdzE0qo9aU1PE6cevtz+liPEja6i9pYR8Ic6WLvaoCZZEWT/cRFhW0iKoljCZHsQBsxOPW bGcYtJcDeUnNx9CA== 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 D1351138EF; Wed, 1 Nov 2023 01:01:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id /pv/IVKjQWX9OgAAMHmgww (envelope-from ); Wed, 01 Nov 2023 01:01:06 +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: Wed, 1 Nov 2023 11:57:09 +1100 Message-ID: <20231101010049.27315-3-neilb@suse.de> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231101010049.27315-1-neilb@suse.de> References: <20231101010049.27315-1-neilb@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Tue, 31 Oct 2023 18:01:18 -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