Skip to content

crimson/os/seastore: introduce 128 bit laddr_t - #55291

Closed
zhscn wants to merge 10 commits into
ceph:mainfrom
zhscn:dev-128-lba
Closed

zhscn wants to merge 10 commits into
ceph:mainfrom
zhscn:dev-128-lba

Conversation

@zhscn

@zhscn zhscn commented Jan 24, 2024

Copy link
Copy Markdown
Member

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

@zhscn
zhscn requested a review from a team as a code owner January 24, 2024 06:35
@zhscn
zhscn force-pushed the dev-128-lba branch 2 times, most recently from 19c8958 to 057d1e3 Compare January 24, 2024 11:29
@cyx1231st

Copy link
Copy Markdown
Member

Sorry about the delay -- I'll try to get to it this week after some prioritized work done.

@xxhdx1985126

Copy link
Copy Markdown
Member

Sorry about the delay -- I'll try to get to it this week after some prioritized work done.

No problem:-) We've just fixed the staged fltree unittest case yesterday:-)

@github-actions

github-actions Bot commented Feb 7, 2024

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@zhscn

zhscn commented Feb 29, 2024

Copy link
Copy Markdown
Member Author

jenkins test make check

@cyx1231st

Copy link
Copy Markdown
Member

I might need to prioritize reviewing the cleanups to the lba tree to get my memory back, probably also helpful to make lba related PR (such as this one) easier to review.

If there are related cleanups in this PR or worth doing, feel free to split it out.

@github-actions

github-actions Bot commented Mar 8, 2024

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@zhscn
zhscn force-pushed the dev-128-lba branch 5 times, most recently from b78c1ee to e46409b Compare March 19, 2024 08:50
@zhscn

zhscn commented Jun 25, 2024

Copy link
Copy Markdown
Member Author

Hi @cyx1231st, I've divided the original 128 LBA implementation into two parts. This first part(this PR) updates the byte addressing laddr_t to block (4K) addressing using a 128-bit laddr_t.

The next step is implementing deterministic operations for clone, rollback, and recovery scenarios.

@cyx1231st

Copy link
Copy Markdown
Member

@zhscn thanks for keeping this PR rebased and make it smaller for review.

This is a critical change but I've been prioritized to review the other PRs, sorry about that. I'll start to review this.

@cyx1231st cyx1231st left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll keep on reviewing, let me know if there is a new version ready to push, so I can send out my pending comments before the original version is gone.

