Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp803124rdh; Thu, 23 Nov 2023 20:20:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWSlDMqgD2fT2vig7f+QcBZGj28+LnHhzt7/QxFNYbfrZcdcxrxa16jjibaXsHdGbjqgGA X-Received: by 2002:a05:6214:2b4:b0:66d:2064:c7ee with SMTP id m20-20020a05621402b400b0066d2064c7eemr1543167qvv.20.1700799631926; Thu, 23 Nov 2023 20:20:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700799631; cv=none; d=google.com; s=arc-20160816; b=yA+XS7+t2NxtnAu4xcfSIpW0VCk/wVa9nKmrhLv0JmFaQVC2K947iwF/yp/VtDPfTK KI3BMGze5AdQKvf8BimsytynGWCPtlnETCzN2RKrR9baVV1MZuKEqqvESvb/aA3wcuDT lvNd7vYS/1MjNHhYBIOpP/TKxNuzR5welrDIFqhoXayx8CiIpSEOrAR9TDYKDzP9gP+5 8aZp4u/T9m+MpKmmeS1gVvO/LDFzBU6a8vN+4g5s/f3TtyH3Jaewsfhl2xJAo7rTNIKy gUl9k9PrxFjUCoxCkTZG10S8DirgirFFrghIgzS3WlmcaO6h4kAEE3+xSRFKpn7m0Krd 3bcg== 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:dkim-signature:dkim-signature; bh=DBSMnYSr0eqfko0i5Ej3oZMZHSXC7IdlKH2BFhfaHrE=; fh=oGCWKUgN5rqvEqhxhGaFnCKhx0upqxg87fHnuYmJPFg=; b=zdJeLcHGYrV5fDO1njjSETgBL3sD3crG2PY6k5gQfSs4p8Q0VlzVYMxo0ze6zkCkHA NRMsngeCr81cqzN9TgLow6pzJKDtWPDiO+3U7jHemdb0l/vxyMganzajzgds75tQOtrB /3ri9M4jIvfER4BwhWQ8iyWFq+qu9P9ARCzbwqxp5AKX8qQSt2WKzSVxuQ57lSpbLnUh G0RqEQqz+kvhXKCzOM5LAoNesaWtpYFuTHMTZMURJFActgX4e+aBgcKCnQ/4Fdj7boIc 4eOebwSQJY5ZKJvbfWmjVI1l5wc0QPeqtgK8yKzBqYkAd33X2MuMoCK1bq74oaGo2Jrg 8eLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=gBGSt5PO; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-nfs+bounces-51-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-51-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y16-20020ad457d0000000b0066d02899548si2596678qvx.34.2023.11.23.20.20.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 20:20:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-51-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=gBGSt5PO; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-nfs+bounces-51-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-51-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 88EDD1C2095C for ; Fri, 24 Nov 2023 04:20:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB38546A8; Fri, 24 Nov 2023 04:20:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="gBGSt5PO"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="CCVog4k6" X-Original-To: linux-nfs@vger.kernel.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7D88D6F for ; Thu, 23 Nov 2023 20:20:24 -0800 (PST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 80F63338AD; Fri, 24 Nov 2023 00:31:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1700785898; 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=DBSMnYSr0eqfko0i5Ej3oZMZHSXC7IdlKH2BFhfaHrE=; b=gBGSt5POvMyYL8sn9BUnF+dge+ut9Ht7KkXbujh7a+6qAfRT7bMNoBQjrgt32KcBx7CIbu tat2MNvJfHaKJzyIu9TSUZOuY1fXj9AlqO9foTii0aFOh8M9FXPvYnocj4nJ40CWiM23uP Z+7oZ/dA/KoX/2Ti97MK0oNywInFqro= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1700785898; 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=DBSMnYSr0eqfko0i5Ej3oZMZHSXC7IdlKH2BFhfaHrE=; b=CCVog4k63X8Ne2ex7wP8fGYoTMFdbwJojJOKx+aXLLp00ZAloh28hMaSmaPQadFylzvaLX 6bJ5VHSjWJPBMEDA== 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 5D4D61340B; Fri, 24 Nov 2023 00:31:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id EBepBOjuX2W5egAAD6G6ig (envelope-from ); Fri, 24 Nov 2023 00:31:36 +0000 From: NeilBrown To: Chuck Lever , Jeff Layton Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia , Dai Ngo , Tom Talpey Subject: [PATCH 06/11] nfsd: allow admin-revoked state to appear in /proc/fs/nfsd/clients/*/states Date: Fri, 24 Nov 2023 11:28:41 +1100 Message-ID: <20231124002925.1816-7-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 Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: 1.70 X-Spamd-Result: default: False [1.70 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; 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)[]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.986]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] Change the "show" functions to show some content even if a file cannot be found. This is primarily useful for debugging - to ensure states are being removed eventually. Also remove a "Kinda dead" comment which is no longer correct as we now support write delegations. Signed-off-by: NeilBrown --- fs/nfsd/nfs4state.c | 82 ++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 477a9e9aebbd..52e680235afe 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -2680,17 +2680,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, "); @@ -2705,14 +2698,19 @@ 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); + if (st->sc_status & NFS4_STID_ADMIN_REVOKED) + seq_puts(s, ", admin-revoked"); seq_printf(s, " }\n"); -out: - spin_unlock(&nf->fi_lock); return 0; } @@ -2726,30 +2724,31 @@ 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); + if (st->sc_status & NFS4_STID_ADMIN_REVOKED) + seq_puts(s, ", admin-revoked"); seq_printf(s, " }\n"); -out: spin_unlock(&nf->fi_lock); return 0; } @@ -2762,27 +2761,28 @@ 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); + if (st->sc_status & NFS4_STID_ADMIN_REVOKED) + seq_puts(s, ", admin-revoked"); + seq_puts(s, " }\n"); return 0; } -- 2.42.1