Will use this to get the path string to do the mds auth check. It
may fail when the there is no any dentry in local cache, which could
be caused by just unlinking the last dentry while the inode keeps
opening and then try to change the mode.
Fixes: https://tracker.ceph.com/issues/57154
Signed-off-by: Xiubo Li <xiubli@redhat.com>
(cherry picked from commit
fd7aaab290728e47ff699063fa26ad63f848bbf1)
dir = nullptr;
}
+ bool make_path_string(std::string& s)
+ {
+ bool ret = false;
+
+ if (dir) {
+ ret = dir->parent_inode->make_path_string(s);
+ } else {
+ s = "???";
+ }
+ s += "/";
+ s.append(name.data(), name.length());
+
+ return ret;
+ }
+
void dump(Formatter *f) const;
friend std::ostream &operator<<(std::ostream &oss, const Dentry &Dentry);
p = filepath(ino);
}
+/*
+ * make a filepath suitable for mds auth access check:
+ */
+bool Inode::make_path_string(std::string& s)
+{
+ if (client->_get_root_ino(false) == ino) {
+ return true;
+ } else if (!dentries.empty()) {
+ Dentry *dn = get_first_parent();
+ ceph_assert(dn->dir && dn->dir->parent_inode);
+ return dn->make_path_string(s);
+ }
+
+ return false;
+}
+
/*
* make a filepath suitable for an mds request:
* - if we are non-snapped/live, the ino is sufficient, e.g. #1234
void make_long_path(filepath& p);
void make_short_path(filepath& p);
+ bool make_path_string(std::string& s);
void make_nosnap_relative_path(filepath& p);
// The ref count. 1 for each dentry, fh, inode_map,