struct ref_update_result_t {
extent_ref_count_t refcount = 0;
pladdr_t addr;
pladdr_t addr = L_ADDR_NULL;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this default to PL_ADDR_NULL?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, PL_ADDR_NULL was removed by mistake, will update it in next push.

@cyx1231st cyx1231st left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make the essential documentation accurate first to involve more reviewers.

* and this offset is always 4KiB aligned. 15 bits indicate the hard limit of an
* object is 1 << (15 + 12) = 128 MiB.
*
* TODO: implement determinsitic allocation in LBAManager

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: implement determinisitic allocation in LBAManager, see get_next_hint(laddr).

* laddr_t uses uint128_t to represent the logical address internally.
* The layout of laddr:
*
* [pool:8][shard:8][crush:32][random:31][metadata:1][recover:1][local_clone_id:32][offset:15]

@cyx1231st cyx1231st Jun 27, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, change to [is_metadata:1][random:31] for larger possible laddr space for object data/metadata.

@athanatos athanatos Jun 27, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably an obvious question -- why place metadata, recover, local_clone_id after random?

edit: ah, to distinguish between metadata and clones of the same object, right? metadata is more significant than local_clone_id so that data for different clones of the same object will sort together?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The random field is intended to distinguish between objects of different (pool, shard, crush, clone), right? We can't actually use it for both that and reserved, I think? Perhaps those should be split? metadata makes sense -- we might want to use different placement policy with anything with that bit set. I'm less sure about recover, though. There aren't currently any cases I can think of where we might want to have more than one temp object for a particular object, but I'm not sure we want to make that impossible.

For temp objects, it'll still be possible to enumerate temp objects, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edit: ah, to distinguish between metadata and clones of the same object, right? metadata is more significant than local_clone_id so that data for different clones of the same object will sort together?

Yes, seems it's better to seperate them into different address space.

The random field is intended to distinguish between objects of different (pool, shard, crush, clone), right? We can't actually use it for both that and reserved, I think?

You're right, comments here is wrong.

Perhaps those should be split?

Reserved bits seem reasonable, but it's not easy to determine where those bits should place, eg. reserve for gloabl bits or object local bits.

I'm less sure about recover, though. There aren't currently any cases I can think of where we might want to have more than one temp object for a particular object, but I'm not sure we want to make that impossible.

For temp objects, it'll still be possible to enumerate temp objects, right?

This bit is introduced due to static layout, please see the long documentation blow, currently it's not used.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't actually use it for both that and reserved

My understanding is the [random:31] portion can shrink anytime to allow some bits to serve other purposes in the future.

For temp objects, it'll still be possible to enumerate temp objects, right?

The scope of such enumeration is a PG, right?

My understanding is if we want to enumerate/list temp objects efficiently within a PG, they might need to be arranged together there.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For temp objects, it'll still be possible to enumerate temp objects, right?

I think the 128-bit lba key implementation doesn't affect objects enumeration, as we always to first list onodes from the onode tree and then access the objects' data/omaps in the enumeration, and no matter how the extents' laddr arranges, we can always get the right laddrs through onodes. Am I right?

* the same crush, and if more fields need to be added in the future, take
* bits from this field.
* metadata: the extents with data_category_t::METADATA will set this bit.
* recover: the extents of TEMP_RECOVERING objects will set this bit.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, let's split out the optimization around the "recover" bit.

* when a new clone object is created.
* offset: this field represents the extent of the offset relative to the onode base,
* and this offset is always 4KiB aligned. 15 bits indicate the hard limit of an
* object is 1 << (15 + 12) = 128 MiB.

@cyx1231st cyx1231st Jun 27, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if 15-bit (128MiB) is sufficient in case of RGW/CephFS ?

* laddr_t uses uint128_t to represent the logical address internally.
* The layout of laddr:
*
* [pool:8][shard:8][crush:32][random:31][metadata:1][recover:1][local_clone_id:32][offset:15]

@cyx1231st cyx1231st Jun 27, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure if the 8-bit pool field is sufficient to prevent transaction conflicts, it depends on how many pools an OSD might contain possibly, and the complete pool field has 64 bits.

I know the 8-bit pool is taken from the original hint, but now we will have 128 bits.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include/rados.h has a 32 bit pool in the ceph_pg type. I think it's 64 bit elsewhere without a particularly good reason. 8 bits is probably too small, but 12 bits is probably entirely safe as long as we're willing to remap pool ids. Even that probably won't be necessary any time soon as I don't think there's a way to force the creation of a pool with a large ID. Realistically, I think the only way for a cluster to have pools with large numeric pool ids would be a usage pattern that involved frequently creating and deleting pools.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, 12-bit pool field seems better.

* recover: the extents of TEMP_RECOVERING objects will set this bit.
* local_clone_id: monotonically increasing within the same object, increases
* when a new clone object is created.
* offset: this field represents the extent of the offset relative to the onode base,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean after this PR, the granularity of laddr will be changed from 1B to 4KB?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's also the reason that here exists loffset_t for 4KB unaligned logical address.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, then all the calculations related to laddr +- size have to be adjusted.

* object is 1 << (15 + 12) = 128 MiB.
*
* TODO: implement determinsitic allocation in LBAManager
*/

@cyx1231st cyx1231st Jun 27, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make sure this part is accurately documented, so we can involve more reviewers to align on the general decisions and the scope.

The layout of the laddr fields should be designed carefully, shouldn't be changed very frequently.

@zhscn

zhscn commented Jun 28, 2024 •

Copy link
Copy Markdown
Member Author

Change log 2024/07/03:

  • local_clone_id becomes unordered between different clones for an object; metadata is taken account of object prefix.

Change log 2024/07/01:

  • add break change section for local_clone_id

@athanatos This PR is split from our full 128 laddr_t implementation, so some of the code may look very confusing, sorry for the inconvenience. After communicating with @cyx1231st, the code no longer reflects the latest design. The new design displays as following:

existing laddr_t issues

Currently allocating a laddr for an object/extent follows these steps:

