Skip to content

Commit

Permalink
osd: handle trim() during backfill and async recovery
Browse files Browse the repository at this point in the history
Signed-off-by: Neha Ojha <nojha@redhat.com>
(cherry picked from commit e538c31)
  • Loading branch information
neha-ojha committed Aug 2, 2018
1 parent ab597ad commit 62ff545
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
10 changes: 8 additions & 2 deletions src/osd/PG.cc
Expand Up @@ -3621,7 +3621,8 @@ void PG::append_log(
eversion_t trim_to,
eversion_t roll_forward_to,
ObjectStore::Transaction &t,
bool transaction_applied)
bool transaction_applied,
bool async)
{
if (transaction_applied)
update_snap_map(logv, t);
Expand Down Expand Up @@ -3676,7 +3677,12 @@ void PG::append_log(

dout(10) << __func__ << " approx pg log length = "
<< pg_log.get_log().approx_size() << dendl;
pg_log.trim(trim_to, info);
dout(10) << __func__ << " transaction_applied = "
<< transaction_applied << dendl;
if (!transaction_applied || async)
dout(10) << __func__ << " " << pg_whoami
<< " is async_recovery or backfill target" << dendl;
pg_log.trim(trim_to, info, transaction_applied, async);

// update the local pg, pg log
dirty_info = true;
Expand Down
3 changes: 2 additions & 1 deletion src/osd/PG.h
Expand Up @@ -2885,7 +2885,8 @@ class PG : public DoutPrefixProvider {
eversion_t trim_to,
eversion_t roll_forward_to,
ObjectStore::Transaction &t,
bool transaction_applied = true);
bool transaction_applied = true,
bool async = false);
bool check_log_for_corruption(ObjectStore *store);
void trim_log();

Expand Down
9 changes: 6 additions & 3 deletions src/osd/PGLog.cc
Expand Up @@ -161,13 +161,16 @@ void PGLog::clear_info_log(

void PGLog::trim(
eversion_t trim_to,
pg_info_t &info)
pg_info_t &info,
bool transaction_applied,
bool async)
{
dout(10) << __func__ << " proposed trim_to = " << trim_to << dendl;
// trim?
if (trim_to > log.tail) {
// We shouldn't be trimming the log past last_complete
assert(trim_to <= info.last_complete);
// Don't assert for async_recovery_targets or backfill_targets
if (transaction_applied && !async)
assert(trim_to <= info.last_complete);

dout(10) << "trim " << log << " to " << trim_to << dendl;
log.trim(cct, trim_to, &trimmed, &trimmed_dups, &write_from_dups);
Expand Down
4 changes: 3 additions & 1 deletion src/osd/PGLog.h
Expand Up @@ -704,7 +704,9 @@ struct PGLog : DoutPrefixProvider {

void trim(
eversion_t trim_to,
pg_info_t &info);
pg_info_t &info,
bool transaction_applied = true,
bool async = false);

void roll_forward_to(
eversion_t roll_forward_to,
Expand Down
2 changes: 1 addition & 1 deletion src/osd/PrimaryLogPG.h
Expand Up @@ -421,7 +421,7 @@ class PrimaryLogPG : public PG, public PGBackend::Listener {
if (hset_history) {
info.hit_set = *hset_history;
}
append_log(logv, trim_to, roll_forward_to, t, transaction_applied);
append_log(logv, trim_to, roll_forward_to, t, transaction_applied, async);
}

void op_applied(const eversion_t &applied_version) override;
Expand Down

0 comments on commit 62ff545

Please sign in to comment.