From 62ff545c01acbd5cd3837230a61a853ff0db2595 Mon Sep 17 00:00:00 2001 From: Neha Ojha Date: Mon, 16 Jul 2018 16:31:22 -0700 Subject: [PATCH] osd: handle trim() during backfill and async recovery Signed-off-by: Neha Ojha (cherry picked from commit e538c31f0f3133f811a8e478fcb25b575cad66bf) --- src/osd/PG.cc | 10 ++++++++-- src/osd/PG.h | 3 ++- src/osd/PGLog.cc | 9 ++++++--- src/osd/PGLog.h | 4 +++- src/osd/PrimaryLogPG.h | 2 +- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index c386e4c2fdc..c3fb6ef7c13 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -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); @@ -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; diff --git a/src/osd/PG.h b/src/osd/PG.h index 31cda1b7128..136368a1990 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -2885,7 +2885,8 @@ protected: 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(); diff --git a/src/osd/PGLog.cc b/src/osd/PGLog.cc index d5557fc9365..ef9426613e6 100644 --- a/src/osd/PGLog.cc +++ b/src/osd/PGLog.cc @@ -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); diff --git a/src/osd/PGLog.h b/src/osd/PGLog.h index 7c016077324..3ef21d553b5 100644 --- a/src/osd/PGLog.h +++ b/src/osd/PGLog.h @@ -704,7 +704,9 @@ public: 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, diff --git a/src/osd/PrimaryLogPG.h b/src/osd/PrimaryLogPG.h index f4ee21b23c3..1d3737dfb56 100644 --- a/src/osd/PrimaryLogPG.h +++ b/src/osd/PrimaryLogPG.h @@ -421,7 +421,7 @@ public: 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; -- 2.47.3