]> git.proxmox.com Git - ceph.git/blobdiff - ceph/qa/workunits/rbd/krbd_fallocate.sh
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / qa / workunits / rbd / krbd_fallocate.sh
index 05fc8a98c6409d45aed24c437bb4ebe728651316..f6e80656063eaaee606a54cc611455fed7a14e07 100755 (executable)
@@ -1,12 +1,9 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
-# This documents the state of things as of 4.12-rc4.
-#
 # - fallocate -z deallocates because BLKDEV_ZERO_NOUNMAP hint is ignored by
 # krbd
 #
-# - unaligned fallocate -z/-p appear to not deallocate -- see caveat #2 in
-# linux.git commit 6ac56951dc10 ("rbd: implement REQ_OP_WRITE_ZEROES")
+# - big unaligned blkdiscard and fallocate -z/-p leave the objects in place
 
 set -ex
 
@@ -42,6 +39,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 +51,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
@@ -71,7 +74,7 @@ $(printf %x $IMAGE_SIZE)
 EOF
     [[ $(rados -p rbd ls | grep -c rbd_data.$IMAGE_ID) -eq $num_objects_expected ]]
     for ((i = 0; i < $num_objects_expected; i++)); do
-        rados -p rbd stat rbd_data.$IMAGE_ID.$(printf %016x $i) | grep "size $((OBJECT_SIZE / 2))"
+        rados -p rbd stat rbd_data.$IMAGE_ID.$(printf %016x $i) | egrep "(size $((OBJECT_SIZE / 2)))|(size 0)"
     done
 }
 
@@ -89,35 +92,59 @@ IMAGE_ID="$(rbd info --format=json $IMAGE_NAME |
 
 DEV=$(sudo rbd map $IMAGE_NAME)
 
+# make sure -ENOENT is hidden
+assert_zeroes 0
+py_blkdiscard 0
+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 $NUM_OBJECTS
 
 # 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