  1. laddr hint: construct a hint using the pool, shard and crush fields of the object with layout:
    [shard:8][pool:8][crush:32][zero:16]
  1. laddr allocation: The LBAManager use hint~length to allocate a laddr:
    1. when hint~length doesn't conflict with the existing mappings, then hint is the final result of allocation.
    2. in case of collision, start forward searching to find an avaliable space.

However, this procedure have several problems:

  1. the pool and shard fields should be swapped. Once EC is implemented it would be better if shards of an object could be grouped in the same pool;
  2. different object might conflict during laddr allocation. For example, object A with pool 0x11, shard 0x22 and crush 0x1 gets hint 0x1122000000010000, reserving the region from 0xFF12000000010000 to 0xFF12000001010000(16MiB in total). When the next object B has hint 0x1122000000020000, it would conflict with object A and require a lba search to find a appropriate address.
  3. cloning process is ineffective. The clone onodes of the same object have the same lba hint during allocation.
  4. laddr_t is byte addressing, that one logical address represtent 1 Byte data. However, the laddr is always block(4KiB) aligend, meaning its lowest 12 bits are always zero, resulting in wasted bits.
  5. the most significant bits in crush represtent the pg id, which causes ineffeciency when a pg is not located at a certaion OSD, the corresponding lba address space can not be allocated effeciently by this OSD.

introduce 128 bit laddr_t to solve these problems

We have some methods to speed up laddr allocation:

  1. change from byte addressing to block(4KiB) addressing, where laddr_t works like block id. This change brings 12 additional bits to resolve collisions.
  2. introduce local_clone_id for each object. When creating a snapshot for an object, the local clone id of newly created object increments When creating a snapshot for an object, take a random clone id for it, this id could be a part of hint to reduce collision between different snapshots in the lba tree.
  3. introduce a metadata bit to group non-data logical extents to standalone address space.

Here we get the initial layout of 128bit laddr_t:

[pool:12][shard:8][crush:32][metadata:1][random:28][local_clone_id:32][zero:15]

optimization for 128 bit laddr

The introduction of the 128-bit laddr reduces the fan-out of LBA leaf nodes from 140 to 89, as the size of lba_map_val_t (pladdr_t 9 -> 17) grows from 21 to 29.

Old layout of LBALeafNode:

Layout (4k):
  checksum   :                            4b
  size       : uint32_t[1]                4b
  meta       : lba_node_meta_le_t[3]      (1*24)b
  keys       : laddr_t[140]               (140*8)b
  values     : lba_map_val_t[140]         (140*21)b
                                          = 4092

New layout of LBALeafNode:

Layout (4k):
  checksum   :                            4b
  size       : uint32_t[1]                4b
  meta       : lba_node_meta_le_t[3]      (1*40)b
  keys       : laddr_t[89]                (89*16)b
  values     : lba_map_val_t[89]          (89*29)b
                                          = 4053

To further reduce space usage, we propose optimizing laddr_t with a static layout that introduces semantic information to each field.

static layout

[upgrade:1][pool:12][shard:8][crush:32][metadata:1][random:26][recover:1][local_clone_id_and_offset:47]

update on 2024/07/03:

[upgrade:1][pool:12][shard:8][crush:32][random:27][object_data_and_metadata:48]
object_data_and_metadata:
[metadata:1][dynamic_bits:47]

object prefix

The primary purpose of the static layout is to introduce object prefix. Each object has a unique object prefix on the lba tree, ensuring it never conflicts with other objects. With the object prefix and local clone id, laddr allocation for a clone object becomes deterministic, eliminating collision concerns. All clone onodes from one object share the same object prefix.


2024/07/03 udpate:
Both the data and metadata extents share the same object prefix [upgrade:1][pool:12][shard:8][crush:32][random:27]. The most significant bit in object_data_and_metadata represtents the type of extents, ObjectDataBlock or OMapNode.

OSD level metadata extents, RootBlock, CollectionNode and SeastoreNodeExtent, has constent prefix whose bits are all of zero, and the rest 48 bits are just random number.


What's more, the lba_map_val_t struct doesn't need to store the complete 128-bit laddr, it can only keep the local clone id(less than 64 bits) relative to current lba key to represtent the real intermidate key.

Now the layout of LBALeafNode becomes:

Layout (4k):
  checksum   :                            4b
  size       : uint32_t[1]                4b
  meta       : lba_node_meta_le_t[3]      (1*40)b
  keys       : laddr_t[109]               (109*16)b
  values     : lba_map_val_t[109]         (109*21)b
                                          = 4081

Additionally, the static object prefix will be also require by LBC(logical bucket cache) in the future, we can trace the interested extents and their prefixes to build a LRU list for guiding the GC process to determine whether needs to evict an extent to the slower devices.

metadata

The object prefix works only for the data of an object, meaning the extent OjbectDataBlcok. For object metadata and global metadata, it's better to place them in separate address space, that's why the layout contains one metadata bit.

recover

Temporary recover objects should maintain the same object prefix as the pending recovery object with different local clone id , otherwise the local clone id in lba_map_val_t won't work. However, temporary objects should not mix with normal objects, thus a special recover bit is introduced in laddr_t for such cases.

the pros of static layout

In summary, the static layout has these advantages:

