From: Sage Weil Date: Thu, 6 Oct 2016 16:44:03 +0000 (-0400) Subject: osd: make fastinfo apply conditionally X-Git-Tag: v11.1.0~600^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8e86de6078b2d8d573d611a30d4689fcb7c05939;p=ceph.git osd: make fastinfo apply conditionally This way we don't have to bother deleting the fastinfo attr, which will reduce the amount of work the underlying store has to do. Signed-off-by: Sage Weil --- diff --git a/src/osd/PG.cc b/src/osd/PG.cc index d902aac9b33e..8f4ed7d072ca 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -2801,10 +2801,12 @@ int PG::_prepare_write_info(map *km, } // try to do info efficiently? - if (!dirty_big_info && try_fast_info) { + if (!dirty_big_info && try_fast_info && + info.last_update > last_written_info.last_update) { pg_fast_info_t fast; fast.populate_from(info); - fast.apply_to(&last_written_info); + bool did = fast.try_apply_to(&last_written_info); + assert(did); // we verified last_update increased above if (info == last_written_info) { ::encode(fast, (*km)[fastinfo_key]); return 0; @@ -2823,7 +2825,6 @@ int PG::_prepare_write_info(map *km, } *_dout << dendl; } - (*km)[fastinfo_key]; // erase any previous fastinfo last_written_info = info; // info. store purged_snaps separately. @@ -3126,7 +3127,7 @@ int PG::read_info( if (!p.end()) { pg_fast_info_t fast; ::decode(fast, p); - fast.apply_to(&info); + fast.try_apply_to(&info); } return 0; } @@ -3164,6 +3165,8 @@ void PG::read_state(ObjectStore *store, bufferlist &bl) info_struct_v); assert(r >= 0); + last_written_info = info; + ostringstream oss; pg_log.read_log_and_missing( store, diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 80367a4e184e..e53f88799518 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -2297,7 +2297,9 @@ struct pg_fast_info_t { stats.stats.sum.num_objects_dirty = info.stats.stats.sum.num_objects_dirty; } - void apply_to(pg_info_t* info) { + bool try_apply_to(pg_info_t* info) { + if (last_update <= info->last_update) + return false; info->last_update = last_update; info->last_complete = last_complete; info->last_user_version = last_user_version; @@ -2320,6 +2322,7 @@ struct pg_fast_info_t { info->stats.stats.sum.num_wr = stats.stats.sum.num_wr; info->stats.stats.sum.num_wr_kb = stats.stats.sum.num_wr_kb; info->stats.stats.sum.num_objects_dirty = stats.stats.sum.num_objects_dirty; + return true; } void encode(bufferlist& bl) const {