Skip to content

Commit 09f3c87

Browse files
committed
ceph-dencoder: MDS - Add missing types
Currently, ceph-dencoder lacks certain mds types, preventing us from accurately checking the ceph corpus for encode-decode mismatches. This pull request aims to address this issue by adding the missing types to ceph-dencoder. To successfully incorporate these types into ceph-dencoder, we need to introduce the necessary `dump` and `generate_test_instances` functions that was missing in some types. These functions are essential for proper encode and decode of the added types. This PR will enhance the functionality of ceph-dencoder by including the missing types, enabling a comprehensive analysis of encode-decode consistency. With the addition of these types, we can ensure the robustness and correctness of the ceph corpus. This update will significantly contribute to improving the overall reliability and accuracy of ceph-dencoder. It allows for a more comprehensive assessment of the encode-decode behavior, leading to enhanced data integrity and stability within the ceph ecosystem. Fixes: https://tracker.ceph.com/issues/61788 Signed-off-by: Nitzan Mordechai <[email protected]>
1 parent ac7e052 commit 09f3c87

File tree

21 files changed

+324
-26
lines changed

21 files changed

+324
-26
lines changed

src/include/cephfs/metrics/Types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,10 @@ struct ClientMetricMessage {
688688
apply_visitor(DumpPayloadVisitor(f), payload);
689689
}
690690

691+
static void generate_test_instances(std::list<ClientMetricMessage*>& ls) {
692+
ls.push_back(new ClientMetricMessage(CapInfoPayload(1, 2, 3)));
693+
}
694+
691695
void print(std::ostream *out) const {
692696
apply_visitor(PrintPayloadVisitor(out), payload);
693697
}

src/include/cephfs/types.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ struct vinodeno_t {
226226
ls.push_back(new vinodeno_t);
227227
ls.push_back(new vinodeno_t(1, 2));
228228
}
229-
230229
inodeno_t ino;
231230
snapid_t snapid;
232231
};
@@ -371,7 +370,6 @@ struct inline_data_t {
371370
void decode(ceph::buffer::list::const_iterator& bl);
372371
void dump(ceph::Formatter *f) const;
373372
static void generate_test_instances(std::list<inline_data_t*>& ls);
374-
375373
version_t version = 1;
376374

377375
private:

src/mds/Capability.cc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,8 @@ void Capability::Export::dump(ceph::Formatter *f) const
7373

7474
void Capability::Export::generate_test_instances(std::list<Capability::Export*>& ls)
7575
{
76-
ls.push_back(new Export);
77-
ls.push_back(new Export);
78-
ls.back()->wanted = 1;
79-
ls.back()->issued = 2;
80-
ls.back()->pending = 3;
81-
ls.back()->client_follows = 4;
82-
ls.back()->mseq = 5;
83-
ls.back()->last_issue_stamp = utime_t(6, 7);
76+
ls.push_back(new Export());
77+
ls.push_back(new Export(1, 2, 3, 4, 5, 6, 7, utime_t(8, 9), 10));
8478
}
8579

8680
void Capability::Import::encode(ceph::buffer::list &bl) const
@@ -108,6 +102,11 @@ void Capability::Import::dump(ceph::Formatter *f) const
108102
f->dump_unsigned("migrate_seq", mseq);
109103
}
110104

105+
void Capability::Import::generate_test_instances(std::list<Capability::Import*>& ls)
106+
{
107+
ls.push_back(new Import());
108+
ls.push_back(new Import(1, 2, 3));
109+
}
111110
/*
112111
* Capability::revoke_info
113112
*/

src/mds/Capability.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class Capability : public Counter<Capability> {
100100
void encode(ceph::buffer::list &bl) const;
101101
void decode(ceph::buffer::list::const_iterator &p);
102102
void dump(ceph::Formatter *f) const;
103+
static void generate_test_instances(std::list<Import*>& ls);
103104

104105
int64_t cap_id = 0;
105106
ceph_seq_t issue_seq = 0;

src/mds/FSMap.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ void MirrorInfo::dump(ceph::Formatter *f) const {
115115
f->close_section(); // peers
116116
}
117117

118+
void MirrorInfo::generate_test_instances(std::list<MirrorInfo*>& ls) {
119+
ls.push_back(new MirrorInfo());
120+
ls.push_back(new MirrorInfo());
121+
ls.back()->mirrored = true;
122+
ls.back()->peers.insert(Peer());
123+
ls.back()->peers.insert(Peer());
124+
}
125+
118126
void MirrorInfo::print(std::ostream& out) const {
119127
out << "[peers=" << peers << "]" << std::endl;
120128
}

src/mds/FSMap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ struct MirrorInfo {
168168
Peers peers;
169169

170170
void dump(ceph::Formatter *f) const;
171+
static void generate_test_instances(std::list<MirrorInfo*>& ls);
171172
void print(std::ostream& out) const;
172173

173174
void encode(ceph::buffer::list &bl) const;

src/mds/PurgeQueue.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ void PurgeItem::decode(bufferlist::const_iterator &p)
9999
DECODE_FINISH(p);
100100
}
101101

102+
void PurgeItem::generate_test_instances(std::list<PurgeItem*>& ls) {
103+
ls.push_back(new PurgeItem());
104+
ls.push_back(new PurgeItem());
105+
ls.back()->action = PurgeItem::PURGE_FILE;
106+
ls.back()->ino = 1;
107+
ls.back()->size = 2;
108+
ls.back()->layout = file_layout_t();
109+
ls.back()->old_pools = {1, 2};
110+
ls.back()->snapc = SnapContext();
111+
ls.back()->stamp = utime_t(3, 4);
112+
}
102113
// if Objecter has any slow requests, take that as a hint and
103114
// slow down our rate of purging
104115
PurgeQueue::PurgeQueue(

src/mds/PurgeQueue.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class PurgeItem
6161
fragtree.dump(f);
6262
f->close_section();
6363
}
64+
static void generate_test_instances(std::list<PurgeItem*>& ls);
6465

6566
std::string_view get_type_str() const;
6667

src/mds/SessionMap.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,6 @@ class SessionMapStore {
574574
}
575575

576576
static void generate_test_instances(std::list<SessionMapStore*>& ls);
577-
578577
void reset_state()
579578
{
580579
session_map.clear();

src/mds/SimpleLock.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ void SimpleLock::dump(ceph::Formatter *f) const {
4343
f->close_section();
4444
}
4545

46+
void SimpleLock::generate_test_instances(std::list<SimpleLock*>& ls) {
47+
ls.push_back(new SimpleLock);
48+
ls.push_back(new SimpleLock);
49+
ls.back()->set_state(LOCK_SYNC);
50+
}
51+
52+
4653
int SimpleLock::get_wait_shift() const {
4754
switch (get_type()) {
4855
case CEPH_LOCK_DN: return 0;

0 commit comments

Comments
 (0)