]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: write padded data into buffer cache
authorSage Weil <sage@redhat.com>
Thu, 9 Mar 2017 14:38:50 +0000 (09:38 -0500)
committerSage Weil <sage@redhat.com>
Tue, 21 Mar 2017 18:56:27 +0000 (13:56 -0500)
We rely on the buffer cache to avoid reading any deferred write data. In
order for that to work, we have to ensure the entire block whose
overwrite is deferred is in the buffer cache.  Otherwise, a write to 0~5
that results in a deferred write could break a subsequent read from 5~5
that reads the same block from disk before the deferred write lands.

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

index 03bb73528aa5ce193967775196ff0084d5a5040d..c0821f969d42e7548c9c094f6e80097c32a39315 100644 (file)
@@ -8615,9 +8615,9 @@ void BlueStore::_do_write_small(
   unsigned alloc_len = min_alloc_size;
   uint64_t b_off = P2PHASE(offset, alloc_len);
   uint64_t b_off0 = b_off;
-  _buffer_cache_write(txc, b, b_off, bl,
-                     wctx->buffered ? 0 : Buffer::FLAG_NOCACHE);
   _pad_zeros(&bl, &b_off0, block_size);
+  _buffer_cache_write(txc, b, b_off0, bl,
+                     wctx->buffered ? 0 : Buffer::FLAG_NOCACHE);
   Extent *le = o->extent_map.set_lextent(offset, b_off,
                         length, b, &wctx->old_extents);
   txc->statfs_delta.stored() += le->length;
index 6f72ba3d87551c329118027f03d871e897a2b1ec..19dbd220fe4e8309ce0e8a2c29ceb80ab3772466 100644 (file)
@@ -286,7 +286,8 @@ public:
     }
     int _discard(Cache* cache, uint32_t offset, uint32_t length);
 
-    void write(Cache* cache, uint64_t seq, uint32_t offset, bufferlist& bl, unsigned flags) {
+    void write(Cache* cache, uint64_t seq, uint32_t offset, bufferlist& bl,
+              unsigned flags) {
       std::lock_guard<std::recursive_mutex> l(cache->lock);
       Buffer *b = new Buffer(this, Buffer::STATE_WRITING, seq, offset, bl,
                             flags);