From f3b8b52550e4ac8f943bac27adf35902c3371b16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Henriques?= Date: Wed, 2 Mar 2022 16:46:16 +0000 Subject: [PATCH] mds: add support for snapshots alternate_name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luís Henriques --- src/mds/Server.cc | 3 +++ src/mds/snap.cc | 8 ++++++-- src/mds/snap.h | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mds/Server.cc b/src/mds/Server.cc index b87264c3ee3ec..7eef27352f47e 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -10332,8 +10332,10 @@ void Server::handle_client_lssnap(MDRequestRef& mdr) break; encode(snap_name, dnbl); + //infinite lease LeaseStat e(CEPH_LEASE_VALID, -1, 0); + e.alternate_name = std::string(p->second->alternate_name); mds->locker->encode_lease(dnbl, mdr->session->info, e); dout(20) << "encode_infinite_lease" << dendl; @@ -10496,6 +10498,7 @@ void Server::handle_client_mksnap(MDRequestRef& mdr) info.ino = diri->ino(); info.snapid = snapid; info.name = snapname; + info.alternate_name = req->get_alternate_name(); info.stamp = mdr->get_op_stamp(); info.metadata = payload.metadata; diff --git a/src/mds/snap.cc b/src/mds/snap.cc index c5b8728e92714..625e345e890ef 100644 --- a/src/mds/snap.cc +++ b/src/mds/snap.cc @@ -25,18 +25,19 @@ using namespace std; void SnapInfo::encode(bufferlist& bl) const { - ENCODE_START(3, 2, bl); + ENCODE_START(4, 2, bl); encode(snapid, bl); encode(ino, bl); encode(stamp, bl); encode(name, bl); encode(metadata, bl); + encode(alternate_name, bl); ENCODE_FINISH(bl); } void SnapInfo::decode(bufferlist::const_iterator& bl) { - DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl); + DECODE_START_LEGACY_COMPAT_LEN(4, 2, 2, bl); decode(snapid, bl); decode(ino, bl); decode(stamp, bl); @@ -44,6 +45,9 @@ void SnapInfo::decode(bufferlist::const_iterator& bl) if (struct_v >= 3) { decode(metadata, bl); } + if (struct_v >= 4) { + decode(alternate_name, bl); + } DECODE_FINISH(bl); } diff --git a/src/mds/snap.h b/src/mds/snap.h index f8b5b701af46f..012e944d92d32 100644 --- a/src/mds/snap.h +++ b/src/mds/snap.h @@ -38,6 +38,7 @@ struct SnapInfo { inodeno_t ino; utime_t stamp; std::string name; + std::string alternate_name; mutable std::string long_name; ///< cached _$ino_$name std::map metadata;