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>
Otherwise add_key() in set_kernel_secret() fails as if running against
an ancient kernel and we fall back to secret= in options for the first
image being mapped on the machine.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
On Debian-based distros, hexdump(1) comes from FreeBSD in bsdmainutils
package (other distros ship a Linux version from util-linux). It turns
out that '-s skip' for anything but a regular file has been broken for
ages in FreeBSD -- instead of calling fseek(), it consumed the input
byte by byte with getchar(). This was fixed in commit 7cd5ae492557
"hexdump(1): Speed up -s flag on devices" last year, but it hasn't made
it to the Debian world yet.
bsdmainutils_9.0.6ubuntu3 in xenial had a custom patch for that, but
it's no longer there in bsdmainutils_11.1.2ubuntu1 in bionic. hexdump
-s <large offset> is now a fancy infinite loop!
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
rbd rounds off and ignores discards that are smaller than alloc_size,
but the page cache is invalidated according to the original offset and
length, before calling into the driver. For a 512~4193792 discard, all
pages except for the first will be invalidated, but the first page may
remain cached after being partially zeroed out. This results in an
inconsistency when alloc_size != 512. E.g. for 64k:
0 512 4k 64k 4M
| | | | |
page cache: xxxxxxxx00000000xxxxxxxx0000000000000000
RADOS: xxxxxxxxxxxxxxxxxxxxxxxx0000000000000000
Given that these tests asserts on-disk state, we need to read directly
from disk. krbd_discard_512b.t and krbd_zeroout.t are fine -- there is
no rounding there.
Fixes: https://tracker.ceph.com/issues/41753
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
It turns out this test has not been triggering the right code path for
a while now (krbd_parent_overlap.t was added just over a year ago, but
the original test goes back a few years).
To do its job it needs an empty clone with the overlap set to somewhere
in the middle of an object. The test relied on shrinking for this, but
shrinking no longer fits the bill because a copyup is now performed for
the object with the overlap -- we never go to the parent after that.
Let's size the parent so that it ends in the middle of an object and
then grow an empty clone instead. Also, while reading from page cache
does seem to trigger a read that straddles the overlap, it's not very
reliable, so supplement it with a direct read.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Discard no longer guarantees zeroing, use BLKZEROOUT and "fallocate -z"
instead (blkdiscard(8) in xenial doesn't support -z).
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
We've had multiple overflows in ceph_calc_file_object_mapping().
It wasn't being used by rbd, but it now is.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
The block layer used to not enforce ioctl(BLKROSET) and set_disk_ro().
This has been fixed in 4.16-rc1.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
/bin/bash is a Linuxism. Other operating systems install bash to
different paths. Use /usr/bin/env in shebangs to find bash.
Signed-off-by: Alan Somers <asomers@gmail.com>
Make g_conf.keyring a plain old string rather than an array of strings.
Don't do substitution using the user's HOME variable-- this could lead
to security holes for setuid processes.
Get rid of AuthMonitor::read_keyfile because there is already a Keyring
member function, Keyring::load, that does the same thing.
qa/rbd/common.sh: we can now use cconf to figure out what the keyring
is.
Signed-off-by: Colin McCabe <colinm@hq.newdream.net>