From: Edwin Rodriguez Date: Wed, 8 Oct 2025 15:55:25 +0000 (-0400) Subject: mds: Avoid use of moved 'fs' in FSMap::commit_filesystem and FSMap::decode X-Git-Tag: v21.0.0~184^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=058f55c366d47493bb4fe00679f5017046a654a2;p=ceph.git mds: Avoid use of moved 'fs' in FSMap::commit_filesystem and FSMap::decode Fixes: https://tracker.ceph.com/issues/73421 Signed-off-by: Edwin Rodriguez --- diff --git a/src/mds/FSMap.cc b/src/mds/FSMap.cc index 1e063cbd8b83..b3b528877884 100644 --- a/src/mds/FSMap.cc +++ b/src/mds/FSMap.cc @@ -517,7 +517,11 @@ const Filesystem& FSMap::commit_filesystem(fs_cluster_id_t fscid, Filesystem fs) legacy_client_fscid = fs.fscid; } - auto [it, inserted] = filesystems.emplace(std::piecewise_construct, std::forward_as_tuple(fs.fscid), std::forward_as_tuple(std::move(fs))); + auto fs_fscid = fs.fscid; // Avoid use of fs after its moved + // the use and move are unsequenced, i.e. there is no guarantee about the order in which they are evaluated + auto [it, inserted] = filesystems.emplace( + std::piecewise_construct, std::forward_as_tuple(fs_fscid), + std::forward_as_tuple(std::move(fs))); ceph_assert(inserted); return it->second; } @@ -681,7 +685,11 @@ void FSMap::decode(bufferlist::const_iterator& p) for (__u32 i = 0; i < len; i++) { auto fs = Filesystem(); decode(fs, p); /* need fscid to insert into map */ - [[maybe_unused]] auto [it, inserted] = filesystems.emplace(std::piecewise_construct, std::forward_as_tuple(fs.fscid), std::forward_as_tuple(std::move(fs))); + auto fs_fscid = fs.fscid; // Avoid use of fs after its moved + // the use and move are unsequenced, i.e. there is no guarantee about the order in which they are evaluated + [[maybe_unused]] auto [it, inserted] = filesystems.emplace( + std::piecewise_construct, std::forward_as_tuple(fs_fscid), + std::forward_as_tuple(std::move(fs))); ceph_assert(inserted); } }