mirror of
https://github.com/ceph/ceph
synced 2024-12-30 15:33:31 +00:00
qa: krbd_blkroset.t: update for read-only changes
If an image is mapped read-only, setting its partition(s) to read-write via BLKROSET is no longer allowed. Add read-only OSD caps test cases. Fixes: https://tracker.ceph.com/issues/42915 Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
parent
204ac51d86
commit
366a369c8d
@ -2,8 +2,11 @@
|
||||
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 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
|
||||
@ -144,10 +147,16 @@ R/O, unpartitioned:
|
||||
.*BLKROSET: Permission denied (re)
|
||||
[1]
|
||||
$ sudo blockdev --setrw $DEV
|
||||
.*BLKROSET: Read-only file system (re)
|
||||
[1]
|
||||
$ blockdev --getro $DEV
|
||||
0
|
||||
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:
|
||||
@ -174,18 +183,30 @@ R/O, partitioned:
|
||||
.*BLKROSET: Permission denied (re)
|
||||
[1]
|
||||
$ sudo blockdev --setrw ${DEV}p1
|
||||
.*BLKROSET: Read-only file system (re)
|
||||
[1]
|
||||
$ blockdev --setrw ${DEV}p2
|
||||
.*BLKROSET: Permission denied (re)
|
||||
[1]
|
||||
$ sudo blockdev --setrw ${DEV}p2
|
||||
.*BLKROSET: Read-only file system (re)
|
||||
[1]
|
||||
$ blockdev --getro ${DEV}p1
|
||||
0
|
||||
1
|
||||
$ blockdev --getro ${DEV}p2
|
||||
0
|
||||
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
|
||||
|
||||
|
||||
@ -270,6 +291,45 @@ Partitioned:
|
||||
$ 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
|
||||
============================
|
||||
|
||||
@ -288,6 +348,8 @@ 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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user