  1. each object has a unique prefix , clone procedure no longer needs to reserve space on the lba tree .
  2. reduce the size of lba_map_val_t, increase the fan-out of LBALeafNode
  3. help GC filter out hot data on fast device.

the cons of static layout

The main disadvantage of static laddr_t is that code becomes complex.

fsck when updating the layout

The main drawback of static layout is it can not upgrade the layout seamlessly as hint. Therefore, rebuilding lba tree is requried to migrate old subtrees to new subtrees after a layout change, this is the use case of upgrade bit in laddr_t.

Since most fields of laddr_t come from object info, it's unlikely to remove fields in the future. OSD should store the current layout to superblock. If the layout changes, the OSD or fsck tool could read the old info and transfrom it to the new layout.

dynamic field for object_data_and_metadata

For RBD clients, this field could be split into two parts: local_clone_id uses 32 bits, and offset relative to onode base uses 15 bits(the hard limit of an object is 128MiB). For RGW clients, it doesn't use snapshot for rados object, so setting local_clone_id bits is meaningless. This difference requires the field to be adjustable per OSD or per pool.

It also requires the fsck mechanism to adapt changes of this option.


update on 2024/07/03:

object_data_and_metadata:
[metadata:1][dynamic_bits:47]

For metadata extents of objects, the metadata bit is always zero and the the dynamic_bits is random number. Taking snapshot for matadata extents is just allocating a new laddr to the new extent at presistent.

For data extents of objects, the dynamic bits has static layout for local_clone_id and offset that is object base laddr related, but the bits they used can be adjusted by osd/pool/object level configuration:

object_data_and_metadata:
[metadata:1][local_clone_id:x][offset:47-x]

break change

An object's local_clone_id should be consistent across different OSDs, which requires the local_clone_id to be exposed to the PG layer for the object recovery usage to avoid out-of-order cases with local_clone_id.
Changes might look like: zhscn@5c27dac

The goal of this PR

This PR should not introduce anything more complicated, just implement a 128-bit laddr_t prototype to solve the address exhaustion problem first. The optimizations described in the above document will be implemented in future PRs.

@cyx1231st

Copy link
Copy Markdown
Member

For global metadata (RootBlock, CollectionNode and SeastoreNodeExtent), L_ADDR_MIN would still be sufficient as before, so they are unrelated to the metadata-bit.

For per-object metadata, as I'm getting the concept of object-prefix more clearly -- "each object has a unique object prefix on the lba tree", is it semantically better to move the metadata-bit after object-prefix, so metadata and data of the same object share the same object-prefix naturally (same object under the same lba subtree) ?

@cyx1231st

Copy link
Copy Markdown
Member
  1. the most significant bits in crush represtent the pg id, which causes ineffeciency when a pg is not located at a certaion OSD, the corresponding lba address space can not be allocated effeciently by this OSD.

Is it related to the solution?

@cyx1231st

Copy link
Copy Markdown
Member

An object's local_clone_id should be consistent across different OSDs, which requires the local_clone_id to be exposed to the PG layer for the object recovery usage to avoid out-of-order cases with local_clone_id.

Not fully understood this, will the current 64-bit implementation cause inconsistent ordering of the clones among OSDs? If not, why leveraging a local-clone-id as part of the laddr will cause the ordering problem. IIUC the laddr itself isn't related to the object ordering, right?

@xxhdx1985126

xxhdx1985126 commented Jul 2, 2024 •

Copy link
Copy Markdown
Member

An object's local_clone_id should be consistent across different OSDs, which requires the local_clone_id to be exposed to the PG layer for the object recovery usage to avoid out-of-order cases with local_clone_id.

Not fully understood this, will the current 64-bit implementation cause inconsistent ordering of the clones among OSDs? If not, why leveraging a local-clone-id as part of the laddr will cause the ordering problem. IIUC the laddr itself isn't related to the object ordering, right?

It's not local-clone-id causing ordering problem. The issue is that the recovery order of clones/head are not deterministic, and in SeaStore, the corner cases can be significantly reduced if we can make sure that the order of local-clone-id and the order in which the clones are created are consistent. So we chose to encapsulate the local-clone-id in the object PUSH messages, so that the OSD being recovered can maintain the correct order of the clones.

@zhscn

zhscn commented Jul 2, 2024 •

Copy link
Copy Markdown
Member Author

For global metadata (RootBlock, CollectionNode and SeastoreNodeExtent), L_ADDR_MIN would still be sufficient as before, so they are unrelated to the metadata-bit.

For per-object metadata, as I'm getting the concept of object-prefix more clearly -- "each object has a unique object prefix on the lba tree", is it semantically better to move the metadata-bit after object-prefix, so metadata and data of the same object share the same object-prefix naturally (same object under the same lba subtree) ?

object prefix doesn't apply to object metadata due to the lack of handling of overflow cases for laddr allocation. Here the laoyout works as a hint.

