From 4435097738d5eb20ff08375b95f6c2a0a9a05fac Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 18 Aug 2008 13:23:37 -0700 Subject: [PATCH] osd: sync on finish_recovery, but don't block --- src/osd/PG.cc | 30 +++++++++++++++++++++++++----- src/osd/PG.h | 7 ++++++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 9cbafcf4bc3e2..6874a93b9ae7b 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -1123,22 +1123,42 @@ void PG::activate(ObjectStore::Transaction& t, } +struct C_PG_FinishRecovery : public Context { + PG *pg; + C_PG_FinishRecovery(PG *p) : pg(p) {} + void finish(int r) { + pg->_finish_recovery(this); + } +}; + void PG::finish_recovery() { dout(10) << "finish_recovery" << dendl; state_set(PG_STATE_CLEAN); assert(info.last_complete == info.last_update); + /* + * sync all this before purging strays. but don't block! + */ + finish_sync_event = new C_PG_FinishRecovery(this); + ObjectStore::Transaction t; bufferlist bl; ::encode(info, bl); t.collection_setattr(info.pgid.to_coll(), "info", bl); - osd->store->apply_transaction(t); - //osd->store->sync(); -#warning fix finish_recovery sync behavior + osd->store->apply_transaction(t, finish_sync_event); +} - purge_strays(); - update_stats(); +void PG::_finish_recovery(Context *c) +{ + lock(); + if (c == finish_sync_event) { + finish_sync_event = 0; + dout(10) << "_finish_recovery" << dendl; + purge_strays(); + update_stats(); + } + unlock(); } diff --git a/src/osd/PG.h b/src/osd/PG.h index b4f4938dc7f1e..46875f4fcdf2b 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -609,7 +609,11 @@ public: void purge_strays(); + + Context *finish_sync_event; + void finish_recovery(); + void _finish_recovery(Context *c); loff_t get_log_write_pos() { return 0; @@ -627,7 +631,8 @@ public: have_master_log(true), must_notify_mon(false), stat_num_bytes(0), stat_num_blocks(0), - pg_stats_valid(false) + pg_stats_valid(false), + finish_sync_event(NULL) { } virtual ~PG() { } -- 2.39.5