From: Xiubo Li Date: Thu, 19 Oct 2023 02:20:55 +0000 (+0800) Subject: client: use the fs' full path instead of from mountpoint's root X-Git-Tag: v18.2.4~114^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=25c0817e9ae940ce822aba962d696c4c29dddc21;p=ceph.git client: use the fs' full path instead of from mountpoint's root The mountpoint's root ino# possibly not be the full CephFS filesystem root, it's just the mountpoint of this particular client. Just prepend the mountpoint path to the full path. Introduced-by: c1bf8d88e9d client: check the cephx mds auth access for setattr Introduced-by: ce216595c03 client: check the cephx mds auth access for open Fixes: https://github.com/ceph/ceph/pull/48027#issuecomment-1741019086 Signed-off-by: Xiubo Li (cherry picked from commit e46dc20cdfb157f94781032451057d1e138535cc) --- diff --git a/src/client/Client.cc b/src/client/Client.cc index f05b898dc69..db343c44cd6 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -7985,6 +7985,20 @@ int Client::_getvxattr( return res; } +bool Client::make_absolute_path_string(Inode *in, std::string& path) +{ + if (!metadata.count("root") || !in) + return false; + + path = metadata["root"].data(); + if (!in->make_path_string(path)) { + path.clear(); + return false; + } + + return true; +} + int Client::_do_setattr(Inode *in, struct ceph_statx *stx, int mask, const UserPerm& perms, InodeRef *inp, std::vector* aux) @@ -8027,8 +8041,7 @@ int Client::_do_setattr(Inode *in, struct ceph_statx *stx, int mask, int res; { std::string path; - res = in->make_path_string(path); - if (res) { + if (make_absolute_path_string(in, path)) { ldout(cct, 20) << " absolute path: " << path << dendl; if (path.length()) path = path.substr(1); // drop leading / @@ -10267,8 +10280,7 @@ int Client::_open(Inode *in, int flags, mode_t mode, Fh **fhp, } std::string path; - int result = in->make_path_string(path); - if (result) { + if (make_absolute_path_string(in, path)) { ldout(cct, 20) << __func__ << " absolute path: " << path << dendl; if (path.length()) path = path.substr(1); // drop leading / diff --git a/src/client/Client.h b/src/client/Client.h index b7c3b105fd2..c2b0a4a9441 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -1362,6 +1362,7 @@ private: const UserPerm& perms, std::string alternate_name, InodeRef *inp = 0); int _mknod(Inode *dir, const char *name, mode_t mode, dev_t rdev, const UserPerm& perms, InodeRef *inp = 0); + bool make_absolute_path_string(Inode *in, std::string& path); int _do_setattr(Inode *in, struct ceph_statx *stx, int mask, const UserPerm& perms, InodeRef *inp, std::vector* aux=nullptr);