]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: make fastinfo apply conditionally
authorSage Weil <sage@redhat.com>
Thu, 6 Oct 2016 16:44:03 +0000 (12:44 -0400)
committerSage Weil <sage@redhat.com>
Tue, 18 Oct 2016 13:26:31 +0000 (09:26 -0400)
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 <sage@redhat.com>
src/osd/PG.cc
src/osd/osd_types.h

index d902aac9b33eebbcbd2d146b120cc0956794c385..8f4ed7d072ca01510ecbf2ec0e2ba09b6fe99009 100644 (file)
@@ -2801,10 +2801,12 @@ int PG::_prepare_write_info(map<string,bufferlist> *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<string,bufferlist> *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,
index 80367a4e184e85dd67f15ff164467646d9bf0adb..e53f88799518b2e2f0c1bee5e1550f2f386b3a2f 100644 (file)
@@ -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 {