Skip to content

squid: libcephfs: introduce snapdiff v2 API to fix ABI breakage - #72936

Open
vshankar wants to merge 8 commits into
ceph:squidfrom
vshankar:wip-80286-squid
Open

vshankar wants to merge 8 commits into
ceph:squidfrom
vshankar:wip-80286-squid

Conversation

Igor Fedotov and others added 8 commits October 21, 2026 18:28
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]>
(cherry picked from commit 02436eb)
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]>
(cherry picked from commit 5777ca5)
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]>
(cherry picked from commit 4f067bb)
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]>
(cherry picked from commit 4188bc7)
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]>
(cherry picked from commit 29ba8b4)
Credit to @idryomov for noticing this.

Signed-off-by: Venky Shankar <[email protected]>
(cherry picked from commit b66c6a8)
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]>
(cherry picked from commit da460f1)

Conflicts:
  src/include/cephfs/libcephfs.h

Fixup major/minor/extra version to be simimlar to main.
@vshankar vshankar added this to the squid milestone Oct 21, 2026
@vshankar vshankar added the cephfs Ceph File System label Oct 21, 2026
github-actions[bot]

This comment was marked as outdated.

@github-actions github-actions Bot added the releng-audit-fail Release engineering: failed backport verification audit. label Oct 21, 2026
@vshankar

Copy link
Copy Markdown
Contributor Author

/audit retest

@github-actions

Copy link
Copy Markdown

🔄 Audit Retest Triggered by @vshankar.

View workflow run

@github-actions github-actions Bot removed the releng-audit-fail Release engineering: failed backport verification audit. label Oct 21, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ceph Release Engineering Audit Report

Commit Parity Visualizer

BACKPORT PR #72936 SOURCE PR SOURCE STATUS
86a39c6 cephfs/snapdiff: introduce mask param for file attr changes PR #68054 9c958c6 cephfs/snapdiff: introduce mask param for file attr changes
cdeea41 libcephfs: introduce snapdiff v2 API to fix ABI breakage PR #70912 02436eb libcephfs: introduce snapdiff v2 API to fix ABI breakage
1ae157e pybind/cephfs: implement support for snapdiff v2 API 5777ca5 pybind/cephfs: implement support for snapdiff v2 API
0835192 pybind/cephfs: fix double-free in SnapDiffHandle[,2] close 4f067bb pybind/cephfs: fix double-free in SnapDiffHandle[,2] close
e758fb2 tests: add coverage for libcephfs snapdiff v2 API 4188bc7 tests: add coverage for libcephfs snapdiff v2 API
af00ee6 cephfs-mirror: revert to using snapdiff v1 API 29ba8b4 cephfs-mirror: revert to using snapdiff v1 API
c3cf989 mds: revert to dout(30) in Server::build_snap_diff() b66c6a8 mds: revert to dout(30) in Server::build_snap_diff()
b043358 libcephfs: bump minor version to 11.1.0 da460f1 libcephfs: bump minor version to 11.1.0

Automated Backport Parity Review - Cherry-Pick Conflicts / Deviations

⚠️ WARNING: Cherry-pick conflicts or deviations were found that require component lead review.

A conflict or deviation was detected during the simulation of this backport. The code in this PR does not match a clean cherry-pick of the upstream commits.

This does not necessarily indicate an issue but a maintainer should review.

**Click to expand conflict summaries.**

Deviation in Backport b043358 (cherry-pick of da460f1)

Affected File(s)

Range Diff

Click to expand
--- Original (da460f13)
+++ Backport (b0433580)
@@ -10,3 +10,9 @@
 has been reset to 0.
 
 Signed-off-by: Venky Shankar <[email protected]>
+(cherry picked from commit da460f135ff817878a7f104e5b40221dac87d0e2)
+
+Conflicts:
+  src/include/cephfs/libcephfs.h
+
+Fixup major/minor/extra version to be simimlar to main.

================================================================================
RANGE DIFF
================================================================================

1:  da460f135ff < -:  ----------- libcephfs: bump minor version to 11.1.0
-:  ----------- > 1:  b0433580b8f libcephfs: bump minor version to 11.1.0

