mirror of
https://github.com/ceph/ceph
synced 2024-12-25 21:03:31 +00:00
a9ed8d3279
rbd rounds off and ignores discards that are smaller than alloc_size, but the page cache is invalidated according to the original offset and length, before calling into the driver. For a 512~4193792 discard, all pages except for the first will be invalidated, but the first page may remain cached after being partially zeroed out. This results in an inconsistency when alloc_size != 512. E.g. for 64k: 0 512 4k 64k 4M | | | | | page cache: xxxxxxxx00000000xxxxxxxx0000000000000000 RADOS: xxxxxxxxxxxxxxxxxxxxxxxx0000000000000000 Given that these tests asserts on-disk state, we need to read directly from disk. krbd_discard_512b.t and krbd_zeroout.t are fine -- there is no rounding there. Fixes: https://tracker.ceph.com/issues/41753 Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
331 lines
9.1 KiB
Perl
331 lines
9.1 KiB
Perl
|
|
$ rbd create --size 4M img
|
|
$ DEV=$(sudo rbd map -o alloc_size=4194304 img)
|
|
|
|
Zero, < 1 block:
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 156672 -l 512 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 131584 -l 64512 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 131584 -l 65024 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 131072 -l 65024 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
Zero, 1 block:
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 131072 -l 65536 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 131072 -l 66048 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 130560 -l 66048 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 130560 -l 66560 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
Zero, < 2 blocks:
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 163840 -l 65536 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 131584 -l 130048 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 131584 -l 130560 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 131072 -l 130560 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
Zero, 2 blocks:
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 131072 -l 131072 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 131072 -l 131584 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 130560 -l 131584 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 130560 -l 132096 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
Zero, 37 blocks:
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 589824 -l 2424832 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 589312 -l 2424832 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 590336 -l 2424832 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
Truncate:
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 4193792 -l 512 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
03ffe00 0000 0000 0000 0000 0000 0000 0000 0000
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 4129280 -l 65024 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
03f0200 0000 0000 0000 0000 0000 0000 0000 0000
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 4128768 -l 65536 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
03f0000 0000 0000 0000 0000 0000 0000 0000 0000
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 4128256 -l 66048 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
03efe00 0000 0000 0000 0000 0000 0000 0000 0000
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 4063744 -l 130560 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
03e0200 0000 0000 0000 0000 0000 0000 0000 0000
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 4063232 -l 131072 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
03e0000 0000 0000 0000 0000 0000 0000 0000 0000
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 4062720 -l 131584 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
03dfe00 0000 0000 0000 0000 0000 0000 0000 0000
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 512 -l 4193792 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0000200 0000 0000 0000 0000 0000 0000 0000 0000
|
|
*
|
|
0400000
|
|
|
|
Delete:
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 0 -l 4194304 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 0000 0000 0000 0000 0000 0000 0000 0000
|
|
*
|
|
0400000
|
|
|
|
Empty clone:
|
|
|
|
$ xfs_io -c 'pwrite -S 0xab -w 0 4M' $DEV >/dev/null
|
|
$ sudo rbd unmap $DEV
|
|
$ rbd snap create img@snap
|
|
$ rbd snap protect img@snap
|
|
|
|
$ rbd clone img@snap cloneimg1
|
|
$ DEV=$(sudo rbd map -o alloc_size=4194304 cloneimg1)
|
|
$ blkdiscard -o 720896 -l 2719744 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 abab abab abab abab abab abab abab abab
|
|
*
|
|
0400000
|
|
$ sudo rbd unmap $DEV
|
|
|
|
$ rbd clone img@snap cloneimg2
|
|
$ DEV=$(sudo rbd map -o alloc_size=4194304 cloneimg2)
|
|
$ blkdiscard -o 1474560 -l 2719744 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 abab abab abab abab abab abab abab abab
|
|
*
|
|
0400000
|
|
$ sudo rbd unmap $DEV
|
|
|
|
$ rbd clone img@snap cloneimg3
|
|
$ DEV=$(sudo rbd map -o alloc_size=4194304 cloneimg3)
|
|
$ blkdiscard -o 0 -l 4194304 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 abab abab abab abab abab abab abab abab
|
|
*
|
|
0400000
|
|
$ sudo rbd unmap $DEV
|
|
|
|
Full clone:
|
|
|
|
$ rbd clone img@snap cloneimg4
|
|
$ DEV=$(sudo rbd map -o alloc_size=4194304 cloneimg4)
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 720896 -l 2719744 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 1474560 -l 2719744 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
0168000 0000 0000 0000 0000 0000 0000 0000 0000
|
|
*
|
|
0400000
|
|
|
|
$ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null
|
|
$ blkdiscard -o 0 -l 4194304 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 0000 0000 0000 0000 0000 0000 0000 0000
|
|
*
|
|
0400000
|
|
|
|
$ sudo rbd unmap $DEV
|
|
|
|
Multiple object requests:
|
|
|
|
$ rbd create --size 50M --stripe-unit 16K --stripe-count 5 fancyimg
|
|
$ DEV=$(sudo rbd map -o alloc_size=4194304 fancyimg)
|
|
|
|
$ xfs_io -c 'pwrite -b 4M -w 0 50M' $DEV >/dev/null
|
|
$ blkdiscard -o 0 -l 143360 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
3200000
|
|
|
|
$ xfs_io -c 'pwrite -b 4M -w 0 50M' $DEV >/dev/null
|
|
$ blkdiscard -o 0 -l 286720 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
3200000
|
|
|
|
$ xfs_io -c 'pwrite -b 4M -w 0 50M' $DEV >/dev/null
|
|
$ blkdiscard -o 0 -l 573440 $DEV
|
|
$ dd if=$DEV iflag=direct bs=4M status=none | hexdump
|
|
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
|
*
|
|
3200000
|
|
|
|
$ sudo rbd unmap $DEV
|
|
|
|
$ rbd rm --no-progress fancyimg
|
|
$ rbd rm --no-progress cloneimg4
|
|
$ rbd rm --no-progress cloneimg3
|
|
$ rbd rm --no-progress cloneimg2
|
|
$ rbd rm --no-progress cloneimg1
|
|
$ rbd snap unprotect img@snap
|
|
$ rbd snap rm --no-progress img@snap
|
|
$ rbd rm --no-progress img
|