Skip to content

rados: use omap v2 bindings#643

Merged
mergify[bot] merged 6 commits intoceph:masterfrom
gman0:omap-keys-v2
Mar 9, 2022
Merged

rados: use omap v2 bindings#643
mergify[bot] merged 6 commits intoceph:masterfrom
gman0:omap-keys-v2

Conversation

@gman0
Copy link
Contributor

@gman0 gman0 commented Feb 10, 2022

This PR is a follow-up to our previous discussion in #629 (comment) .

All RADOS bindings that handle OMap keys now use their "more flexible" librados versions that consume byte strings with explicit lengths instead of expecting them to be null-terminated.

I have done a bit of refactoring too -- creating new C-allocated arrays to store the key sizes seemed like too much boilerplate. To that end I have added cutil.GoCSLenSlice that handles byte arrays and size arrays in one go.

Also, it seems that some of the *Step structs were unnecessary: these particular C functions in librados make copies of their args anyway, so it seems there is no need to keep them around for longer in the *Step structs...

I've tried to split this PR into multiple commits for easier review. Please see commit messages for more details about the individual changes.

Checklist

  • Added tests for features and functional changes
  • Public functions and types are documented
  • Standard formatting is applied to Go code
  • Is this a new API? Is this new API marked PREVIEW?

@gman0 gman0 force-pushed the omap-keys-v2 branch 2 times, most recently from 3c32e59 to 68745c6 Compare February 10, 2022 20:45
@ansiwen
Copy link
Collaborator

ansiwen commented Feb 10, 2022

Awesome, thanks! Will review soon.

@ansiwen ansiwen added API This PR includes a change to the public API of a go-ceph package no-API This PR does not include any changes to the public API of a go-ceph package and removed API This PR includes a change to the public API of a go-ceph package labels Feb 14, 2022
Copy link
Collaborator

@ansiwen ansiwen left a comment

Choose a reason for hiding this comment

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

I only have one little comment request, otherwise looks good. 👍

@gman0
Copy link
Contributor Author

gman0 commented Mar 4, 2022

  • NewBufferGroupStrings() now uses C.CBytes()
  • Added a TODO comment regarding PtrGuard to buffergroup.go
  • Renamed BufferGroup.CStrings to BufferGroup.Buffers

@gman0
Copy link
Contributor Author

gman0 commented Mar 4, 2022

If you are ok with the changes please let me know if the commits need to be squashed.

@ansiwen
Copy link
Collaborator

ansiwen commented Mar 4, 2022

If you are ok with the changes please let me know if the commits need to be squashed.

No, I'm fine with it as is. Only if there is a back and forth or fix-ups in the commits, I would prefer them to be squashed, but it seems to me, that your commits are not that.

@gman0
Copy link
Contributor Author

gman0 commented Mar 7, 2022

@Mergifyio rebase

gman0 added 6 commits March 7, 2022 15:21
BufferGroup is a helper structure that holds Go-allocated slices of
C-allocated strings and their respective lengths. Useful for C functions
that consume byte buffers with explicit length instead of null-terminated
strings.
GetOmapSte.Next() and ReadOpOmapGetValsByKeysStep.Next() now use
rados_omap_get_next2().
ReadOp.GetOmapValuesByKeys() now uses rados_read_op_omap_get_vals_by_keys2().
C strings that are passed in to rados_read_op_omap_get_vals2() are copied by
the function, see [1][2] for its implementation. It's therefore not necessary for
them to be owned by GetOmapStep. It's enough to construct and destruct them
in ReadOp.GetOmapValues.

[1] https://github.com/ceph/ceph/blob/2bd3dd512ab42f6e5d5d0dd5f5428b783681802e/src/librados/librados_c.cc#L4334-L4358
[2] https://github.com/ceph/ceph/blob/2bd3dd512ab42f6e5d5d0dd5f5428b783681802e/src/include/rados/librados.hpp#L572-L587
WriteOp.SetOmap now uses rados_write_op_omap_set2().

The entirety of setOmapStep struct was removed as it's not necessary for it to
own the various C-allocated values passed to rados_write_op_omap_set2()
as arguments. rados_write_op_omap_set2() makes copies of all the string-based
args [1], so it's sufficient for them to be short lived.

[1] https://github.com/ceph/ceph/blob/2bd3dd512ab42f6e5d5d0dd5f5428b783681802e/src/librados/librados_c.cc#L3852-L3871
WriteOp.RmOmapKeys now uses rados_write_op_omap_rm_keys2().

The entirety of removeOmapKeysStep struct was removed as it's not necessary for
it to own the various C-allocated values passed to
rados_write_op_omap_rm_keys2() as arguments. rados_write_op_omap_rm_keys2()
makes copies of all the string-based args [1], so it's sufficient for them to
be short lived.

[1] https://github.com/ceph/ceph/blob/2bd3dd512ab42f6e5d5d0dd5f5428b783681802e/src/librados/librados_c.cc#L3888-L3902
@mergify
Copy link

mergify bot commented Mar 7, 2022

rebase

✅ Branch has been successfully rebased

@gman0
Copy link
Contributor Author

gman0 commented Mar 8, 2022

@phlogistonjohn @ansiwen I think all comments have been addressed. Can you take a look please?

Copy link
Collaborator

@phlogistonjohn phlogistonjohn left a comment

Choose a reason for hiding this comment

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

Thanks for all the hard work & documenting the various places the ceph code does copies! It makes it easy for me to be confident in these simplifications.

@mergify mergify bot merged commit 3eba56c into ceph:master Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-API This PR does not include any changes to the public API of a go-ceph package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants