mirror of
https://github.com/ceph/ceph
synced 2025-01-02 00:52:22 +00:00
qa: krbd_exclusive_option.sh: update for recent kernel changes
Since 5.3: - a plain "rbd map" acquires the lock, so it's not different from "rbd map -o exclusive" in this regard - if the lock is held by the exclusive peer, I/O is failed right away instead of blocking - lock_timeout option is respected only by "rbd map" and not by I/O Since 5.5: - if the mapping is read-only, the lock isn't acquired Added blacklisting test case, dropped lock_timeout test case. Fixes: https://tracker.ceph.com/issues/43127 Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
parent
041a71b3e8
commit
50933b863a
@ -53,6 +53,15 @@ function assert_unlocked() {
|
||||
grep '"lockers":\[\]'
|
||||
}
|
||||
|
||||
function blacklist_add() {
|
||||
local dev_id="${1#/dev/rbd}"
|
||||
|
||||
local client_addr
|
||||
client_addr="$(< $SYSFS_DIR/$dev_id/client_addr)"
|
||||
|
||||
ceph osd blacklist add $client_addr
|
||||
}
|
||||
|
||||
SYSFS_DIR="/sys/bus/rbd/devices"
|
||||
IMAGE_NAME="exclusive-option-test"
|
||||
|
||||
@ -69,11 +78,27 @@ assert_unlocked
|
||||
expect_false sudo rbd map -o exclusive $IMAGE_NAME
|
||||
assert_unlocked
|
||||
|
||||
expect_false sudo rbd map -o lock_on_read $IMAGE_NAME
|
||||
assert_unlocked
|
||||
|
||||
rbd feature enable $IMAGE_NAME exclusive-lock
|
||||
rbd snap create $IMAGE_NAME@snap
|
||||
|
||||
DEV=$(sudo rbd map $IMAGE_NAME)
|
||||
assert_locked $DEV
|
||||
[[ $(blockdev --getro $DEV) -eq 0 ]]
|
||||
sudo rbd unmap $DEV
|
||||
assert_unlocked
|
||||
|
||||
DEV=$(sudo rbd map $IMAGE_NAME@snap)
|
||||
assert_unlocked
|
||||
[[ $(blockdev --getro $DEV) -eq 1 ]]
|
||||
sudo rbd unmap $DEV
|
||||
assert_unlocked
|
||||
|
||||
DEV=$(sudo rbd map -o ro $IMAGE_NAME)
|
||||
assert_unlocked
|
||||
[[ $(blockdev --getro $DEV) -eq 1 ]]
|
||||
sudo rbd unmap $DEV
|
||||
assert_unlocked
|
||||
|
||||
@ -84,34 +109,76 @@ sudo rbd unmap $DEV
|
||||
assert_unlocked
|
||||
|
||||
DEV=$(sudo rbd map -o exclusive $IMAGE_NAME@snap)
|
||||
assert_locked $DEV
|
||||
assert_unlocked
|
||||
[[ $(blockdev --getro $DEV) -eq 1 ]]
|
||||
sudo rbd unmap $DEV
|
||||
assert_unlocked
|
||||
|
||||
DEV=$(sudo rbd map -o exclusive,ro $IMAGE_NAME)
|
||||
assert_locked $DEV
|
||||
assert_unlocked
|
||||
[[ $(blockdev --getro $DEV) -eq 1 ]]
|
||||
sudo rbd unmap $DEV
|
||||
assert_unlocked
|
||||
|
||||
# alternate syntax
|
||||
DEV=$(sudo rbd map --exclusive --read-only $IMAGE_NAME)
|
||||
assert_locked $DEV
|
||||
assert_unlocked
|
||||
[[ $(blockdev --getro $DEV) -eq 1 ]]
|
||||
sudo rbd unmap $DEV
|
||||
assert_unlocked
|
||||
|
||||
DEV=$(sudo rbd map $IMAGE_NAME)
|
||||
assert_unlocked
|
||||
assert_locked $DEV
|
||||
OTHER_DEV=$(sudo rbd map -o noshare $IMAGE_NAME)
|
||||
assert_locked $OTHER_DEV
|
||||
dd if=/dev/urandom of=$DEV bs=4k count=10 oflag=direct
|
||||
assert_locked $DEV
|
||||
OTHER_DEV=$(sudo rbd map -o noshare,exclusive $IMAGE_NAME)
|
||||
dd if=/dev/urandom of=$OTHER_DEV bs=4k count=10 oflag=direct
|
||||
assert_locked $OTHER_DEV
|
||||
sudo rbd unmap $DEV
|
||||
sudo rbd unmap $OTHER_DEV
|
||||
assert_unlocked
|
||||
|
||||
DEV=$(sudo rbd map $IMAGE_NAME)
|
||||
assert_locked $DEV
|
||||
OTHER_DEV=$(sudo rbd map -o noshare,exclusive $IMAGE_NAME)
|
||||
assert_locked $OTHER_DEV
|
||||
dd if=$DEV of=/dev/null bs=4k count=10 iflag=direct
|
||||
expect_false dd if=/dev/urandom of=$DEV bs=4k count=10 oflag=direct
|
||||
assert_locked $OTHER_DEV
|
||||
sudo rbd unmap $OTHER_DEV
|
||||
assert_unlocked
|
||||
dd if=$DEV of=/dev/null bs=4k count=10 iflag=direct
|
||||
assert_unlocked
|
||||
dd if=/dev/urandom of=$DEV bs=4k count=10 oflag=direct
|
||||
assert_locked $DEV
|
||||
sudo rbd unmap $DEV
|
||||
assert_unlocked
|
||||
|
||||
DEV=$(sudo rbd map -o lock_on_read $IMAGE_NAME)
|
||||
assert_locked $DEV
|
||||
OTHER_DEV=$(sudo rbd map -o noshare,exclusive $IMAGE_NAME)
|
||||
assert_locked $OTHER_DEV
|
||||
expect_false dd if=$DEV of=/dev/null bs=4k count=10 iflag=direct
|
||||
expect_false dd if=/dev/urandom of=$DEV bs=4k count=10 oflag=direct
|
||||
sudo udevadm settle
|
||||
assert_locked $OTHER_DEV
|
||||
sudo rbd unmap $OTHER_DEV
|
||||
assert_unlocked
|
||||
dd if=$DEV of=/dev/null bs=4k count=10 iflag=direct
|
||||
assert_locked $DEV
|
||||
dd if=/dev/urandom of=$DEV bs=4k count=10 oflag=direct
|
||||
assert_locked $DEV
|
||||
sudo rbd unmap $DEV
|
||||
assert_unlocked
|
||||
|
||||
DEV=$(sudo rbd map -o exclusive $IMAGE_NAME)
|
||||
assert_locked $DEV
|
||||
expect_false sudo rbd map -o noshare $IMAGE_NAME
|
||||
assert_locked $DEV
|
||||
sudo rbd unmap $DEV
|
||||
assert_unlocked
|
||||
|
||||
DEV=$(sudo rbd map -o exclusive $IMAGE_NAME)
|
||||
assert_locked $DEV
|
||||
expect_false sudo rbd map -o noshare,exclusive $IMAGE_NAME
|
||||
@ -119,44 +186,31 @@ assert_locked $DEV
|
||||
sudo rbd unmap $DEV
|
||||
assert_unlocked
|
||||
|
||||
DEV=$(sudo rbd map $IMAGE_NAME)
|
||||
assert_locked $DEV
|
||||
rbd resize --size 1G $IMAGE_NAME
|
||||
assert_unlocked
|
||||
sudo rbd unmap $DEV
|
||||
assert_unlocked
|
||||
|
||||
DEV=$(sudo rbd map -o exclusive $IMAGE_NAME)
|
||||
assert_locked $DEV
|
||||
OTHER_DEV=$(sudo rbd map -o noshare $IMAGE_NAME)
|
||||
dd if=/dev/urandom of=$OTHER_DEV bs=4k count=10 oflag=direct &
|
||||
PID=$!
|
||||
sleep 20
|
||||
expect_false rbd resize --size 2G $IMAGE_NAME
|
||||
assert_locked $DEV
|
||||
[[ "$(ps -o stat= $PID)" =~ ^D ]]
|
||||
sudo rbd unmap $DEV
|
||||
assert_unlocked
|
||||
|
||||
DEV=$(sudo rbd map $IMAGE_NAME)
|
||||
assert_locked $DEV
|
||||
dd if=/dev/urandom of=$DEV bs=4k count=10 oflag=direct
|
||||
{ sleep 10; blacklist_add $DEV; } &
|
||||
PID=$!
|
||||
expect_false dd if=/dev/urandom of=$DEV bs=4k count=200000 oflag=direct
|
||||
wait $PID
|
||||
# break lock
|
||||
OTHER_DEV=$(sudo rbd map -o noshare $IMAGE_NAME)
|
||||
assert_locked $OTHER_DEV
|
||||
sudo rbd unmap $OTHER_DEV
|
||||
assert_unlocked
|
||||
|
||||
DEV=$(sudo rbd map -o exclusive $IMAGE_NAME)
|
||||
assert_locked $DEV
|
||||
OTHER_DEV=$(sudo rbd map -o noshare,lock_timeout=60 $IMAGE_NAME)
|
||||
dd if=/dev/urandom of=$OTHER_DEV bs=4k count=10 oflag=direct &
|
||||
PID=$!
|
||||
sleep 20
|
||||
assert_locked $DEV
|
||||
[[ "$(ps -o stat= $PID)" =~ ^D ]]
|
||||
expect_false wait $PID
|
||||
assert_locked $DEV
|
||||
sudo rbd unmap $DEV
|
||||
sudo rbd unmap $OTHER_DEV
|
||||
assert_unlocked
|
||||
|
||||
DEV=$(sudo rbd map -o exclusive $IMAGE_NAME)
|
||||
assert_locked $DEV
|
||||
sudo rbd map -o noshare,lock_on_read $IMAGE_NAME &
|
||||
SUDO_PID=$!
|
||||
sleep 20
|
||||
assert_locked $DEV
|
||||
PID="$(ps -o pid= --ppid $SUDO_PID)"
|
||||
[[ "$(ps -o stat= $PID)" =~ ^D ]]
|
||||
sudo rbd unmap $DEV
|
||||
wait $SUDO_PID
|
||||
assert_locked $OTHER_DEV
|
||||
sudo rbd unmap $OTHER_DEV
|
||||
assert_unlocked
|
||||
|
Loading…
Reference in New Issue
Block a user