os/bluestore: optimize compress_extent_map

Only examine the range we just wrote to (and to the left
and right).

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2016-09-02 14:08:48 -04:00
parent ec58b21acd
commit 7f35725fdb
2 changed files with 11 additions and 5 deletions

View File

@ -1904,14 +1904,20 @@ bool BlueStore::ExtentMap::has_any_lextents(uint64_t offset, uint64_t length)
return true;
}
int BlueStore::ExtentMap::compress_extent_map()
int BlueStore::ExtentMap::compress_extent_map(uint64_t offset, uint64_t length)
{
if (extent_map.empty())
return 0;
int removed = 0;
auto p = extent_map.begin();
auto p = seek_lextent(offset);
if (p != extent_map.begin()) {
--p; // start to the left of offset
}
auto n = p;
for (++n; n != extent_map.end(); p = n++) {
if (n->logical_offset > offset + length) {
break; // stop after end
}
while (n != extent_map.end() &&
p->logical_offset + p->length == n->logical_offset &&
p->blob == n->blob &&
@ -7313,8 +7319,6 @@ void BlueStore::_wctx_finish(
}
}
}
o->extent_map.compress_extent_map();
}
int BlueStore::_do_write(
@ -7422,6 +7426,8 @@ int BlueStore::_do_write(
_wctx_finish(txc, c, o, &wctx);
o->extent_map.compress_extent_map(offset, length);
o->extent_map.dirty_range(txc->t, offset, length);
if (end > o->onode.size) {

View File

@ -582,7 +582,7 @@ public:
bool has_any_lextents(uint64_t offset, uint64_t length);
/// consolidate adjacent lextents in extent_map
int compress_extent_map();
int compress_extent_map(uint64_t offset, uint64_t length);
/// punch a logical hole. add lextents to deref to target list.
void punch_hole(uint64_t offset, uint64_t length,