  1. the most significant bits in crush represtent the pg id, which causes ineffeciency when a pg is not located at a certaion OSD, the corresponding lba address space can not be allocated effeciently by this OSD.

Is it related to the solution?

128-bit laddr doesn't solve this issue, listing it here is it causes the address exhaustion.

@cyx1231st

cyx1231st commented Jul 3, 2024 •

Copy link
Copy Markdown
Member

#55291 (comment)
It's not local-clone-id causing ordering problem. The issue is that the recovery order of clones/head are not deterministic...

Sounds the issue is related to the design of rados protocol, affecting classic/bluestore and crimson/alienstore as well, and we are planning to address it specifically in SeaStore by exposing the designing local-clone-id across OSDs. (cc @athanatos )

Does the indeterministic recovery order cause incorrectness or only cause performance issues?

@xxhdx1985126

xxhdx1985126 commented Jul 3, 2024 •

Copy link
Copy Markdown
Member

#55291 (comment)
It's not local-clone-id causing ordering problem. The issue is that the recovery order of clones/head are not deterministic...

Sounds the issue is related to the design of rados protocol, affecting classic/bluestore and crimson/alienstore as well, and we are planning to address it specifically in SeaStore by exposing the designing local-clone-id across OSDs. (cc @athanatos )

Does the indeterministic recovery order cause incorrectness or only cause performance issues?

Not only a perf issue, we think that the logic within the SeaStore may become very complex and very error prune if we allow the inconsistency between the local-clone-id order and the clone creation order. Actually, we did allow this at first and the debug work went into chaos, which led us to this design.

In practice, we added a new internal attribute LC_ATTR (local clone attribute) in addition to OI_ATTR and SS_ATTR, and made the following modification for recovery:

diff --git a/src/crimson/osd/replicated_recovery_backend.cc b/src/crimson/osd/replicated_recovery_backend.cc
index 03cf38e6954..1219c64c3c9 100644
--- a/src/crimson/osd/replicated_recovery_backend.cc
+++ b/src/crimson/osd/replicated_recovery_backend.cc
@@ -1153,16 +1153,31 @@ ReplicatedRecoveryBackend::prep_push_target(
                    __func__, target_oid);
     add_temp_obj(target_oid.hobj);
   }
