Skip to content

Commit

Permalink
Merge pull request #11216 from liewegas/wip-bluestore-compress-map
Browse files Browse the repository at this point in the history
os/bluestore: prevent extent merging across shard boundaries

Reviewed-by: Somnath Roy <somnath.roy@sandisk.com>
  • Loading branch information
liewegas committed Sep 27, 2016
2 parents d4f144e + 4ece5b7 commit 5f5880d
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/os/bluestore/BlueStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1888,6 +1888,20 @@ int BlueStore::ExtentMap::compress_extent_map(uint64_t offset, uint64_t length)
if (p != extent_map.begin()) {
--p; // start to the left of offset
}

// identify the *next* shard
auto pshard = shards.begin();
while (pshard != shards.end() &&
p->logical_offset >= pshard->offset) {
++pshard;
}
uint64_t shard_end;
if (pshard != shards.end()) {
shard_end = pshard->offset;
} else {
shard_end = OBJECT_MAX_SIZE;
}

auto n = p;
for (++n; n != extent_map.end(); p = n++) {
if (n->logical_offset > offset + length) {
Expand All @@ -1896,14 +1910,26 @@ int BlueStore::ExtentMap::compress_extent_map(uint64_t offset, uint64_t length)
while (n != extent_map.end() &&
p->logical_offset + p->length == n->logical_offset &&
p->blob == n->blob &&
p->blob_offset + p->length == n->blob_offset) {
p->blob_offset + p->length == n->blob_offset &&
n->logical_offset < shard_end) {
dout(20) << __func__ << " 0x" << std::hex << offset << "~" << length
<< " next shard 0x" << shard_end << std::dec
<< " merging " << *p << " and " << *n << dendl;
p->length += n->length;
rm(n++);
++removed;
}
if (n == extent_map.end()) {
break;
}
if (n->logical_offset >= shard_end) {
++pshard;
if (pshard != shards.end()) {
shard_end = pshard->offset;
} else {
shard_end = OBJECT_MAX_SIZE;
}
}
}
return removed;
}
Expand Down
49 changes: 49 additions & 0 deletions src/test/objectstore/store_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3951,6 +3951,55 @@ TEST_P(StoreTest, SyntheticMatrixSharding) {
do_matrix(m, store);
}

TEST_P(StoreTest, ZipperPatternSharded) {
if(string(GetParam()) != "bluestore")
return;
g_conf->set_val("bluestore_min_alloc_size", "4096");
g_ceph_context->_conf->apply_changes(NULL);
int r = store->umount();
ASSERT_EQ(r, 0);
r = store->mount(); //to force min_alloc_size update
ASSERT_EQ(r, 0);

ObjectStore::Sequencer osr("test");
coll_t cid;
ghobject_t a(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
r = apply_transaction(store, &osr, std::move(t));
ASSERT_EQ(r, 0);
}
bufferlist bl;
int len = 4096;
bufferptr bp(len);
bp.zero();
bl.append(bp);
for (int i=0; i<1000; ++i) {
ObjectStore::Transaction t;
t.write(cid, a, i*2*len, len, bl, 0);
r = apply_transaction(store, &osr, std::move(t));
ASSERT_EQ(r, 0);
}
for (int i=0; i<1000; ++i) {
ObjectStore::Transaction t;
t.write(cid, a, i*2*len + 1, len, bl, 0);
r = apply_transaction(store, &osr, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.remove(cid, a);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
r = apply_transaction(store, &osr, std::move(t));
ASSERT_EQ(r, 0);
}
g_conf->set_val("bluestore_min_alloc_size", "0");
g_ceph_context->_conf->apply_changes(NULL);
}

TEST_P(StoreTest, SyntheticMatrixCsumAlgorithm) {
if (string(GetParam()) != "bluestore")
return;
Expand Down

0 comments on commit 5f5880d

Please sign in to comment.