Skip to content

Commit

Permalink
os/bluestore: optimize compress_extent_map
Browse files Browse the repository at this point in the history
Only examine the range we just wrote to (and to the left
and right).

Signed-off-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Sep 2, 2016
1 parent 48ecb86 commit 605063e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/os/bluestore/BlueStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1874,14 +1874,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 &&
Expand Down Expand Up @@ -7264,8 +7270,6 @@ void BlueStore::_wctx_finish(
}
}
}

o->extent_map.compress_extent_map();
}

int BlueStore::_do_write(
Expand Down Expand Up @@ -7373,6 +7377,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) {
Expand Down
2 changes: 1 addition & 1 deletion src/os/bluestore/BlueStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ class BlueStore : public ObjectStore,
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,
Expand Down

0 comments on commit 605063e

Please sign in to comment.