Project

General

Profile

Actions

Bug #79156

closed
LS

cephfs-mirror: pure truncate/extend is silently omitted when blockdiff returns no changed blocks

Bug #79156: cephfs-mirror: pure truncate/extend is silently omitted when blockdiff returns no changed blocks

Added by Li Sheng 4 months ago. Updated 2 months ago.

Status:
Backporting
Priority:
Normal
Assignee:
-
Category:
Correctness/Safety
Target version:
Due date:
% Done:

0%

Source:
Development
Backport:
umbrella,tentacle
Regression:
No
Severity:
2 - major
Reviewed:
Affected Versions:
ceph-qa-suite:
fs
Component(FS):
MDS, cephfs-mirror
Labels (FS):
qa, snapshots
Pull request ID:
Tags (freeform):
Fixed In:
v21.3.0-3545-ga3c066d742
Released In:
Upkeep Timestamp:
2026-09-23T04:25:17+00:00

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 = 30
  • debug_cephfs_mirror = 20
  • Automated test: TestMirroring.test_cephfs_mirror_blockdiff_pure_truncate

Reproduction

  1. Create one mirrored directory containing four dense regular files:
    1. object_boundary_shrink: 64 MiB
    2. partial_object_shrink: 64 MiB
    3. same_object_shrink: 19 MiB
    4. same_object_extend: 18 MiB
  2. Create snap_a and wait until cephfs-mirror reports it synchronized.
  3. Change only the file sizes:
    1. 64 MiB -> 32 MiB
    2. 64 MiB -> 33 MiB
    3. 19 MiB -> 18 MiB
    4. 18 MiB -> 19 MiB
  4. Create snap_b and wait until peer status reports last_synced_snap=snap_b and snaps_synced=2.
  5. 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.

Related issues 2 (2 open — 0 closed)

Copied to CephFS - Backport #80770: umbrella: cephfs-mirror: pure truncate/extend is silently omitted when blockdiff returns no changed blocksIn ProgressKotresh Hiremath Ravishankar

Actions
Copied to CephFS - Backport #80771: tentacle: cephfs-mirror: pure truncate/extend is silently omitted when blockdiff returns no changed blocksNew

Actions

LS Updated by Li Sheng 4 months ago Actions #1

  • Pull request ID set to 70923

VS Updated by Venky Shankar 4 months ago Actions #2

  • 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 Actions #3

  • 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 Actions #4

  • 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 Actions #5

  • 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
Actions

Also available in: PDF Atom