Skip to content

Commit

Permalink
os/bluestore: call fault_range properly prior to looking for blob to …
Browse files Browse the repository at this point in the history
…reuse

Fixes: https://tracker.ceph.com/issues/21312

Signed-off-by: Igor Fedotov <ifedotov@suse.com>
(cherry picked from commit e0a395e)
  • Loading branch information
ifed01 committed Apr 11, 2019
1 parent 629de1a commit 02b0553
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/os/bluestore/BlueStore.cc
Expand Up @@ -2795,7 +2795,8 @@ void BlueStore::ExtentMap::fault_range(
p->extents = decode_some(v);
p->loaded = true;
dout(20) << __func__ << " open shard 0x" << std::hex
<< p->shard_info->offset << std::dec
<< p->shard_info->offset
<< " for range 0x" << offset << "~" << length << std::dec
<< " (" << v.length() << " bytes)" << dendl;
ceph_assert(p->dirty == false);
ceph_assert(v.length() == p->shard_info->bytes);
Expand Down Expand Up @@ -11497,6 +11498,20 @@ void BlueStore::_do_write_small(
bufferlist bl;
blp.copy(length, bl);

auto max_bsize = std::max(wctx->target_blob_size, min_alloc_size);
auto min_off = offset >= max_bsize ? offset - max_bsize : 0;
uint32_t alloc_len = min_alloc_size;
auto offset0 = p2align<uint64_t>(offset, alloc_len);

bool any_change;

// search suitable extent in both forward and reverse direction in
// [offset - target_max_blob_size, offset + target_max_blob_size] range
// then check if blob can be reused via can_reuse_blob func or apply
// direct/deferred write (the latter for extents including or higher
// than 'offset' only).
o->extent_map.fault_range(db, min_off, offset + max_bsize - min_off);

// Look for an existing mutable blob we can use.
auto begin = o->extent_map.extent_map.begin();
auto end = o->extent_map.extent_map.end();
Expand All @@ -11514,18 +11529,6 @@ void BlueStore::_do_write_small(
prev_ep = end; // to avoid this extent check as it's a duplicate
}

auto max_bsize = std::max(wctx->target_blob_size, min_alloc_size);
auto min_off = offset >= max_bsize ? offset - max_bsize : 0;
uint32_t alloc_len = min_alloc_size;
auto offset0 = p2align<uint64_t>(offset, alloc_len);

bool any_change;

// search suitable extent in both forward and reverse direction in
// [offset - target_max_blob_size, offset + target_max_blob_size] range
// then check if blob can be reused via can_reuse_blob func or apply
// direct/deferred write (the latter for extents including or higher
// than 'offset' only).
do {
any_change = false;

Expand Down

0 comments on commit 02b0553

Please sign in to comment.