diff mbox series

[v6,2/3] syscalls/copy_file_range01: add cross-device test

Message ID 1564030915-3211-2-git-send-email-xuyang2018.jy@cn.fujitsu.com
State Changes Requested
Headers show
Series [v6,1/3] lib: alter find_free_loopdev() | expand

Commit Message

Yang Xu July 25, 2019, 5:01 a.m. UTC
Amir has relaxed cross-device constraint since commit[1], I think we can test it in
copy_file_range01.

[1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5dae222a5

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
---
 .../copy_file_range/copy_file_range01.c       | 58 ++++++++++++++-----
 1 file changed, 43 insertions(+), 15 deletions(-)

Comments

Petr Vorel July 29, 2019, 2 p.m. UTC | #1
Hi,

> Amir has relaxed cross-device constraint since commit[1], I think we can test it in
> copy_file_range01.

> [1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5dae222a5

> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Now sent to the correct patchset version:

Whole patchset LGTM, but here we got quite a lot of failures after increasing
test coverage with .all_filesystems = 1 (which use should be noted in commit
message):

copy_file_range02.c:120: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
copy_file_range02.c:126: FAIL: copy_file_range returned wrong value: 16
...
copy_file_range02.c:126: FAIL: copy_file_range returned wrong value: 16

Kind regards,
Petr
Petr Vorel July 29, 2019, 2:10 p.m. UTC | #2
Hi,

> > Amir has relaxed cross-device constraint since commit[1], I think we can test it in
> > copy_file_range01.

> > [1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5dae222a5

> > Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> > Reviewed-by: Amir Goldstein <amir73il@gmail.com>
> Now sent to the correct patchset version:

> Whole patchset LGTM, but here we got quite a lot of failures after increasing
> test coverage with .all_filesystems = 1 (which use should be noted in commit
> message):

> copy_file_range02.c:120: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
> copy_file_range02.c:126: FAIL: copy_file_range returned wrong value: 16
> ...
> copy_file_range02.c:126: FAIL: copy_file_range returned wrong value: 16

Also .mount_device = 1 and .all_filesystems = 1 require
.needs_root = 1 definition or you get

tst_device.c:97: INFO: Not allowed to open /dev/loop-control. Are you root?: EACCES
tst_device.c:132: INFO: No free devices found
tst_device.c:308: BROK: Failed to acquire device

BTW I wonder whether these could be detected automatically.

Kind regards,
Petr
Yang Xu July 30, 2019, 8:31 a.m. UTC | #3
> Hi,
>
>>> Amir has relaxed cross-device constraint since commit[1], I think we can test it in
>>> copy_file_range01.
>>> [1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5dae222a5
>>> Signed-off-by: Yang Xu<xuyang2018.jy@cn.fujitsu.com>
>>> Reviewed-by: Amir Goldstein<amir73il@gmail.com>
>> Now sent to the correct patchset version:
>> Whole patchset LGTM, but here we got quite a lot of failures after increasing
>> test coverage with .all_filesystems = 1 (which use should be noted in commit
>> message):
>> copy_file_range02.c:120: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
>> copy_file_range02.c:126: FAIL: copy_file_range returned wrong value: 16
>> ...
>> copy_file_range02.c:126: FAIL: copy_file_range returned wrong value: 16
Hi Petr
can you give more information? such as distros, filesystem, envrionment,  do you get 16(EBUSY) on all filesystems?
Because on my machine, I get the following result on 4.18.0-80.el8.x86_64(I test on vfat, extN,xfs,btrfs).

copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EISDIR
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 32
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:122: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0


> Also .mount_device = 1 and .all_filesystems = 1 require
> .needs_root = 1 definition or you get
>
> tst_device.c:97: INFO: Not allowed to open /dev/loop-control. Are you root?: EACCES
> tst_device.c:132: INFO: No free devices found
> tst_device.c:308: BROK: Failed to acquire device
>
> BTW I wonder whether these could be detected automatically.
Here needs root because /dev/loop-control needs it.  But it doesn't represent mount_device and all_filesystems
  need root.
Or, I misunderstand your idea?

> Kind regards,
> Petr
>
>
> .
>
Petr Vorel July 30, 2019, 1:35 p.m. UTC | #4
Hi,

> > > Whole patchset LGTM, but here we got quite a lot of failures after increasing
> > > test coverage with .all_filesystems = 1 (which use should be noted in commit
> > > message):
> > > copy_file_range02.c:120: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
> > > copy_file_range02.c:126: FAIL: copy_file_range returned wrong value: 16
> > > ...
> > > copy_file_range02.c:126: FAIL: copy_file_range returned wrong value: 16
> Hi Petr
> can you give more information? such as distros, filesystem, envrionment,  do you get 16(EBUSY) on all filesystems?
> Because on my machine, I get the following result on 4.18.0-80.el8.x86_64(I test on vfat, extN,xfs,btrfs).
Failing on various distros (VM: openSUSE Tumbleweed, Debian stable and testing,
Centos 7; also on real HW openSUSE), fs: ext4, xfs, btrfs, vfat.

I wonder, what I do wrong. I posted whole output of one machine below.

> > Also .mount_device = 1 and .all_filesystems = 1 require
> > .needs_root = 1 definition or you get

> > tst_device.c:97: INFO: Not allowed to open /dev/loop-control. Are you root?: EACCES
> > tst_device.c:132: INFO: No free devices found
> > tst_device.c:308: BROK: Failed to acquire device

> > BTW I wonder whether these could be detected automatically.
> Here needs root because /dev/loop-control needs it.  But it doesn't represent mount_device and all_filesystems
>  need root.
> Or, I misunderstand your idea?
I thought that for some cases it'd be nice, if .needs_root = 1 was added
internally. But probably bad idea, I guess we should be explicit and add it.

Kind regards,
Petr

tst_device.c:86: INFO: Found free device 1 '/dev/loop1'
tst_supported_fs_types.c:60: INFO: Kernel supports ext2
tst_supported_fs_types.c:44: INFO: mkfs.ext2 does exist
tst_supported_fs_types.c:60: INFO: Kernel supports ext3
tst_supported_fs_types.c:44: INFO: mkfs.ext3 does exist
tst_supported_fs_types.c:60: INFO: Kernel supports ext4
tst_supported_fs_types.c:44: INFO: mkfs.ext4 does exist
tst_supported_fs_types.c:60: INFO: Kernel supports xfs
tst_supported_fs_types.c:44: INFO: mkfs.xfs does exist
tst_supported_fs_types.c:60: INFO: Kernel supports btrfs
tst_supported_fs_types.c:44: INFO: mkfs.btrfs does exist
tst_supported_fs_types.c:60: INFO: Kernel supports vfat
tst_supported_fs_types.c:44: INFO: mkfs.vfat does exist
tst_supported_fs_types.c:83: INFO: Filesystem exfat is not supported
tst_supported_fs_types.c:83: INFO: Filesystem ntfs is not supported
tst_test.c:1161: INFO: Testing on ext2
tst_mkfs.c:90: INFO: Formatting /dev/loop1 with ext2 opts='' extra opts=''
mke2fs 1.45.0 (6-Mar-2019)
tst_test.c:1100: INFO: Timeout per run is 0h 05m 00s
copy_file_range.h:41: INFO: Testing libc copy_file_range()
tst_device.c:86: INFO: Found free device 2 '/dev/loop2'
Setting up swapspace version 1, size = 36 KiB (36864 bytes)
no label, UUID=e585e0bd-0e55-4cdc-a37f-ca81411021c3
swapon: /tmp/wTdW10/file_swap: swapon failed: Invalid argument
copy_file_range02.c:89: CONF: swapon binary not installed
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EISDIR
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 32
copy_file_range02.c:105: CONF: filesystem doesn't support swapfile, skip it
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:122: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
swapoff: file_swap: swapoff failed: Invalid argument
copy_file_range02.c:89: CONF: swapoff binary not installed
tst_test.c:1161: INFO: Testing on ext3
tst_mkfs.c:90: INFO: Formatting /dev/loop1 with ext3 opts='' extra opts=''
mke2fs 1.45.0 (6-Mar-2019)
tst_test.c:1100: INFO: Timeout per run is 0h 05m 00s
copy_file_range.h:41: INFO: Testing libc copy_file_range()
tst_device.c:86: INFO: Found free device 2 '/dev/loop2'
Setting up swapspace version 1, size = 36 KiB (36864 bytes)
no label, UUID=188ffc43-d712-452d-ba6c-5727457d87d9
swapon: /tmp/wTdW10/file_swap: swapon failed: Invalid argument
copy_file_range02.c:89: CONF: swapon binary not installed
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EISDIR
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 32
copy_file_range02.c:105: CONF: filesystem doesn't support swapfile, skip it
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:122: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
swapoff: file_swap: swapoff failed: Invalid argument
copy_file_range02.c:89: CONF: swapoff binary not installed
tst_test.c:1161: INFO: Testing on ext4
tst_mkfs.c:90: INFO: Formatting /dev/loop1 with ext4 opts='' extra opts=''
mke2fs 1.45.0 (6-Mar-2019)
tst_test.c:1100: INFO: Timeout per run is 0h 05m 00s
copy_file_range.h:41: INFO: Testing libc copy_file_range()
tst_device.c:86: INFO: Found free device 2 '/dev/loop2'
Setting up swapspace version 1, size = 36 KiB (36864 bytes)
no label, UUID=3f384ded-2f54-40a5-b43b-826865b3f67e
swapon: /tmp/wTdW10/file_swap: swapon failed: Invalid argument
copy_file_range02.c:89: CONF: swapon binary not installed
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EISDIR
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 32
copy_file_range02.c:105: CONF: filesystem doesn't support swapfile, skip it
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:122: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
swapoff: file_swap: swapoff failed: Invalid argument
copy_file_range02.c:89: CONF: swapoff binary not installed
tst_test.c:1161: INFO: Testing on xfs
tst_mkfs.c:90: INFO: Formatting /dev/loop1 with xfs opts='' extra opts=''
tst_test.c:1100: INFO: Timeout per run is 0h 05m 00s
copy_file_range.h:41: INFO: Testing libc copy_file_range()
tst_device.c:86: INFO: Found free device 2 '/dev/loop2'
Setting up swapspace version 1, size = 36 KiB (36864 bytes)
no label, UUID=3f088e9f-b153-40f8-813b-661bc5fac6f2
swapon: /tmp/wTdW10/file_swap: swapon failed: Invalid argument
copy_file_range02.c:89: CONF: swapon binary not installed
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EISDIR
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 32
copy_file_range02.c:105: CONF: filesystem doesn't support swapfile, skip it
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:122: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
swapoff: file_swap: swapoff failed: Invalid argument
copy_file_range02.c:89: CONF: swapoff binary not installed
tst_test.c:1161: INFO: Testing on btrfs
tst_mkfs.c:90: INFO: Formatting /dev/loop1 with btrfs opts='' extra opts=''
tst_test.c:1100: INFO: Timeout per run is 0h 05m 00s
copy_file_range.h:41: INFO: Testing libc copy_file_range()
tst_device.c:86: INFO: Found free device 2 '/dev/loop2'
Setting up swapspace version 1, size = 36 KiB (36864 bytes)
no label, UUID=807360ba-a49a-4f8b-b088-92dd455858a7
swapon: /tmp/wTdW10/file_swap: swapon failed: Invalid argument
copy_file_range02.c:89: CONF: swapon binary not installed
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EISDIR
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 32
copy_file_range02.c:105: CONF: filesystem doesn't support swapfile, skip it
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:122: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
swapoff: file_swap: swapoff failed: Invalid argument
copy_file_range02.c:89: CONF: swapoff binary not installed
tst_test.c:1161: INFO: Testing on vfat
tst_mkfs.c:90: INFO: Formatting /dev/loop1 with vfat opts='' extra opts=''
tst_test.c:1100: INFO: Timeout per run is 0h 05m 00s
copy_file_range.h:41: INFO: Testing libc copy_file_range()
tst_device.c:86: INFO: Found free device 2 '/dev/loop2'
Setting up swapspace version 1, size = 36 KiB (36864 bytes)
no label, UUID=b805d82d-c5a2-45d1-9ad3-df7921a36ece
swapon: /tmp/wTdW10/file_swap: swapon failed: Invalid argument
copy_file_range02.c:89: CONF: swapon binary not installed
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EISDIR
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 32
copy_file_range02.c:105: CONF: filesystem doesn't support swapfile, skip it
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:122: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
swapoff: file_swap: swapoff failed: Invalid argument
copy_file_range02.c:89: CONF: swapoff binary not installed
tst_supported_fs_types.c:60: INFO: Kernel supports ext2
tst_supported_fs_types.c:44: INFO: mkfs.ext2 does exist
tst_supported_fs_types.c:60: INFO: Kernel supports ext3
tst_supported_fs_types.c:44: INFO: mkfs.ext3 does exist
tst_supported_fs_types.c:60: INFO: Kernel supports ext4
tst_supported_fs_types.c:44: INFO: mkfs.ext4 does exist
tst_supported_fs_types.c:60: INFO: Kernel supports xfs
tst_supported_fs_types.c:44: INFO: mkfs.xfs does exist
tst_supported_fs_types.c:60: INFO: Kernel supports btrfs
tst_supported_fs_types.c:44: INFO: mkfs.btrfs does exist
tst_supported_fs_types.c:60: INFO: Kernel supports vfat
tst_supported_fs_types.c:44: INFO: mkfs.vfat does exist
tst_supported_fs_types.c:83: INFO: Filesystem exfat is not supported
tst_supported_fs_types.c:83: INFO: Filesystem ntfs is not supported
tst_test.c:1161: INFO: Testing on ext2
tst_mkfs.c:90: INFO: Formatting /dev/loop1 with ext2 opts='' extra opts=''
mke2fs 1.45.0 (6-Mar-2019)
tst_test.c:1100: INFO: Timeout per run is 0h 05m 00s
copy_file_range.h:44: INFO: Testing tst copy_file_range()
tst_device.c:86: INFO: Found free device 2 '/dev/loop2'
Setting up swapspace version 1, size = 36 KiB (36864 bytes)
no label, UUID=e95e50e5-abe4-4f74-924f-af25b1a218a8
swapon: /tmp/wTdW10/file_swap: swapon failed: Invalid argument
copy_file_range02.c:89: CONF: swapon binary not installed
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EISDIR
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 32
copy_file_range02.c:105: CONF: filesystem doesn't support swapfile, skip it
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:122: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
swapoff: file_swap: swapoff failed: Invalid argument
copy_file_range02.c:89: CONF: swapoff binary not installed
tst_test.c:1161: INFO: Testing on ext3
tst_mkfs.c:90: INFO: Formatting /dev/loop1 with ext3 opts='' extra opts=''
mke2fs 1.45.0 (6-Mar-2019)
tst_test.c:1100: INFO: Timeout per run is 0h 05m 00s
copy_file_range.h:44: INFO: Testing tst copy_file_range()
tst_device.c:86: INFO: Found free device 2 '/dev/loop2'
Setting up swapspace version 1, size = 36 KiB (36864 bytes)
no label, UUID=9bb43d35-e633-4bcb-9110-28d212c06f53
swapon: /tmp/wTdW10/file_swap: swapon failed: Invalid argument
copy_file_range02.c:89: CONF: swapon binary not installed
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EISDIR
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 32
copy_file_range02.c:105: CONF: filesystem doesn't support swapfile, skip it
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:122: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
swapoff: file_swap: swapoff failed: Invalid argument
copy_file_range02.c:89: CONF: swapoff binary not installed
tst_test.c:1161: INFO: Testing on ext4
tst_mkfs.c:90: INFO: Formatting /dev/loop1 with ext4 opts='' extra opts=''
mke2fs 1.45.0 (6-Mar-2019)
tst_test.c:1100: INFO: Timeout per run is 0h 05m 00s
copy_file_range.h:44: INFO: Testing tst copy_file_range()
tst_device.c:86: INFO: Found free device 2 '/dev/loop2'
Setting up swapspace version 1, size = 36 KiB (36864 bytes)
no label, UUID=52c81016-b46d-41b2-9ee9-4a414c108480
swapon: /tmp/wTdW10/file_swap: swapon failed: Invalid argument
copy_file_range02.c:89: CONF: swapon binary not installed
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EISDIR
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 32
copy_file_range02.c:105: CONF: filesystem doesn't support swapfile, skip it
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:122: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
swapoff: file_swap: swapoff failed: Invalid argument
copy_file_range02.c:89: CONF: swapoff binary not installed
tst_test.c:1161: INFO: Testing on xfs
tst_mkfs.c:90: INFO: Formatting /dev/loop1 with xfs opts='' extra opts=''
tst_test.c:1100: INFO: Timeout per run is 0h 05m 00s
copy_file_range.h:44: INFO: Testing tst copy_file_range()
tst_device.c:86: INFO: Found free device 2 '/dev/loop2'
Setting up swapspace version 1, size = 36 KiB (36864 bytes)
no label, UUID=f8ecfc5d-1cba-4722-a75e-53a7ff49dd96
swapon: /tmp/wTdW10/file_swap: swapon failed: Invalid argument
copy_file_range02.c:89: CONF: swapon binary not installed
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EISDIR
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 32
copy_file_range02.c:105: CONF: filesystem doesn't support swapfile, skip it
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:122: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
swapoff: file_swap: swapoff failed: Invalid argument
copy_file_range02.c:89: CONF: swapoff binary not installed
tst_test.c:1161: INFO: Testing on btrfs
tst_mkfs.c:90: INFO: Formatting /dev/loop1 with btrfs opts='' extra opts=''
tst_test.c:1100: INFO: Timeout per run is 0h 05m 00s
copy_file_range.h:44: INFO: Testing tst copy_file_range()
tst_device.c:86: INFO: Found free device 2 '/dev/loop2'
Setting up swapspace version 1, size = 36 KiB (36864 bytes)
no label, UUID=64581f50-f38d-4ae3-8931-b63f312f26dd
swapon: /tmp/wTdW10/file_swap: swapon failed: Invalid argument
copy_file_range02.c:89: CONF: swapon binary not installed
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EISDIR
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 32
copy_file_range02.c:105: CONF: filesystem doesn't support swapfile, skip it
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:122: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
swapoff: file_swap: swapoff failed: Invalid argument
copy_file_range02.c:89: CONF: swapoff binary not installed
tst_test.c:1161: INFO: Testing on vfat
tst_mkfs.c:90: INFO: Formatting /dev/loop1 with vfat opts='' extra opts=''
tst_test.c:1100: INFO: Timeout per run is 0h 05m 00s
copy_file_range.h:44: INFO: Testing tst copy_file_range()
tst_device.c:86: INFO: Found free device 2 '/dev/loop2'
Setting up swapspace version 1, size = 36 KiB (36864 bytes)
no label, UUID=c008d9a3-6100-41ee-b430-8e566b7785d4
swapon: /tmp/wTdW10/file_swap: swapon failed: Invalid argument
copy_file_range02.c:89: CONF: swapon binary not installed
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EISDIR
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 32
copy_file_range02.c:105: CONF: filesystem doesn't support swapfile, skip it
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
copy_file_range02.c:122: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
swapoff: file_swap: swapoff failed: Invalid argument
copy_file_range02.c:89: CONF: swapoff binary not installed

Summary:
passed   96
failed   48
skipped  36
warnings 0
Yang Xu July 31, 2019, 7:01 a.m. UTC | #5
> Hi,
>
>>>> Whole patchset LGTM, but here we got quite a lot of failures after increasing
>>>> test coverage with .all_filesystems = 1 (which use should be noted in commit
>>>> message):
>>>> copy_file_range02.c:120: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
>>>> copy_file_range02.c:126: FAIL: copy_file_range returned wrong value: 16
>>>> ...
>>>> copy_file_range02.c:126: FAIL: copy_file_range returned wrong value: 16
>> Hi Petr
>> can you give more information? such as distros, filesystem, envrionment,  do you get 16(EBUSY) on all filesystems?
>> Because on my machine, I get the following result on 4.18.0-80.el8.x86_64(I test on vfat, extN,xfs,btrfs).
> Failing on various distros (VM: openSUSE Tumbleweed, Debian stable and testing,
> Centos 7; also on real HW openSUSE), fs: ext4, xfs, btrfs, vfat.
>
> I wonder, what I do wrong. I posted whole output of one machine below.
Hi Petr

You do nothing wrong.  It fails on various distros because the patchset was merged into upstream kernel since 5.2.

I guess it was not merged into any distros stable kernel Now.


patchurl:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=96e6e8f4a
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5dae222a5

also add xfstests case url:
https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git/tree/tests/generic/553{554,564,565}




>>> Also .mount_device = 1 and .all_filesystems = 1 require
>>> .needs_root = 1 definition or you get
>>> tst_device.c:97: INFO: Not allowed to open /dev/loop-control. Are you root?: EACCES
>>> tst_device.c:132: INFO: No free devices found
>>> tst_device.c:308: BROK: Failed to acquire device
>>> BTW I wonder whether these could be detected automatically.
>> Here needs root because /dev/loop-control needs it.  But it doesn't represent mount_device and all_filesystems
>>   need root.
>> Or, I misunderstand your idea?
> I thought that for some cases it'd be nice, if .needs_root = 1 was added
> internally. But probably bad idea, I guess we should be explicit and add it.
> Kind regards,
> Petr
>
> tst_device.c:86: INFO: Found free device 1 '/dev/loop1'
> tst_supported_fs_types.c:60: INFO: Kernel supports ext2
> tst_supported_fs_types.c:44: INFO: mkfs.ext2 does exist
> tst_supported_fs_types.c:60: INFO: Kernel supports ext3
> tst_supported_fs_types.c:44: INFO: mkfs.ext3 does exist
> tst_supported_fs_types.c:60: INFO: Kernel supports ext4
> tst_supported_fs_types.c:44: INFO: mkfs.ext4 does exist
> tst_supported_fs_types.c:60: INFO: Kernel supports xfs
> tst_supported_fs_types.c:44: INFO: mkfs.xfs does exist
> tst_supported_fs_types.c:60: INFO: Kernel supports btrfs
> tst_supported_fs_types.c:44: INFO: mkfs.btrfs does exist
> tst_supported_fs_types.c:60: INFO: Kernel supports vfat
> tst_supported_fs_types.c:44: INFO: mkfs.vfat does exist
> tst_supported_fs_types.c:83: INFO: Filesystem exfat is not supported
> tst_supported_fs_types.c:83: INFO: Filesystem ntfs is not supported
> tst_test.c:1161: INFO: Testing on ext2
> tst_mkfs.c:90: INFO: Formatting /dev/loop1 with ext2 opts='' extra opts=''
> mke2fs 1.45.0 (6-Mar-2019)
> tst_test.c:1100: INFO: Timeout per run is 0h 05m 00s
> copy_file_range.h:41: INFO: Testing libc copy_file_range()
> tst_device.c:86: INFO: Found free device 2 '/dev/loop2'
> Setting up swapspace version 1, size = 36 KiB (36864 bytes)
> no label, UUID=e585e0bd-0e55-4cdc-a37f-ca81411021c3
> swapon: /tmp/wTdW10/file_swap: swapon failed: Invalid argument
  I am curious about why swapon got this error.

> copy_file_range02.c:89: CONF: swapon binary not installed
> copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
> copy_file_range02.c:118: PASS: copy_file_range failed as expected: EISDIR
> copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
> copy_file_range02.c:118: PASS: copy_file_range failed as expected: EBADF
> copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
> copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 32
> copy_file_range02.c:105: CONF: filesystem doesn't support swapfile, skip it
> copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
> copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
> copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
> copy_file_range02.c:118: PASS: copy_file_range failed as expected: EINVAL
> copy_file_range02.c:122: FAIL: copy_file_range failed unexpectedly; expected EOVERFLOW, but got: EINVAL
> copy_file_range02.c:127: FAIL: copy_file_range returned wrong value: 0
> swapoff: file_swap: swapoff failed: Invalid argument
> copy_file_range02.c:89: CONF: swapoff binary not installed
>
>
> .
>
Petr Vorel July 31, 2019, 7:47 a.m. UTC | #6
Hi Xu,

> > I wonder, what I do wrong. I posted whole output of one machine below.
> Hi Petr

> You do nothing wrong.  It fails on various distros because the patchset was merged into upstream kernel since 5.2.

> I guess it was not merged into any distros stable kernel Now.
Thanks for info. I looked into commits during review, but didn't pay attention
when it was merged into mainline.


> patchurl:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=96e6e8f4a
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5dae222a5

> also add xfstests case url:
> https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git/tree/tests/generic/553{554,564,565}
https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git/tree/tests/generic/{553,554,564,565}

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/copy_file_range/copy_file_range01.c b/testcases/kernel/syscalls/copy_file_range/copy_file_range01.c
index a5bd5e7f7..ec55e5da1 100644
--- a/testcases/kernel/syscalls/copy_file_range/copy_file_range01.c
+++ b/testcases/kernel/syscalls/copy_file_range/copy_file_range01.c
@@ -24,7 +24,16 @@ 
 
 static int page_size;
 static int errcount, numcopies;
-static int fd_in, fd_out;
+static int fd_in, fd_out, cross_sup;
+
+static struct tcase {
+	char    *path;
+	int     flags;
+	char    *message;
+} tcases[] = {
+	{FILE_DEST_PATH,  0, "non cross-device"},
+	{FILE_MNTED_PATH, 1, "cross-device"},
+};
 
 static int check_file_content(const char *fname1, const char *fname2,
 	loff_t *off1, loff_t *off2, size_t len)
@@ -90,7 +99,7 @@  static int check_file_offset(const char *m, int fd, loff_t len,
 	return ret;
 }
 
-static void test_one(size_t len, loff_t *off_in, loff_t *off_out)
+static void test_one(size_t len, loff_t *off_in, loff_t *off_out, char *path)
 {
 	int ret;
 	size_t to_copy = len;
@@ -131,7 +140,7 @@  static void test_one(size_t len, loff_t *off_in, loff_t *off_out)
 		to_copy -= TST_RET;
 	} while (to_copy > 0);
 
-	ret = check_file_content(FILE_SRC_PATH, FILE_DEST_PATH,
+	ret = check_file_content(FILE_SRC_PATH, path,
 		off_in, off_out, len);
 	if (ret) {
 		tst_res(TFAIL, "file contents do not match");
@@ -149,10 +158,10 @@  static void test_one(size_t len, loff_t *off_in, loff_t *off_out)
 	}
 }
 
-static void open_files(void)
+static void open_files(char *path)
 {
 	fd_in  = SAFE_OPEN(FILE_SRC_PATH, O_RDONLY);
-	fd_out = SAFE_OPEN(FILE_DEST_PATH, O_CREAT | O_WRONLY | O_TRUNC, 0644);
+	fd_out = SAFE_OPEN(path, O_CREAT | O_WRONLY | O_TRUNC, 0644);
 }
 
 static void close_files(void)
@@ -163,9 +172,16 @@  static void close_files(void)
 		SAFE_CLOSE(fd_in);
 }
 
-static void copy_file_range_verify(void)
+static void copy_file_range_verify(unsigned int n)
 {
 	int i, j, k;
+	struct tcase *tc = &tcases[n];
+
+	if (tc->flags && !cross_sup) {
+		tst_res(TCONF,
+			"copy_file_range doesn't support cross-device, skip it");
+		return;
+	}
 
 	errcount = numcopies = 0;
 	size_t len_arr[]	= {11, page_size-1, page_size, page_size+1};
@@ -182,33 +198,41 @@  static void copy_file_range_verify(void)
 	for (i = 0; i < (int)ARRAY_SIZE(len_arr); i++)
 		for (j = 0; j < num_offsets; j++)
 			for (k = 0; k < num_offsets; k++) {
-				open_files();
-				test_one(len_arr[i], off_arr[j], off_arr[k]);
+				open_files(tc->path);
+				test_one(len_arr[i], off_arr[j], off_arr[k], tc->path);
 				close_files();
 				numcopies++;
 			}
 
 	if (errcount == 0)
 		tst_res(TPASS,
-			"copy_file_range completed all %d copy jobs successfully!",
-			numcopies);
+			"%s copy_file_range completed all %d copy jobs successfully!",
+			tc->message, numcopies);
 	else
-		tst_res(TFAIL, "copy_file_range failed %d of %d copy jobs.",
-				errcount, numcopies);
+		tst_res(TFAIL, "%s copy_file_range failed %d of %d copy jobs.",
+			tc->message, errcount, numcopies);
 }
 
 static void setup(void)
 {
-	int i, fd;
+	int i, fd, fd_test;
 
 	syscall_info();
 
 	page_size = getpagesize();
-
+	cross_sup = 1;
 	fd = SAFE_OPEN(FILE_SRC_PATH, O_RDWR | O_CREAT, 0664);
 	/* Writing page_size * 4 of data into test file */
 	for (i = 0; i < (int)(page_size * 4); i++)
 		SAFE_WRITE(1, fd, CONTENT, CONTSIZE);
+
+	fd_test = SAFE_OPEN(FILE_MNTED_PATH, O_RDWR | O_CREAT, 0664);
+	TEST(sys_copy_file_range(fd, 0, fd_test, 0, CONTSIZE, 0));
+	if (TST_ERR == EXDEV)
+		cross_sup = 0;
+
+	SAFE_CLOSE(fd_test);
+	remove(FILE_MNTED_PATH);
 	SAFE_CLOSE(fd);
 }
 
@@ -220,7 +244,11 @@  static void cleanup(void)
 static struct tst_test test = {
 	.setup = setup,
 	.cleanup = cleanup,
+	.tcnt = ARRAY_SIZE(tcases),
 	.needs_tmpdir = 1,
-	.test_all = copy_file_range_verify,
+	.mount_device = 1,
+	.mntpoint = MNTPOINT,
+	.all_filesystems = 1,
+	.test = copy_file_range_verify,
 	.test_variants = TEST_VARIANTS,
 };