]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: add ceph.snap.btime vxattr
authorDavid Disseldorp <ddiss@suse.de>
Wed, 20 Mar 2019 15:35:38 +0000 (16:35 +0100)
committerVicente Cheng <freeze.bilsted@gmail.com>
Wed, 1 May 2019 01:11:58 +0000 (01:11 +0000)
The ceph.snap.btime vxattr carries the snapshot creation time for files
and directories residing within a snapshot.

Fixes: https://tracker.ceph.com/issues/38838
Signed-off-by: David Disseldorp <ddiss@suse.de>
(cherry picked from commit a85c1a25aa3387929e59d4b14baf7598d1a59bf5)

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

index a716b998c4ef52eace72305a055a076178456b9f..2e380f388f24141c4bf03ca11aaafc35f4b8f891 100644 (file)
@@ -11792,6 +11792,18 @@ size_t Client::_vxattrcb_dir_pin(Inode *in, char *val, size_t size)
   return snprintf(val, size, "%ld", (long)in->dir_pin);
 }
 
+bool Client::_vxattrcb_snap_btime_exists(Inode *in)
+{
+  return !in->snap_btime.is_zero();
+}
+
+size_t Client::_vxattrcb_snap_btime(Inode *in, char *val, size_t size)
+{
+  return snprintf(val, size, "%llu.09%lu",
+      (long long unsigned)in->snap_btime.sec(),
+      (long unsigned)in->snap_btime.nsec());
+}
+
 #define CEPH_XATTR_NAME(_type, _name) "ceph." #_type "." #_name
 #define CEPH_XATTR_NAME2(_type, _name, _name2) "ceph." #_type "." #_name "." #_name2
 
@@ -11872,6 +11884,14 @@ const Client::VXattr Client::_dir_vxattrs[] = {
     exists_cb: &Client::_vxattrcb_dir_pin_exists,
     flags: 0,
   },
+  {
+    name: "ceph.snap.btime",
+    getxattr_cb: &Client::_vxattrcb_snap_btime,
+    readonly: true,
+    hidden: false,
+    exists_cb: &Client::_vxattrcb_snap_btime_exists,
+    flags: 0,
+  },
   { name: "" }     /* Required table terminator */
 };
 
@@ -11889,6 +11909,14 @@ const Client::VXattr Client::_file_vxattrs[] = {
   XATTR_LAYOUT_FIELD(file, layout, object_size),
   XATTR_LAYOUT_FIELD(file, layout, pool),
   XATTR_LAYOUT_FIELD(file, layout, pool_namespace),
+  {
+    name: "ceph.snap.btime",
+    getxattr_cb: &Client::_vxattrcb_snap_btime,
+    readonly: true,
+    hidden: false,
+    exists_cb: &Client::_vxattrcb_snap_btime_exists,
+    flags: 0,
+  },
   { name: "" }     /* Required table terminator */
 };
 
index 3c00d2294f40765c9761e87a58ccf0e523e50983..952579f0916a80713a06ee961064940dffb3ac6c 100644 (file)
@@ -1165,6 +1165,9 @@ private:
   bool _vxattrcb_dir_pin_exists(Inode *in);
   size_t _vxattrcb_dir_pin(Inode *in, char *val, size_t size);
 
+  bool _vxattrcb_snap_btime_exists(Inode *in);
+  size_t _vxattrcb_snap_btime(Inode *in, char *val, size_t size);
+
   size_t _vxattrs_calcu_name_size(const VXattr *vxattrs);
 
   static const VXattr *_get_vxattrs(Inode *in);