]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: do not open dir for a non-dir inode
authorDhairya Parmar <dparmar@redhat.com>
Tue, 8 Apr 2025 13:52:05 +0000 (19:22 +0530)
committerDhairya Parmar <dparmar@redhat.com>
Fri, 20 Jun 2025 09:48:42 +0000 (15:18 +0530)
adds an extra ref to the root which leads to ref leaks:
2025-03-26T15:37:55.162+0530 7fadb8d41640  1 client.4293 dump_inode: DISCONNECTED inode 0x1 #0x1 ref 2 0x1.head(faked_ino=0 nref=2 ll_ref=0 cap_refs={1024=0} open={} mode=41777 size=0/0 nlink=1 btime=2025-03-26T15:37:39.967146+0530 mtime=2025-03-26T15:37:45.113229+0530 ctime=2025-03-26T15:37:45.136266+0530 change_attr=3 caps=pAsLsXs(0=pAsLsXs) COMPLETE has_dir_layout 0x7fad78006970)

which leads to:
2025-03-26T15:37:55.162+0530 7fadb8d41640  2 client.4293 cache still has 1+1 items, waiting (for caps to release?)

Fixes: https://tracker.ceph.com/issues/70553
Signed-off-by: Dhairya Parmar <dparmar@redhat.com>
src/client/Client.cc

index c57e282ca6b21408ea319704e93fc9053026262d..6df734b9201fef384f06ee8a980144c62c95f2a7 100644 (file)
@@ -7722,6 +7722,11 @@ int Client::path_walk(InodeRef dirinode, const filepath& origpath, walk_dentry_r
     ldout(cct, 10) << " " << i << " " << *diri << " " << dname << dendl;
     ldout(cct, 20) << "  (path is " << path << ")" << dendl;
     InodeRef next;
+    if (!diri.get()->is_dir()) {
+      ldout(cct, 20) << diri.get() << " is not a dir inode, name " << dname.c_str() << dendl;
+      rc = -ENOTDIR;
+      goto out;
+    }
     if (should_check_perms()) {
       int r = may_lookup(diri.get(), perms);
       if (r < 0) {