From: Patrick Donnelly Date: Wed, 23 Oct 2024 18:00:35 +0000 (-0400) Subject: mds: encode optmetadata in InodeStat sent to clients X-Git-Tag: v20.0.0^2~32 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6c891f96aaef5be7bc90b166d5a728516370349b;p=ceph.git mds: encode optmetadata in InodeStat sent to clients Deliberately do not dump the entire struct. Some metadata may not be appropriate to share to clients. Signed-off-by: Patrick Donnelly Fixes: https://tracker.ceph.com/issues/66373 --- diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index e83b562a1f96a..57041fcce8ab3 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -3956,7 +3956,24 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session, } else { xattr_version = 0; } - + + bufferlist optmdbl; + { + decltype(InodeStat::optmetadata) optmetadata; + using kind_t = decltype(optmetadata)::optkind_t; + + auto* csp = get_charmap(); + if (csp) { + dout(25) << *csp << dendl; + auto& opt = optmetadata.get_or_create_opt(kind_t::CHARMAP); + auto& cs = opt.template get_meta< charmap_md_t >(); + cs = *csp; + dout(25) << "cs now " << cs << dendl; + } + + encode(optmetadata, optmdbl); + } + // do we have room? if (max_bytes) { unsigned bytes = @@ -3970,6 +3987,7 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session, sizeof(struct ceph_dir_layout) // dir_layout + 4 + file_i->fscrypt_auth.size() // len + data + 4 + file_i->fscrypt_file.size() // len + data + + optmdbl.length() ; if (xattr_version) { @@ -4124,7 +4142,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(7, 1, bl); + ENCODE_START(8, 1, bl); encode(std::tuple{ oi->ino, snapid, @@ -4176,6 +4194,8 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session, encode(!file_i->fscrypt_auth.empty(), bl); encode(file_i->fscrypt_auth, bl); encode(file_i->fscrypt_file, bl); + encode_nohead(optmdbl, bl); + // encode inodestat ENCODE_FINISH(bl); } else { diff --git a/src/messages/MClientReply.h b/src/messages/MClientReply.h index a18c595edb175..be34e8d4f7cc2 100644 --- a/src/messages/MClientReply.h +++ b/src/messages/MClientReply.h @@ -115,6 +115,8 @@ struct DirStat { }; struct InodeStat { + using optmetadata_singleton_client_t = optmetadata_singleton,std::allocator>; + vinodeno_t vino; uint32_t rdev = 0; version_t version = 0; @@ -149,12 +151,18 @@ struct InodeStat { std::vector fscrypt_auth; std::vector fscrypt_file; + optmetadata_multiton optmetadata; + public: InodeStat() {} InodeStat(ceph::buffer::list::const_iterator& p, const uint64_t features) { decode(p, features); } + void print(std::ostream& os) const { + os << "InodeStat(... " << optmetadata << ")"; + } + void decode(ceph::buffer::list::const_iterator &p, const uint64_t features) { using ceph::decode; if (features == (uint64_t)-1) { @@ -221,6 +229,9 @@ struct InodeStat { decode(fscrypt_auth, p); decode(fscrypt_file, p); } + if (struct_v >= 8) { + decode(optmetadata, p); + } DECODE_FINISH(p); } else {