From 348ca7fc2ac99fd23ef56771b674988732788ccb Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Sat, 12 Nov 2016 16:29:30 +0800 Subject: [PATCH] os/bluestore: use built-in methods for ExtentMap resharding and encoding Hope this can improve the code readability a little... Signed-off-by: xie xingguo --- src/os/bluestore/BlueStore.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 9b667975d0c3d..61b94fc695166 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -1734,8 +1734,8 @@ void BlueStore::ExtentMap::reshard(Onode *o, uint64_t min_alloc_size) dout(30) << __func__ << " shard 0x" << std::hex << shard_start << " to 0x" << shard_end << std::dec << dendl; } - if (e.blob->id < 0 && - e.blob_escapes_range(shard_start, shard_end - shard_start)) { + if (!e.blob->is_spanning() && + e.blob_escapes_range(shard_start, shard_end - shard_start)) { // We have two options: (1) split the blob into pieces at the // shard boundaries (and adjust extents accordingly), or (2) // mark it spanning. We prefer to cut the blob if we can. Note that @@ -1744,8 +1744,8 @@ void BlueStore::ExtentMap::reshard(Onode *o, uint64_t min_alloc_size) bool must_span = false; BlobRef b = e.blob; if (b->can_split()) { - uint32_t bstart = e.logical_offset - e.blob_offset; - uint32_t bend = bstart + b->get_blob().get_logical_length(); + uint32_t bstart = e.blob_start(); + uint32_t bend = e.blob_end(); for (const auto& sh : shards) { if (bstart < sh.offset && bend > sh.offset) { uint32_t blob_offset = sh.offset - bstart; @@ -1794,7 +1794,7 @@ bool BlueStore::ExtentMap::encode_some(uint32_t offset, uint32_t length, ++p, ++n) { assert(p->logical_offset >= offset); p->blob->last_encoded_id = -1; - if (p->blob->id < 0 && p->blob_escapes_range(offset, length)) { + if (!p->blob->is_spanning() && p->blob_escapes_range(offset, length)) { dout(30) << __func__ << " 0x" << std::hex << offset << "~" << length << std::dec << " hit new spanning blob " << *p << dendl; return true; @@ -1821,7 +1821,7 @@ bool BlueStore::ExtentMap::encode_some(uint32_t offset, uint32_t length, ++p, ++n) { unsigned blobid; bool include_blob = false; - if (p->blob->id >= 0) { + if (p->blob->is_spanning()) { blobid = p->blob->id << BLOBID_SHIFT_BITS; blobid |= BLOBID_FLAG_SPANNING; } else if (p->blob->last_encoded_id < 0) { -- 2.39.5