]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: carry snapshot creation time with InodeStat
authorDavid Disseldorp <ddiss@suse.de>
Wed, 20 Mar 2019 13:39:56 +0000 (14:39 +0100)
committerVicente Cheng <freeze.bilsted@gmail.com>
Wed, 1 May 2019 01:11:54 +0000 (01:11 +0000)
This allows for a future vxattr exposing the snapshot creation time to
users. The InodeStat encoding version is bumped to account for the new
snap_btime member.

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

src/client/Client.cc
src/client/Inode.h
src/mds/CInode.cc
src/messages/MClientReply.h

index 2cf1a9e731484ff7f85bbf9ea3eab0da9d99d138..a716b998c4ef52eace72305a055a076178456b9f 100644 (file)
@@ -860,6 +860,7 @@ Inode * Client::add_update_inode(InodeStat *st, utime_t from,
     in->uid = st->uid;
     in->gid = st->gid;
     in->btime = st->btime;
+    in->snap_btime = st->snap_btime;
   }
 
   if ((new_version || (new_issued & CEPH_CAP_LINK_SHARED)) &&
index 296017d4c852dc51ef53b5f5f77c602e50955e48..bba7f920aa1a0fac90fe6e6bd5e6996ccf63ace3 100644 (file)
@@ -156,6 +156,7 @@ struct Inode {
   // special stuff
   version_t version;           // auth only
   version_t xattr_version;
+  utime_t   snap_btime;        // snapshot creation (birth) time
 
   // inline data
   version_t  inline_version;
index ea86ff6b960fba365d646f980e326c2b31c99e96..97db2deb66dc6d2166c456f05d10cb8ae0c0c19e 100644 (file)
@@ -3322,7 +3322,21 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session,
     }
   }
 
+  utime_t snap_btime;
   SnapRealm *realm = find_snaprealm();
+  if (snapid != CEPH_NOSNAP && realm) {
+    // add snapshot timestamp vxattr
+    map<snapid_t,const SnapInfo*> infomap;
+    realm->get_snap_info(infomap,
+                         snapid,  // min
+                         snapid); // max
+    if (!infomap.empty()) {
+      ceph_assert(infomap.size() == 1);
+      const SnapInfo *si = infomap.begin()->second;
+      snap_btime = si->stamp;
+    }
+  }
+
 
   bool no_caps = !valid ||
                 session->is_stale() ||
@@ -3581,7 +3595,7 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session,
    * note: encoding matches MClientReply::InodeStat
    */
   if (session->info.has_feature(CEPHFS_FEATURE_REPLY_ENCODING)) {
-    ENCODE_START(2, 1, bl);
+    ENCODE_START(3, 1, bl);
     encode(oi->ino, bl);
     encode(snapid, bl);
     encode(oi->rdev, bl);
@@ -3623,6 +3637,7 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session,
     encode(any_i->btime, bl);
     encode(any_i->change_attr, bl);
     encode(file_i->export_pin, bl);
+    encode(snap_btime, bl);
     ENCODE_FINISH(bl);
   }
   else {
index 4b10128154c0207dfe3a6a4d4133b87047561b0e..fb1ebfe8f01141a6e83ddb9aa6ab39d91c5ec25b 100644 (file)
@@ -112,7 +112,7 @@ struct InodeStat {
   version_t xattr_version = 0;
   ceph_mds_reply_cap cap;
   file_layout_t layout;
-  utime_t ctime, btime, mtime, atime;
+  utime_t ctime, btime, mtime, atime, snap_btime;
   uint32_t time_warp_seq = 0;
   uint64_t size = 0, max_size = 0;
   uint64_t change_attr = 0;
@@ -190,6 +190,9 @@ struct InodeStat {
       } else {
         dir_pin = -ENODATA;
       }
+      if (struct_v >= 3) {
+        decode(snap_btime, p);
+      } // else remains zero
       DECODE_FINISH(p);
     }
     else {