Skip to content

Commit 3e012f7

Browse files
committed
mds/quiesce-db: incorporate review comments
Signed-off-by: Leonid Usov <[email protected]>
1 parent 205fd33 commit 3e012f7

File tree

11 files changed

+102
-36
lines changed

11 files changed

+102
-36
lines changed

src/mds/FSMap.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
*/
1414

1515
#include <ostream>
16+
#include <algorithm>
17+
#include <ranges>
1618

1719
#include "FSMap.h"
1820
#include "common/debug.h"
@@ -868,6 +870,11 @@ void FSMap::sanity(bool pending) const
868870
ceph_assert(info.compat.writeable(fs.mds_map.compat));
869871
}
870872

873+
auto const& leader = fs.mds_map.get_quiesce_db_cluster_leader();
874+
auto const& members = fs.mds_map.get_quiesce_db_cluster_members();
875+
ceph_assert(leader == MDS_GID_NONE || members.contains(leader));
876+
ceph_assert(std::ranges::all_of(members, [&infos = fs.mds_map.mds_info](auto m){return infos.contains(m);}));
877+
871878
for (const auto &j : fs.mds_map.up) {
872879
mds_rank_t rank = j.first;
873880
ceph_assert(fs.mds_map.in.count(rank) == 1);

src/mds/MDSMap.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,15 @@ class MDSMap {
318318
members = qdb_cluster_members;
319319
}
320320

321-
mds_gid_t get_quiesce_db_cluster_leader() {
321+
mds_gid_t get_quiesce_db_cluster_leader() const {
322322
return qdb_cluster_leader;
323323
}
324324

325+
std::unordered_set<mds_gid_t> const& get_quiesce_db_cluster_members() const
326+
{
327+
return qdb_cluster_members;
328+
}
329+
325330
bool update_quiesce_db_cluster(mds_gid_t const& leader, std::same_as<std::unordered_set<mds_gid_t>> auto && members) {
326331
if (leader == qdb_cluster_leader && members == qdb_cluster_members) {
327332
return false;

src/mds/MDSRankQuiesce.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/*
2+
* Ceph - scalable distributed file system
3+
*
4+
* Copyright (C) 2024 IBM, Red Hat
5+
*
6+
* This is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License version 2.1, as published by the Free Software
9+
* Foundation. See file COPYING.
10+
*
11+
*/
12+
113
#include "MDSRank.h"
214
#include "MDCache.h"
315

src/mds/QuiesceAgent.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ void* QuiesceAgent::agent_thread_main() {
182182
dout(3) << "got error: " << rc << " trying to send " << ack << dendl;
183183
}
184184
}
185-
ack.reset();
185+
ack.clear();
186186

187187
lock.lock();
188188

src/mds/QuiesceDb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ struct QuiesceDbRequest {
464464

465465
config(*this);
466466
}
467-
void reset() {
467+
void clear() {
468468
reset([](auto&r){});
469469
}
470470

@@ -644,7 +644,7 @@ struct QuiesceMap {
644644
};
645645
using Roots = std::unordered_map<QuiesceRoot, RootInfo>;
646646
Roots roots;
647-
void reset() {
647+
void clear() {
648648
db_version = {0, 0};
649649
roots.clear();
650650
}

src/mds/QuiesceDbEncoding.h

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,20 @@
1515
#include "include/encoding.h"
1616
#include <stdint.h>
1717

18-
struct QuiesceDbEncoding {
19-
static constexpr int version = 1;
20-
static constexpr int compat = 1;
21-
};
22-
2318
void encode(QuiesceDbVersion const& v, bufferlist& bl, uint64_t features = 0)
2419
{
20+
ENCODE_START(1, 1, bl);
2521
encode(v.epoch, bl, features);
2622
encode(v.set_version, bl, features);
23+
ENCODE_FINISH(bl);
2724
}
2825

2926
void decode(QuiesceDbVersion& v, bufferlist::const_iterator& p)
3027
{
28+
DECODE_START(1, p);
3129
decode(v.epoch, p);
3230
decode(v.set_version, p);
31+
DECODE_FINISH(p);
3332
}
3433

3534
void encode(QuiesceState const & state, bufferlist& bl, uint64_t features=0)
@@ -60,126 +59,162 @@ void decode(QuiesceTimeInterval & interval, bufferlist::const_iterator& p)
6059

6160
void encode(RecordedQuiesceState const& rstate, bufferlist& bl, uint64_t features = 0)
6261
{
62+
ENCODE_START(1, 1, bl);
6363
encode(rstate.state, bl, features);
6464
encode(rstate.at_age.count(), bl, features);
65+
ENCODE_FINISH(bl);
6566
}
6667

6768
void decode(RecordedQuiesceState& rstate, bufferlist::const_iterator& p)
6869
{
70+
DECODE_START(1, p);
6971
decode(rstate.state, p);
7072
decode(rstate.at_age, p);
73+
DECODE_FINISH(p);
7174
}
7275

7376
void encode(QuiesceSet::MemberInfo const& member, bufferlist& bl, uint64_t features = 0)
7477
{
78+
ENCODE_START(1, 1, bl);
7579
encode(member.rstate, bl, features);
7680
encode(member.excluded, bl, features);
81+
ENCODE_FINISH(bl);
7782
}
7883

7984
void decode(QuiesceSet::MemberInfo& member, bufferlist::const_iterator& p)
8085
{
86+
DECODE_START(1, p);
8187
decode(member.rstate, p);
8288
decode(member.excluded, p);
89+
DECODE_FINISH(p);
8390
}
8491

8592
void encode(QuiesceSet const& set, bufferlist& bl, uint64_t features = 0)
8693
{
94+
ENCODE_START(1, 1, bl);
8795
encode(set.version, bl, features);
8896
encode(set.rstate, bl, features);
89-
encode(set.timeout, bl, features);
90-
encode(set.expiration, bl, features);
97+
::encode(set.timeout, bl, features);
98+
::encode(set.expiration, bl, features);
9199
encode(set.members, bl, features);
100+
ENCODE_FINISH(bl);
92101
}
93102

94103
void decode(QuiesceSet& set, bufferlist::const_iterator& p)
95104
{
105+
DECODE_START(1, p);
96106
decode(set.version, p);
97107
decode(set.rstate, p);
98-
decode(set.timeout, p);
99-
decode(set.expiration, p);
108+
::decode(set.timeout, p);
109+
::decode(set.expiration, p);
100110
decode(set.members, p);
111+
DECODE_FINISH(p);
101112
}
102113

103114
void encode(QuiesceDbRequest const& req, bufferlist& bl, uint64_t features = 0)
104115
{
116+
ENCODE_START(1, 1, bl);
105117
encode(req.control.raw, bl, features);
106118
encode(req.set_id, bl);
107119
encode(req.if_version, bl);
108120
encode(req.timeout, bl);
109121
encode(req.expiration, bl);
110122
encode(req.await, bl);
111123
encode(req.roots, bl);
124+
ENCODE_FINISH(bl);
112125
}
113126

114127
void decode(QuiesceDbRequest& req, bufferlist::const_iterator& p)
115128
{
129+
DECODE_START(1, p);
116130
decode(req.control.raw, p);
117131
decode(req.set_id, p);
118132
decode(req.if_version, p);
119133
decode(req.timeout, p);
120134
decode(req.expiration, p);
121135
decode(req.await, p);
122136
decode(req.roots, p);
137+
DECODE_FINISH(p);
123138
}
124139

125140
void encode(QuiesceDbListing const& listing, bufferlist& bl, uint64_t features = 0)
126141
{
142+
ENCODE_START(1, 1, bl);
127143
encode(listing.db_version, bl, features);
128-
encode(listing.db_age, bl, features);
144+
::encode(listing.db_age, bl, features);
129145
encode(listing.sets, bl, features);
146+
ENCODE_FINISH(bl);
130147
}
131148

132149
void decode(QuiesceDbListing& listing, bufferlist::const_iterator& p)
133150
{
151+
DECODE_START(1, p);
134152
decode(listing.db_version, p);
135-
decode(listing.db_age, p);
153+
::decode(listing.db_age, p);
136154
decode(listing.sets, p);
155+
DECODE_FINISH(p);
137156
}
138157

139158
void encode(QuiesceDbPeerListing const& listing, bufferlist& bl, uint64_t features = 0)
140159
{
160+
ENCODE_START(1, 1, bl);
141161
encode(listing.origin, bl, features);
142162
encode(listing.db, bl, features);
163+
ENCODE_FINISH(bl);
143164
}
144165

145166
void decode(QuiesceDbPeerListing& listing, bufferlist::const_iterator& p)
146167
{
168+
DECODE_START(1, p);
147169
decode(listing.origin, p);
148170
decode(listing.db, p);
171+
DECODE_FINISH(p);
149172
}
150173

151174
void encode(QuiesceMap::RootInfo const& root, bufferlist& bl, uint64_t features = 0)
152175
{
176+
ENCODE_START(1, 1, bl);
153177
encode(root.state, bl, features);
154-
encode(root.ttl, bl, features);
178+
::encode(root.ttl, bl, features);
179+
ENCODE_FINISH(bl);
155180
}
156181

157182
void decode(QuiesceMap::RootInfo& root, bufferlist::const_iterator& p)
158183
{
184+
DECODE_START(1, p);
159185
decode(root.state, p);
160-
decode(root.ttl, p);
186+
::decode(root.ttl, p);
187+
DECODE_FINISH(p);
161188
}
162189

163190
void encode(QuiesceMap const& map, bufferlist& bl, uint64_t features = 0)
164191
{
192+
ENCODE_START(1, 1, bl);
165193
encode(map.db_version, bl, features);
166194
encode(map.roots, bl, features);
195+
ENCODE_FINISH(bl);
167196
}
168197

169198
void decode(QuiesceMap& map, bufferlist::const_iterator& p)
170199
{
200+
DECODE_START(1, p);
171201
decode(map.db_version, p);
172202
decode(map.roots, p);
203+
DECODE_FINISH(p);
173204
}
174205

175206
void encode(QuiesceDbPeerAck const& ack, bufferlist& bl, uint64_t features = 0)
176207
{
208+
ENCODE_START(1, 1, bl);
177209
encode(ack.origin, bl, features);
178210
encode(ack.diff_map, bl, features);
211+
ENCODE_FINISH(bl);
179212
}
180213

181214
void decode(QuiesceDbPeerAck& ack, bufferlist::const_iterator& p)
182215
{
216+
DECODE_START(1, p);
183217
decode(ack.origin, p);
184218
decode(ack.diff_map, p);
219+
DECODE_FINISH(p);
185220
}

src/mds/QuiesceDbManager.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ void QuiesceDbManager::leader_record_ack(QuiesceInterface::PeerId from, QuiesceM
421421
if (diff_map.db_version > db_version()) {
422422
dout(3) << "ignoring unknown version ack by rank " << from << " (" << diff_map.db_version << " > " << db_version() << ")" << dendl;
423423
dout(5) << "will send the peer a full DB" << dendl;
424-
info.diff_map.reset();
424+
info.diff_map.clear();
425425
} else {
426426
info.diff_map = std::move(diff_map);
427427
info.last_seen = QuiesceClock::now();

src/messages/MMDSQuiesceDbAck.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
/*
44
* Ceph - scalable distributed file system
55
*
6-
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
6+
* Copyright (C) 2024 IBM, Red Hat
77
*
88
* This is free software; you can redistribute it and/or
99
* modify it under the terms of the GNU Lesser General Public
1010
* License version 2.1, as published by the Free Software
11-
* Foundation. See file COPYING.
11+
* Foundation. See file COPYING.
1212
*
1313
*/
1414

@@ -36,9 +36,7 @@ class MMDSQuiesceDbAck final : public MMDSOp {
3636

3737
void encode_payload_from(QuiesceDbPeerAck const& ack)
3838
{
39-
ENCODE_START(QuiesceDbEncoding::version, QuiesceDbEncoding::compat, payload);
40-
encode(ack, payload);
41-
ENCODE_FINISH(payload);
39+
::encode(ack, payload);
4240
}
4341

4442
void decode_payload() override {
@@ -48,9 +46,7 @@ class MMDSQuiesceDbAck final : public MMDSOp {
4846
void decode_payload_into(QuiesceDbPeerAck &ack) const
4947
{
5048
auto p = payload.cbegin();
51-
DECODE_START(QuiesceDbEncoding::version, p);
52-
decode(ack, p);
53-
DECODE_FINISH(p);
49+
::decode(ack, p);
5450
}
5551

5652
private:

src/messages/MMDSQuiesceDbListing.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* Ceph - scalable distributed file system
55
*
6-
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
6+
* Copyright (C) 2024 IBM, Red Hat
77
*
88
* This is free software; you can redistribute it and/or
99
* modify it under the terms of the GNU Lesser General Public
@@ -35,9 +35,7 @@ class MMDSQuiesceDbListing final : public MMDSOp {
3535

3636
void encode_payload_from(QuiesceDbPeerListing const& peer_listing)
3737
{
38-
ENCODE_START(QuiesceDbEncoding::version, QuiesceDbEncoding::compat, payload);
39-
encode(peer_listing, payload);
40-
ENCODE_FINISH(payload);
38+
::encode(peer_listing, payload);
4139
}
4240

4341
void decode_payload() override {
@@ -47,9 +45,7 @@ class MMDSQuiesceDbListing final : public MMDSOp {
4745
void decode_payload_into(QuiesceDbPeerListing &peer_listing) const
4846
{
4947
auto p = payload.cbegin();
50-
DECODE_START(QuiesceDbEncoding::version, p);
51-
decode(peer_listing, p);
52-
DECODE_FINISH(p);
48+
::decode(peer_listing, p);
5349
}
5450

5551
private:

src/test/mds/TestQuiesceAgent.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ TEST_F(QuiesceAgentTest, QuiesceProtocol) {
333333
EXPECT_EQ(1, latest_ack.roots.size());
334334
EXPECT_EQ(QS_QUIESCED, latest_ack.roots.at("root1").state);
335335

336-
latest_ack.reset();
336+
latest_ack.clear();
337337

338338
// complete the other root with failure
339339
EXPECT_TRUE(complete_quiesce("root2", -1));
@@ -344,7 +344,7 @@ TEST_F(QuiesceAgentTest, QuiesceProtocol) {
344344
EXPECT_EQ(QS_QUIESCED, latest_ack.roots.at("root1").state);
345345
EXPECT_EQ(QS_FAILED, latest_ack.roots.at("root2").state);
346346

347-
latest_ack.reset();
347+
latest_ack.clear();
348348

349349
// complete the third root with success
350350
// complete one root with success
@@ -457,7 +457,7 @@ TEST_F(QuiesceAgentTest, DuplicateQuiesceRequest) {
457457
EXPECT_TRUE(quiesce_requests.contains("root1"));
458458
EXPECT_TRUE(quiesce_requests.contains("root2"));
459459

460-
latest_ack.reset();
460+
latest_ack.clear();
461461
// now, bring the roots back
462462
{
463463
auto ack = update(3, {

0 commit comments

Comments
 (0)