@@ -1584,6 +1584,69 @@ SeaStore::Shard::_write(
15841584 });
15851585}
15861586
1587+ SeaStore::Shard::tm_ret
1588+ SeaStore::Shard::_clone_omaps (
1589+ internal_context_t &ctx,
1590+ OnodeRef &onode,
1591+ OnodeRef &d_onode,
1592+ const omap_type_t otype)
1593+ {
1594+ return trans_intr::repeat ([&ctx, onode, d_onode, this , otype] {
1595+ return seastar::do_with (
1596+ std::optional<std::string>(std::nullopt ),
1597+ [&ctx, onode, d_onode, this , otype](auto &start) {
1598+ auto & layout = onode->get_layout ();
1599+ return omap_list (
1600+ *onode,
1601+ otype == omap_type_t ::XATTR
1602+ ? layout.xattr_root
1603+ : layout.omap_root ,
1604+ *ctx.transaction ,
1605+ start,
1606+ OMapManager::omap_list_config_t ().with_inclusive (false , false )
1607+ ).si_then ([&ctx, onode, d_onode, this , otype, &start](auto p) mutable {
1608+ auto complete = std::get<0 >(p);
1609+ auto &attrs = std::get<1 >(p);
1610+ if (attrs.empty ()) {
1611+ assert (complete);
1612+ return tm_iertr::make_ready_future<
1613+ seastar::stop_iteration>(
1614+ seastar::stop_iteration::yes);
1615+ }
1616+ std::string nstart = attrs.rbegin ()->first ;
1617+ return _omap_set_kvs (
1618+ d_onode,
1619+ otype == omap_type_t ::XATTR
1620+ ? d_onode->get_layout ().xattr_root
1621+ : d_onode->get_layout ().omap_root ,
1622+ *ctx.transaction ,
1623+ std::map<std::string, ceph::bufferlist>(attrs.begin (), attrs.end ())
1624+ ).si_then ([complete, nstart=std::move (nstart),
1625+ &start, &ctx, d_onode, otype](auto root) mutable {
1626+ if (root.must_update ()) {
1627+ if (otype == omap_type_t ::XATTR) {
1628+ d_onode->update_xattr_root (*ctx.transaction , root);
1629+ } else {
1630+ assert (otype == omap_type_t ::OMAP);
1631+ d_onode->update_omap_root (*ctx.transaction , root);
1632+ }
1633+ }
1634+ if (complete) {
1635+ return seastar::make_ready_future<
1636+ seastar::stop_iteration>(
1637+ seastar::stop_iteration::yes);
1638+ } else {
1639+ start = std::move (nstart);
1640+ return seastar::make_ready_future<
1641+ seastar::stop_iteration>(
1642+ seastar::stop_iteration::no);
1643+ }
1644+ });
1645+ });
1646+ });
1647+ });
1648+ }
1649+
15871650SeaStore::Shard::tm_ret
15881651SeaStore::Shard::_clone (
15891652 internal_context_t &ctx,
@@ -1595,8 +1658,6 @@ SeaStore::Shard::_clone(
15951658 return seastar::do_with (
15961659 ObjectDataHandler (max_object_size),
15971660 [this , &ctx, &onode, &d_onode](auto &objHandler) {
1598- // TODO: currently, we only care about object data, leaving cloning
1599- // of xattr/omap for future work
16001661 auto &object_size = onode->get_layout ().size ;
16011662 d_onode->update_onode_size (*ctx.transaction , object_size);
16021663 return objHandler.clone (
@@ -1605,6 +1666,10 @@ SeaStore::Shard::_clone(
16051666 *ctx.transaction ,
16061667 *onode,
16071668 d_onode.get ()});
1669+ }).si_then ([&ctx, &onode, &d_onode, this ] {
1670+ return _clone_omaps (ctx, onode, d_onode, omap_type_t ::XATTR);
1671+ }).si_then ([&ctx, &onode, &d_onode, this ] {
1672+ return _clone_omaps (ctx, onode, d_onode, omap_type_t ::OMAP);
16081673 });
16091674}
16101675
0 commit comments