Skip to content

Commit

Permalink
os/bluestore: add ExtentMap::add() helper
Browse files Browse the repository at this point in the history
Matches rm().

Signed-off-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Sep 13, 2016
1 parent 1dcb8e8 commit 401a224
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/os/bluestore/BlueStore.cc
Expand Up @@ -1933,10 +1933,10 @@ void BlueStore::ExtentMap::punch_hole(
uint64_t front = offset - p->logical_offset;
old_extents->insert(
*new Extent(offset, p->blob_offset + front, length, p->blob));
extent_map.insert(*new Extent(end,
p->blob_offset + front + length,
p->length - front - length,
p->blob));
add(end,
p->blob_offset + front + length,
p->length - front - length,
p->blob);
p->length = front;
break;
} else {
Expand All @@ -1961,8 +1961,7 @@ void BlueStore::ExtentMap::punch_hole(
uint64_t keep = (p->logical_offset + p->length) - end;
old_extents->insert(*new Extent(p->logical_offset, p->blob_offset,
p->length - keep, p->blob));
extent_map.insert(*new Extent(end, p->blob_offset + p->length - keep, keep,
p->blob));
add(end, p->blob_offset + p->length - keep, keep, p->blob);
rm(p);
break;
}
Expand Down Expand Up @@ -7979,9 +7978,7 @@ int BlueStore::_clone(TransContext *txc,
}
}
// dup extent
newo->extent_map.extent_map.insert(*new Extent(e.logical_offset,
e.blob_offset,
e.length, cb));
newo->extent_map.add(e.logical_offset, e.blob_offset, e.length, cb);
txc->statfs_delta.stored() += e.length;
if (e.blob->get_blob().is_compressed()) {
txc->statfs_delta.compressed_original() -= e.length;
Expand Down
5 changes: 5 additions & 0 deletions src/os/bluestore/BlueStore.h
Expand Up @@ -605,6 +605,11 @@ class BlueStore : public ObjectStore,
/// seek to the first lextent including or after offset
extent_map_t::iterator seek_lextent(uint64_t offset);

/// add a new Extent
void add(uint32_t lo, uint32_t o, uint32_t l, BlobRef& b) {
extent_map.insert(*new Extent(lo, o, l, b));
}

/// remove (and delete) an Extent
void rm(extent_map_t::iterator p) {
Extent *e = &*p;
Expand Down

0 comments on commit 401a224

Please sign in to comment.