From 89a25e9fe1d2478a3cc6f5afc6a210f348f3da82 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 15 Jun 2025 14:08:18 +0800 Subject: [PATCH] mds/flock: exclude non-persisted fields from ceph_lock_state_t::dump() Commit 09f3c879 added ceph_lock_state_t to ceph-dencoder verification, but some fields are intentionally not persisted, causing test failures in readable.sh and check-generated.sh due to encode/decode mismatches. The following fields are excluded from dump() as they are not persisted: - type: always set in constructor, no need to persist - waiting_locks: runtime-only field for active lock management - client_waiting_lock_counts: runtime-only field for client tracking Current tests pass by reusing instances (preserving non-persisted fields), but upcoming changes will use fresh instances per decode, exposing this inconsistency. This change ensures dump() output matches what is actually encoded/decoded, fixing test compatibility with the new allocation strategy. Signed-off-by: Kefu Chai --- src/mds/flock.cc | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/mds/flock.cc b/src/mds/flock.cc index 647d0a94d07..eaa953c3ef8 100644 --- a/src/mds/flock.cc +++ b/src/mds/flock.cc @@ -59,7 +59,10 @@ void ceph_lock_state_t::decode(ceph::bufferlist::const_iterator& bl) { } void ceph_lock_state_t::dump(ceph::Formatter *f) const { - f->dump_int("type", type); + // do not dump fields which are not persisted: + // - type: set in constructor + // - waiting_locks: runtime-only field + // - client_waiting_lock_counts: runtime-only field f->dump_int("held_locks", held_locks.size()); for (auto &p : held_locks) { f->open_object_section("lock"); @@ -71,17 +74,6 @@ void ceph_lock_state_t::dump(ceph::Formatter *f) const { f->dump_int("type", p.second.type); f->close_section(); } - f->dump_int("waiting_locks", waiting_locks.size()); - for (auto &p : waiting_locks) { - f->open_object_section("lock"); - f->dump_int("start", p.second.start); - f->dump_int("length", p.second.length); - f->dump_int("client", p.second.client); - f->dump_int("owner", p.second.owner); - f->dump_int("pid", p.second.pid); - f->dump_int("type", p.second.type); - f->close_section(); - } f->dump_int("client_held_lock_counts", client_held_lock_counts.size()); for (auto &p : client_held_lock_counts) { f->open_object_section("client"); @@ -89,7 +81,6 @@ void ceph_lock_state_t::dump(ceph::Formatter *f) const { f->dump_int("count", p.second); f->close_section(); } - f->dump_int("client_waiting_lock_counts", client_waiting_lock_counts.size()); } -- 2.39.5