From: David Disseldorp Date: Wed, 20 Mar 2019 13:39:56 +0000 (+0100) Subject: mds: carry snapshot creation time with InodeStat X-Git-Tag: v14.2.2~95^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=395960a4a3e12df2cb7f5df1f5b9a1adc6702fe3;p=ceph.git mds: carry snapshot creation time with InodeStat 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 (cherry picked from commit 83da9d58b915de8da43686eb56f37d08842ded5d) --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 2cf1a9e73148..a716b998c4ef 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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)) && diff --git a/src/client/Inode.h b/src/client/Inode.h index 296017d4c852..bba7f920aa1a 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -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; diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index ea86ff6b960f..97db2deb66dc 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -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 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 { diff --git a/src/messages/MClientReply.h b/src/messages/MClientReply.h index 4b10128154c0..fb1ebfe8f011 100644 --- a/src/messages/MClientReply.h +++ b/src/messages/MClientReply.h @@ -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 {