From: Ning Yao Date: Wed, 25 Nov 2015 15:00:52 +0000 (+0800) Subject: osd: don't update unneccessary epoch for pg X-Git-Tag: v10.0.2~126^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2b390fc2acd92ba450c3728e1159397eb0956a86;p=ceph.git osd: don't update unneccessary epoch for pg epoch always remains unless state of cluster changes. Therefore, avoid update epoch for every Op in order to same cpu cost and disk bandwidth. Signed-off-by: Ning Yao --- diff --git a/src/osd/PG.cc b/src/osd/PG.cc index b5a743bf3f8d..2d4b51c174b0 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -218,7 +218,8 @@ PG::PG(OSDService *o, OSDMapRef curmap, peer_features(CEPH_FEATURES_SUPPORTED_DEFAULT), acting_features(CEPH_FEATURES_SUPPORTED_DEFAULT), upacting_features(CEPH_FEATURES_SUPPORTED_DEFAULT), - do_sort_bitwise(false) + do_sort_bitwise(false), + last_epoch(0) { #ifdef PG_DEBUG_REFS osd->add_pgid(p, this); @@ -2657,11 +2658,13 @@ int PG::_prepare_write_info(map *km, pg_info_t &info, coll_t coll, map &past_intervals, ghobject_t &pgmeta_oid, - bool dirty_big_info) + bool dirty_big_info, + bool dirty_epoch) { // info. store purged_snaps separately. interval_set purged_snaps; - ::encode(epoch, (*km)[epoch_key]); + if (dirty_epoch) + ::encode(epoch, (*km)[epoch_key]); purged_snaps.swap(info.purged_snaps); ::encode(info, (*km)[info_key]); purged_snaps.swap(info.purged_snaps); @@ -2711,10 +2714,13 @@ void PG::prepare_write_info(map *km) info.stats.stats.add(unstable_stats); unstable_stats.clear(); + bool need_update_epoch = last_epoch < get_osdmap()->get_epoch(); int ret = _prepare_write_info(km, get_osdmap()->get_epoch(), info, coll, past_intervals, pgmeta_oid, - dirty_big_info); + dirty_big_info, need_update_epoch); assert(ret == 0); + if (need_update_epoch) + last_epoch = get_osdmap()->get_epoch(); last_persisted_osdmap_ref = osdmap_ref; dirty_info = false; diff --git a/src/osd/PG.h b/src/osd/PG.h index 4f8ef48e21db..24b7fd15503b 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -2043,6 +2043,7 @@ public: uint64_t upacting_features; bool do_sort_bitwise; + epoch_t last_epoch; public: const spg_t& get_pgid() const { return pg_id; } @@ -2161,7 +2162,8 @@ public: pg_info_t &info, coll_t coll, map &past_intervals, ghobject_t &pgmeta_oid, - bool dirty_big_info); + bool dirty_big_info, + bool dirty_epoch); void write_if_dirty(ObjectStore::Transaction& t); eversion_t get_next_version() const { diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index 11de3bc32b48..8eb7dcf534b5 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -530,7 +530,7 @@ int write_info(ObjectStore::Transaction &t, epoch_t epoch, pg_info_t &info, info, coll, past_intervals, pgmeta_oid, - true); + true, true); if (ret) cerr << "Failed to write info" << std::endl; t.omap_setkeys(coll, pgmeta_oid, km); return ret;