From bc97ce063542b0ca78f955eeb329e02d4650887b Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Wed, 21 Dec 2016 14:13:28 +0000 Subject: [PATCH] os/bluestore: make BufferSpace offsets 32-bit wide. Signed-off-by: Igor Fedotov --- src/os/bluestore/BlueStore.cc | 24 ++++++++++++------------ src/os/bluestore/BlueStore.h | 18 +++++++++--------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 9eb88409e4606..0aa3c073afd22 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -974,7 +974,7 @@ void BlueStore::BufferSpace::_clear() } } -int BlueStore::BufferSpace::_discard(uint64_t offset, uint64_t length) +int BlueStore::BufferSpace::_discard(uint32_t offset, uint32_t length) { // note: we already hold cache->lock ldout(cache->cct, 20) << __func__ << std::hex << " 0x" << offset << "~" << length @@ -982,7 +982,7 @@ int BlueStore::BufferSpace::_discard(uint64_t offset, uint64_t length) int cache_private = 0; cache->_audit("discard start"); auto i = _data_lower_bound(offset); - uint64_t end = offset + length; + uint32_t end = offset + length; while (i != buffer_map.end()) { Buffer *b = i->second.get(); if (b->offset >= end) { @@ -995,7 +995,7 @@ int BlueStore::BufferSpace::_discard(uint64_t offset, uint64_t length) int64_t front = offset - b->offset; if (b->end() > end) { // drop middle (split) - uint64_t tail = b->end() - end; + uint32_t tail = b->end() - end; if (b->data.length()) { bufferlist bl; bl.substr_of(b->data, b->length - tail, tail); @@ -1025,7 +1025,7 @@ int BlueStore::BufferSpace::_discard(uint64_t offset, uint64_t length) continue; } // drop front - uint64_t keep = b->end() - end; + uint32_t keep = b->end() - end; if (b->data.length()) { bufferlist bl; bl.substr_of(b->data, b->length - keep, keep); @@ -1041,15 +1041,15 @@ int BlueStore::BufferSpace::_discard(uint64_t offset, uint64_t length) } void BlueStore::BufferSpace::read( - uint64_t offset, uint64_t length, + uint32_t offset, uint32_t length, BlueStore::ready_regions_t& res, - interval_set& res_intervals) + interval_set& res_intervals) { std::lock_guard l(cache->lock); res.clear(); res_intervals.clear(); - uint64_t want_bytes = length; - uint64_t end = offset + length; + uint32_t want_bytes = length; + uint32_t end = offset + length; for (auto i = _data_lower_bound(offset); i != buffer_map.end() && offset < end && i->first < end; ++i) { @@ -1057,8 +1057,8 @@ void BlueStore::BufferSpace::read( assert(b->end() > offset); if (b->is_writing() || b->is_clean()) { if (b->offset < offset) { - uint64_t skip = offset - b->offset; - uint64_t l = MIN(length, b->length - skip); + uint32_t skip = offset - b->offset; + uint32_t l = MIN(length, b->length - skip); res[offset].substr_of(b->data, skip, l); res_intervals.insert(offset, l); offset += l; @@ -1069,7 +1069,7 @@ void BlueStore::BufferSpace::read( continue; } if (b->offset > offset) { - uint64_t gap = b->offset - offset; + uint32_t gap = b->offset - offset; if (length <= gap) { break; } @@ -5129,7 +5129,7 @@ int BlueStore::_do_read( unsigned b_len = std::min(left, lp->length - l_off); ready_regions_t cache_res; - interval_set cache_interval; + interval_set cache_interval; bptr->shared_blob->bc.read(b_off, b_len, cache_res, cache_interval); dout(20) << __func__ << " blob " << *bptr << std::hex << " need 0x" << b_off << "~" << b_len diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index d74f9256d01a4..8e9eb35f7f90c 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -263,7 +263,7 @@ public: } map>::iterator _data_lower_bound( - uint64_t offset) { + uint32_t offset) { auto i = buffer_map.lower_bound(offset); if (i != buffer_map.begin()) { --i; @@ -277,13 +277,13 @@ public: void _clear(); // return value is the highest cache_private of a trimmed buffer, or 0. - int discard(uint64_t offset, uint64_t length) { + int discard(uint32_t offset, uint32_t length) { std::lock_guard l(cache->lock); return _discard(offset, length); } - int _discard(uint64_t offset, uint64_t length); + int _discard(uint32_t offset, uint32_t length); - void write(uint64_t seq, uint64_t offset, bufferlist& bl, unsigned flags) { + void write(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); @@ -291,19 +291,19 @@ public: _add_buffer(b, (flags & Buffer::FLAG_NOCACHE) ? 0 : 1, nullptr); } void finish_write(uint64_t seq); - void did_read(uint64_t offset, bufferlist& bl) { + void did_read(uint32_t offset, bufferlist& bl) { std::lock_guard l(cache->lock); Buffer *b = new Buffer(this, Buffer::STATE_CLEAN, 0, offset, bl); b->cache_private = _discard(offset, bl.length()); _add_buffer(b, 1, nullptr); } - void read(uint64_t offset, uint64_t length, + void read(uint32_t offset, uint32_t length, BlueStore::ready_regions_t& res, - interval_set& res_intervals); + interval_set& res_intervals); - void truncate(uint64_t offset) { - discard(offset, (uint64_t)-1 - offset); + void truncate(uint32_t offset) { + discard(offset, (uint32_t)-1 - offset); } void split(size_t pos, BufferSpace &r); -- 2.39.5