]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: add ceph.{cluster_fsid/client_id} vxattrs suppport 39000/head
authorXiubo Li <xiubli@redhat.com>
Tue, 24 Nov 2020 08:49:06 +0000 (16:49 +0800)
committerVicente Cheng <freeze.bilsted@gmail.com>
Thu, 21 Jan 2021 14:34:10 +0000 (14:34 +0000)
These two vxattrs will only exist in local client side, with which
we can easily know which mountpoint the file belongs to and also
they can help locate the debugfs path quickly.

Fixes: https://tracker.ceph.com/issues/48337
Signed-off-by: Xiubo Li <xiubli@redhat.com>
(cherry picked from commit 5635f25dd4a134f2fb32d2cb9dd73c0e947295e6)

Conflicts:
src/client/Client.cc
src/client/Client.h
  - drop the mirror.info xattr related code
            because octopus does not introduce it

src/client/Client.cc
src/client/Client.h

index 2a7f9bee407bcedff94a9aab76a0920f8786eb61..acd5aa2d11db3e2ff6d6bacdaa246f685e9707c4 100755 (executable)
@@ -12012,6 +12012,17 @@ size_t Client::_vxattrcb_snap_btime(Inode *in, char *val, size_t size)
       (long unsigned)in->snap_btime.nsec());
 }
 
+size_t Client::_vxattrcb_cluster_fsid(Inode *in, char *val, size_t size)
+{
+  return snprintf(val, size, "%s", monclient->get_fsid().to_string().c_str());
+}
+
+size_t Client::_vxattrcb_client_id(Inode *in, char *val, size_t size)
+{
+  auto name = messenger->get_myname();
+  return snprintf(val, size, "%s%ld", name.type_str(), name.num());
+}
+
 #define CEPH_XATTR_NAME(_type, _name) "ceph." #_type "." #_name
 #define CEPH_XATTR_NAME2(_type, _name, _name2) "ceph." #_type "." #_name "." #_name2
 
@@ -12118,6 +12129,24 @@ const Client::VXattr Client::_file_vxattrs[] = {
   { name: "" }     /* Required table terminator */
 };
 
+const Client::VXattr Client::_common_vxattrs[] = {
+  {
+    name: "ceph.cluster_fsid",
+    getxattr_cb: &Client::_vxattrcb_cluster_fsid,
+    readonly: true,
+    exists_cb: nullptr,
+    flags: 0,
+  },
+  {
+    name: "ceph.client_id",
+    getxattr_cb: &Client::_vxattrcb_client_id,
+    readonly: true,
+    exists_cb: nullptr,
+    flags: 0,
+  },
+  { name: "" }     /* Required table terminator */
+};
+
 const Client::VXattr *Client::_get_vxattrs(Inode *in)
 {
   if (in->is_dir())
@@ -12138,7 +12167,16 @@ const Client::VXattr *Client::_match_vxattr(Inode *in, const char *name)
        vxattr++;
       }
     }
+
+    // for common vxattrs
+    vxattr = _common_vxattrs;
+    while (!vxattr->name.empty()) {
+      if (vxattr->name == name)
+        return vxattr;
+      vxattr++;
+    }
   }
+
   return NULL;
 }
 
index 09f2ef97052b19dbcd2933ca74f2e7dd6e23eb72..1090c108e8d97f43fc6d1ffd3bd8a4b5e598d907 100644 (file)
@@ -1010,6 +1010,7 @@ private:
 
   static const VXattr _dir_vxattrs[];
   static const VXattr _file_vxattrs[];
+  static const VXattr _common_vxattrs[];
 
 
 
@@ -1159,6 +1160,9 @@ private:
   bool _vxattrcb_snap_btime_exists(Inode *in);
   size_t _vxattrcb_snap_btime(Inode *in, char *val, size_t size);
 
+  size_t _vxattrcb_cluster_fsid(Inode *in, char *val, size_t size);
+  size_t _vxattrcb_client_id(Inode *in, char *val, size_t size);
+
   static const VXattr *_get_vxattrs(Inode *in);
   static const VXattr *_match_vxattr(Inode *in, const char *name);