Linux filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Chunsheng Luo <luochunsheng@ustc.edu>
Cc: bschubert@ddn.com, fweimer@redhat.com,
	linux-fsdevel@vger.kernel.org, luis@igalia.com,
	mszeredi@redhat.com
Subject: Re: [PATCH 1/2] fuse: fix COPY_FILE_RANGE interface
Date: Tue, 12 Aug 2025 12:49:14 -0700	[thread overview]
Message-ID: <20250812194914.GK7942@frogsfrogsfrogs> (raw)
In-Reply-To: <20250812090818.2810-1-luochunsheng@ustc.edu>

On Tue, Aug 12, 2025 at 05:08:18PM +0800, Chunsheng Luo wrote:
> On 8/6/25 19:43, Bernd Schubert wrote: 
> 
> > On 8/6/25 11:17, Luis Henriques wrote:
> >> On Tue, Aug 05 2025, Miklos Szeredi wrote:
> >> 
> >>> The FUSE protocol uses struct fuse_write_out to convey the return value of
> >>> copy_file_range, which is restricted to uint32_t.  But the COPY_FILE_RANGE
> >>> interface supports a 64-bit size copies.
> >>>
> >>> Currently the number of bytes copied is silently truncated to 32-bit, which
> >>> is unfortunate at best.
> >>>
> >>> Introduce a new op COPY_FILE_RANGE_64, which is identical, except the
> >>> number of bytes copied is returned in a 64-bit value.
> >>>
> >>> If the fuse server does not support COPY_FILE_RANGE_64, fall back to
> >>> COPY_FILE_RANGE and truncate the size to UINT_MAX - 4096.
> >> 
> >> I was wondering if it wouldn't make more sense to truncate the size to
> >> MAX_RW_COUNT instead.  My reasoning is that, if I understand the code
> >> correctly (which is probably a big 'if'!), the VFS will fallback to
> >> splice() if the file system does not implement copy_file_range.  And in
> >> this case splice() seems to limit the operation to MAX_RW_COUNT.
> >
> > I personally don't like the hard coded value too much and would use
> > 
> > inarg.len = min_t(size_t, len, (UINT_MAX - 4096));
> > 
> > (btw, 0xfffff000 is UINT_MAX - 4095, isn't it?).
> > 
> > Though that is all nitpick. The worst part that could happen are
> > applications that do not handle partial file copy and then wouldn't
> > copy the entire file. For these it probably would be better to return
> > -ENOSYS.
> > 
> > LGTM, 
> > 
> > Reviewed-by: Bernd Schubert <bschubert@ddn.com>
> 
> Abot "truncate the size to UINT_MAX - 4096":
> 4096 refers to PAGE_SIZE (the standard memory page size in most systems)?
> If so, wouldn't UINT_MAX & PAGE_MASK be more appropriate? 
> like: `#define MAX_RW_COUNT (INT_MAX & PAGE_MASK)`
> UINT_MAX & PAGE_MASK ensures the operation does not cross a page boundary.

Yeah, I was wondering that too -- if we're going to cap a
copy_file_range to something resembling MAX_RW_COUNT, then why not use
that symbol directly? :)

--D

> Thanks
> Chunsheng Luo
> 

  reply	other threads:[~2025-08-12 19:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-05 18:30 [PATCH 1/2] fuse: fix COPY_FILE_RANGE interface Miklos Szeredi
2025-08-05 18:30 ` [PATCH 2/2] copy_file_range: limit size if in compat mode Miklos Szeredi
2025-08-12 11:21   ` Miklos Szeredi
2025-08-15 14:22     ` Christian Brauner
2025-08-12 14:26   ` Amir Goldstein
2025-08-12 15:50     ` Miklos Szeredi
2025-08-06  9:17 ` [PATCH 1/2] fuse: fix COPY_FILE_RANGE interface Luis Henriques
2025-08-06 16:01   ` Darrick J. Wong
2025-08-06 19:48     ` Luis Henriques
2025-08-11 15:45       ` Darrick J. Wong
2025-08-06 19:43   ` Bernd Schubert
2025-08-12  9:08     ` Chunsheng Luo
2025-08-12 19:49       ` Darrick J. Wong [this message]
2025-08-07  6:24 ` Chunsheng Luo
2025-08-11 15:47   ` Darrick J. Wong

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=20250812194914.GK7942@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=bschubert@ddn.com \
    --cc=fweimer@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=luis@igalia.com \
    --cc=luochunsheng@ustc.edu \
    --cc=mszeredi@redhat.com \
    /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