From 3e84ce862ef2cdbe7ffc36e3f79cc07fb442f34a Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 29 Apr 2012 07:57:10 -0700 Subject: [PATCH] osd: use PG::write_if_dirty() helper Signed-off-by: Sage Weil --- src/osd/OSD.cc | 17 +++++++---------- src/osd/PG.cc | 8 ++++++++ src/osd/PG.h | 2 ++ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index f47d27719eda..0b93793ea47e 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -3295,8 +3295,7 @@ void OSD::handle_osd_map(MOSDMap *m) i++) { PG *pg = i->second; pg->lock_with_map_lock_held(); - if (pg->dirty_info) - pg->write_info(t); + pg->write_if_dirty(t); pg->unlock(); } } @@ -3613,8 +3612,7 @@ void OSD::activate_map(ObjectStore::Transaction& t, list& tfin) PG::RecoveryCtx rctx(&query_map, &info_map, ¬ify_list, &tfin, &t); pg->handle_activate_map(&rctx); - if (pg->dirty_info) - pg->write_info(t); + pg->write_if_dirty(t); pg->unlock(); } @@ -3929,6 +3927,7 @@ void OSD::do_split(PG *parent, set& childpgids, ObjectStore::Transaction& for (map::iterator q = children.begin(); q != children.end(); q++) { PG *pg = q->second; pg->handle_create(&rctx); + pg->write_if_dirty(t); wake_pg_waiters(pg->info.pgid); pg->unlock(); } @@ -4148,6 +4147,7 @@ void OSD::handle_pg_create(OpRequestRef op) wake_pg_waiters(pg->info.pgid); PG::RecoveryCtx rctx(&query_map, &info_map, 0, &fin->contexts, t); pg->handle_create(&rctx); + pg->write_if_dirty(*t); pg->update_stats(); int tr = store->queue_transaction(&pg->osr, t, new ObjectStore::C_DeleteTransaction(t), fin); @@ -4274,8 +4274,7 @@ void OSD::handle_pg_notify(OpRequestRef op) PG::RecoveryCtx rctx(&query_map, &info_map, 0, &fin->contexts, t); pg->handle_notify(from, it->first, &rctx); - if (pg->dirty_info) - pg->write_info(*t); + pg->write_if_dirty(*t); int tr = store->queue_transaction(&pg->osr, t, new ObjectStore::C_DeleteTransaction(t), fin); assert(tr == 0); @@ -4323,8 +4322,7 @@ void OSD::handle_pg_log(OpRequestRef op) map< int, MOSDPGInfo* > info_map; PG::RecoveryCtx rctx(&query_map, &info_map, 0, &fin->contexts, t); pg->handle_log(from, m, &rctx); - if (pg->dirty_info) - pg->write_info(*t); + pg->write_if_dirty(*t); pg->unlock(); do_queries(query_map); do_infos(info_map); @@ -4374,8 +4372,7 @@ void OSD::handle_pg_info(OpRequestRef op) PG::RecoveryCtx rctx(0, &info_map, 0, &fin->contexts, t); pg->handle_info(from, p->first, &rctx); - if (pg->dirty_info) - pg->write_info(*t); + pg->write_if_dirty(*t); int tr = store->queue_transaction(&pg->osr, t, new ObjectStore::C_DeleteTransaction(t), fin); assert(!tr); diff --git a/src/osd/PG.cc b/src/osd/PG.cc index cfe0698bd0c4..b447dd806752 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -1906,6 +1906,14 @@ void PG::write_log(ObjectStore::Transaction& t) dirty_log = false; } +void PG::write_if_dirty(ObjectStore::Transaction& t) +{ + if (dirty_info) + write_info(t); + if (dirty_log) + write_log(t); +} + void PG::trim(ObjectStore::Transaction& t, eversion_t trim_to) { // trim? diff --git a/src/osd/PG.h b/src/osd/PG.h index c9975f04f372..6b107bdb5508 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -1299,6 +1299,8 @@ public: void write_info(ObjectStore::Transaction& t); void write_log(ObjectStore::Transaction& t); + void write_if_dirty(ObjectStore::Transaction& t); + void add_log_entry(pg_log_entry_t& e, bufferlist& log_bl); void append_log(vector& logv, eversion_t trim_to, ObjectStore::Transaction &t); -- 2.47.3