How to proceed:

  • Authors (Genuine Conflicts): If this is a genuine conflict requiring manual resolution, ensure your resolution is correct. You must explain the conflict resolution in the commit message (e.g., leave the standard Git Conflicts: block intact) and include an explanation for changes.
  • Authors (Need Help?): Reach out to the Component Lead for technical guidance on complex code conflicts.
  • Component Leads (Review): Please review the Range Diff(s) above to verify the author's manual conflict resolution is correct for this release branch. If the deviation is intentional, documented, and approved then the component lead or @ceph/ceph-release-manager can bypass this check by commenting /audit override.

Be familiar with the rules and guidelines for writing backports.


🛟 Need Help?

If you need technical help resolving these issues, please consult with the Component Lead. If you need administrative overrides, please see the #ceph-upstream-releases channel on Slack and request a review from the @ceph/ceph-release-manager.

📋 Component Lead / Release Manager

To override the audit failure, apply releng-audit-override label or comment /audit override.


⚠️ Note: Automated audit checks will be suspended on future pushes to prevent comment spam while you work.

When you are ready for a new audit, please remove the releng-audit-fail label or comment /audit retest.

View workflow run

@github-actions github-actions Bot added the releng-audit-fail Release engineering: failed backport verification audit. label Oct 21, 2026
@vshankar

Copy link
Copy Markdown
Contributor Author

/audit override

@github-actions github-actions Bot added releng-audit-override and removed releng-audit-fail Release engineering: failed backport verification audit. labels Oct 21, 2026
@github-actions

Copy link
Copy Markdown

✅ Audit Override Applied by @vshankar.

View workflow run

@yuriw

yuriw commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-yuri5-testing-20261117.214518-squid.

@yuriw

yuriw commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

@vshankar

Removing this from wip-yuri5-testing-20261117.214518-squid — it breaks the squid build everywhere (all deb and rpm builds fail).

Build: https://jenkins.ceph.com/job/ceph-dev-pipeline/11057/

cephfs.pyx:429:30: undeclared name not builtin: DIRENT_D_OFF
cephfs.pyx:429:43: Cannot convert 'dirent *' to Python object

(then Cython hits AssertionError in to_py_call_code and the cython_cephfs target fails)

The backport adds d_off=DIRENT_D_OFF(&difent.dir_entry) in cephfs.pyx, but squid has no DIRENT_D_OFF anywhere. On main it is defined in src/pybind/cephfs/c_cephfs.pxd (a #define plus a cdef extern declaration). That part was not backported, so the name is undeclared.

Please backport the DIRENT_D_OFF macro and declaration from main (or use dirent.d_off directly if squid only needs Linux), then re-request QA.

Removed labels: wip-yuri5-testing, needs-qa.

@yuriw

yuriw commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

This PR has been removed from wip-yuri5-testing-20261117.214518-squid.

@vshankar

Copy link
Copy Markdown
Contributor Author

@vshankar

Removing this from wip-yuri5-testing-20261117.214518-squid — it breaks the squid build everywhere (all deb and rpm builds fail).

Build: https://jenkins.ceph.com/job/ceph-dev-pipeline/11057/

cephfs.pyx:429:30: undeclared name not builtin: DIRENT_D_OFF
cephfs.pyx:429:43: Cannot convert 'dirent *' to Python object

(then Cython hits AssertionError in to_py_call_code and the cython_cephfs target fails)

The backport adds d_off=DIRENT_D_OFF(&difent.dir_entry) in cephfs.pyx, but squid has no DIRENT_D_OFF anywhere. On main it is defined in src/pybind/cephfs/c_cephfs.pxd (a #define plus a cdef extern declaration). That part was not backported, so the name is undeclared.

Please backport the DIRENT_D_OFF macro and declaration from main (or use dirent.d_off directly if squid only needs Linux), then re-request QA.

Removed labels: wip-yuri5-testing, needs-qa.

Apologies. I will fix it up.

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.

2 participants