]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
client: use the fs' full path instead of from mountpoint's root
authorXiubo Li <xiubli@redhat.com>
Thu, 19 Oct 2023 02:20:55 +0000 (10:20 +0800)
committerXiubo Li <xiubli@redhat.com>
Thu, 19 Oct 2023 02:24:54 +0000 (10:24 +0800)
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 <xiubli@redhat.com>
src/client/Client.cc
src/client/Client.h

index 4e7e3961e8e1d14ed0c1d59200d7026472f80000..84b30a2d36774df360c587851d81f8a6da1bd751 100644 (file)
@@ -8000,6 +8000,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<uint8_t>* aux)
@@ -8042,8 +8056,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 /
@@ -10272,8 +10285,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 /
index 63df6b815bd247aee46ac5d54feaa58f387c4fd0..9c1303384be8eafa354fc4354f26339f53778baf 100644 (file)
@@ -1625,6 +1625,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<uint8_t>* aux=nullptr);