]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: note txc seq for tail cache
authorSage Weil <sage@redhat.com>
Mon, 21 Mar 2016 19:44:54 +0000 (15:44 -0400)
committerSage Weil <sage@redhat.com>
Wed, 30 Mar 2016 15:23:14 +0000 (11:23 -0400)
We'll need this soon...

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 9045fffac23f0f15e7d616d59924f975794dff0a..16464cdf419ed7892b7f95f4f21372faa01a7ebf 100644 (file)
@@ -4943,6 +4943,7 @@ void BlueStore::_dump_onode(OnodeRef o, int log_level)
 }
 
 void BlueStore::_pad_zeros(
+  TransContext *txc,
   OnodeRef o,
   bufferlist *bl, uint64_t *offset, uint64_t *length,
   uint64_t block_size)
@@ -4991,6 +4992,7 @@ void BlueStore::_pad_zeros(
       o->tail_bl.clear();
       o->tail_bl.append(tail, 0, back_copy);
       o->tail_offset = end - back_copy;
+      o->tail_txc_seq = txc->seq;
       dout(20) << __func__ << " cached "<< back_copy << " of tail block at "
               << o->tail_offset << dendl;
     }
@@ -5037,6 +5039,7 @@ void BlueStore::_pad_zeros_head(
 }
 
 void BlueStore::_pad_zeros_tail(
+  TransContext *txc,
   OnodeRef o,
   bufferlist *bl, uint64_t offset, uint64_t *length,
   uint64_t block_size)
@@ -5073,6 +5076,7 @@ void BlueStore::_pad_zeros_tail(
     o->tail_bl.clear();
     o->tail_bl.append(tail, 0, back_copy);
     o->tail_offset = end - back_copy;
+    o->tail_txc_seq = txc->seq;
     dout(20) << __func__ << " cached "<< back_copy << " of tail block at "
             << o->tail_offset << dendl;
   }
@@ -5496,7 +5500,7 @@ int BlueStore::_do_write(
        offset >= o->onode.size &&                                  // past eof +
        (offset / block_size != (o->onode.size - 1) / block_size)) {// diff block
       dout(20) << __func__ << " append" << dendl;
-      _pad_zeros(o, &bl, &offset, &length, block_size);
+      _pad_zeros(txc, o, &bl, &offset, &length, block_size);
       assert(offset % block_size == 0);
       assert(length % block_size == 0);
       uint64_t x_off = offset - bp->first;
@@ -5565,7 +5569,7 @@ int BlueStore::_do_write(
             offset == bp->first);
       bp->second.clear_flag(bluestore_extent_t::FLAG_COW_HEAD);
       bp->second.clear_flag(bluestore_extent_t::FLAG_UNWRITTEN);
-      _pad_zeros(o, &bl, &offset, &length, block_size);
+      _pad_zeros(txc, o, &bl, &offset, &length, block_size);
       uint64_t x_off = offset - bp->first;
       dout(20) << __func__ << " write " << offset << "~" << length
               << " x_off " << x_off << dendl;
@@ -5609,7 +5613,7 @@ int BlueStore::_do_write(
        _pad_zeros_head(o, &bl, &offset, &length, block_size);
       }
       if (((offset + length) & ~block_mask) != 0 && !cow_rmw_tail) {
-       _pad_zeros_tail(o, &bl, offset, &length, block_size);
+       _pad_zeros_tail(txc, o, &bl, offset, &length, block_size);
       }
       if ((offset & ~block_mask) == 0 && (length & ~block_mask) == 0) {
        uint64_t x_off = offset - bp->first;
@@ -5643,7 +5647,7 @@ int BlueStore::_do_write(
     } else if (((offset + length) & ~block_mask) &&
               offset + length > o->onode.size) {
       dout(20) << __func__ << " past eof, padding out tail block" << dendl;
-      _pad_zeros_tail(o, &bl, offset, &length, block_size);
+      _pad_zeros_tail(txc, o, &bl, offset, &length, block_size);
     }
     bp->second.clear_flag(bluestore_extent_t::FLAG_COW_HEAD);
     bp->second.clear_flag(bluestore_extent_t::FLAG_COW_TAIL);
index d21dc05ed194e9909f8a00f7213f2ef4deec0fde..ffd48fc639cf5c737ce4e8382a9a410ba2430914 100644 (file)
@@ -136,7 +136,8 @@ public:
     std::condition_variable flush_cond;   ///< wait here for unapplied txns
     set<TransContext*> flush_txns;   ///< committing or wal txns
 
-    uint64_t tail_offset;
+    uint64_t tail_offset = 0;
+    uint64_t tail_txc_seq = 0;
     bufferlist tail_bl;
 
     Onode(const ghobject_t& o, const string& k)
@@ -842,12 +843,14 @@ private:
   int _do_write_overlays(TransContext *txc, CollectionRef& c, OnodeRef o,
                         uint64_t offset, uint64_t length);
   void _do_read_all_overlays(bluestore_wal_op_t& wo);
-  void _pad_zeros(OnodeRef o, bufferlist *bl, uint64_t *offset, uint64_t *length,
+  void _pad_zeros(TransContext *txc,
+                 OnodeRef o, bufferlist *bl, uint64_t *offset, uint64_t *length,
                  uint64_t block_size);
   void _pad_zeros_head(OnodeRef o, bufferlist *bl,
                       uint64_t *offset, uint64_t *length,
                       uint64_t block_size);
-  void _pad_zeros_tail(OnodeRef o, bufferlist *bl,
+  void _pad_zeros_tail(TransContext *txc,
+                      OnodeRef o, bufferlist *bl,
                       uint64_t offset, uint64_t *length,
                       uint64_t block_size);
   int _do_allocate(TransContext *txc,