]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
Handle dir->dentries.empty()
authorJos Collin <jcollin@redhat.com>
Thu, 8 Feb 2018 12:31:28 +0000 (18:01 +0530)
committerJos Collin <jcollin@redhat.com>
Tue, 13 Feb 2018 03:42:53 +0000 (09:12 +0530)
Handle dir->dentries.empty() (during stale file handle error) situation appropriately.

Fixes: http://tracker.ceph.com/issues/21995
Signed-off-by: Jos Collin <jcollin@redhat.com>
src/client/Client.cc

index 4265fa79b604e6a3b01592023458a96dbd1f9a23..03b8e042b6ece6e0fb100b4d954e6f1cd256fc3c 100644 (file)
@@ -6083,8 +6083,23 @@ int Client::_lookup(Inode *dir, const string& dname, int mask, InodeRef *target,
   }
 
   if (dname == "..") {
-    if (dir->dentries.empty())
-      *target = dir;
+    if (dir->dentries.empty()) {
+      MetaRequest *req = new MetaRequest(CEPH_MDS_OP_LOOKUPPARENT);
+      filepath path(dir->ino);
+      req->set_filepath(path);
+
+      InodeRef tmptarget;
+      int r = make_request(req, perms, &tmptarget, NULL, rand() % mdsmap->get_num_in_mds());
+
+      if (r == 0) {
+       Inode *tempino = tmptarget.get();
+       _ll_get(tempino);
+       *target = tempino;
+       ldout(cct, 3) << __func__ << " found target " << (*target)->ino << dendl;
+      } else {
+       *target = dir;
+      }
+    }
     else
       *target = dir->get_first_parent()->dir->parent_inode; //dirs can't be hard-linked
     goto done;