mon/OSDMonitor: move (removed, purged) snap update into a helper

This is trivial at the moment, but we'll make it clever next.

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2019-06-07 10:57:04 -05:00
parent c0233801a8
commit 1e7718c37c
2 changed files with 26 additions and 9 deletions

View File

@ -1582,21 +1582,18 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t)
for (auto q = i.second.begin();
q != i.second.end();
++q) {
bufferlist v;
string k = make_removed_snap_key_value(i.first, q.get_start(),
q.get_len(), pending_inc.epoch, &v);
t->put(OSD_SNAP_PREFIX, k, v);
insert_snap_update(false, i.first, q.get_start(), q.get_end(),
pending_inc.epoch,
t);
}
}
for (auto& i : pending_inc.new_purged_snaps) {
for (auto q = i.second.begin();
q != i.second.end();
++q) {
bufferlist v;
string k = make_snap_purged_key_value(i.first, q.get_start(),
q.get_len(), pending_inc.epoch,
&v);
t->put(OSD_SNAP_PREFIX, k, v);
insert_snap_update(true, i.first, q.get_start(), q.get_end(),
pending_inc.epoch,
t);
}
}
@ -6271,6 +6268,19 @@ int OSDMonitor::_lookup_snap(bool purged,
return 0;
}
void OSDMonitor::insert_snap_update(
bool purged,
int64_t pool,
snapid_t start, snapid_t end,
epoch_t epoch,
MonitorDBStore::TransactionRef t)
{
bufferlist v;
string k = _make_snap_key_value(purged, pool, start, end - start,
pending_inc.epoch, &v);
t->put(OSD_SNAP_PREFIX, k, v);
}
bool OSDMonitor::try_prune_purged_snaps()
{
if (!mon->mgrstatmon()->is_readable()) {

View File

@ -536,6 +536,13 @@ private:
return _lookup_snap(true, pool, snap, begin,end);
}
void insert_snap_update(
bool purged,
int64_t pool,
snapid_t start, snapid_t end,
epoch_t epoch,
MonitorDBStore::TransactionRef t);
bool prepare_set_flag(MonOpRequestRef op, int flag);
bool prepare_unset_flag(MonOpRequestRef op, int flag);