]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ObjectCacher: do not merge uncommitted journal bhs
authorJason Dillaman <dillaman@redhat.com>
Thu, 2 Jun 2016 04:43:53 +0000 (00:43 -0400)
committerJason Dillaman <dillaman@redhat.com>
Thu, 9 Jun 2016 18:06:15 +0000 (14:06 -0400)
Avoid the possibility of an overwrite callback for regions
that were never associated with a journal write.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit c6060ade16205337de3941a10d05e234b738fa07)

src/librbd/LibrbdWriteback.cc
src/osdc/ObjectCacher.cc
src/osdc/ObjectCacher.h

index 8551820cf90f28830b6a4baf2eb397a7ce20f11c..e3ba517849c231ce059a3cc04ffd18ec5ca690dd 100644 (file)
@@ -287,6 +287,11 @@ namespace librbd {
                                          ceph_tid_t new_journal_tid) {
     typedef std::vector<std::pair<uint64_t,uint64_t> > Extents;
 
+    ldout(m_ictx->cct, 20) << __func__ << ": " << oid << " "
+                           << off << "~" << len << " "
+                           << "journal_tid=" << original_journal_tid << ", "
+                           << "new_journal_tid=" << new_journal_tid << dendl;
+
     assert(m_ictx->owner_lock.is_locked());
     uint64_t object_no = oid_to_object_no(oid.name, m_ictx->object_prefix);
 
index 6fc815d617cf29f4e423b456f3c7924be30bf83a..7e76b3cdd6d06118f774beb3d1a1fe216d591349 100644 (file)
@@ -361,12 +361,12 @@ ObjectCacher::BufferHead *ObjectCacher::Object::map_write(ObjectExtent &ex,
     if (p == data.end()) {
       if (final == NULL) {
         final = new BufferHead(this);
+        replace_journal_tid(final, tid);
         final->set_start( cur );
         final->set_length( max );
         oc->bh_add(this, final);
         ldout(oc->cct, 10) << "map_write adding trailing bh " << *final << dendl;
       } else {
-        replace_journal_tid(final, tid);
         oc->bh_stat_sub(final);
         final->set_length(final->length() + max);
         oc->bh_stat_add(final);
@@ -375,19 +375,20 @@ ObjectCacher::BufferHead *ObjectCacher::Object::map_write(ObjectExtent &ex,
       cur += max;
       continue;
     }
-    
+
     ldout(oc->cct, 10) << "cur is " << cur << ", p is " << *p->second << dendl;
     //oc->verify_stats();
 
     if (p->first <= cur) {
       BufferHead *bh = p->second;
       ldout(oc->cct, 10) << "map_write bh " << *bh << " intersected" << dendl;
-      
+
       if (p->first < cur) {
         assert(final == 0);
         if (cur + max >= bh->end()) {
           // we want right bit (one splice)
           final = split(bh, cur);   // just split it, take right half.
+          replace_journal_tid(final, tid);
           ++p;
           assert(p->second == final);
         } else {
@@ -396,6 +397,7 @@ ObjectCacher::BufferHead *ObjectCacher::Object::map_write(ObjectExtent &ex,
           ++p;
           assert(p->second == final);
           split(final, cur+max);
+          replace_journal_tid(final, tid);
         }
       } else {
         assert(p->first == cur);
@@ -410,36 +412,37 @@ ObjectCacher::BufferHead *ObjectCacher::Object::map_write(ObjectExtent &ex,
           oc->mark_dirty(final);
           --p;  // move iterator back to final
           assert(p->second == final);
-          replace_journal_tid(bh, 0);
+          replace_journal_tid(bh, tid);
           merge_left(final, bh);
         } else {
           final = bh;
+          replace_journal_tid(final, tid);
         }
       }
-      
+
       // keep going.
       loff_t lenfromcur = final->end() - cur;
       cur += lenfromcur;
       left -= lenfromcur;
       ++p;
-      continue; 
+      continue;
     } else {
       // gap!
       loff_t next = p->first;
       loff_t glen = MIN(next - cur, max);
       ldout(oc->cct, 10) << "map_write gap " << cur << "~" << glen << dendl;
       if (final) {
-       replace_journal_tid(final, tid);
         oc->bh_stat_sub(final);
         final->set_length(final->length() + glen);
         oc->bh_stat_add(final);
       } else {
         final = new BufferHead(this);
+       replace_journal_tid(final, tid);
         final->set_start( cur );
         final->set_length( glen );
         oc->bh_add(this, final);
       }
-      
+
       cur += glen;
       left -= glen;
       continue;    // more?
@@ -448,7 +451,7 @@ ObjectCacher::BufferHead *ObjectCacher::Object::map_write(ObjectExtent &ex,
 
   // set version
   assert(final);
-  replace_journal_tid(final, tid);
+  assert(final->get_journal_tid() == tid);
   ldout(oc->cct, 10) << "map_write final is " << *final << dendl;
 
   return final;
index 0d93942c1f6752874ada4357591ba4353d0ac8a9..d136c392850cb466092d55dd558013c55c53350b 100644 (file)
@@ -201,8 +201,7 @@ class ObjectCacher {
     }
 
     inline bool can_merge_journal(BufferHead *bh) const {
-      return (get_journal_tid() == 0 || bh->get_journal_tid() == 0 ||
-             get_journal_tid() == bh->get_journal_tid());
+      return (get_journal_tid() == bh->get_journal_tid());
     }
 
     struct ptr_lt {