}
}
-void bluestore_extent_ref_map_t::_maybe_merge_left(map<uint32_t,record_t>::iterator& p)
+void bluestore_extent_ref_map_t::_maybe_merge_left(
+ map<uint64_t,record_t>::iterator& p)
{
if (p == ref_map.begin())
return;
}
}
-void bluestore_extent_ref_map_t::get(uint32_t offset, uint32_t length)
+void bluestore_extent_ref_map_t::get(uint64_t offset, uint32_t length)
{
- map<uint32_t,record_t>::iterator p = ref_map.lower_bound(offset);
+ auto p = ref_map.lower_bound(offset);
if (p != ref_map.begin()) {
--p;
if (p->first + p->second.length <= offset) {
}
if (p->first > offset) {
// gap
- uint32_t newlen = MIN(p->first - offset, length);
+ uint64_t newlen = MIN(p->first - offset, length);
p = ref_map.insert(
- map<uint32_t,record_t>::value_type(offset,
+ map<uint64_t,record_t>::value_type(offset,
record_t(newlen, 1))).first;
offset += newlen;
length -= newlen;
if (p->first < offset) {
// split off the portion before offset
assert(p->first + p->second.length > offset);
- uint32_t left = p->first + p->second.length - offset;
+ uint64_t left = p->first + p->second.length - offset;
p->second.length = offset - p->first;
- p = ref_map.insert(map<uint32_t,record_t>::value_type(
+ p = ref_map.insert(map<uint64_t,record_t>::value_type(
offset, record_t(left, p->second.refs))).first;
// continue below
}
}
void bluestore_extent_ref_map_t::put(
- uint32_t offset, uint32_t length,
+ uint64_t offset, uint32_t length,
vector<bluestore_pextent_t> *release)
{
- map<uint32_t,record_t>::iterator p = ref_map.lower_bound(offset);
+ auto 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)");
}
}
if (p->first < offset) {
- uint32_t left = p->first + p->second.length - offset;
+ uint64_t left = p->first + p->second.length - offset;
p->second.length = offset - p->first;
- p = ref_map.insert(map<uint32_t,record_t>::value_type(
+ p = ref_map.insert(map<uint64_t,record_t>::value_type(
offset, record_t(left, p->second.refs))).first;
}
while (length > 0) {
_check();
}
-bool bluestore_extent_ref_map_t::contains(uint32_t offset, uint32_t length) const
+bool bluestore_extent_ref_map_t::contains(uint64_t offset, uint32_t length) const
{
- map<uint32_t,record_t>::const_iterator p = ref_map.lower_bound(offset);
+ auto p = ref_map.lower_bound(offset);
if (p == ref_map.end() || p->first > offset) {
if (p == ref_map.begin()) {
return false; // nothing before
return false;
if (p->first + p->second.length >= offset + length)
return true;
- uint32_t overlap = p->first + p->second.length - offset;
+ uint64_t overlap = p->first + p->second.length - offset;
offset += overlap;
length -= overlap;
++p;
}
bool bluestore_extent_ref_map_t::intersects(
- uint32_t offset,
+ uint64_t offset,
uint32_t length) const
{
- map<uint32_t,record_t>::const_iterator p = ref_map.lower_bound(offset);
+ auto p = ref_map.lower_bound(offset);
if (p != ref_map.begin()) {
--p;
if (p->first + p->second.length <= offset) {
auto p = ref_map.begin();
small_encode_varint_lowz(p->first, bl);
p->second.encode(bl);
- int32_t pos = p->first;
+ int64_t pos = p->first;
while (--n) {
++p;
- small_encode_varint_lowz((int64_t)p->first - pos, bl);
+ small_encode_varint_lowz(p->first - pos, bl);
p->second.encode(bl);
pos = p->first;
}
f->close_section();
}
-void bluestore_extent_ref_map_t::generate_test_instances(list<bluestore_extent_ref_map_t*>& o)
+void bluestore_extent_ref_map_t::generate_test_instances(
+ list<bluestore_extent_ref_map_t*>& o)
{
o.push_back(new bluestore_extent_ref_map_t);
o.push_back(new bluestore_extent_ref_map_t);
struct record_t {
uint32_t length;
uint32_t refs;
- record_t(uint32_t l=0, uint32_t r=0) : length(l), refs(r) {}
+ record_t(uint64_t l=0, uint32_t r=0) : length(l), refs(r) {}
void encode(bufferlist& bl) const {
small_encode_varint_lowz(length, bl);
small_encode_varint(refs, bl);
};
WRITE_CLASS_ENCODER(record_t)
- map<uint32_t,record_t> ref_map;
+ map<uint64_t,record_t> ref_map;
void _check() const;
- void _maybe_merge_left(map<uint32_t,record_t>::iterator& p);
+ void _maybe_merge_left(map<uint64_t,record_t>::iterator& p);
void clear() {
ref_map.clear();
return ref_map.empty();
}
- void get(uint32_t offset, uint32_t len);
- void put(uint32_t offset, uint32_t len, vector<bluestore_pextent_t> *release);
+ void get(uint64_t offset, uint32_t len);
+ void put(uint64_t offset, uint32_t len, vector<bluestore_pextent_t> *release);
- bool contains(uint32_t offset, uint32_t len) const;
- bool intersects(uint32_t offset, uint32_t len) const;
+ bool contains(uint64_t offset, uint32_t len) const;
+ bool intersects(uint64_t offset, uint32_t len) const;
void encode(bufferlist& bl) const;
void decode(bufferlist::iterator& p);