Re: warning for EOPNOTSUPP vfs_copy_file_range

From: Paul Gortmaker
Date: Thu May 19 2022 - 23:16:34 EST


[Re: warning for EOPNOTSUPP vfs_copy_file_range] On 19/05/2022 (Thu 15:31) Luís Henriques wrote:

> Amir Goldstein <amir73il@xxxxxxxxx> writes:
>
> > On Thu, May 19, 2022 at 11:22 AM He Zhe <zhe.he@xxxxxxxxxxxxx> wrote:
> >>
> >> Hi,
> >>
> >> We are experiencing the following warning from
> >> "WARN_ON_ONCE(ret == -EOPNOTSUPP);" in vfs_copy_file_range, from
> >> 64bf5ff58dff ("vfs: no fallback for ->copy_file_range")
> >>
> >> # cat /sys/class/net/can0/phys_switch_id
> >>
> >> WARNING: CPU: 7 PID: 673 at fs/read_write.c:1516 vfs_copy_file_range+0x380/0x440

[...]

> > Sigh! Those filesystems have no business doing copy_file_range()
> >
> > Here is a patch that Luis has been trying to push last year
> > to fix a problem with copy_file_range() from tracefs:
> >
> > https://lore.kernel.org/linux-fsdevel/20210702090012.28458-1-lhenriques@xxxxxxx/
>
> Yikes! It's been a while and I completely forgot about it. I can
> definitely try to respin this patch if someone's interested in picking
> it. I'll have to go re-read everything again and see what's missing and
> what has changed in between.

If it helps any, you don't need CAN bus or anything complicated. I was
able to reproduce it with the loopback device on linux-next of today
with a new userspace (from Yocto) that actively uses copy_file_range()

Note that a cp or redirect is needed to trigger the copy - with the
new userspace requiremet. Or write your own reproducer that goes at the
syscall directly on an old userspace (untested by me).

root@qemux86-64:/sys/class/net/lo# cat phys_switch_id
cat: phys_switch_id: Operation not supported
root@qemux86-64:/sys/class/net/lo# cat phys_switch_id > /tmp/foo
[ 87.527506] ------------[ cut here ]------------
[ 87.527675] WARNING: CPU: 2 PID: 238 at /home/paul/git/linux-head/fs/read_write.c:1511 vfs_copy_file_range+0x47c/0x4e0

Paul.
--

>
> Cheers,
> --
> Luís
>
> > Luis gave up on it, because no maintainer stepped up to take
> > the patch, but I think that is the right way to go.
> >
> > Maybe this bug report can raise awareness to that old patch.
> >
> > Al, could you have a look?
> >
> > Thanks,
> > Amir.
> >