]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: encode inode's parent/d_name in cap_reconnect_t
authorYan, Zheng <zyan@redhat.com>
Mon, 6 Jul 2020 09:04:51 +0000 (17:04 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 25 Aug 2020 00:39:55 +0000 (08:39 +0800)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/client/Client.cc
src/client/Dentry.h
src/client/Inode.cc
src/client/Inode.h

index 62c82d57c1a3f1e78474ff23efa7fd5d7249efc1..038e703dbaecb81d3c8d104fd40ff4cbe226af16 100755 (executable)
@@ -1037,6 +1037,8 @@ void Client::update_dentry_lease(Dentry *dn, LeaseStat *dlease, utime_t from, Me
     }
   }
   dn->cap_shared_gen = dn->dir->parent_inode->shared_gen;
+  if (dlease->mask & CEPH_LEASE_PRIMARY_LINK)
+    dn->mark_primary();
 }
 
 
@@ -2825,7 +2827,7 @@ void Client::send_reconnect(MetaSession *session)
               << " wants " << ccap_string(in->caps_wanted())
               << dendl;
       filepath path;
-      in->make_long_path(path);
+      in->make_short_path(path);
       ldout(cct, 10) << "    path " << path << dendl;
 
       bufferlist flockbl;
index ffbb5104b49b934741eaae155c1b9a43a0cbcbda..7559c45f49b59e293a0a5fbd744b30504d2ee783 100644 (file)
@@ -64,6 +64,10 @@ public:
     inode.reset();
     dir->num_null_dentries++;
   }
+  void mark_primary() {
+    if (inode && inode->dentries.front() != this)
+      inode->dentries.push_front(&inode_xlist_link);
+  }
   void detach(void) {
     ceph_assert(!inode);
     auto p = dir->dentries.find(name);
index 2b7738adf4a5b70192761b781d539af25d2439da..91bcc815c61588b4fcebf501fa708464ef5f6bdc 100644 (file)
@@ -95,9 +95,19 @@ void Inode::make_long_path(filepath& p)
     dn->dir->parent_inode->make_long_path(p);
     p.push_dentry(dn->name);
   } else if (snapdir_parent) {
-    snapdir_parent->make_nosnap_relative_path(p);
-    string empty;
-    p.push_dentry(empty);
+    make_nosnap_relative_path(p);
+  } else
+    p = filepath(ino);
+}
+
+void Inode::make_short_path(filepath& p)
+{
+  if (!dentries.empty()) {
+    Dentry *dn = get_first_parent();
+    ceph_assert(dn->dir && dn->dir->parent_inode);
+    p = filepath(dn->name, dn->dir->parent_inode->ino);
+  } else if (snapdir_parent) {
+    make_nosnap_relative_path(p);
   } else
     p = filepath(ino);
 }
index afaf64e0515ce36811abdf72cd068d11b9a1982e..5b932a98709a9c66d0623dd42ebf31fcab7dcf9f 100644 (file)
@@ -238,6 +238,7 @@ struct Inode {
   }
 
   void make_long_path(filepath& p);
+  void make_short_path(filepath& p);
   void make_nosnap_relative_path(filepath& p);
 
   void get();