linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
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	[thread overview]
Message-ID: <20220926163847.47558-5-jlayton@kernel.org> (raw)
In-Reply-To: <20220926163847.47558-1-jlayton@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 <jlayton@kernel.org>
---
 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


      parent reply	other threads:[~2022-09-26 17:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-26 16:38 [PATCH 0/4] nfsd: minor cleanup and sanity check patches for nfsd Jeff Layton
2022-09-26 16:38 ` [PATCH 1/4] nfsd: only fill out return pointer on success in nfsd4_lookup_stateid Jeff Layton
2022-09-26 16:38 ` [PATCH 2/4] nfsd: fix comments about spinlock handling with delegations Jeff Layton
2022-09-26 16:38 ` [PATCH 3/4] nfsd: make nfsd4_run_cb a bool return function Jeff Layton
2022-09-26 17:51   ` Chuck Lever III
2022-09-26 18:24     ` Jeff Layton
2022-09-26 18:31       ` Chuck Lever III
2022-09-26 16:38 ` Jeff Layton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220926163847.47558-5-jlayton@kernel.org \
    --to=jlayton@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).