]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mds/flock: exclude non-persisted fields from ceph_lock_state_t::dump()
authorKefu Chai <tchaikov@gmail.com>
Sun, 15 Jun 2025 06:08:18 +0000 (14:08 +0800)
committerKefu Chai <tchaikov@gmail.com>
Sun, 15 Jun 2025 06:44:41 +0000 (14:44 +0800)
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 <tchaikov@gmail.com>
src/mds/flock.cc

index 647d0a94d07a4c4d52b7a3df7eb42cc0718760d8..eaa953c3ef89a528c4c4e459a0da522260abc5ff 100644 (file)
@@ -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());
 }