+  auto iter = attrs.find(LC_ATTR);
+  ceph_assert(iter != attrs.end());
   // create a new object
   if (!complete || !recovery_info.object_exist) {
+    auto clone_id = LOCAL_CLONE_ID_NULL;
+    auto it = iter->second.cbegin();
+    decode(clone_id, it);
+    logger().debug("{}: creating target_oid {}, local_clone_id {}",
+      __func__, target_oid, clone_id);
     t->remove(coll->get_cid(), target_oid);
-    t->touch(coll->get_cid(), target_oid);
+    t->touch(
+      coll->get_cid(),
+      target_oid,
+      complete
+      ? std::nullopt
+      : std::make_optional<ghobject_t>(recovery_info.soid),
+      std::make_optional<local_clone_id_t>(clone_id));
     object_info_t oi;
     oi.decode_no_oid(attrs.at(OI_ATTR));
     t->set_alloc_hint(coll->get_cid(), target_oid,
                       oi.expected_object_size,
                       oi.expected_write_size,
                       oi.alloc_hint_flags);
+  } else {
+    t->setattr(coll->get_cid(), target_oid, LC_ATTR, iter->second);
   }
   if (complete) {
     // remove xattr and update later if overwrite on original object

Since we are adding new attr instead of changing existing attrs' semantic, I think only crimson + seastore need to worry about this modification, other components can simply ignore this change and remain untouched.

@xxhdx1985126

xxhdx1985126 commented Jul 3, 2024 •

Copy link
Copy Markdown
Member

Sounds the issue is related to the design of rados protocol

I think it's not about rados protocol, it's not changing protocols, only adds some new payload in recovery related messages.

@cyx1231st

Copy link
Copy Markdown
Member

#55291 (comment)

For global metadata (RootBlock, CollectionNode and SeastoreNodeExtent), L_ADDR_MIN would still be sufficient as before, so they are unrelated to the metadata-bit.

For per-object metadata, as I'm getting the concept of object-prefix more clearly -- "each object has a unique object prefix on the lba tree", is it semantically better to move the metadata-bit after object-prefix, so metadata and data of the same object share the same object-prefix naturally (same object under the same lba subtree) ?

object prefix doesn't apply to object metadata due to the lack of handling of overflow cases for laddr allocation. Here the laoyout works as a hint.

Allowing object metadata to share object-prefix already avoids collisions with other objects, and it is possible to further randomize the hint within the 47-bit local_clone_id_and_offset, similar to the current Onode::get_metadata_hint() when pick the next metadata hint upon collision. And 47bits(+12bits) seems to be a large enouge address space for metadata of an object, right?

Another property probably @xxhdx1985126 might be interested, if place both metadata/data under the same defined object-prefix, it'll be allow to implement faster methods to remove the object entirely, if the object metadata is not scattered/mixed with the other objects.

@zhscn

zhscn commented Jul 3, 2024 •

Copy link
Copy Markdown
Member Author

#55291 (comment)

it is possible to further randomize the hint within the 47-bit local_clone_id_and_offset

Looks reasonable, the details about metadata allocation and taking snapshots will be added into the documentation lately.

@xxhdx1985126

Copy link
Copy Markdown
Member

#55291 (comment)

For global metadata (RootBlock, CollectionNode and SeastoreNodeExtent), L_ADDR_MIN would still be sufficient as before, so they are unrelated to the metadata-bit.
For per-object metadata, as I'm getting the concept of object-prefix more clearly -- "each object has a unique object prefix on the lba tree", is it semantically better to move the metadata-bit after object-prefix, so metadata and data of the same object share the same object-prefix naturally (same object under the same lba subtree) ?

object prefix doesn't apply to object metadata due to the lack of handling of overflow cases for laddr allocation. Here the laoyout works as a hint.

Allowing object metadata to share object-prefix already avoids collisions with other objects, and it is possible to further randomize the hint within the 47-bit local_clone_id_and_offset, similar to the current Onode::get_metadata_hint() when pick the next metadata hint upon collision. And 47bits(+12bits) seems to be a large enouge address space for metadata of an object, right?

Another property probably @xxhdx1985126 might be interested, if place both metadata/data under the same defined object-prefix, it'll be allow to implement faster methods to remove the object entirely, if the object metadata is not scattered/mixed with the other objects.

Great! Thanks! Hah, we also wanted metadata extents of the same object to have the same prefix, but got stuck with how to allocate the medata extents' laddr, given your approach, we believe this is feasible. @zhscn will update the above document, and get down to implementing it once the discussion concludes:-)

@xxhdx1985126

Copy link
Copy Markdown
Member

#55291 (comment)
It's not local-clone-id causing ordering problem. The issue is that the recovery order of clones/head are not deterministic...

Sounds the issue is related to the design of rados protocol, affecting classic/bluestore and crimson/alienstore as well, and we are planning to address it specifically in SeaStore by exposing the designing local-clone-id across OSDs. (cc @athanatos )
Does the indeterministic recovery order cause incorrectness or only cause performance issues?

Not only a perf issue, we think that the logic within the SeaStore may become very complex and very error prune if we allow the inconsistency between the local-clone-id order and the clone creation order. Actually, we did allow this at first and the debug work went into chaos, which led us to this design.

In practice, we added a new internal attribute LC_ATTR (local clone attribute) in addition to OI_ATTR and SS_ATTR, and made the following modification for recovery:

diff --git a/src/crimson/osd/replicated_recovery_backend.cc b/src/crimson/osd/replicated_recovery_backend.cc
index 03cf38e6954..1219c64c3c9 100644
--- a/src/crimson/osd/replicated_recovery_backend.cc
+++ b/src/crimson/osd/replicated_recovery_backend.cc
@@ -1153,16 +1153,31 @@ ReplicatedRecoveryBackend::prep_push_target(
                    __func__, target_oid);
     add_temp_obj(target_oid.hobj);
   }
