Repository navigation
libcephfs: introduce snapdiff v2 API to fix ABI breakage - #70912
Conversation
| snap1id = cephfs.snap_info(b"/snapdiff_test/.snap/snap1")['id'] | ||
| snap2id = cephfs.snap_info(b"/snapdiff_test/.snap/snap2")['id'] | ||
| diff = cephfs.opensnapdiff(b"/snapdiff_test", b"/", b"snap2", b"snap1", | ||
| diff = cephfs.opensnapdiff2(b"/snapdiff_test", b"/", b"snap2", b"snap1", |
There was a problem hiding this comment.
Shouldn't we have test case for opensnapdiff binding too?
There was a problem hiding this comment.
Fair. Will add that.
There was a problem hiding this comment.
Done -- kept test_snapdiff() and added test_snapdiff2()
anoopcs9
left a comment
There was a problem hiding this comment.
In general, I think the existing tests on the v1 APIs should stay as they are.
Sure. For the C++ test, I will then branch the snapdiff call based on diff_mask (diff_mask=0 calls v1 API, else v2). |
| h.opened = 1 | ||
| return h | ||
|
|
||
| def opensnapdiff2(self, root_path, rel_path, snap1name, snap2name, diff_mask) -> SnapDiffHandle2: |
There was a problem hiding this comment.
Does the Python binding need literally the same treatment as the C API? It seems like diff_mask parameter could just be added to the existing opensnapdiff() and defaulted to 0. The implementation could be switched to ceph_open_snapdiff2() under the hood as SnapDiffHandle in Python never exposed anything about the underlying struct ceph_snapdiff_info.
There was a problem hiding this comment.
That is a fair point. I initially split it into opensnapdiff2 to maintain a strict 1:1 mapping with the C API and to follow the precedent set by mds_command and mds_command2.
However, since Python handles default keyword arguments gracefully without breaking downstream consumers, unifying them into a single opensnapdiff(..., diff_mask=0) method definitely keeps the Python surface area cleaner.
I do not have a strong opinion on this and willing to switch to this if required.
| * @param rel_path subpath under the root to build delta for | ||
| * @param snap1 the first snapshot name | ||
| * @param snap2 the second snapshot name | ||
| * @param diff_mask file metadata change mask to apply for delta building |
There was a problem hiding this comment.
It's noted in other places but not where it matters the most -- on the public API:
| * @param diff_mask file metadata change mask to apply for delta building | |
| * @param diff_mask file metadata change mask to apply for delta building (CEPH_SNAPDIFF_*) |
142a420 to
ede6d63
Compare
|
Change with latest push
|
ede6d63 to
c7a9405
Compare
anoopcs9
left a comment
There was a problem hiding this comment.
One last comment, otherwise lgtm.
The previous addition of the `diff_mask` parameter to the snapdiff API altered the signature of `ceph_open_snapdiff` and affected the public `ceph_snapdiff_info` struct, breaking both API and ABI for downstream consumers (such as go-ceph). This commit restores the original v1 API and ABI to preserve backward compatibility. To support passing the `diff_mask` to the Client layer, this introduces a v2 API: - `ceph_open_snapdiff2` - `ceph_readdir_snapdiff2` - `ceph_close_snapdiff2` To future-proof the API, the v2 handle (`struct ceph_snapdiff_info2`) is declared as an opaque pointer in the public header. Internally, the v2 struct embeds the v1 struct to eliminate code duplication across the public endpoints. Fixes: https://tracker.ceph.com/issues/79154 Reported-by: Anoop C S <[email protected]> Introduced-by: 9c958c6 Signed-off-by: Venky Shankar <[email protected]>
Updates the Cython bindings (`c_cephfs.pxd`, `mock_cephfs.pxi`, and `cephfs.pyx`) to support the new `ceph_open_snapdiff2` C API. Introduces a new `opensnapdiff2` method and a corresponding `SnapDiffHandle2` class to allow Python consumers to pass the `diff_mask` parameter. The original `opensnapdiff` and `SnapDiffHandle` implementations are left untouched to ensure backward compatibility for existing scripts. Fixes: https://tracker.ceph.com/issues/79154 Reported-by: Anoop C S <[email protected]> Introduced-by: 9c958c6 Signed-off-by: Venky Shankar <[email protected]>
The C++ `ceph_close_snapdiff2` (and its v1 version) function unconditionally deletes the allocated `ceph_snapdiff_info2` struct. Previously, if this function returned an error code, the Cython wrapper raised a Python exception before setting `self.opened = 0` and `self.handle = NULL`. Because the internal state remained "open" with a dangling pointer, Python's garbage collector would eventually trigger `__dealloc__`. This caused `close()` to be executed a second time on the already-freed pointer, resulting in a double-free segmentation fault. This commit fixes the issue by unconditionally updating the object's internal state to closed and nullifying the pointer before evaluating the return code and raising any exceptions. Caught by @anoopcs9 during review. Signed-off-by: Venky Shankar <[email protected]>
Update the libcephfs snapdiff test suite to validate both the restored v1 ABI and the newly introduced v2 API. - Introduced the `for_each_readdir_snapdiff2` helper to test the v2 API using the opaque `ceph_snapdiff_info_v2` struct and `diff_mask`. - Retained the original `for_each_readdir_snapdiff` helper to ensure the restored v1 API remains continuously tested for strict backward compatibility. - Updated `readdir_snapdiff_and_compare` to dynamically route to the v1 helper when `diff_mask == 0`, and to the v2 helper when a mask is actively being tested. - Python tests: Added coverage for the `opensnapdiff2` binding and `SnapDiffHandle2` iteration. Signed-off-by: Venky Shankar <[email protected]>
Updates the CephFS mirroring daemon to drop the `diff_mask` parameter and revert to using the standard `ceph_open_snapdiff` API. The mirror daemon does not use the new mask functionality righit now, it can safely rely on the restored v1 ABI. This resolves compilation and integration mismatches caused by the previous API breakage. cephfs-mirror will rely on v2 API in a separate change. Signed-off-by: Venky Shankar <[email protected]>
Credit to @idryomov for noticing this. Signed-off-by: Venky Shankar <[email protected]>
Bump the libcephfs minor version to reflect the addition of the new snapdiff v2 APIs (ceph_open_snapdiff2, ceph_readdir_snapdiff2, and ceph_close_snapdiff2). Since these functions introduce new functionality to the public API while strictly maintaining backward compatibility with the existing v1 ABI, a minor version increment is required. The extra/patch version has been reset to 0. Signed-off-by: Venky Shankar <[email protected]>
c7a9405 to
da460f1
Compare
|
This PR has been added to main integration testing by vshankar started 2026-08-31-13:37. |
https://tracker.ceph.com/issues/79154
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
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.