Skip to content

Commit 056bea4

Browse files
authored
Merge pull request ceph#64626 from xxhdx1985126/wip-72173
crimson/os/seastore: add support for OP_SPLIT_COLLECTION2 Reviewed-by: Samuel Just <[email protected]>
2 parents 372cd64 + 3335968 commit 056bea4

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

src/crimson/os/seastore/seastore.cc

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,15 @@ SeaStore::Shard::_do_transaction_step(
16481648
i.decode_bl(hint);
16491649
return tm_iertr::now();
16501650
}
1651+
case Transaction::OP_SPLIT_COLLECTION2:
1652+
{
1653+
uint32_t bits = op->split_bits;
1654+
coll_t cid = i.get_cid(op->cid);
1655+
coll_t dest_cid = i.get_cid(op->dest_cid);
1656+
DEBUGT("op OP_SPLIT_COLLECTION2, cid={}, dest_cid={}, bits={}",
1657+
*ctx.transaction, cid, dest_cid, bits);
1658+
return _split_collection(ctx, cid, bits);
1659+
}
16511660
}
16521661

16531662
using onode_iertr = OnodeManager::get_onode_iertr::extend<
@@ -2226,6 +2235,40 @@ SeaStore::Shard::_rmattrs(
22262235
onode);
22272236
}
22282237

2238+
SeaStore::Shard::tm_ret
2239+
SeaStore::Shard::_split_collection(
2240+
internal_context_t &ctx,
2241+
const coll_t &cid,
2242+
int bits)
2243+
{
2244+
return transaction_manager->read_collection_root(
2245+
*ctx.transaction
2246+
).si_then([=, this, &ctx](auto _cmroot) {
2247+
return seastar::do_with(
2248+
_cmroot,
2249+
[=, this, &ctx](auto &cmroot) {
2250+
return collection_manager->update(
2251+
cmroot,
2252+
*ctx.transaction,
2253+
cid,
2254+
bits
2255+
).si_then([this, &ctx, &cmroot] {
2256+
if (cmroot.must_update()) {
2257+
transaction_manager->write_collection_root(
2258+
*ctx.transaction,
2259+
cmroot);
2260+
}
2261+
});
2262+
}
2263+
);
2264+
}).handle_error_interruptible(
2265+
tm_iertr::pass_further{},
2266+
crimson::ct_error::assert_all{
2267+
"Invalid error in SeaStoreS::_create_collection"
2268+
}
2269+
);
2270+
}
2271+
22292272
SeaStore::Shard::tm_ret
22302273
SeaStore::Shard::_create_collection(
22312274
internal_context_t &ctx,

src/crimson/os/seastore/seastore.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,9 @@ class SeaStore final : public FuturizedStore {
435435
tm_ret _create_collection(
436436
internal_context_t &ctx,
437437
const coll_t& cid, int bits);
438+
tm_ret _split_collection(
439+
internal_context_t &ctx,
440+
const coll_t& cid, int bits);
438441
tm_ret _remove_collection(
439442
internal_context_t &ctx,
440443
const coll_t& cid);

src/test/crimson/seastore/test_seastore.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,28 @@ TEST_P(seastore_test_t, collection_create_list_remove)
700700
});
701701
}
702702

703+
TEST_P(seastore_test_t, collection_split)
704+
{
705+
run_async([this] {
706+
coll_t test_coll{spg_t{pg_t{1, 0}}};
707+
{
708+
sharded_seastore->create_new_collection(test_coll).get();
709+
{
710+
CTransaction t;
711+
t.create_collection(test_coll, 4);
712+
do_transaction(std::move(t));
713+
}
714+
{
715+
coll_t test_coll2{spg_t{pg_t{17, 0}}};
716+
sharded_seastore->create_new_collection(test_coll2).get();
717+
CTransaction t;
718+
t.split_collection(test_coll, 5, 5, test_coll2);
719+
do_transaction(std::move(t));
720+
}
721+
}
722+
});
723+
}
724+
703725
TEST_P(seastore_test_t, meta) {
704726
run_async([this] {
705727
set_meta("key1", "value1");

0 commit comments

Comments
 (0)