+  auto iter = attrs.find(LC_ATTR);
+  ceph_assert(iter != attrs.end());
   // create a new object
   if (!complete || !recovery_info.object_exist) {
+    auto clone_id = LOCAL_CLONE_ID_NULL;
+    auto it = iter->second.cbegin();
+    decode(clone_id, it);
+    logger().debug("{}: creating target_oid {}, local_clone_id {}",
+      __func__, target_oid, clone_id);
     t->remove(coll->get_cid(), target_oid);
-    t->touch(coll->get_cid(), target_oid);
+    t->touch(
+      coll->get_cid(),
+      target_oid,
+      complete
+      ? std::nullopt
+      : std::make_optional<ghobject_t>(recovery_info.soid),
+      std::make_optional<local_clone_id_t>(clone_id));
     object_info_t oi;
     oi.decode_no_oid(attrs.at(OI_ATTR));
     t->set_alloc_hint(coll->get_cid(), target_oid,
                       oi.expected_object_size,
                       oi.expected_write_size,
                       oi.alloc_hint_flags);
+  } else {
+    t->setattr(coll->get_cid(), target_oid, LC_ATTR, iter->second);
   }
   if (complete) {
     // remove xattr and update later if overwrite on original object

Since we are adding new attr instead of changing existing attrs' semantic, I think only crimson + seastore need to worry about this modification, other components can simply ignore this change and remain untouched.

After the discussion with @cyx1231st , we'll change to the random local-clone-id allocation approach, which should simplify the design and avoid the need to touch layers above SeaStore.

@zhscn

zhscn commented Jul 3, 2024 •

Copy link
Copy Markdown
Member Author

The design documentation #55291 (comment) is up to data. The summay of changes:

  1. local_clone_id is unordered and randomized in case of taking snapshot and recover.
  2. change the meaning of original metadata bit to the metadata of object. The hint of global metadata (RootBlock, CollectionNode and SeastoreNodeExtent) is L_ADDR_MIN. Objects should not use L_ADDR_MIN as prefix.
[upgrade:1][pool:12][shard:8][crush:32][random:27][object_data_and_metadata:48]

object_data_and_metadata:
[metadata:1][dynamic_bits:47]

dynamic bits for meatadata:
[random:47]

dynamic bits for data:
[local_clone_id:x][offset:47-x]

@cyx1231st

Copy link
Copy Markdown
Member

I don't see any further concerns looking at the design and scope.

Just some nits:

  • crush -> reverse_hash (might be more accurate)
  • random -> local_object_id (consistent with local_clone_id)

Might look better like:

[upgrade:1][pool:12][shard:8][reverse_hash:32][local_object_id:27][is_metadata:1][object_content:47]

Let's organize the commits to split pure-refactor/cleanup and core-modifications with clear messages.

That would be helpful a lot in understanding the core changes and impacts more quickly.

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants