Skip to content

Commit

Permalink
osd/PGLog: manipulate trimed entries containers more effectively
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
  • Loading branch information
ifed01 committed Nov 29, 2017
1 parent d82f5c4 commit c2e2f03
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 27 deletions.
54 changes: 31 additions & 23 deletions src/osd/PGLog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void PGLog::IndexedLog::trim(
break;
generic_dout(20) << "trim " << e << dendl;
if (trimmed)
trimmed->insert(e.version);
trimmed->emplace(e.version);

unindex(e); // remove from index,

Expand Down Expand Up @@ -591,8 +591,8 @@ void PGLog::write_log_and_missing(
dirty_to,
dirty_from,
writeout_from,
trimmed,
trimmed_dups,
&trimmed,
&trimmed_dups,
missing,
!touched_log,
require_rollback,
Expand Down Expand Up @@ -621,8 +621,8 @@ void PGLog::write_log_and_missing_wo_missing(
_write_log_and_missing_wo_missing(
t, km, log, coll, log_oid,
divergent_priors, eversion_t::max(), eversion_t(), eversion_t(),
set<eversion_t>(),
set<string>(),
nullptr,
nullptr,
true, true, require_rollback,
eversion_t::max(), eversion_t(), eversion_t(), nullptr);
}
Expand All @@ -643,8 +643,8 @@ void PGLog::write_log_and_missing(
eversion_t::max(),
eversion_t(),
eversion_t(),
set<eversion_t>(),
set<string>(),
nullptr,
nullptr,
missing,
true, require_rollback, false,
eversion_t::max(),
Expand All @@ -663,8 +663,8 @@ void PGLog::_write_log_and_missing_wo_missing(
eversion_t dirty_to,
eversion_t dirty_from,
eversion_t writeout_from,
const set<eversion_t> &trimmed,
const set<string> &trimmed_dups,
set<eversion_t> *trimmed,
set<string> *trimmed_dups,
bool dirty_divergent_priors,
bool touch_log,
bool require_rollback,
Expand All @@ -674,16 +674,20 @@ void PGLog::_write_log_and_missing_wo_missing(
set<string> *log_keys_debug
)
{
set<string> to_remove(trimmed_dups);
for (set<eversion_t>::const_iterator i = trimmed.begin();
i != trimmed.end();
set<string> to_remove;
to_remove.swap(*trimmed_dups);
for (auto i = trimmed->begin();
i != trimmed->end();
++i) {
to_remove.insert(i->get_key_name());
string key = i->get_key_name();
if (log_keys_debug) {
assert(log_keys_debug->count(i->get_key_name()));
log_keys_debug->erase(i->get_key_name());
auto it = log_keys_debug->find(key);
assert(it != log_keys_debug->end());
log_keys_debug->erase(it);
}
to_remove.emplace(std::move(key));
}
trimmed->clear();

// dout(10) << "write_log_and_missing, clearing up to " << dirty_to << dendl;
if (touch_log)
Expand Down Expand Up @@ -793,8 +797,8 @@ void PGLog::_write_log_and_missing(
eversion_t dirty_to,
eversion_t dirty_from,
eversion_t writeout_from,
const set<eversion_t> &trimmed,
const set<string> &trimmed_dups,
set<eversion_t> *trimmed,
set<string> *trimmed_dups,
const pg_missing_tracker_t &missing,
bool touch_log,
bool require_rollback,
Expand All @@ -805,16 +809,20 @@ void PGLog::_write_log_and_missing(
bool *rebuilt_missing_with_deletes, // in/out param
set<string> *log_keys_debug
) {
set<string> to_remove(trimmed_dups);
for (set<eversion_t>::const_iterator i = trimmed.begin();
i != trimmed.end();
set<string> to_remove;
to_remove.swap(*trimmed_dups);
for (auto i = trimmed->begin();
i != trimmed->end();
++i) {
to_remove.insert(i->get_key_name());
string key = i->get_key_name();
if (log_keys_debug) {
assert(log_keys_debug->count(i->get_key_name()));
log_keys_debug->erase(i->get_key_name());
auto it = log_keys_debug->find(key);
assert(it != log_keys_debug->end());
log_keys_debug->erase(it);
}
to_remove.emplace(std::move(key));
}
trimmed->clear();

if (touch_log)
t.touch(coll, log_oid);
Expand Down
8 changes: 4 additions & 4 deletions src/osd/PGLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -1221,8 +1221,8 @@ struct PGLog : DoutPrefixProvider {
eversion_t dirty_to,
eversion_t dirty_from,
eversion_t writeout_from,
const set<eversion_t> &trimmed,
const set<string> &trimmed_dups,
set<eversion_t> *trimmed,
set<string> *trimmed_dups,
bool dirty_divergent_priors,
bool touch_log,
bool require_rollback,
Expand All @@ -1240,8 +1240,8 @@ struct PGLog : DoutPrefixProvider {
eversion_t dirty_to,
eversion_t dirty_from,
eversion_t writeout_from,
const set<eversion_t> &trimmed,
const set<string> &trimmed_dups,
set<eversion_t> *trimmed,
set<string> *trimmed_dups,
const pg_missing_tracker_t &missing,
bool touch_log,
bool require_rollback,
Expand Down

0 comments on commit c2e2f03

Please sign in to comment.