diff options
author | Cyril Hrubis <chrubis@suse.cz> | 2020-04-29 16:04:39 +0200 |
---|---|---|
committer | Cyril Hrubis <chrubis@suse.cz> | 2020-05-06 15:50:06 +0200 |
commit | 0f66eee021ee72d108bf7529c72a86d8729fcc96 (patch) | |
tree | aea20397165fce5d27de1801831030fd8dc64595 /testcases | |
parent | 008ae344a926901c11df903aa5d4362152718a08 (diff) |
syscalls/ioctl_loop05: Do not fail on success
The code in __loop_update_dio() uses inode->i_sb->s_bdev to get the
logical block size for the backing file for the loop device. If that
pointer is NULL, which happens to be the case for Btrfs, the checks for
alignment and block size are ignored and direct I/O can be turned on
regardless of the offset and logical block size.
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
CC: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Diffstat (limited to 'testcases')
-rw-r--r-- | testcases/kernel/syscalls/ioctl/ioctl_loop05.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_loop05.c b/testcases/kernel/syscalls/ioctl/ioctl_loop05.c index 3a028ba2c..6cf701f47 100644 --- a/testcases/kernel/syscalls/ioctl/ioctl_loop05.c +++ b/testcases/kernel/syscalls/ioctl/ioctl_loop05.c @@ -6,9 +6,21 @@ * This is a basic ioctl test about loopdevice. * * It is designed to test LOOP_SET_DIRECT_IO can updata a live - * loop device dio mode. It need the backing file also supports + * loop device dio mode. It needs the backing file also supports * dio mode and the lo_offset is aligned with the logical block size. + * + * The direct I/O error handling is a bit messy on Linux, some filesystems + * return error when it coudln't be enabled, some silently fall back to regular + * buffered I/O. + * + * The LOOP_SET_DIRECT_IO ioctl() may ignore all checks if it cannot get the + * logical block size which is the case if the block device pointer in the + * backing file inode is not set. In this case the direct I/O appears to be + * enabled but falls back to buffered I/O later on. This is the case at least + * for Btrfs. Because of that the test passes both with failure as well as + * success with non-zero offset. */ + #include <stdio.h> #include <unistd.h> #include <string.h> @@ -58,7 +70,7 @@ static void verify_ioctl_loop(void) TST_RETRY_FUNC(ioctl(dev_fd, LOOP_SET_STATUS, &loopinfo), TST_RETVAL_EQ0); TEST(ioctl(dev_fd, LOOP_SET_DIRECT_IO, 1)); if (TST_RET == 0) { - tst_res(TPASS, "LOOP_SET_DIRECT_IO succeeded"); + tst_res(TPASS, "LOOP_SET_DIRECT_IO succeeded, offset is ignored"); check_dio_value(1); SAFE_IOCTL(dev_fd, LOOP_SET_DIRECT_IO, 0); } else { @@ -71,7 +83,7 @@ static void verify_ioctl_loop(void) TEST(ioctl(dev_fd, LOOP_SET_DIRECT_IO, 1)); if (TST_RET == 0) { - tst_res(TFAIL, "LOOP_SET_DIRECT_IO succeeded unexpectedly"); + tst_res(TPASS, "LOOP_SET_DIRECT_IO succeeded"); SAFE_IOCTL(dev_fd, LOOP_SET_DIRECT_IO, 0); return; } |