From: Yan, Zheng Date: Mon, 6 Jul 2020 09:04:51 +0000 (+0800) Subject: client: encode inode's parent/d_name in cap_reconnect_t X-Git-Tag: v16.1.0~1258^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7f43840fd3f9a8f88f809dcad5d3d381e76ba7f3;p=ceph.git client: encode inode's parent/d_name in cap_reconnect_t Signed-off-by: "Yan, Zheng" --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 62c82d57c1a..038e703dbae 100755 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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; diff --git a/src/client/Dentry.h b/src/client/Dentry.h index ffbb5104b49..7559c45f49b 100644 --- a/src/client/Dentry.h +++ b/src/client/Dentry.h @@ -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); diff --git a/src/client/Inode.cc b/src/client/Inode.cc index 2b7738adf4a..91bcc815c61 100644 --- a/src/client/Inode.cc +++ b/src/client/Inode.cc @@ -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); } diff --git a/src/client/Inode.h b/src/client/Inode.h index afaf64e0515..5b932a98709 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -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();