]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: add assert to catch dentry ref drop during unlink
authorIgor Golikov <igolikov@ibm.com>
Wed, 27 May 2026 13:18:44 +0000 (16:18 +0300)
committerVenky Shankar <vshankar@redhat.com>
Wed, 1 Jul 2026 05:34:38 +0000 (11:04 +0530)
Add ceph_assert(dn->ref > 0) after Dentry::unlink() in Client::unlink()
to catch the case where internal put() calls drop the dentry reference
to zero before we proceed to detach/lru_remove.

This turns a silent use-after-free into a clean assertion failure with
a full stack trace, making it possible to catch the exact conditions
in a test environment.

Signed-off-by: Igor Golikov <igolikov@ibm.com>
Fixes: https://tracker.ceph.com/issues/74625
src/client/Client.cc

index 3a2041a8753737cf01a493ee9e2f4936b9c8afaf..5d1464b3a3bc02f8eeb41146eaefcdd5bca383b9 100644 (file)
@@ -3800,6 +3800,7 @@ void Client::unlink(Dentry *dn, bool keepdir, bool keepdentry)
     dec_dentry_nr();
     ldout(cct, 20) << "unlink  inode " << in << " parents now " << in->dentries << dendl;
   }
+  ceph_assert(dn->ref > 0);
 
   if (keepdentry) {
     dn->lease_mds = -1;