linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bert Karwatzki <spasswolf@web.de>
To: Amir Goldstein <amir73il@gmail.com>,
	Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>,
	axboe@kernel.dk, dhowells@redhat.com, hch@lst.de,
	 jlayton@kernel.org, josef@toxicpanda.com,
	linux-fsdevel@vger.kernel.org,  miklos@szeredi.hu,
	viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs: read_write: make default in vfs_copy_file_range() reachable
Date: Tue, 05 Dec 2023 10:50:20 +0100	[thread overview]
Message-ID: <b0803db66dfd4816b21d78bcbccefdb75318444d.camel@web.de> (raw)
In-Reply-To: <CAOQ4uxg-4NSysxmviKxDhnrA5P455T074ku=F24Wa5KJnCgspQ@mail.gmail.com>

Am Dienstag, dem 05.12.2023 um 07:01 +0200 schrieb Amir Goldstein:
> On Tue, Dec 5, 2023 at 5:45 AM Amir Goldstein <amir73il@gmail.com> wrote:
> >
> > On Tue, Dec 5, 2023 at 2:16 AM Bert Karwatzki <spasswolf@web.de> wrote:
> > >
> > > If vfs_copy_file_range() is called with (flags & COPY_FILE_SPLICE == 0)
> > > and both file_out->f_op->copy_file_range and file_in->f_op-
> > > >remap_file_range
> > > are NULL, too, the default call to do_splice_direct() cannot be reached.
> > > This patch adds an else clause to make the default reachable in all
> > > cases.
> > >
> > > Signed-off-by: Bert Karwatzki <spasswolf@web.de>
> >
> > Hi Bert,
> >
> > Thank you for testing and reporting this so early!!
> >
> > I would edit the commit message differently, but anyway, I think that
> > the fix should be folded into commit 05ee2d85cd4a ("fs: use
> > do_splice_direct() for nfsd/ksmbd server-side-copy").
> >
> > Since I end up making a mistake every time I touch this code,
> > I also added a small edit to your patch below, that should make the logic
> > more clear to readers. Hopefully, that will help me avoid making a mistake
> > the next time I touch this code...
> >
> > Would you mind testing my revised fix, so we can add:
> >   Tested-by: Bert Karwatzki <spasswolf@web.de>
> > when folding it into the original patch?
> >
>
> Attached an even cleaner version of the fix patch for you to test.
> I tested fstests check -g copy_range on ext4.
> My fault was that I had tested earlier only on xfs and overlayfs
> (the two other cases in the if/else if statement).
>
> Thanks,
> Amir.
>
> > > ---
> > >  fs/read_write.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > diff --git a/fs/read_write.c b/fs/read_write.c
> > > index e0c2c1b5962b..3599c54bd26d 100644
> > > --- a/fs/read_write.c
> > > +++ b/fs/read_write.c
> > > @@ -1554,6 +1554,8 @@ ssize_t vfs_copy_file_range(struct file *file_in,
> > > loff_t pos_in,
> > >                 /* fallback to splice */
> > >                 if (ret <= 0)
> > >                         splice = true;
> > > +       } else {
> >
> > This is logically correct because of the earlier "same sb" check in
> > generic_copy_file_checks(), but we better spell out the logic here as well:
> >
> > +            } else if (file_inode(file_in)->i_sb ==
> > file_inode(file_out)->i_sb) {
> > +                    /* Fallback to splice for same sb copy for
> > backward compat */
> >
> > > +               splice = true;
> > >         }
> > >
> > >         file_end_write(file_out);
> > > --
> > > 2.39.2
> > >
> > > Since linux-next-20231204 I noticed that it was impossible to start the
> > > game Path of Exile (using the steam client). I bisected the error to
> > > commit 05ee2d85cd4ace5cd37dc24132e3fd7f5142ebef. Reverting this commit
> > > in linux-next-20231204 made the game start again and after inserting
> > > printks into vfs_copy_file_range() I found that steam (via python3)
> > > calls this function with (flags & COPY_FILE_SPLICE == 0),
> > > file_out->f_op->copy_file_range == NULL and
> > > file_in->f_op->remap_file_range == NULL so the default is never reached.
> > > This patch adds a catch all else clause so the default is reached in
> > > all cases. This patch fixes the describe issue with steam and Path of
> > > Exile.
> > >
> > > Bert Karwatzki

Your new patch works fine (I applied it to linux-next-20231204), again tested by
starting Path of Exile via steam from an ext4 filesystem.

Bert Karwatzki

  reply	other threads:[~2023-12-05  9:50 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-30 14:16 [PATCH v2 0/3] Avert possible deadlock with splice() and fanotify Amir Goldstein
2023-11-30 14:16 ` [PATCH v2 1/3] fs: fork splice_file_range() from do_splice_direct() Amir Goldstein
2023-11-30 16:27   ` Jeff Layton
2023-12-04  8:37   ` Christoph Hellwig
2023-12-04  8:38     ` Christoph Hellwig
2023-12-04 13:29       ` Amir Goldstein
2023-12-04 14:07         ` Christoph Hellwig
2023-12-04 14:29           ` Amir Goldstein
2023-12-04 17:16             ` Jan Kara
2023-12-04 18:53               ` Amir Goldstein
2023-11-30 14:16 ` [PATCH v2 2/3] fs: move file_start_write() into direct_splice_actor() Amir Goldstein
2023-12-04  8:38   ` Christoph Hellwig
2023-11-30 14:16 ` [PATCH v2 3/3] fs: use do_splice_direct() for nfsd/ksmbd server-side-copy Amir Goldstein
2023-11-30 16:49   ` Jan Kara
2023-12-04  8:39   ` Christoph Hellwig
2023-12-04 13:19     ` Amir Goldstein
2023-12-04 14:02       ` Christoph Hellwig
2023-12-05  0:16   ` [PATCH] fs: read_write: make default in vfs_copy_file_range() reachable Bert Karwatzki
2023-12-05  3:45     ` Amir Goldstein
2023-12-05  5:01       ` Amir Goldstein
2023-12-05  9:50         ` Bert Karwatzki [this message]
2023-11-30 16:32 ` [PATCH v2 0/3] Avert possible deadlock with splice() and fanotify Jeff Layton
2023-12-01 10:40 ` Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b0803db66dfd4816b21d78bcbccefdb75318444d.camel@web.de \
    --to=spasswolf@web.de \
    --cc=amir73il@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=dhowells@redhat.com \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=jlayton@kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).