Bug #63770
Updated by Ilya Dryomov 5 months ago
On an image without fast-diff feature: <pre> $ rbd create -s 1G --image-shared foo $ sudo rbd device map foo /dev/rbd0 $ sudo xfs_io -d -c 'pwrite 0 2M' /dev/rbd0 wrote 2097152/2097152 bytes at offset 0 $ rbd snap create foo@snap Creating snap: 100% complete...done. $ sudo blkdiscard -o 1M -l 2M /dev/rbd0 $ sudo rbd device unmap /dev/rbd0 </pre> Running a diff from the beginning of time to HEAD: <pre> $ rbd diff foo Offset Length Type 0 2097152 data </pre> 0~1M extent is expected instead of 0~2M extent, because the size of the object in question is 1M: <pre> $ rbd info foo | grep block_name_prefix block_name_prefix: rbd_data.81db3b85b87e $ rados -p rbd stat rbd_data.81db3b85b87e.0000000000000000 rbd/rbd_data.81db3b85b87e.0000000000000000 mtime 2023-12-08T12:26:57.000000+0100, size 1048576 </pre> This appears to be yet another bug in calc_snap_set_diff() which only ever appends to the diff: <pre> calc_snap_set_diff start 0 end 18446744073709551614, snap_set seq 24 clone 24 snaps [24] -> [24,24] size 2097152 overlap to next [0,1048576] start, after 0 diff_to_next [1048576~1048576] diff now [0~2097152] clone 18446744073709551614 snaps [] -> [25,18446744073709551614] size 1048576 overlap to next [] end </pre> calc_snap_set_diff().