mirror of
https://github.com/ceph/ceph
synced 2025-02-23 11:07:35 +00:00
Merge pull request #21513 from idryomov/wip-krbd-notrim-test
qa: krbd_fallocate.sh: add notrim test case Reviewed-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
commit
b74489ece3
@ -42,6 +42,10 @@ EOF
|
||||
|
||||
function allocate() {
|
||||
xfs_io -c "pwrite -b $OBJECT_SIZE -W 0 $IMAGE_SIZE" $DEV
|
||||
assert_allocated
|
||||
}
|
||||
|
||||
function assert_allocated() {
|
||||
cmp <(od -xAx $DEV) - <<EOF
|
||||
000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
|
||||
*
|
||||
@ -50,16 +54,18 @@ EOF
|
||||
[[ $(rados -p rbd ls | grep -c rbd_data.$IMAGE_ID) -eq $NUM_OBJECTS ]]
|
||||
}
|
||||
|
||||
function assert_deallocated() {
|
||||
function assert_zeroes() {
|
||||
local num_objects_expected=$1
|
||||
|
||||
cmp <(od -xAx $DEV) - <<EOF
|
||||
000000 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
*
|
||||
$(printf %x $IMAGE_SIZE)
|
||||
EOF
|
||||
[[ $(rados -p rbd ls | grep -c rbd_data.$IMAGE_ID) -eq 0 ]]
|
||||
[[ $(rados -p rbd ls | grep -c rbd_data.$IMAGE_ID) -eq $num_objects_expected ]]
|
||||
}
|
||||
|
||||
function assert_deallocated_unaligned() {
|
||||
function assert_zeroes_unaligned() {
|
||||
local num_objects_expected=$1
|
||||
|
||||
cmp <(od -xAx $DEV) - <<EOF
|
||||
@ -90,39 +96,58 @@ IMAGE_ID="$(rbd info --format=json $IMAGE_NAME |
|
||||
DEV=$(sudo rbd map $IMAGE_NAME)
|
||||
|
||||
# make sure -ENOENT is hidden
|
||||
assert_deallocated
|
||||
assert_zeroes 0
|
||||
py_blkdiscard 0
|
||||
assert_deallocated
|
||||
assert_zeroes 0
|
||||
|
||||
# blkdev_issue_discard
|
||||
allocate
|
||||
py_blkdiscard 0
|
||||
assert_deallocated
|
||||
assert_zeroes 0
|
||||
|
||||
# blkdev_issue_zeroout w/ BLKDEV_ZERO_NOUNMAP
|
||||
allocate
|
||||
py_fallocate FALLOC_FL_ZERO_RANGE\|FALLOC_FL_KEEP_SIZE 0
|
||||
assert_deallocated
|
||||
assert_zeroes 0
|
||||
|
||||
# blkdev_issue_zeroout w/ BLKDEV_ZERO_NOFALLBACK
|
||||
allocate
|
||||
py_fallocate FALLOC_FL_PUNCH_HOLE\|FALLOC_FL_KEEP_SIZE 0
|
||||
assert_deallocated
|
||||
assert_zeroes 0
|
||||
|
||||
# unaligned blkdev_issue_discard
|
||||
allocate
|
||||
py_blkdiscard $((OBJECT_SIZE / 2))
|
||||
assert_deallocated_unaligned 1
|
||||
assert_zeroes_unaligned 1
|
||||
|
||||
# unaligned blkdev_issue_zeroout w/ BLKDEV_ZERO_NOUNMAP
|
||||
allocate
|
||||
py_fallocate FALLOC_FL_ZERO_RANGE\|FALLOC_FL_KEEP_SIZE $((OBJECT_SIZE / 2))
|
||||
assert_deallocated_unaligned $NUM_OBJECTS
|
||||
assert_zeroes_unaligned $NUM_OBJECTS
|
||||
|
||||
# unaligned blkdev_issue_zeroout w/ BLKDEV_ZERO_NOFALLBACK
|
||||
allocate
|
||||
py_fallocate FALLOC_FL_PUNCH_HOLE\|FALLOC_FL_KEEP_SIZE $((OBJECT_SIZE / 2))
|
||||
assert_deallocated_unaligned $NUM_OBJECTS
|
||||
assert_zeroes_unaligned $NUM_OBJECTS
|
||||
|
||||
sudo rbd unmap $DEV
|
||||
|
||||
DEV=$(sudo rbd map -o notrim $IMAGE_NAME)
|
||||
|
||||
# blkdev_issue_discard
|
||||
allocate
|
||||
py_blkdiscard 0 |& grep 'Operation not supported'
|
||||
assert_allocated
|
||||
|
||||
# blkdev_issue_zeroout w/ BLKDEV_ZERO_NOUNMAP
|
||||
allocate
|
||||
py_fallocate FALLOC_FL_ZERO_RANGE\|FALLOC_FL_KEEP_SIZE 0
|
||||
assert_zeroes $NUM_OBJECTS
|
||||
|
||||
# blkdev_issue_zeroout w/ BLKDEV_ZERO_NOFALLBACK
|
||||
allocate
|
||||
py_fallocate FALLOC_FL_PUNCH_HOLE\|FALLOC_FL_KEEP_SIZE 0 |& grep 'Operation not supported'
|
||||
assert_allocated
|
||||
|
||||
sudo rbd unmap $DEV
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user