diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /qa/rbd | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'qa/rbd')
-rw-r--r-- | qa/rbd/common.sh | 103 | ||||
-rw-r--r-- | qa/rbd/krbd_blkroset.t | 352 | ||||
-rw-r--r-- | qa/rbd/krbd_deep_flatten.t | 329 | ||||
-rw-r--r-- | qa/rbd/krbd_default_map_options.t | 64 | ||||
-rw-r--r-- | qa/rbd/krbd_discard.t | 398 | ||||
-rw-r--r-- | qa/rbd/krbd_discard_4M.t | 330 | ||||
-rw-r--r-- | qa/rbd/krbd_discard_512b.t | 416 | ||||
-rw-r--r-- | qa/rbd/krbd_discard_granularity.t | 40 | ||||
-rw-r--r-- | qa/rbd/krbd_get_features.t | 31 | ||||
-rw-r--r-- | qa/rbd/krbd_huge_image.t | 41 | ||||
-rw-r--r-- | qa/rbd/krbd_modprobe.t | 10 | ||||
-rw-r--r-- | qa/rbd/krbd_msgr_segments.t | 85 | ||||
-rw-r--r-- | qa/rbd/krbd_parent_overlap.t | 69 | ||||
-rw-r--r-- | qa/rbd/krbd_whole_object_zeroout.t | 143 | ||||
-rw-r--r-- | qa/rbd/krbd_zeroout.t | 422 | ||||
-rwxr-xr-x | qa/rbd/rbd.sh | 50 |
16 files changed, 2883 insertions, 0 deletions
diff --git a/qa/rbd/common.sh b/qa/rbd/common.sh new file mode 100644 index 000000000..232cf45ad --- /dev/null +++ b/qa/rbd/common.sh @@ -0,0 +1,103 @@ +#!/usr/bin/env bash + +die() { + echo "$*" + exit 1 +} + +cleanup() { + rm -rf $TDIR + TDIR="" +} + +set_variables() { + # defaults + [ -z "$bindir" ] && bindir=$PWD # location of init-ceph + if [ -z "$conf" ]; then + conf="$basedir/ceph.conf" + [ -e $conf ] || conf="/etc/ceph/ceph.conf" + fi + [ -e $conf ] || die "conf file not found" + + CCONF="ceph-conf -c $conf" + + [ -z "$mnt" ] && mnt="/c" + if [ -z "$monhost" ]; then + $CCONF -t mon -i 0 'mon addr' > $TDIR/cconf_mon + if [ $? -ne 0 ]; then + $CCONF -t mon.a -i 0 'mon addr' > $TDIR/cconf_mon + [ $? -ne 0 ] && die "can't figure out \$monhost" + fi + read monhost < $TDIR/cconf_mon + fi + + [ -z "$imgsize" ] && imgsize=1024 + [ -z "$user" ] && user=admin + [ -z "$keyring" ] && keyring="`$CCONF keyring`" + [ -z "$secret" ] && secret="`ceph-authtool $keyring -n client.$user -p`" + + monip="`echo $monhost | sed 's/:/ /g' | awk '{print $1}'`" + monport="`echo $monhost | sed 's/:/ /g' | awk '{print $2}'`" + + [ -z "$monip" ] && die "bad mon address" + + [ -z "$monport" ] && monport=6789 + + set -e + + mydir=`hostname`_`echo $0 | sed 's/\//_/g'` + + img_name=test.`hostname`.$$ +} + +rbd_load() { + modprobe rbd +} + +rbd_create_image() { + id=$1 + rbd create $img_name.$id --size=$imgsize +} + +rbd_add() { + id=$1 + echo "$monip:$monport name=$user,secret=$secret rbd $img_name.$id" \ + > /sys/bus/rbd/add + + pushd /sys/bus/rbd/devices &> /dev/null + [ $? -eq 0 ] || die "failed to cd" + devid="" + rm -f "$TDIR/rbd_devs" + for f in *; do echo $f >> "$TDIR/rbd_devs"; done + sort -nr "$TDIR/rbd_devs" > "$TDIR/rev_rbd_devs" + while read f < "$TDIR/rev_rbd_devs"; do + read d_img_name < "$f/name" + if [ "x$d_img_name" == "x$img_name.$id" ]; then + devid=$f + break + fi + done + popd &> /dev/null + + [ "x$devid" == "x" ] && die "failed to find $img_name.$id" + + export rbd$id=$devid + while [ ! -e /dev/rbd$devid ]; do sleep 1; done +} + +rbd_test_init() { + rbd_load +} + +rbd_remove() { + echo $1 > /sys/bus/rbd/remove +} + +rbd_rm_image() { + id=$1 + rbd rm $imgname.$id +} + +TDIR=`mktemp -d` +trap cleanup INT TERM EXIT +set_variables diff --git a/qa/rbd/krbd_blkroset.t b/qa/rbd/krbd_blkroset.t new file mode 100644 index 000000000..428636de0 --- /dev/null +++ b/qa/rbd/krbd_blkroset.t @@ -0,0 +1,352 @@ + +Setup +===== + + $ RO_KEY=$(ceph auth get-or-create-key client.ro mon 'profile rbd' mgr 'profile rbd' osd 'profile rbd-read-only') + $ rbd create --size 10 img + $ rbd snap create --no-progress img@snap + $ rbd snap protect img@snap + $ rbd clone img@snap cloneimg + $ rbd create --size 1 imgpart + $ DEV=$(sudo rbd map imgpart) + $ cat <<EOF | sudo sfdisk $DEV >/dev/null 2>&1 + > unit: sectors + > /dev/rbd0p1 : start= 512, size= 512, Id=83 + > /dev/rbd0p2 : start= 1024, size= 512, Id=83 + > EOF + $ sudo rbd unmap $DEV + $ rbd snap create --no-progress imgpart@snap + + +Image HEAD +========== + +R/W, unpartitioned: + + $ DEV=$(sudo rbd map img) + $ blockdev --getro $DEV + 0 + $ dd if=/dev/urandom of=$DEV bs=1k seek=1 count=1 status=none + $ blkdiscard $DEV + $ blockdev --setro $DEV + .*BLKROSET: Permission denied (re) + [1] + $ sudo blockdev --setro $DEV + $ blockdev --getro $DEV + 1 + $ dd if=/dev/urandom of=$DEV bs=1k seek=1 count=1 status=none + dd: error writing '/dev/rbd?': Operation not permitted (glob) + [1] + $ blkdiscard $DEV + blkdiscard: /dev/rbd?: BLKDISCARD ioctl failed: Operation not permitted (glob) + [1] + $ blockdev --setrw $DEV + .*BLKROSET: Permission denied (re) + [1] + $ sudo blockdev --setrw $DEV + $ blockdev --getro $DEV + 0 + $ dd if=/dev/urandom of=$DEV bs=1k seek=1 count=1 status=none + $ blkdiscard $DEV + $ sudo rbd unmap $DEV + +R/W, partitioned: + + $ DEV=$(sudo rbd map imgpart) + $ udevadm settle + $ blockdev --getro ${DEV}p1 + 0 + $ blockdev --getro ${DEV}p2 + 0 + $ dd if=/dev/urandom of=${DEV}p1 bs=1k seek=1 count=1 status=none + $ blkdiscard ${DEV}p1 + $ dd if=/dev/urandom of=${DEV}p2 bs=1k seek=1 count=1 status=none + $ blkdiscard ${DEV}p2 + $ blockdev --setro ${DEV}p1 + .*BLKROSET: Permission denied (re) + [1] + $ sudo blockdev --setro ${DEV}p1 + $ blockdev --getro ${DEV}p1 + 1 + $ blockdev --getro ${DEV}p2 + 0 + $ dd if=/dev/urandom of=${DEV}p1 bs=1k seek=1 count=1 status=none + dd: error writing '/dev/rbd?p1': Operation not permitted (glob) + [1] + $ blkdiscard ${DEV}p1 + blkdiscard: /dev/rbd?p1: BLKDISCARD ioctl failed: Operation not permitted (glob) + [1] + $ dd if=/dev/urandom of=${DEV}p2 bs=1k seek=1 count=1 status=none + $ blkdiscard ${DEV}p2 + $ blockdev --setrw ${DEV}p1 + .*BLKROSET: Permission denied (re) + [1] + $ sudo blockdev --setrw ${DEV}p1 + $ blockdev --getro ${DEV}p1 + 0 + $ blockdev --getro ${DEV}p2 + 0 + $ dd if=/dev/urandom of=${DEV}p1 bs=1k seek=1 count=1 status=none + $ blkdiscard ${DEV}p1 + $ dd if=/dev/urandom of=${DEV}p2 bs=1k seek=1 count=1 status=none + $ blkdiscard ${DEV}p2 + $ sudo rbd unmap $DEV + + $ DEV=$(sudo rbd map imgpart) + $ udevadm settle + $ blockdev --getro ${DEV}p1 + 0 + $ blockdev --getro ${DEV}p2 + 0 + $ dd if=/dev/urandom of=${DEV}p1 bs=1k seek=1 count=1 status=none + $ blkdiscard ${DEV}p1 + $ dd if=/dev/urandom of=${DEV}p2 bs=1k seek=1 count=1 status=none + $ blkdiscard ${DEV}p2 + $ blockdev --setro ${DEV}p2 + .*BLKROSET: Permission denied (re) + [1] + $ sudo blockdev --setro ${DEV}p2 + $ blockdev --getro ${DEV}p1 + 0 + $ blockdev --getro ${DEV}p2 + 1 + $ dd if=/dev/urandom of=${DEV}p1 bs=1k seek=1 count=1 status=none + $ blkdiscard ${DEV}p1 + $ dd if=/dev/urandom of=${DEV}p2 bs=1k seek=1 count=1 status=none + dd: error writing '/dev/rbd?p2': Operation not permitted (glob) + [1] + $ blkdiscard ${DEV}p2 + blkdiscard: /dev/rbd?p2: BLKDISCARD ioctl failed: Operation not permitted (glob) + [1] + $ blockdev --setrw ${DEV}p2 + .*BLKROSET: Permission denied (re) + [1] + $ sudo blockdev --setrw ${DEV}p2 + $ blockdev --getro ${DEV}p1 + 0 + $ blockdev --getro ${DEV}p2 + 0 + $ dd if=/dev/urandom of=${DEV}p1 bs=1k seek=1 count=1 status=none + $ blkdiscard ${DEV}p1 + $ dd if=/dev/urandom of=${DEV}p2 bs=1k seek=1 count=1 status=none + $ blkdiscard ${DEV}p2 + $ sudo rbd unmap $DEV + +R/O, unpartitioned: + + $ DEV=$(sudo rbd map --read-only img) + $ blockdev --getro $DEV + 1 + $ dd if=/dev/urandom of=$DEV bs=1k seek=1 count=1 status=none + dd: error writing '/dev/rbd?': Operation not permitted (glob) + [1] + $ blkdiscard $DEV + blkdiscard: /dev/rbd?: BLKDISCARD ioctl failed: Operation not permitted (glob) + [1] + $ blockdev --setrw $DEV + .*BLKROSET: Permission denied (re) + [1] + $ sudo blockdev --setrw $DEV # succeeds but effectively ignored + $ blockdev --getro $DEV + 1 + $ dd if=/dev/urandom of=$DEV bs=1k seek=1 count=1 status=none + dd: error writing '/dev/rbd?': Operation not permitted (glob) + [1] + $ blkdiscard $DEV + blkdiscard: /dev/rbd?: BLKDISCARD ioctl failed: Operation not permitted (glob) + [1] + $ sudo rbd unmap $DEV + +R/O, partitioned: + + $ DEV=$(sudo rbd map --read-only imgpart) + $ udevadm settle + $ blockdev --getro ${DEV}p1 + 1 + $ blockdev --getro ${DEV}p2 + 1 + $ dd if=/dev/urandom of=${DEV}p1 bs=1k seek=1 count=1 status=none + dd: error writing '/dev/rbd?p1': Operation not permitted (glob) + [1] + $ blkdiscard ${DEV}p1 + blkdiscard: /dev/rbd?p1: BLKDISCARD ioctl failed: Operation not permitted (glob) + [1] + $ dd if=/dev/urandom of=${DEV}p2 bs=1k seek=1 count=1 status=none + dd: error writing '/dev/rbd?p2': Operation not permitted (glob) + [1] + $ blkdiscard ${DEV}p2 + blkdiscard: /dev/rbd?p2: BLKDISCARD ioctl failed: Operation not permitted (glob) + [1] + $ blockdev --setrw ${DEV}p1 + .*BLKROSET: Permission denied (re) + [1] + $ sudo blockdev --setrw ${DEV}p1 # succeeds but effectively ignored + $ blockdev --setrw ${DEV}p2 + .*BLKROSET: Permission denied (re) + [1] + $ sudo blockdev --setrw ${DEV}p2 # succeeds but effectively ignored + $ blockdev --getro ${DEV}p1 + 1 + $ blockdev --getro ${DEV}p2 + 1 + $ dd if=/dev/urandom of=${DEV}p1 bs=1k seek=1 count=1 status=none + dd: error writing '/dev/rbd?p1': Operation not permitted (glob) + [1] + $ blkdiscard ${DEV}p1 + blkdiscard: /dev/rbd?p1: BLKDISCARD ioctl failed: Operation not permitted (glob) + [1] + $ dd if=/dev/urandom of=${DEV}p2 bs=1k seek=1 count=1 status=none + dd: error writing '/dev/rbd?p2': Operation not permitted (glob) + [1] + $ blkdiscard ${DEV}p2 + blkdiscard: /dev/rbd?p2: BLKDISCARD ioctl failed: Operation not permitted (glob) + [1] + $ sudo rbd unmap $DEV + + +Image snapshot +============== + +Unpartitioned: + + $ DEV=$(sudo rbd map img@snap) + $ blockdev --getro $DEV + 1 + $ dd if=/dev/urandom of=$DEV bs=1k seek=1 count=1 status=none + dd: error writing '/dev/rbd?': Operation not permitted (glob) + [1] + $ blkdiscard $DEV + blkdiscard: /dev/rbd?: BLKDISCARD ioctl failed: Operation not permitted (glob) + [1] + $ blockdev --setrw $DEV + .*BLKROSET: Permission denied (re) + [1] + $ sudo blockdev --setrw $DEV # succeeds but effectively ignored + $ blockdev --getro $DEV + 1 + $ dd if=/dev/urandom of=$DEV bs=1k seek=1 count=1 status=none + dd: error writing '/dev/rbd?': Operation not permitted (glob) + [1] + $ blkdiscard $DEV + blkdiscard: /dev/rbd?: BLKDISCARD ioctl failed: Operation not permitted (glob) + [1] + $ sudo rbd unmap $DEV + +Partitioned: + + $ DEV=$(sudo rbd map imgpart@snap) + $ udevadm settle + $ blockdev --getro ${DEV}p1 + 1 + $ blockdev --getro ${DEV}p2 + 1 + $ dd if=/dev/urandom of=${DEV}p1 bs=1k seek=1 count=1 status=none + dd: error writing '/dev/rbd?p1': Operation not permitted (glob) + [1] + $ blkdiscard ${DEV}p1 + blkdiscard: /dev/rbd?p1: BLKDISCARD ioctl failed: Operation not permitted (glob) + [1] + $ dd if=/dev/urandom of=${DEV}p2 bs=1k seek=1 count=1 status=none + dd: error writing '/dev/rbd?p2': Operation not permitted (glob) + [1] + $ blkdiscard ${DEV}p2 + blkdiscard: /dev/rbd?p2: BLKDISCARD ioctl failed: Operation not permitted (glob) + [1] + $ blockdev --setrw ${DEV}p1 + .*BLKROSET: Permission denied (re) + [1] + $ sudo blockdev --setrw ${DEV}p1 # succeeds but effectively ignored + $ blockdev --setrw ${DEV}p2 + .*BLKROSET: Permission denied (re) + [1] + $ sudo blockdev --setrw ${DEV}p2 # succeeds but effectively ignored + $ blockdev --getro ${DEV}p1 + 1 + $ blockdev --getro ${DEV}p2 + 1 + $ dd if=/dev/urandom of=${DEV}p1 bs=1k seek=1 count=1 status=none + dd: error writing '/dev/rbd?p1': Operation not permitted (glob) + [1] + $ blkdiscard ${DEV}p1 + blkdiscard: /dev/rbd?p1: BLKDISCARD ioctl failed: Operation not permitted (glob) + [1] + $ dd if=/dev/urandom of=${DEV}p2 bs=1k seek=1 count=1 status=none + dd: error writing '/dev/rbd?p2': Operation not permitted (glob) + [1] + $ blkdiscard ${DEV}p2 + blkdiscard: /dev/rbd?p2: BLKDISCARD ioctl failed: Operation not permitted (glob) + [1] + $ sudo rbd unmap $DEV + + +read-only OSD caps +================== + +R/W: + + $ DEV=$(sudo rbd map --id ro --key $(echo $RO_KEY) img) + rbd: sysfs write failed + rbd: map failed: (1) Operation not permitted + [1] + +R/O: + + $ DEV=$(sudo rbd map --id ro --key $(echo $RO_KEY) --read-only img) + $ blockdev --getro $DEV + 1 + $ sudo rbd unmap $DEV + +Snapshot: + + $ DEV=$(sudo rbd map --id ro --key $(echo $RO_KEY) img@snap) + $ blockdev --getro $DEV + 1 + $ sudo rbd unmap $DEV + +R/W, clone: + + $ DEV=$(sudo rbd map --id ro --key $(echo $RO_KEY) cloneimg) + rbd: sysfs write failed + rbd: map failed: (1) Operation not permitted + [1] + +R/O, clone: + + $ DEV=$(sudo rbd map --id ro --key $(echo $RO_KEY) --read-only cloneimg) + $ blockdev --getro $DEV + 1 + $ sudo rbd unmap $DEV + + +rw -> ro with open_count > 0 +============================ + + $ DEV=$(sudo rbd map img) + $ { sleep 10; sudo blockdev --setro $DEV; } & + $ dd if=/dev/urandom of=$DEV bs=1k oflag=direct status=noxfer + dd: error writing '/dev/rbd?': Operation not permitted (glob) + [1-9]\d*\+0 records in (re) + [1-9]\d*\+0 records out (re) + [1] + $ sudo rbd unmap $DEV + + +"-o rw --read-only" should result in read-only mapping +====================================================== + + $ DEV=$(sudo rbd map -o rw --read-only img) + $ blockdev --getro $DEV + 1 + $ sudo rbd unmap $DEV + + +Teardown +======== + + $ rbd snap purge imgpart >/dev/null 2>&1 + $ rbd rm imgpart >/dev/null 2>&1 + $ rbd rm cloneimg >/dev/null 2>&1 + $ rbd snap unprotect img@snap + $ rbd snap purge img >/dev/null 2>&1 + $ rbd rm img >/dev/null 2>&1 + diff --git a/qa/rbd/krbd_deep_flatten.t b/qa/rbd/krbd_deep_flatten.t new file mode 100644 index 000000000..486b966d9 --- /dev/null +++ b/qa/rbd/krbd_deep_flatten.t @@ -0,0 +1,329 @@ + +Write: + + $ rbd create --size 12M --image-feature layering,deep-flatten img + $ DEV=$(sudo rbd map img) + $ xfs_io -c 'pwrite -w 0 12M' $DEV >/dev/null + $ sudo rbd unmap $DEV + $ rbd snap create --no-progress img@snap + $ rbd snap protect img@snap + $ rbd clone img@snap cloneimg + $ rbd snap create --no-progress cloneimg@snap + $ DEV=$(sudo rbd map cloneimg) + $ xfs_io -c 'pwrite -S 0xab -w 6M 1k' $DEV >/dev/null + $ sudo rbd unmap $DEV + + $ DEV=$(sudo rbd map cloneimg) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0600000 abab abab abab abab abab abab abab abab + * + 0600400 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + $ DEV=$(sudo rbd map cloneimg@snap) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + + $ rbd flatten --no-progress cloneimg + $ rbd snap unprotect img@snap + $ rbd snap rm --no-progress img@snap + $ rbd rm --no-progress img + + $ DEV=$(sudo rbd map cloneimg) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0600000 abab abab abab abab abab abab abab abab + * + 0600400 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + $ DEV=$(sudo rbd map cloneimg@snap) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + + $ rbd snap rm --no-progress cloneimg@snap + $ rbd rm --no-progress cloneimg + +Write, whole object: + + $ rbd create --size 12M --image-feature layering,deep-flatten img + $ DEV=$(sudo rbd map img) + $ xfs_io -c 'pwrite -w 0 12M' $DEV >/dev/null + $ sudo rbd unmap $DEV + $ rbd snap create --no-progress img@snap + $ rbd snap protect img@snap + $ rbd clone img@snap cloneimg + $ rbd snap create --no-progress cloneimg@snap + $ DEV=$(sudo rbd map cloneimg) + $ xfs_io -d -c 'pwrite -b 4M -S 0xab 4M 4M' $DEV >/dev/null + $ sudo rbd unmap $DEV + + $ DEV=$(sudo rbd map cloneimg) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 abab abab abab abab abab abab abab abab + * + 0800000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + $ DEV=$(sudo rbd map cloneimg@snap) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + + $ rbd flatten --no-progress cloneimg + $ rbd snap unprotect img@snap + $ rbd snap rm --no-progress img@snap + $ rbd rm --no-progress img + + $ DEV=$(sudo rbd map cloneimg) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 abab abab abab abab abab abab abab abab + * + 0800000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + $ DEV=$(sudo rbd map cloneimg@snap) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + + $ rbd snap rm --no-progress cloneimg@snap + $ rbd rm --no-progress cloneimg + +Zeroout: + + $ rbd create --size 12M --image-feature layering,deep-flatten img + $ DEV=$(sudo rbd map img) + $ xfs_io -c 'pwrite -w 0 12M' $DEV >/dev/null + $ sudo rbd unmap $DEV + $ rbd snap create --no-progress img@snap + $ rbd snap protect img@snap + $ rbd clone img@snap cloneimg + $ rbd snap create --no-progress cloneimg@snap + $ DEV=$(sudo rbd map cloneimg) + $ fallocate -z -o 6M -l 1k $DEV + $ sudo rbd unmap $DEV + + $ DEV=$(sudo rbd map cloneimg) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0600000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0600400 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + $ DEV=$(sudo rbd map cloneimg@snap) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + + $ rbd flatten --no-progress cloneimg + $ rbd snap unprotect img@snap + $ rbd snap rm --no-progress img@snap + $ rbd rm --no-progress img + + $ DEV=$(sudo rbd map cloneimg) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0600000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0600400 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + $ DEV=$(sudo rbd map cloneimg@snap) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + + $ rbd snap rm --no-progress cloneimg@snap + $ rbd rm --no-progress cloneimg + +Zeroout, whole object: + + $ rbd create --size 12M --image-feature layering,deep-flatten img + $ DEV=$(sudo rbd map img) + $ xfs_io -c 'pwrite -w 0 12M' $DEV >/dev/null + $ sudo rbd unmap $DEV + $ rbd snap create --no-progress img@snap + $ rbd snap protect img@snap + $ rbd clone img@snap cloneimg + $ rbd snap create --no-progress cloneimg@snap + $ DEV=$(sudo rbd map cloneimg) + $ fallocate -z -o 4M -l 4M $DEV + $ sudo rbd unmap $DEV + + $ DEV=$(sudo rbd map cloneimg) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0800000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + $ DEV=$(sudo rbd map cloneimg@snap) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + + $ rbd flatten --no-progress cloneimg + $ rbd snap unprotect img@snap + $ rbd snap rm --no-progress img@snap + $ rbd rm --no-progress img + + $ DEV=$(sudo rbd map cloneimg) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0800000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + $ DEV=$(sudo rbd map cloneimg@snap) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + + $ rbd snap rm --no-progress cloneimg@snap + $ rbd rm --no-progress cloneimg + +Discard, whole object, empty clone: + + $ rbd create --size 12M --image-feature layering,deep-flatten img + $ DEV=$(sudo rbd map img) + $ xfs_io -c 'pwrite -w 0 12M' $DEV >/dev/null + $ sudo rbd unmap $DEV + $ rbd snap create --no-progress img@snap + $ rbd snap protect img@snap + $ rbd clone img@snap cloneimg + $ rbd snap create --no-progress cloneimg@snap + $ DEV=$(sudo rbd map cloneimg) + $ blkdiscard -o 4M -l 4M $DEV + $ sudo rbd unmap $DEV + + $ DEV=$(sudo rbd map cloneimg) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + $ DEV=$(sudo rbd map cloneimg@snap) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + + $ rbd flatten --no-progress cloneimg + $ rbd snap unprotect img@snap + $ rbd snap rm --no-progress img@snap + $ rbd rm --no-progress img + + $ DEV=$(sudo rbd map cloneimg) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + $ DEV=$(sudo rbd map cloneimg@snap) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + + $ rbd snap rm --no-progress cloneimg@snap + $ rbd rm --no-progress cloneimg + +Discard, whole object, full clone: + + $ rbd create --size 12M --image-feature layering,deep-flatten img + $ DEV=$(sudo rbd map img) + $ xfs_io -c 'pwrite -w 0 12M' $DEV >/dev/null + $ sudo rbd unmap $DEV + $ rbd snap create --no-progress img@snap + $ rbd snap protect img@snap + $ rbd clone img@snap cloneimg + $ rbd snap create --no-progress cloneimg@snap + $ DEV=$(sudo rbd map cloneimg) + $ xfs_io -c 'pwrite -S 0xab -w 0 12M' $DEV >/dev/null + $ blkdiscard -o 4M -l 4M $DEV + $ sudo rbd unmap $DEV + + $ DEV=$(sudo rbd map cloneimg) + $ hexdump $DEV + 0000000 abab abab abab abab abab abab abab abab + * + 0400000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0800000 abab abab abab abab abab abab abab abab + * + 0c00000 + $ sudo rbd unmap $DEV + $ DEV=$(sudo rbd map cloneimg@snap) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + + $ rbd flatten --no-progress cloneimg + $ rbd snap unprotect img@snap + $ rbd snap rm --no-progress img@snap + $ rbd rm --no-progress img + + $ DEV=$(sudo rbd map cloneimg) + $ hexdump $DEV + 0000000 abab abab abab abab abab abab abab abab + * + 0400000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0800000 abab abab abab abab abab abab abab abab + * + 0c00000 + $ sudo rbd unmap $DEV + $ DEV=$(sudo rbd map cloneimg@snap) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0c00000 + $ sudo rbd unmap $DEV + + $ rbd snap rm --no-progress cloneimg@snap + $ rbd rm --no-progress cloneimg diff --git a/qa/rbd/krbd_default_map_options.t b/qa/rbd/krbd_default_map_options.t new file mode 100644 index 000000000..5dac5d6ae --- /dev/null +++ b/qa/rbd/krbd_default_map_options.t @@ -0,0 +1,64 @@ +Set up + + $ ceph osd pool create rbda + pool 'rbda' created + $ rbd pool init rbda + $ rbd create rbda/image1 --size 1000 + +Test at map options level + + $ OPTIONS="alloc_size=65536,lock_on_read" + $ EXPECTED="${OPTIONS}" + $ DEV=$(sudo rbd map rbda/image1 --options ${OPTIONS}) + $ sudo grep -q ${EXPECTED} /sys/bus/rbd/devices/${DEV#/dev/rbd}/config_info + $ sudo rbd unmap rbda/image1 + +Test at global level + + $ OPTIONS="alloc_size=4096,crc" + $ EXPECTED="${OPTIONS}" + $ rbd config global set global rbd_default_map_options ${OPTIONS} + $ DEV=$(sudo rbd map rbda/image1) + $ sudo grep -q ${EXPECTED} /sys/bus/rbd/devices/${DEV#/dev/rbd}/config_info + $ sudo rbd unmap rbda/image1 + + $ OPTIONS="alloc_size=65536,lock_on_read" + $ EXPECTED="alloc_size=65536,crc,lock_on_read" + $ DEV=$(sudo rbd map rbda/image1 --options ${OPTIONS}) + $ sudo grep -q ${EXPECTED} /sys/bus/rbd/devices/${DEV#/dev/rbd}/config_info + $ sudo rbd unmap rbda/image1 + +Test at pool level + + $ OPTIONS="alloc_size=8192,share" + $ EXPECTED="${OPTIONS}" + $ rbd config pool set rbda rbd_default_map_options ${OPTIONS} + $ DEV=$(sudo rbd map rbda/image1) + $ sudo grep -q ${EXPECTED} /sys/bus/rbd/devices/${DEV#/dev/rbd}/config_info + $ sudo rbd unmap rbda/image1 + + $ OPTIONS="lock_on_read,alloc_size=65536" + $ EXPECTED="alloc_size=65536,lock_on_read,share" + $ DEV=$(sudo rbd map rbda/image1 --options ${OPTIONS}) + $ sudo grep -q ${EXPECTED} /sys/bus/rbd/devices/${DEV#/dev/rbd}/config_info + $ sudo rbd unmap rbda/image1 + +Test at image level + + $ OPTIONS="alloc_size=16384,tcp_nodelay" + $ EXPECTED="${OPTIONS}" + $ rbd config image set rbda/image1 rbd_default_map_options ${OPTIONS} + $ DEV=$(sudo rbd map rbda/image1) + $ sudo grep -q ${EXPECTED} /sys/bus/rbd/devices/${DEV#/dev/rbd}/config_info + $ sudo rbd unmap rbda/image1 + + $ OPTIONS="lock_on_read,alloc_size=65536" + $ EXPECTED="alloc_size=65536,lock_on_read,tcp_nodelay" + $ DEV=$(sudo rbd map rbda/image1 --options ${OPTIONS}) + $ sudo grep -q ${EXPECTED} /sys/bus/rbd/devices/${DEV#/dev/rbd}/config_info + $ sudo rbd unmap rbda/image1 + +Teardown + + $ ceph osd pool rm rbda rbda --yes-i-really-really-mean-it + pool 'rbda' removed diff --git a/qa/rbd/krbd_discard.t b/qa/rbd/krbd_discard.t new file mode 100644 index 000000000..528e1dc3d --- /dev/null +++ b/qa/rbd/krbd_discard.t @@ -0,0 +1,398 @@ + + $ rbd create --size 4M img + $ DEV=$(sudo rbd map 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 + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0030000 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 + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0030000 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 + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0030000 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 + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0030000 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 + * + 0030000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0040000 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 + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0030000 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 + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0040000 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 + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0040000 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 + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0040000 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 + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0040000 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 + * + 0090000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 02e0000 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 + * + 0090000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 02d0000 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 + * + 00a0000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 02e0000 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 + * + 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 + * + 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 + * + 03f0000 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 + * + 03f0000 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 + * + 03e0000 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 + * + 0010000 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 --no-progress img@snap + $ rbd snap protect img@snap + + $ rbd clone img@snap cloneimg1 + $ DEV=$(sudo rbd map 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 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 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 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 + * + 00b0000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0340000 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 + * + 0170000 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 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 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0008000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0014000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 001c000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0028000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0030000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 003c000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0044000 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 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0050000 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 diff --git a/qa/rbd/krbd_discard_4M.t b/qa/rbd/krbd_discard_4M.t new file mode 100644 index 000000000..7ed744c11 --- /dev/null +++ b/qa/rbd/krbd_discard_4M.t @@ -0,0 +1,330 @@ + + $ 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 --no-progress 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 diff --git a/qa/rbd/krbd_discard_512b.t b/qa/rbd/krbd_discard_512b.t new file mode 100644 index 000000000..6669ca8fc --- /dev/null +++ b/qa/rbd/krbd_discard_512b.t @@ -0,0 +1,416 @@ + + $ rbd create --size 4M img + $ DEV=$(sudo rbd map -o alloc_size=512 img) + +Zero, < 1 block: + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ blkdiscard -o 156672 -l 512 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0026400 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0026600 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 + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020200 0000 0000 0000 0000 0000 0000 0000 0000 + * + 002fe00 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 + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020200 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0030000 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 + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 002fe00 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 + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0030000 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 + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0030200 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 + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 001fe00 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0030000 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 + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 001fe00 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0030200 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 + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0028000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0038000 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 + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020200 0000 0000 0000 0000 0000 0000 0000 0000 + * + 003fe00 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 + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020200 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0040000 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 + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 003fe00 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 + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0040000 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 + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0040200 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 + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 001fe00 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0040000 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 + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 001fe00 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0040200 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 + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0090000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 02e0000 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 + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 008fe00 0000 0000 0000 0000 0000 0000 0000 0000 + * + 02dfe00 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 + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0090200 0000 0000 0000 0000 0000 0000 0000 0000 + * + 02e0200 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 + $ hexdump $DEV + 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 + $ hexdump $DEV + 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 + $ hexdump $DEV + 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 + $ hexdump $DEV + 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 + $ hexdump $DEV + 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 + $ hexdump $DEV + 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 + $ hexdump $DEV + 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 + $ hexdump $DEV + 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 + $ hexdump $DEV + 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 --no-progress img@snap + $ rbd snap protect img@snap + + $ rbd clone img@snap cloneimg1 + $ DEV=$(sudo rbd map -o alloc_size=512 cloneimg1) + $ blkdiscard -o 720896 -l 2719744 $DEV + $ hexdump $DEV + 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=512 cloneimg2) + $ blkdiscard -o 1474560 -l 2719744 $DEV + $ hexdump $DEV + 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=512 cloneimg3) + $ blkdiscard -o 0 -l 4194304 $DEV + $ hexdump $DEV + 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=512 cloneimg4) + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ blkdiscard -o 720896 -l 2719744 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 00b0000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0348000 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 + $ hexdump $DEV + 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 + $ hexdump $DEV + 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=512 fancyimg) + + $ xfs_io -c 'pwrite -b 4M -w 0 50M' $DEV >/dev/null + $ blkdiscard -o 0 -l 143360 $DEV + $ hexdump $DEV + 0000000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0023000 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 + $ hexdump $DEV + 0000000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0046000 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 + $ hexdump $DEV + 0000000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 008c000 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 diff --git a/qa/rbd/krbd_discard_granularity.t b/qa/rbd/krbd_discard_granularity.t new file mode 100644 index 000000000..844643bae --- /dev/null +++ b/qa/rbd/krbd_discard_granularity.t @@ -0,0 +1,40 @@ + + $ rbd create --size 20M img + + $ DEV=$(sudo rbd map img) + $ blockdev --getiomin $DEV + 65536 + $ blockdev --getioopt $DEV + 65536 + $ cat /sys/block/${DEV#/dev/}/queue/discard_granularity + 65536 + $ sudo rbd unmap $DEV + + $ DEV=$(sudo rbd map -o alloc_size=512 img) + $ blockdev --getiomin $DEV + 512 + $ blockdev --getioopt $DEV + 512 + $ cat /sys/block/${DEV#/dev/}/queue/discard_granularity + 512 + $ sudo rbd unmap $DEV + + $ DEV=$(sudo rbd map -o alloc_size=4194304 img) + $ blockdev --getiomin $DEV + 4194304 + $ blockdev --getioopt $DEV + 4194304 + $ cat /sys/block/${DEV#/dev/}/queue/discard_granularity + 4194304 + $ sudo rbd unmap $DEV + + $ DEV=$(sudo rbd map -o alloc_size=8388608 img) + $ blockdev --getiomin $DEV + 4194304 + $ blockdev --getioopt $DEV + 4194304 + $ cat /sys/block/${DEV#/dev/}/queue/discard_granularity + 4194304 + $ sudo rbd unmap $DEV + + $ rbd rm --no-progress img diff --git a/qa/rbd/krbd_get_features.t b/qa/rbd/krbd_get_features.t new file mode 100644 index 000000000..0c26e9c33 --- /dev/null +++ b/qa/rbd/krbd_get_features.t @@ -0,0 +1,31 @@ + +journaling makes the image only unwritable, rather than both unreadable +and unwritable: + + $ rbd create --size 1 --image-feature layering,exclusive-lock,journaling img + $ rbd snap create --no-progress img@snap + $ rbd snap protect img@snap + $ rbd clone --image-feature layering,exclusive-lock,journaling img@snap cloneimg + + $ DEV=$(sudo rbd map img) + rbd: sysfs write failed + rbd: map failed: (6) No such device or address + [6] + $ DEV=$(sudo rbd map --read-only img) + $ blockdev --getro $DEV + 1 + $ sudo rbd unmap $DEV + + $ DEV=$(sudo rbd map cloneimg) + rbd: sysfs write failed + rbd: map failed: (6) No such device or address + [6] + $ DEV=$(sudo rbd map --read-only cloneimg) + $ blockdev --getro $DEV + 1 + $ sudo rbd unmap $DEV + + $ rbd rm --no-progress cloneimg + $ rbd snap unprotect img@snap + $ rbd snap rm --no-progress img@snap + $ rbd rm --no-progress img diff --git a/qa/rbd/krbd_huge_image.t b/qa/rbd/krbd_huge_image.t new file mode 100644 index 000000000..e0ce6a954 --- /dev/null +++ b/qa/rbd/krbd_huge_image.t @@ -0,0 +1,41 @@ + + $ get_field() { + > rbd info --format=json $1 | python3 -c "import sys, json; print(json.load(sys.stdin)['$2'])" + > } + +Write to first and last sectors and make sure we hit the right objects: + + $ ceph osd pool create hugeimg 12 >/dev/null 2>&1 + $ rbd pool init hugeimg + $ rbd create --size 4E --object-size 4K --image-feature layering hugeimg/img + $ DEV=$(sudo rbd map hugeimg/img) + $ xfs_io -c 'pwrite 0 512' $DEV >/dev/null # first sector + $ xfs_io -c 'pwrite 4611686018427387392 512' $DEV >/dev/null # last sector + $ sudo rbd unmap $DEV + + $ get_field hugeimg/img size + 4611686018427387904 + $ get_field hugeimg/img objects + 1125899906842624 + $ rados -p hugeimg ls | grep $(get_field hugeimg/img block_name_prefix) | sort + .*\.0000000000000000 (re) + .*\.0003ffffffffffff (re) + +Dump first and last megabytes: + + $ DEV=$(sudo rbd map hugeimg/img) + $ dd if=$DEV bs=1M count=1 status=none | hexdump + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0000200 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0100000 + $ dd if=$DEV bs=1M skip=4398046511103 status=none | hexdump + 0000000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 00ffe00 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0100000 + $ sudo rbd unmap $DEV + + $ ceph osd pool delete hugeimg hugeimg --yes-i-really-really-mean-it >/dev/null 2>&1 diff --git a/qa/rbd/krbd_modprobe.t b/qa/rbd/krbd_modprobe.t new file mode 100644 index 000000000..a0e04d394 --- /dev/null +++ b/qa/rbd/krbd_modprobe.t @@ -0,0 +1,10 @@ + + $ sudo modprobe -r rbd + $ sudo modprobe -r libceph + $ lsmod | grep libceph + [1] + $ rbd create --size 1 img + $ DEV=$(sudo rbd map img) + $ sudo grep -q ',key=' /sys/bus/rbd/devices/${DEV#/dev/rbd}/config_info + $ sudo rbd unmap $DEV + $ rbd rm --no-progress img diff --git a/qa/rbd/krbd_msgr_segments.t b/qa/rbd/krbd_msgr_segments.t new file mode 100644 index 000000000..b89a921a1 --- /dev/null +++ b/qa/rbd/krbd_msgr_segments.t @@ -0,0 +1,85 @@ + + $ get_block_name_prefix() { + > rbd info --format=json $1 | python3 -c "import sys, json; print(json.load(sys.stdin)['block_name_prefix'])" + > } + +Short segments: + + $ rbd create --size 12M img + $ DEV=$(sudo rbd map img) + $ xfs_io -d -c 'pwrite 5120 512' $DEV >/dev/null + $ xfs_io -d -c 'pwrite 12577280 512' $DEV >/dev/null + $ hexdump $DEV + 0000000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0001400 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0001600 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0bfea00 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0bfec00 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0c00000 + $ sudo rbd unmap $DEV + $ rbd rm --no-progress img + +Short segment, ceph_msg_data_bio_cursor_init(): + + $ rbd create --size 12M img + $ DEV=$(sudo rbd map img) + $ xfs_io -d -c 'pwrite 0 512' $DEV >/dev/null + $ rados -p rbd stat $(get_block_name_prefix img).0000000000000000 + .* size 512 (re) + $ xfs_io -d -c 'pread -b 2M 0 2M' $DEV >/dev/null + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0000200 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0c00000 + $ sudo rbd unmap $DEV + $ rbd rm --no-progress img + +Short segment, ceph_msg_data_bio_advance(): + + $ rbd create --size 12M img + $ DEV=$(sudo rbd map img) + $ xfs_io -d -c 'pwrite 0 1049088' $DEV >/dev/null + $ rados -p rbd stat $(get_block_name_prefix img).0000000000000000 + .* size 1049088 (re) + $ xfs_io -d -c 'pread -b 2M 0 2M' $DEV >/dev/null + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0100200 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0c00000 + $ sudo rbd unmap $DEV + $ rbd rm --no-progress img + +Cloned bios (dm-snapshot.ko, based on generic/081): + + $ rbd create --size 300M img + $ DEV=$(sudo rbd map img) + $ sudo vgcreate vg_img $DEV + Physical volume "/dev/rbd?" successfully created* (glob) + Volume group "vg_img" successfully created + $ sudo lvcreate -L 256M -n lv_img vg_img + Logical volume "lv_img" created. + $ udevadm settle + $ sudo mkfs.ext4 -q /dev/mapper/vg_img-lv_img + $ sudo lvcreate -L 4M --snapshot -n lv_snap vg_img/lv_img | grep created + Logical volume "lv_snap" created. + $ udevadm settle + $ sudo mount /dev/mapper/vg_img-lv_snap /mnt + $ sudo xfs_io -f -c 'pwrite 0 5M' /mnt/file1 >/dev/null + $ sudo umount /mnt + $ sudo vgremove -f vg_img + Logical volume "lv_snap" successfully removed + Logical volume "lv_img" successfully removed + Volume group "vg_img" successfully removed + $ sudo pvremove $DEV + Labels on physical volume "/dev/rbd?" successfully wiped* (glob) + $ sudo rbd unmap $DEV + $ rbd rm --no-progress img diff --git a/qa/rbd/krbd_parent_overlap.t b/qa/rbd/krbd_parent_overlap.t new file mode 100644 index 000000000..3489d83db --- /dev/null +++ b/qa/rbd/krbd_parent_overlap.t @@ -0,0 +1,69 @@ + +For reads, only the object extent needs to be reverse mapped: + + $ rbd create --size 5M img + $ DEV=$(sudo rbd map img) + $ xfs_io -c 'pwrite 0 5M' $DEV >/dev/null + $ sudo rbd unmap $DEV + $ rbd snap create --no-progress img@snap + $ rbd snap protect img@snap + $ rbd clone img@snap cloneimg + $ rbd resize --no-progress --size 12M cloneimg + $ DEV=$(sudo rbd map cloneimg) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0500000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0c00000 + $ dd if=$DEV iflag=direct bs=4M status=none | hexdump + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0500000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0c00000 + $ sudo rbd unmap $DEV + $ rbd rm --no-progress cloneimg + $ rbd snap unprotect img@snap + $ rbd snap rm --no-progress img@snap + $ rbd rm --no-progress img + +For writes, the entire object needs to be reverse mapped: + + $ rbd create --size 2M img + $ DEV=$(sudo rbd map img) + $ xfs_io -c 'pwrite 0 1M' $DEV >/dev/null + $ sudo rbd unmap $DEV + $ rbd snap create --no-progress img@snap + $ rbd snap protect img@snap + $ rbd clone img@snap cloneimg + $ rbd resize --no-progress --size 8M cloneimg + $ DEV=$(sudo rbd map cloneimg) + $ xfs_io -c 'pwrite -S 0xef 3M 1M' $DEV >/dev/null + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0100000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0300000 efef efef efef efef efef efef efef efef + * + 0400000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0800000 + $ sudo rbd unmap $DEV + $ DEV=$(sudo rbd map cloneimg) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0100000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0300000 efef efef efef efef efef efef efef efef + * + 0400000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0800000 + $ sudo rbd unmap $DEV + $ rbd rm --no-progress cloneimg + $ rbd snap unprotect img@snap + $ rbd snap rm --no-progress img@snap + $ rbd rm --no-progress img diff --git a/qa/rbd/krbd_whole_object_zeroout.t b/qa/rbd/krbd_whole_object_zeroout.t new file mode 100644 index 000000000..850c8c968 --- /dev/null +++ b/qa/rbd/krbd_whole_object_zeroout.t @@ -0,0 +1,143 @@ + + $ get_block_name_prefix() { + > rbd info --format=json $1 | python3 -c "import sys, json; print(json.load(sys.stdin)['block_name_prefix'])" + > } + + $ rbd create --size 200M img + $ DEV=$(sudo rbd map img) + $ xfs_io -c 'pwrite -b 4M 0 200M' $DEV >/dev/null + $ sudo rbd unmap $DEV + $ rbd snap create --no-progress img@snap + $ rbd snap protect img@snap + +cloneimg1: +1 object in an object set, 4M +25 full object sets +25 objects in total + + $ rbd clone img@snap cloneimg1 + $ DEV=$(sudo rbd map cloneimg1) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + c800000 + $ fallocate -z -l 100M $DEV + $ hexdump $DEV + 0000000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 6400000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + c800000 + $ sudo rbd unmap $DEV + $ DEV=$(sudo rbd map cloneimg1) + $ hexdump $DEV + 0000000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 6400000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + c800000 + $ sudo rbd unmap $DEV + +cloneimg2: +7 objects in an object set, 28M +3 full object sets +min((100M % 28M) / 512K, 7) = 7 objects in the last object set +28 objects in total + + $ rbd clone --stripe-unit 512K --stripe-count 7 img@snap cloneimg2 + $ DEV=$(sudo rbd map cloneimg2) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + c800000 + $ fallocate -z -l 100M $DEV + $ hexdump $DEV + 0000000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 6400000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + c800000 + $ sudo rbd unmap $DEV + $ DEV=$(sudo rbd map cloneimg2) + $ hexdump $DEV + 0000000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 6400000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + c800000 + $ sudo rbd unmap $DEV + +cloneimg3: +23 objects in an object set, 92M +1 full object set +min((100M % 92M) / 512K, 23) = 16 objects in the last object set +39 objects in total + + $ rbd clone --stripe-unit 512K --stripe-count 23 img@snap cloneimg3 + $ DEV=$(sudo rbd map cloneimg3) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + c800000 + $ fallocate -z -l 100M $DEV + $ hexdump $DEV + 0000000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 6400000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + c800000 + $ sudo rbd unmap $DEV + $ DEV=$(sudo rbd map cloneimg3) + $ hexdump $DEV + 0000000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 6400000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + c800000 + $ sudo rbd unmap $DEV + +cloneimg4: +65 objects in an object set, 260M +0 full object sets +min((100M % 260M) / 512K, 65) = 65 objects in the last object set +65 objects in total + + $ rbd clone --stripe-unit 512K --stripe-count 65 img@snap cloneimg4 + $ DEV=$(sudo rbd map cloneimg4) + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + c800000 + $ fallocate -z -l 100M $DEV + $ hexdump $DEV + 0000000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 6400000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + c800000 + $ sudo rbd unmap $DEV + $ DEV=$(sudo rbd map cloneimg4) + $ hexdump $DEV + 0000000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 6400000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + c800000 + $ sudo rbd unmap $DEV + + $ rados -p rbd ls | grep -c $(get_block_name_prefix cloneimg1) + 25 + $ rados -p rbd ls | grep -c $(get_block_name_prefix cloneimg2) + 28 + $ rados -p rbd ls | grep -c $(get_block_name_prefix cloneimg3) + 39 + $ rados -p rbd ls | grep -c $(get_block_name_prefix cloneimg4) + 65 + + $ 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 diff --git a/qa/rbd/krbd_zeroout.t b/qa/rbd/krbd_zeroout.t new file mode 100644 index 000000000..10bb230e8 --- /dev/null +++ b/qa/rbd/krbd_zeroout.t @@ -0,0 +1,422 @@ + + $ rbd create --size 4M img + $ DEV=$(sudo rbd map img) + +Zero, < 1 block: + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 156672 -l 512 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0026400 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0026600 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 131584 -l 64512 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020200 0000 0000 0000 0000 0000 0000 0000 0000 + * + 002fe00 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 131584 -l 65024 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020200 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0030000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 131072 -l 65024 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 002fe00 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + +Zero, 1 block: + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 131072 -l 65536 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0030000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 131072 -l 66048 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0030200 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 130560 -l 66048 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 001fe00 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0030000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 130560 -l 66560 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 001fe00 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0030200 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + +Zero, < 2 blocks: + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 163840 -l 65536 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0028000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0038000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 131584 -l 130048 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020200 0000 0000 0000 0000 0000 0000 0000 0000 + * + 003fe00 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 131584 -l 130560 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020200 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0040000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 131072 -l 130560 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 003fe00 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + +Zero, 2 blocks: + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 131072 -l 131072 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0040000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 131072 -l 131584 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0020000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0040200 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 130560 -l 131584 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 001fe00 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0040000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 130560 -l 132096 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 001fe00 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0040200 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + +Zero, 37 blocks: + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 589824 -l 2424832 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0090000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 02e0000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 589312 -l 2424832 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 008fe00 0000 0000 0000 0000 0000 0000 0000 0000 + * + 02dfe00 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 590336 -l 2424832 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0090200 0000 0000 0000 0000 0000 0000 0000 0000 + * + 02e0200 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + +Truncate: + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 4193792 -l 512 $DEV + $ hexdump $DEV + 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 + $ fallocate -z -o 4129280 -l 65024 $DEV + $ hexdump $DEV + 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 + $ fallocate -z -o 4128768 -l 65536 $DEV + $ hexdump $DEV + 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 + $ fallocate -z -o 4128256 -l 66048 $DEV + $ hexdump $DEV + 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 + $ fallocate -z -o 4063744 -l 130560 $DEV + $ hexdump $DEV + 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 + $ fallocate -z -o 4063232 -l 131072 $DEV + $ hexdump $DEV + 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 + $ fallocate -z -o 4062720 -l 131584 $DEV + $ hexdump $DEV + 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 + $ fallocate -z -o 512 -l 4193792 $DEV + $ hexdump $DEV + 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 + $ fallocate -z -o 0 -l 4194304 $DEV + $ hexdump $DEV + 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 --no-progress img@snap + $ rbd snap protect img@snap + + $ rbd clone img@snap cloneimg1 + $ DEV=$(sudo rbd map cloneimg1) + $ fallocate -z -o 720896 -l 2719744 $DEV + $ hexdump $DEV + 0000000 abab abab abab abab abab abab abab abab + * + 00b0000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0348000 abab abab abab abab abab abab abab abab + * + 0400000 + $ sudo rbd unmap $DEV + + $ rbd clone img@snap cloneimg2 + $ DEV=$(sudo rbd map cloneimg2) + $ fallocate -z -o 1474560 -l 2719744 $DEV + $ hexdump $DEV + 0000000 abab abab abab abab abab abab abab abab + * + 0168000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0400000 + $ sudo rbd unmap $DEV + + $ rbd clone img@snap cloneimg3 + $ DEV=$(sudo rbd map cloneimg3) + $ fallocate -z -o 0 -l 4194304 $DEV + $ hexdump $DEV + 0000000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0400000 + $ sudo rbd unmap $DEV + +Full clone: + + $ rbd clone img@snap cloneimg4 + $ DEV=$(sudo rbd map cloneimg4) + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 720896 -l 2719744 $DEV + $ hexdump $DEV + 0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 00b0000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0348000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 0400000 + + $ xfs_io -c 'pwrite -w 0 4M' $DEV >/dev/null + $ fallocate -z -o 1474560 -l 2719744 $DEV + $ hexdump $DEV + 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 + $ fallocate -z -o 0 -l 4194304 $DEV + $ hexdump $DEV + 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 fancyimg) + + $ xfs_io -c 'pwrite -b 4M -w 0 50M' $DEV >/dev/null + $ fallocate -z -o 0 -l 143360 $DEV + $ hexdump $DEV + 0000000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0023000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 3200000 + + $ xfs_io -c 'pwrite -b 4M -w 0 50M' $DEV >/dev/null + $ fallocate -z -o 0 -l 286720 $DEV + $ hexdump $DEV + 0000000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 0046000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd + * + 3200000 + + $ xfs_io -c 'pwrite -b 4M -w 0 50M' $DEV >/dev/null + $ fallocate -z -o 0 -l 573440 $DEV + $ hexdump $DEV + 0000000 0000 0000 0000 0000 0000 0000 0000 0000 + * + 008c000 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 diff --git a/qa/rbd/rbd.sh b/qa/rbd/rbd.sh new file mode 100755 index 000000000..2b7ce8ee2 --- /dev/null +++ b/qa/rbd/rbd.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +set -x + +basedir=`echo $0 | sed 's/[^/]*$//g'`. +. $basedir/common.sh + +rbd_test_init + + +create_multiple() { + for i in `seq 1 10`; do + rbd_create_image $i + done + + for i in `seq 1 10`; do + rbd_add $i + done + for i in `seq 1 10`; do + devname=/dev/rbd`eval echo \\$rbd$i` + echo $devname + done + for i in `seq 1 10`; do + devid=`eval echo \\$rbd$i` + rbd_remove $devid + done + for i in `seq 1 10`; do + rbd_rm_image $i + done +} + +test_dbench() { + rbd_create_image 0 + rbd_add 0 + + devname=/dev/rbd$rbd0 + + mkfs -t ext3 $devname + mount -t ext3 $devname $mnt + + dbench -D $mnt -t 30 5 + sync + + umount $mnt + rbd_remove $rbd0 + rbd_rm_image 0 +} + +create_multiple +test_dbench + |