]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: add ceph.{cluster_fsid/client_id} vxattrs suppport 39001/head
authorXiubo Li <xiubli@redhat.com>
Tue, 24 Nov 2020 08:49:06 +0000 (16:49 +0800)
committerVicente Cheng <freeze.bilsted@gmail.com>
Wed, 17 Feb 2021 07:32:47 +0000 (07:32 +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
  - add .hidden member because we still need it
            in nautilus
src/client/Client.h
  - drop the mirror.info xattr related code
            because nautilus does not introduce it

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

index 2c56b9d3893540566b04aec959c2e5cdc68c4294..187413229aef0a6094b8f8d435c840e6e0eebaa0 100755 (executable)
@@ -11938,6 +11938,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
 
@@ -12054,6 +12065,26 @@ 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,
+    hidden: false,
+    exists_cb: nullptr,
+    flags: 0,
+  },
+  {
+    name: "ceph.client_id",
+    getxattr_cb: &Client::_vxattrcb_client_id,
+    readonly: true,
+    hidden: false,
+    exists_cb: nullptr,
+    flags: 0,
+  },
+  { name: "" }     /* Required table terminator */
+};
+
 const Client::VXattr *Client::_get_vxattrs(Inode *in)
 {
   if (in->is_dir())
@@ -12074,7 +12105,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 9c4f02c04473c2ba643ed1d4bfe867bb236a2f55..2749cc42b5615d2d512525d3b50c9ef877658dc8 100644 (file)
@@ -1008,6 +1008,7 @@ private:
 
   static const VXattr _dir_vxattrs[];
   static const VXattr _file_vxattrs[];
+  static const VXattr _common_vxattrs[];
 
 
 
@@ -1157,6 +1158,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);