From: Sage Weil Date: Thu, 9 Mar 2017 14:38:50 +0000 (-0500) Subject: os/bluestore: write padded data into buffer cache X-Git-Tag: v12.0.1~12^2~40 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bcd2a32912128970943f0376ec66257b886fd0b4;p=ceph.git os/bluestore: write padded data into buffer cache 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 --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 03bb73528aa..c0821f969d4 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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; diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 6f72ba3d875..19dbd220fe4 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -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 l(cache->lock); Buffer *b = new Buffer(this, Buffer::STATE_WRITING, seq, offset, bl, flags);