os/bluestore: change bluestore_extent_ref_map_t key value(i.e. offset) from 64 to 32 bits.

Signed-off-by: Igor Fedotov <ifedotov@mirantis.com>
This commit is contained in:
Igor Fedotov 2016-06-17 14:51:35 +03:00
parent c2fa9a36a7
commit 6a71e01812
2 changed files with 22 additions and 22 deletions

View File

@ -147,7 +147,7 @@ void bluestore_extent_ref_map_t::_check() const
}
}
void bluestore_extent_ref_map_t::_maybe_merge_left(map<uint64_t,record_t>::iterator& p)
void bluestore_extent_ref_map_t::_maybe_merge_left(map<uint32_t,record_t>::iterator& p)
{
if (p == ref_map.begin())
return;
@ -161,9 +161,9 @@ void bluestore_extent_ref_map_t::_maybe_merge_left(map<uint64_t,record_t>::itera
}
}
void bluestore_extent_ref_map_t::get(uint64_t offset, uint32_t length)
void bluestore_extent_ref_map_t::get(uint32_t offset, uint32_t length)
{
map<uint64_t,record_t>::iterator p = ref_map.lower_bound(offset);
map<uint32_t,record_t>::iterator p = ref_map.lower_bound(offset);
if (p != ref_map.begin()) {
--p;
if (p->first + p->second.length <= offset) {
@ -179,9 +179,9 @@ void bluestore_extent_ref_map_t::get(uint64_t offset, uint32_t length)
}
if (p->first > offset) {
// gap
uint64_t newlen = MIN(p->first - offset, length);
uint32_t newlen = MIN(p->first - offset, length);
p = ref_map.insert(
map<uint64_t,record_t>::value_type(offset,
map<uint32_t,record_t>::value_type(offset,
record_t(newlen, 1))).first;
offset += newlen;
length -= newlen;
@ -192,9 +192,9 @@ void bluestore_extent_ref_map_t::get(uint64_t offset, uint32_t length)
if (p->first < offset) {
// split off the portion before offset
assert(p->first + p->second.length > offset);
uint64_t left = p->first + p->second.length - offset;
uint32_t left = p->first + p->second.length - offset;
p->second.length = offset - p->first;
p = ref_map.insert(map<uint64_t,record_t>::value_type(
p = ref_map.insert(map<uint32_t,record_t>::value_type(
offset, record_t(left, p->second.refs))).first;
// continue below
}
@ -219,10 +219,10 @@ void bluestore_extent_ref_map_t::get(uint64_t offset, uint32_t length)
}
void bluestore_extent_ref_map_t::put(
uint64_t offset, uint32_t length,
uint32_t offset, uint32_t length,
vector<bluestore_pextent_t> *release)
{
map<uint64_t,record_t>::iterator p = ref_map.lower_bound(offset);
map<uint32_t,record_t>::iterator p = ref_map.lower_bound(offset);
if (p == ref_map.end() || p->first > offset) {
if (p == ref_map.begin()) {
assert(0 == "put on missing extent (nothing before)");
@ -233,9 +233,9 @@ void bluestore_extent_ref_map_t::put(
}
}
if (p->first < offset) {
uint64_t left = p->first + p->second.length - offset;
uint32_t left = p->first + p->second.length - offset;
p->second.length = offset - p->first;
p = ref_map.insert(map<uint64_t,record_t>::value_type(
p = ref_map.insert(map<uint32_t,record_t>::value_type(
offset, record_t(left, p->second.refs))).first;
}
while (length > 0) {
@ -272,9 +272,9 @@ void bluestore_extent_ref_map_t::put(
_check();
}
bool bluestore_extent_ref_map_t::contains(uint64_t offset, uint32_t length) const
bool bluestore_extent_ref_map_t::contains(uint32_t offset, uint32_t length) const
{
map<uint64_t,record_t>::const_iterator p = ref_map.lower_bound(offset);
map<uint32_t,record_t>::const_iterator p = ref_map.lower_bound(offset);
if (p == ref_map.end() || p->first > offset) {
if (p == ref_map.begin()) {
return false; // nothing before
@ -291,7 +291,7 @@ bool bluestore_extent_ref_map_t::contains(uint64_t offset, uint32_t length) cons
return false;
if (p->first + p->second.length >= offset + length)
return true;
uint64_t overlap = p->first + p->second.length - offset;
uint32_t overlap = p->first + p->second.length - offset;
offset += overlap;
length -= overlap;
++p;
@ -300,10 +300,10 @@ bool bluestore_extent_ref_map_t::contains(uint64_t offset, uint32_t length) cons
}
bool bluestore_extent_ref_map_t::intersects(
uint64_t offset,
uint32_t offset,
uint32_t length) const
{
map<uint64_t,record_t>::const_iterator p = ref_map.lower_bound(offset);
map<uint32_t,record_t>::const_iterator p = ref_map.lower_bound(offset);
if (p != ref_map.begin()) {
--p;
if (p->first + p->second.length <= offset) {

View File

@ -150,10 +150,10 @@ struct bluestore_extent_ref_map_t {
};
WRITE_CLASS_ENCODER(record_t)
map<uint64_t,record_t> ref_map;
map<uint32_t,record_t> ref_map;
void _check() const;
void _maybe_merge_left(map<uint64_t,record_t>::iterator& p);
void _maybe_merge_left(map<uint32_t,record_t>::iterator& p);
void clear() {
ref_map.clear();
@ -162,11 +162,11 @@ struct bluestore_extent_ref_map_t {
return ref_map.empty();
}
void get(uint64_t offset, uint32_t len);
void put(uint64_t offset, uint32_t len, vector<bluestore_pextent_t> *release);
void get(uint32_t offset, uint32_t len);
void put(uint32_t offset, uint32_t len, vector<bluestore_pextent_t> *release);
bool contains(uint64_t offset, uint32_t len) const;
bool intersects(uint64_t offset, uint32_t len) const;
bool contains(uint32_t offset, uint32_t len) const;
bool intersects(uint32_t offset, uint32_t len) const;
void encode(bufferlist& bl) const;
void decode(bufferlist::iterator& p);