Bug #79156
closedcephfs-mirror: pure truncate/extend is silently omitted when blockdiff returns no changed blocks
0%
Description
Description¶
cephfs-mirror can silently create the remote snapshot and advance the mirror checkpoint while leaving a regular file at its previous size when the only change between snapshots is a truncate or size extension.
This was reproduced on Ceph main commit 294c4c77a08. The mirror reports snap_b as synchronized, but the target snapshot keeps the size and SHA-256 from snap_a.
Environment¶
- Ceph main:
294c4c77a08 - vstart test environment with two CephFS filesystems
- ceph-fuse clients
debug_mds = 30debug_cephfs_mirror = 20- Automated test:
TestMirroring.test_cephfs_mirror_blockdiff_pure_truncate
Reproduction¶
- Create one mirrored directory containing four dense regular files:
object_boundary_shrink: 64 MiBpartial_object_shrink: 64 MiBsame_object_shrink: 19 MiBsame_object_extend: 18 MiB
- Create
snap_aand wait until cephfs-mirror reports it synchronized. - Change only the file sizes:
- 64 MiB -> 32 MiB
- 64 MiB -> 33 MiB
- 19 MiB -> 18 MiB
- 18 MiB -> 19 MiB
- Create
snap_band wait until peer status reportslast_synced_snap=snap_bandsnaps_synced=2. - Compare file type, exact byte size, and SHA-256 between source and target
snap_b.
Actual result¶
All four cases reproduce. The destination retains the exact size and SHA-256 of snap_a:
| Case | Source snap_b | Destination snap_b |
|---|---|---|
| object boundary shrink | 33554432 bytes | 67108864 bytes |
| partial object shrink | 34603008 bytes | 67108864 bytes |
| same object shrink | 18874368 bytes | 19922944 bytes |
| same object extend | 19922944 bytes | 18874368 bytes |
The source and destination hashes differ in every case. The destination hash is the old snap_a hash.
Ran 1 test in 143.209s FAILED (failures=1) RUNNER_EXIT=255
Blockdiff evidence¶
For the three shrink cases, ceph_file_blockdiff() completes successfully but returns no changed blocks:
file_blockdiff_init_state: (snapid1, size)=(2,67108864) (snapid2, size)=(3,33554432)
file_blockdiff: block_diff={rval: 1, scan_idx=8, blocks=[]}
file_blockdiff: block_diff={rval: 0, scan_idx=8, blocks=[]}
run_datasync: done for epath=./object_boundary_shrink
file_blockdiff_init_state: (snapid1, size)=(2,67108864) (snapid2, size)=(3,34603008)
file_blockdiff: block_diff={rval: 1, scan_idx=9, blocks=[]}
file_blockdiff: block_diff={rval: 0, scan_idx=9, blocks=[]}
file_blockdiff_init_state: (snapid1, size)=(2,19922944) (snapid2, size)=(3,18874368)
file_blockdiff: block_diff={rval: 1, scan_idx=5, blocks=[]}
file_blockdiff: block_diff={rval: 0, scan_idx=5, blocks=[]}
The MDS logs contain file_blockdiff: truncated extent for the 64 MiB shrink cases.
PeerReplayer::get_changed_blocks() invokes its callback only when blocks.num_blocks is non-zero. PeerReplayer::copy_to_remote() performs ceph_ftruncate(remote_fd, stx.stx_size) at the end of that callback. Therefore, when blockdiff returns blocks=[], the remote file is never truncated even though datasync completes successfully.
The pure extension case is also silently omitted. It should be traced separately to determine whether the entry is filtered before blockdiff and whether #74984 contributes to that part of the result. It does not explain the shrink cases because those files reach blockdiff and return blocks=[].
Expected result¶
A size-only change must update the target file length even when blockdiff reports zero changed data extents. The mirror must not create the target snapshot or advance its checkpoint while the target file size differs from the source snapshot.
Related issues¶
- #79011 is also a silent blockdiff omission, but concerns objects first created after the older snapshot.
- #78964 concerns sparse holes returning EIO and failing synchronization.
- #74984 concerns entries omitted by snapdiff during snapshot writeback/mtime handling.
- None of these records covers successful blockdiff with
blocks=[]followed by a missing remote truncate.
VS Updated by Venky Shankar 4 months ago
- Status changed from New to Fix Under Review
- Target version set to v22.0.0
- Backport set to umbrella,tentacle
UB Updated by Upkeep Bot 2 months ago
- Copied to Backport #80770: umbrella: cephfs-mirror: pure truncate/extend is silently omitted when blockdiff returns no changed blocks added
UB Updated by Upkeep Bot 2 months ago
- Copied to Backport #80771: tentacle: cephfs-mirror: pure truncate/extend is silently omitted when blockdiff returns no changed blocks added
UB Updated by Upkeep Bot 2 months ago
- Status changed from Fix Under Review to Backporting
- Merge Commit set to a3c066d742107e382be27966d077e1196df24883
- Fixed In set to v21.3.0-3545-ga3c066d742
- Upkeep Timestamp set to 2026-09-23T04:25:17+00:00