| Message ID | 20250326142259.50981-1-pvorel@suse.cz |
|---|---|
| State | Changes Requested |
| Headers | show |
| Series | [1/1] ioctl_ficlone03.c: Support test on more filesystems | expand |
Hi! > + /* ext[234] and tmpfs does not support immutable destination */ > + if (errno_exp == EPERM && > + (fs_type == TST_EXT234_MAGIC || fs_type == TST_TMPFS_MAGIC)) { Maybe a bit better if (tc->dst_fd == immut_fd && ...) > + errno_exp = EOPNOTSUPP; > + } > > TST_EXP_FAIL(ioctl(*tc->dst_fd, FICLONE, *tc->src_fd), > - tc->errno_exp, > - "%s", tc->msg); > + errno_exp, "%s", tc->msg); > > clone_range->src_fd = *tc->src_fd; > > TST_EXP_FAIL(ioctl(*tc->dst_fd, FICLONERANGE, clone_range), > - tc->errno_exp, > - "%s", tc->msg); > + errno_exp, "%s", tc->msg); > } > > static void setup(void) I find it strange that we manage to set the FS_IMMUTABLE_FL in the setup with the FS_IOC_SETFLAGS without any error. Maybe it would make sense to check with ext devs what is going on here. > @@ -117,6 +123,10 @@ static struct tst_test test = { > .mkfs_ver = "mkfs.xfs >= 1.5.0", > .mkfs_opts = (const char *const []) {"-m", "reflink=1", NULL}, > }, > + {.type = "ext2"}, > + {.type = "ext3"}, > + {.type = "ext4"}, > + {.type = "tmpfs"}, > {} > }, > .bufs = (struct tst_buffers []) { > -- > 2.49.0 > > > -- > Mailing list info: https://lists.linux.it/listinfo/ltp
Hi ext devs, ... > > static void setup(void) > I find it strange that we manage to set the FS_IMMUTABLE_FL in the setup > with the FS_IOC_SETFLAGS without any error. Maybe it would make sense to > check with ext devs what is going on here. > > @@ -117,6 +123,10 @@ static struct tst_test test = { > > .mkfs_ver = "mkfs.xfs >= 1.5.0", > > .mkfs_opts = (const char *const []) {"-m", "reflink=1", NULL}, > > }, > > + {.type = "ext2"}, > > + {.type = "ext3"}, > > + {.type = "ext4"}, > > + {.type = "tmpfs"}, > > {} While I was working on extending [1] LTP ioctl_ficlone03.c to run on more filesystems [2], I found that ext[2-4] don't support FS_IMMUTABLE_FL. immut_fd = open(MNTPOINT"/immutable", O_CREAT | O_RDWR, 0640); mnt_file = open(MNTPOINT"/file", O_CREAT | O_RDWR, 0640); int attr = FS_IMMUTABLE_FL; ioctl(immut_fd, FS_IOC_SETFLAGS, &attr); ... struct file_clone_range *clone_range; ioctl(immut_fd, FICLONE, mnt_file), ioctl(immut_fd, FICLONERANGE, clone_range), The last two ioctl() with FICLONE and FICLONERANGE get errno EOPNOTSUPP (instead of EPERM as on other fs). Cyril raised concern [3], why first ioctl() FS_IOC_SETFLAGS even works. Shouldn't it also gets EINVAL as vfat, exfat and ntfs get? There is not any info in dmesg. Thanks for any hint. Kind regards, Petr [1] https://patchwork.ozlabs.org/project/ltp/patch/20250326142259.50981-1-pvorel@suse.cz/ [2] https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/ioctl/ioctl_ficlone03.c [3] https://lore.kernel.org/ltp/aHEccDO8lJiTzbEs@yuki.lan/
Hi! On Tue 22-07-25 12:23:46, Petr Vorel wrote: > ... > > > static void setup(void) > > > I find it strange that we manage to set the FS_IMMUTABLE_FL in the setup > > with the FS_IOC_SETFLAGS without any error. Maybe it would make sense to > > check with ext devs what is going on here. > > > > @@ -117,6 +123,10 @@ static struct tst_test test = { > > > .mkfs_ver = "mkfs.xfs >= 1.5.0", > > > .mkfs_opts = (const char *const []) {"-m", "reflink=1", NULL}, > > > }, > > > + {.type = "ext2"}, > > > + {.type = "ext3"}, > > > + {.type = "ext4"}, > > > + {.type = "tmpfs"}, > > > {} > > While I was working on extending [1] LTP ioctl_ficlone03.c to run on more > filesystems [2], I found that ext[2-4] don't support FS_IMMUTABLE_FL. Why do you think FS_IMMUTABLE_FL is unsupported? ext2 was the filesystem actually introducing it to the kernel ;) > immut_fd = open(MNTPOINT"/immutable", O_CREAT | O_RDWR, 0640); > mnt_file = open(MNTPOINT"/file", O_CREAT | O_RDWR, 0640); > int attr = FS_IMMUTABLE_FL; > ioctl(immut_fd, FS_IOC_SETFLAGS, &attr); > ... > > struct file_clone_range *clone_range; > ioctl(immut_fd, FICLONE, mnt_file), > ioctl(immut_fd, FICLONERANGE, clone_range), > > The last two ioctl() with FICLONE and FICLONERANGE get errno EOPNOTSUPP > (instead of EPERM as on other fs). Cyril raised concern [3], why first > ioctl() FS_IOC_SETFLAGS even works. Shouldn't it also gets EINVAL as > vfat, exfat and ntfs get? Unlink FICLONE and FICLONERANGE which are indeed unsupported on any ext? based filesystem so EOPNOTSUPP seems like a correct answer to me. So I'm confused where you see a problem. Honza
Hi Jan, all, > Hi! > On Tue 22-07-25 12:23:46, Petr Vorel wrote: > > ... > > > > static void setup(void) > > > I find it strange that we manage to set the FS_IMMUTABLE_FL in the setup > > > with the FS_IOC_SETFLAGS without any error. Maybe it would make sense to > > > check with ext devs what is going on here. > > > > @@ -117,6 +123,10 @@ static struct tst_test test = { > > > > .mkfs_ver = "mkfs.xfs >= 1.5.0", > > > > .mkfs_opts = (const char *const []) {"-m", "reflink=1", NULL}, > > > > }, > > > > + {.type = "ext2"}, > > > > + {.type = "ext3"}, > > > > + {.type = "ext4"}, > > > > + {.type = "tmpfs"}, > > > > {} > > While I was working on extending [1] LTP ioctl_ficlone03.c to run on more > > filesystems [2], I found that ext[2-4] don't support FS_IMMUTABLE_FL. > Why do you think FS_IMMUTABLE_FL is unsupported? ext2 was the filesystem > actually introducing it to the kernel ;) Lol, I should have git grep kernel sources and google before asking silly question :). Thanks for correcting me. > > immut_fd = open(MNTPOINT"/immutable", O_CREAT | O_RDWR, 0640); > > mnt_file = open(MNTPOINT"/file", O_CREAT | O_RDWR, 0640); > > int attr = FS_IMMUTABLE_FL; > > ioctl(immut_fd, FS_IOC_SETFLAGS, &attr); > > ... > > struct file_clone_range *clone_range; > > ioctl(immut_fd, FICLONE, mnt_file), > > ioctl(immut_fd, FICLONERANGE, clone_range), > > The last two ioctl() with FICLONE and FICLONERANGE get errno EOPNOTSUPP > > (instead of EPERM as on other fs). Cyril raised concern [3], why first > > ioctl() FS_IOC_SETFLAGS even works. Shouldn't it also gets EINVAL as > > vfat, exfat and ntfs get? > Unlink FICLONE and FICLONERANGE which are indeed unsupported on any ext? > based filesystem so EOPNOTSUPP seems like a correct answer to me. > So I'm confused where you see a problem. Thanks for info, obviously there is no problem now :). I'll amend the commit message before merge that FICLONE and FICLONERANGE are not supported (not FS_IMMUTABLE_FL). Kind regards, Petr > Honza
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_ficlone03.c b/testcases/kernel/syscalls/ioctl/ioctl_ficlone03.c index 6716423d9c..f4e7bf2906 100644 --- a/testcases/kernel/syscalls/ioctl/ioctl_ficlone03.c +++ b/testcases/kernel/syscalls/ioctl/ioctl_ficlone03.c @@ -43,16 +43,22 @@ static struct tcase { static void run(unsigned int n) { struct tcase *tc = &tcases[n]; + int errno_exp = tc->errno_exp; + long fs_type = tst_fs_type(MNTPOINT); + + /* ext[234] and tmpfs does not support immutable destination */ + if (errno_exp == EPERM && + (fs_type == TST_EXT234_MAGIC || fs_type == TST_TMPFS_MAGIC)) { + errno_exp = EOPNOTSUPP; + } TST_EXP_FAIL(ioctl(*tc->dst_fd, FICLONE, *tc->src_fd), - tc->errno_exp, - "%s", tc->msg); + errno_exp, "%s", tc->msg); clone_range->src_fd = *tc->src_fd; TST_EXP_FAIL(ioctl(*tc->dst_fd, FICLONERANGE, clone_range), - tc->errno_exp, - "%s", tc->msg); + errno_exp, "%s", tc->msg); } static void setup(void) @@ -117,6 +123,10 @@ static struct tst_test test = { .mkfs_ver = "mkfs.xfs >= 1.5.0", .mkfs_opts = (const char *const []) {"-m", "reflink=1", NULL}, }, + {.type = "ext2"}, + {.type = "ext3"}, + {.type = "ext4"}, + {.type = "tmpfs"}, {} }, .bufs = (struct tst_buffers []) {
ext[2-4] don't support immutable. vfat, exfat and ntfs would fail, therefore not supported: ioctl_ficlone03.c:80: TBROK: ioctl(7,((((1U) << (((0+8)+8)+14)) | ((('f')) << (0+8)) | (((2)) << 0) | ((((sizeof(long)))) << ((0+8)+8)))),...) failed: EINVAL (22) ioctl_ficlone03.c:95: TWARN: ioctl(7,((((2U) << (((0+8)+8)+14)) | ((('f')) << (0+8)) | (((1)) << 0) | ((((sizeof(long)))) << ((0+8)+8)))),...) failed: EINVAL (22) ioctl_ficlone03.c:97: TWARN: ioctl(7,((((1U) << (((0+8)+8)+14)) | ((('f')) << (0+8)) | (((2)) << 0) | ((((sizeof(long)))) << ((0+8)+8)))),...) failed: EINVAL (22) ioctl_ficlone03.c:104: TWARN: close(-1) failed: EBADF (9) Signed-off-by: Petr Vorel <pvorel@suse.cz> --- Based on Andrea's patch which fixes 32bit failure on Bcachefs: https://patchwork.ozlabs.org/project/ltp/patch/20250326-fix_ioctl_ficlone03_32bit_bcachefs-v1-1-554a0315ebf5@suse.com/ NOTE: if found useful I'll recheck whether test works on older kernels. .../kernel/syscalls/ioctl/ioctl_ficlone03.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)