Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp166245rwb; Mon, 26 Sep 2022 10:37:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6USzznGD2enmzH2pwXkBxelTubxYVuQ52UBq5hQRfV2HZFWNvIwUjMHR0FMgryp/L4Ahna X-Received: by 2002:a63:4507:0:b0:43c:9cf4:f1d6 with SMTP id s7-20020a634507000000b0043c9cf4f1d6mr9103381pga.316.1664213835909; Mon, 26 Sep 2022 10:37:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664213835; cv=none; d=google.com; s=arc-20160816; b=m8f2lL/tdNKmOdeh4z5d+atv37f03cmfdSHLSmXj+38r5uhIUoBhoKjNaP6maS3yF/ iWnMxkRCAzjl2H/P9nbrQQVG6nxEtwK3CKRIkrjsEhE9X+pIgRpMqPNITq84Z6t4O7We QZAbh9JD+Px+tfBZgFm3hWOETFUziGKitTfJN4bpmC0r8D6V6UzkZLGw3PNlDfTPmPMH dPVnklRERIQVX7+xJlGvzIjNswuQ5VpRQypXw7q5TKJtaQ8uOa7JM3slbjetFvRjrcdJ XXgE0qL2iqxJJBh/62NmWkAP/9saEcbMpNIuQhYP4fjcCHoNFuVDhV7aYtvw4+IK7R42 xNuA== 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; bh=uu3Ratd3NkPkZfpMArn9MSEK4Wt34yr7em5D4GhX1F4=; b=iDFvQST27bj/47r/ejobXhkaQ7yysRBXtVUnBUkqCk0+3tPju1NUNDzpwFJ32HGk4J I6m6IOIpP5lUsQ4cXufDyjE0+B1NBtb9ZXpZzONKvU/LFYRbLHjNrRy1Mzn8pGra3+Bq ftGcBefpfjMacJkZerq413J6h+9aQ/cxi0Ei6VkmUzY10DjhKQ9ss9Naeby9NSZKW2t3 KYQcVDw+OB24yLNEmNyT02T0cVJdCCRRbZbRPJg2cLgfw8zlhvVwSv05SSB+o4MaH3Is 0R5EaXErezokH3Qs61wExTXC8fzHzI94JnYL0913AVTIJhtDlAS01Y3FLUvBrVJ6IQ0A hR6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OYHIVw3M; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q16-20020a170902f79000b0016d9f9bdccfsi12984192pln.417.2022.09.26.10.35.45; Mon, 26 Sep 2022 10:37:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OYHIVw3M; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230436AbiIZRYF (ORCPT + 99 others); Mon, 26 Sep 2022 13:24:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231158AbiIZRXp (ORCPT ); Mon, 26 Sep 2022 13:23:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CC91151DC6 for ; Mon, 26 Sep 2022 09:38:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 642D161029 for ; Mon, 26 Sep 2022 16:38:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E651C43470; Mon, 26 Sep 2022 16:38:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664210331; bh=4aQTxyFHk1yHlT+oR3aAscCn1o/8MjoCJ22b8O8VS0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OYHIVw3MMdQXk9mxmpKIXKFofAjkTYzOwIwFNHeb05WCP4LTtxmt/l+z7urZTC5c1 4z65Q12NST1zZB0tmMfI9LM8VUWF8n0OSWaYNpEnkJwd646qd545H8YXVkkITX/wM2 mUeXVLlASX4IELpTGMTNAsjqXfWQOvCuP5sS1vlG6vzRxeLNgvQk/+bOeZQG1TxkC9 LsGqeyGN9Wae9Bqc2/S7I6LR7S635KngVIHktsqA1T4J7RYXj05QlPSzq+UeAe8Vv7 XH9y6PRe1Zs4xUJHqTYyIMv7cNCfi09P7kxoKg+sIODBPH7ssuQESb2YjS9Z8svj9c 3mcaYJwdWu4XA== From: Jeff Layton To: chuck.lever@oracle.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 4/4] nfsd: extra checks when freeing delegation stateids Date: Mon, 26 Sep 2022 12:38:47 -0400 Message-Id: <20220926163847.47558-5-jlayton@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926163847.47558-1-jlayton@kernel.org> References: <20220926163847.47558-1-jlayton@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org We've had some reports of problems in the refcounting for delegation stateids that we've yet to track down. Add some extra checks to ensure that we've removed the object from various lists before freeing it. Link: https://bugzilla.redhat.com/show_bug.cgi?id=2127067 Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) This one may need adjustment after Dai fixes the use of openlockstateid here. diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 90533f43fea9..490092a10285 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1060,9 +1060,12 @@ static struct nfs4_ol_stateid * nfs4_alloc_open_stateid(struct nfs4_client *clp) static void nfs4_free_deleg(struct nfs4_stid *stid) { - struct nfs4_ol_stateid *stp = openlockstateid(stid); + struct nfs4_delegation *dp = delegstateid(stid); - WARN_ON(!list_empty(&stp->st_stid.sc_cp_list)); + WARN_ON_ONCE(!list_empty(&stid->sc_cp_list)); + WARN_ON_ONCE(!list_empty(&dp->dl_perfile)); + WARN_ON_ONCE(!list_empty(&dp->dl_perclnt)); + WARN_ON_ONCE(!list_empty(&dp->dl_recall_lru)); kmem_cache_free(deleg_slab, stid); atomic_long_dec(&num_delegations); } -- 2.37.3