]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: use PG::write_if_dirty() helper
authorSage Weil <sage.weil@dreamhost.com>
Sun, 29 Apr 2012 14:57:10 +0000 (07:57 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Sun, 29 Apr 2012 15:11:24 +0000 (08:11 -0700)
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/osd/OSD.cc
src/osd/PG.cc
src/osd/PG.h

index f47d27719eda946ca80f3aaf8a1bb055460ca779..0b93793ea47e04ff5164275abb9a6d71df2edf48 100644 (file)
@@ -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<Context*>& tfin)
     PG::RecoveryCtx rctx(&query_map, &info_map, &notify_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<pg_t>& childpgids, ObjectStore::Transaction&
   for (map<pg_t,PG*>::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);
index cfe0698bd0c4656b35f733cf30bace9593fb6b4c..b447dd8067520777b2f8437d26aff25b7604d76b 100644 (file)
@@ -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?
index c9975f04f3723b789bb27c384b42ec970de627c5..6b107bdb550856b1f0c1098ebdc73376f6053b9d 100644 (file)
@@ -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<pg_log_entry_t>& logv, eversion_t trim_to, ObjectStore::Transaction &t);