Skip to content

Commit

Permalink
os/bluestore: change bluestore_extent_ref_map_t key value(i.e. offset…
Browse files Browse the repository at this point in the history
…) from 64 to 32 bits.

Signed-off-by: Igor Fedotov <[email protected]>
  • Loading branch information
Igor Fedotov committed Jun 17, 2016
1 parent c2fa9a3 commit 6a71e01
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
32 changes: 16 additions & 16 deletions src/os/bluestore/bluestore_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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;
Expand All @@ -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
}
Expand All @@ -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)");
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions src/os/bluestore/bluestore_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit 6a71e01

Please sign in to comment.