Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp728176rdb; Mon, 29 Jan 2024 17:11:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IGj06N6k2ZEBLuyuts7GUaOGwMRBHNJNCf6Fp0RQH8F7uEpZ8lP4wJxHgEMNDSpT1IKDkKr X-Received: by 2002:a17:90a:6b83:b0:295:1740:e89f with SMTP id w3-20020a17090a6b8300b002951740e89fmr258917pjj.6.1706577096011; Mon, 29 Jan 2024 17:11:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706577095; cv=pass; d=google.com; s=arc-20160816; b=SGH6o8FseRbbrrQRDVaRlH0CDtdeiA2bwObCsIbKPWERzvxSerKdrqx82Wj8Qzn1/J xRwBEqY6edykg8+sWkFQv4lvKimtyZNBoq7VD6WoxN2vu+yi70J1/0ckJAWNmY1Burhe 2TohLUMYtYXDw1Dl34AGCjL5qE2Uya8Cze312FXF/gFbFKcBLb26VZTYzfWr6FsVwmvT +1CwI6zYAo/lygDU6k37ZBHrUrd5M55VKisaJ0AHFMcO9Qlj26UKQcQrbq2d0tuwC/IY JbbCcAkfptezwrnHEpmdtOsvyjJibM9ywYiNBYDfKmeejJt1fuNoeB9Z55Nzedw4fYiR NZ/Q== ARC-Message-Signature: i=2; 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 :dkim-signature:dkim-signature; bh=bZs+ONYOZpKeX4h+oQ+9vW74ciSIq6qS9ax6DvIFoRY=; fh=DPK+PwXoUUGZcwbQK6Acek0sHLUTB6JOgAucPVabbeA=; b=jmgQhCcqkcCJNKUB4vV/YjHzznRam46g4B4T3Rw7Rz5/RtqHDVSKkD10s+MlyKg/ju OucfBOcGOFpnGeedPATis26mVLl0g0wlLM/yYXt4XcL8yJJap1PMZx3Q4M2KxMGu2v5U zZwGqZ9xScbSyvtVar3zhOVY6ZLImtTkKe27xufhn5HQnx2AjS/x4G5rC3KSyjwJ0H1A z0d4DVDFUOssDXV4+vz4GKOHIZtvwFvbASyHnICHpPHeaN7BfeD8V/DV73i8She+QqTn pdjquQxC6qxvs3BHorka+FjR1dj7qXPhUAsjGZosp8nPZPpwatXfDcmq2dF3Ag2RHabk bkYQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="Olc/yvaT"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="MkYu4/98"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-nfs+bounces-1585-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-1585-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bf9-20020a170902b90900b001d8b574af48si3664292plb.230.2024.01.29.17.11.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 17:11:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-1585-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="Olc/yvaT"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="MkYu4/98"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-nfs+bounces-1585-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-1585-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 71D962849F3 for ; Tue, 30 Jan 2024 01:11:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4649022083; Tue, 30 Jan 2024 01:11:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Olc/yvaT"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Jak0cjU7"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="MkYu4/98"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="W3YjmN2f" X-Original-To: linux-nfs@vger.kernel.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93AD4D266 for ; Tue, 30 Jan 2024 01:11:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706577094; cv=none; b=fesz7TdInETlI0axsqRlvPFrihIEbyK+q6gndYitqT/Kv1azr2Mms6xfe+Qv05NHO+Jke7Lr73Aw957f7wL22HTIGiT1+uhLQqzUxB7c654YBq2Z2g4KV/OlafMs0t7e8cL43/8CAKwogmc0E+hygbZlb+iCFeBQjZ32bOvPBZc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706577094; c=relaxed/simple; bh=kStnCaeYh9I3gsYRjXIvZhMiy4LkymQxlojuk0qtUko=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VIdugXP65tfwurmdcIIRRKm1swzSohWkzwydsTkZQviZLfNwEuvOmmetD6Wk9IgHBIe2cq2i80lQULQwNj8TXKW0exF0TqgJwvikakSgr0gh85/puEgPNba9WEZradZrP3wbP2yy8vliNlO0uJHYZXaMNRGtAY8V6890IqugRfg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Olc/yvaT; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=Jak0cjU7; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=MkYu4/98; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=W3YjmN2f; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de 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-out2.suse.de (Postfix) with ESMTPS id EA2C01F7ED; Tue, 30 Jan 2024 01:11:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706577090; 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=bZs+ONYOZpKeX4h+oQ+9vW74ciSIq6qS9ax6DvIFoRY=; b=Olc/yvaT06q0S7Z5KbOtLfGJJtsQciLzmKpfzB9q+vv31pEvCsqem7+v3G71uFkLqlH88n PYtPRQotqwhoChljNh5OlLnWgFkODGuZJklzE+xC6mgq+uqQ6QnpbxBzWPsER8hq/AYb4k sw7BrqgZjbOa0KormDwgH6M0ctLo3/A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706577090; 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=bZs+ONYOZpKeX4h+oQ+9vW74ciSIq6qS9ax6DvIFoRY=; b=Jak0cjU7fcivpwZobJVTrmQg1V71NnqVC5TzhUPJcBr9ebq4ilb5nRPRdAWAtctOEfMU+x CgSB0nTmGDrc5+DA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706577088; 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=bZs+ONYOZpKeX4h+oQ+9vW74ciSIq6qS9ax6DvIFoRY=; b=MkYu4/98Fsl33ktaGf0n9+oQ61wNoXhG95/fIXdFopekkTk5LdDTPva7rwM3BQw4apgV4A DkEAn3Cg/LyLVfXdcLZDgcnnx7/FZbO0yF53c1KDXiQFv4Sk5MTHT4bk1ZUmqBRN2t54of JiDrSdd1Pi+6hZO3p7h/ZvK0zQcSIWk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706577088; 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=bZs+ONYOZpKeX4h+oQ+9vW74ciSIq6qS9ax6DvIFoRY=; b=W3YjmN2f29OE+0CBjC+2w3EQTD38FwfUv72lGNKJV/yjWPARJ+8YO3d0Ye/rT+ko7NCGXk Yfy1KNK19cg0N9AA== 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 5763412FF7; Tue, 30 Jan 2024 01:11:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id KRs6BL5MuGWhQAAAD6G6ig (envelope-from ); Tue, 30 Jan 2024 01:11:26 +0000 From: NeilBrown To: Chuck Lever , Jeff Layton Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia , Dai Ngo , Tom Talpey , Christoph Hellwig , Tom Haynes Subject: [PATCH 03/13] nfsd: don't call functions with side-effecting inside WARN_ON() Date: Tue, 30 Jan 2024 12:08:23 +1100 Message-ID: <20240130011102.8623-4-neilb@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130011102.8623-1-neilb@suse.de> References: <20240130011102.8623-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-out2.suse.de; none X-Spamd-Result: default: False [4.87 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[vger.kernel.org,netapp.com,oracle.com,talpey.com,lst.de,gmail.com]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.03)[55.92%] X-Spam-Level: **** X-Spam-Score: 4.87 X-Spam-Flag: NO Code like: WARN_ON(foo()) looks like an assertion and might not be expected to have any side effects. When testing if a function with side-effects fails a construct like if (foo()) WARN_ON(1); makes the intent more obvious. nfsd has several WARN_ON calls where the test has side effects, so it would be good to change them. These cases don't really need the WARN_ON. They have never failed in 8 years of usage so let's just remove the WARN_ON wrapper. Suggested-by: Chuck Lever Reviewed-by: Jeff Layton Signed-off-by: NeilBrown --- fs/nfsd/nfs4state.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index ae00f9327245..59982fa5d4fa 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1600,7 +1600,7 @@ static void release_open_stateid_locks(struct nfs4_ol_stateid *open_stp, while (!list_empty(&open_stp->st_locks)) { stp = list_entry(open_stp->st_locks.next, struct nfs4_ol_stateid, st_locks); - WARN_ON(!unhash_lock_stateid(stp)); + unhash_lock_stateid(stp); put_ol_stateid_locked(stp, reaplist); } } @@ -2229,7 +2229,7 @@ __destroy_client(struct nfs4_client *clp) spin_lock(&state_lock); while (!list_empty(&clp->cl_delegations)) { dp = list_entry(clp->cl_delegations.next, struct nfs4_delegation, dl_perclnt); - WARN_ON(!unhash_delegation_locked(dp)); + unhash_delegation_locked(dp); list_add(&dp->dl_recall_lru, &reaplist); } spin_unlock(&state_lock); @@ -6170,7 +6170,7 @@ nfs4_laundromat(struct nfsd_net *nn) dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); if (!state_expired(<, dp->dl_time)) break; - WARN_ON(!unhash_delegation_locked(dp)); + unhash_delegation_locked(dp); list_add(&dp->dl_recall_lru, &reaplist); } spin_unlock(&state_lock); @@ -8010,7 +8010,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, stp = list_first_entry(&lo->lo_owner.so_stateids, struct nfs4_ol_stateid, st_perstateowner); - WARN_ON(!unhash_lock_stateid(stp)); + unhash_lock_stateid(stp); put_ol_stateid_locked(stp, &reaplist); } spin_unlock(&clp->cl_lock); @@ -8303,7 +8303,7 @@ nfs4_state_shutdown_net(struct net *net) spin_lock(&state_lock); list_for_each_safe(pos, next, &nn->del_recall_lru) { dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); - WARN_ON(!unhash_delegation_locked(dp)); + unhash_delegation_locked(dp); list_add(&dp->dl_recall_lru, &reaplist); } spin_unlock(&state_lock); -- 2.43.0