From: Venky Shankar Date: Mon, 19 Oct 2020 09:38:47 +0000 (-0400) Subject: mds: include snapshot metadata in trace reply to client X-Git-Tag: v16.1.0~184^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=721f37d2c6b75a9ff16c849f879b602f98bdbcdd;p=ceph.git mds: include snapshot metadata in trace reply to client MDS sends (custom user) metadata associated with a snapshot in trace reply to the client. This is required to implement API for fetching snapshot info (snap-id, metadata, etc...). Signed-off-by: Venky Shankar --- diff --git a/src/client/Client.cc b/src/client/Client.cc index ec109470a0d7..3bf2e836f866 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -899,6 +899,7 @@ Inode * Client::add_update_inode(InodeStat *st, utime_t from, in->gid = st->gid; in->btime = st->btime; in->snap_btime = st->snap_btime; + in->snap_metadata = st->snap_metadata; } if ((new_version || (new_issued & CEPH_CAP_LINK_SHARED)) && diff --git a/src/client/Inode.h b/src/client/Inode.h index 5d5cae562ec7..797eb063eefd 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -159,6 +159,7 @@ struct Inode { version_t version; // auth only version_t xattr_version; utime_t snap_btime; // snapshot creation (birth) time + std::map snap_metadata; // inline data version_t inline_version; diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 182c77b0c7b6..7ae8057c881c 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -3725,6 +3725,7 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session, } utime_t snap_btime; + std::map snap_metadata; SnapRealm *realm = find_snaprealm(); if (snapid != CEPH_NOSNAP && realm) { // add snapshot timestamp vxattr @@ -3736,6 +3737,7 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session, ceph_assert(infomap.size() == 1); const SnapInfo *si = infomap.begin()->second; snap_btime = si->stamp; + snap_metadata = si->metadata; } } @@ -3995,7 +3997,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(4, 1, bl); + ENCODE_START(5, 1, bl); encode(oi->ino, bl); encode(snapid, bl); encode(oi->rdev, bl); @@ -4039,6 +4041,7 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session, encode(file_i->export_pin, bl); encode(snap_btime, bl); encode(file_i->rstat.rsnaps, bl); + encode(snap_metadata, bl); ENCODE_FINISH(bl); } else { diff --git a/src/messages/MClientReply.h b/src/messages/MClientReply.h index 92ccccb86db4..4fb8c19d8d07 100644 --- a/src/messages/MClientReply.h +++ b/src/messages/MClientReply.h @@ -135,6 +135,7 @@ struct InodeStat { quota_info_t quota; mds_rank_t dir_pin; + std::map snap_metadata; public: InodeStat() {} @@ -145,7 +146,7 @@ struct InodeStat { void decode(ceph::buffer::list::const_iterator &p, const uint64_t features) { using ceph::decode; if (features == (uint64_t)-1) { - DECODE_START(4, p); + DECODE_START(5, p); decode(vino.ino, p); decode(vino.snapid, p); decode(rdev, p); @@ -196,6 +197,9 @@ struct InodeStat { if (struct_v >= 4) { decode(rstat.rsnaps, p); } // else remains zero + if (struct_v >= 5) { + decode(snap_metadata, p); + } DECODE_FINISH(p); } else {