Christoph Hellwig
2018-Oct-15 12:47 UTC
[Ocfs2-devel] [PATCH 07/25] vfs: combine the clone and dedupe into a single remap_file_range
On Mon, Oct 15, 2018 at 09:04:13AM +0300, Amir Goldstein wrote:> I supposed you figured out the reason already.No, I hadn't.> It makes it appearance in patch 16/25 as RFR_VFS_FLAGS. > All those "advisory" flags, we want to pass them in to filesystem as FYI, > but we don't want to explicitly add support for e.g. RFR_CAN_SHORTEN > to every filesystem, when vfs has already taken care of the advice.I don't think this model makes sense. If they really are purely handled in the VFS we can mask them before passing them to the file system, if not we need to check them, or the they are avisory and we can have a simple #define instead of the helper. RFR_TO_SRC_EOF is checked in generic_remap_file_range_prep, so the file system should know about it Also looking at it again now it seems entirely superflous - we can just pass down then len == we use in higher level code instead of having a flag and will side step the issue here. RFR_CAN_SHORTEN is advisory as no one has to shorten, but that can easily be solved by including it everywhere. RFR_SHORT_DEDUPE is as far as I can tell entirely superflous to start with, as RFR_CAN_SHORTEN can be used instead. So something like this in fs.h: #define REMAP_FILE_ADVISORY_FLAGS REMAP_FILE_CAN_SHORTEN And then in the file system: if (flags & ~REMAP_FILE_ADVISORY_FLAGS) -EINVAL; or if (flags & ~(REMAP_FILE_ADVISORY_FLAGS | REMAP_FILE_DEDUP)) -EINVAL; should be all that is needed.
Darrick J. Wong
2018-Oct-15 17:13 UTC
[Ocfs2-devel] [PATCH 07/25] vfs: combine the clone and dedupe into a single remap_file_range
On Mon, Oct 15, 2018 at 05:47:19AM -0700, Christoph Hellwig wrote:> On Mon, Oct 15, 2018 at 09:04:13AM +0300, Amir Goldstein wrote: > > I supposed you figured out the reason already. > > No, I hadn't. > > > It makes it appearance in patch 16/25 as RFR_VFS_FLAGS. > > All those "advisory" flags, we want to pass them in to filesystem as FYI, > > but we don't want to explicitly add support for e.g. RFR_CAN_SHORTEN > > to every filesystem, when vfs has already taken care of the advice. > > I don't think this model makes sense. If they really are purely > handled in the VFS we can mask them before passing them to the file > system, if not we need to check them, or the they are avisory and > we can have a simple #define instead of the helper. > > RFR_TO_SRC_EOF is checked in generic_remap_file_range_prep, > so the file system should know about it Also looking at it again now > it seems entirely superflous - we can just pass down then len == we > use in higher level code instead of having a flag and will side step > the issue here.I'm not a fan of hidden behaviors like that, particularly when we already have a flags field where callers can explicitly ask for the to-eof behavior.> RFR_CAN_SHORTEN is advisory as no one has to shorten, but that can > easily be solved by including it everywhere.CAN_SHORTEN isn't included everywhere -- FICLONE{,RANGE} don't enable it because they have no way to communicate the number of bytes cloned back to userspace. Either we can clone every byte the user asked for, or we send back -EINVAL. (Maybe I'm misinterpreting what you meant by 'solved by including it everywhere'?)> RFR_SHORT_DEDUPE is as far as I can tell entirely superflous to > start with, as RFR_CAN_SHORTEN can be used instead.For now it's superfluous. At first I was thinking that we could return a short bytes_deduped if, say, the first part of the range actually did match, but it became pretty obvious via shared/010 that duperemove can't handle that, so we really must stick to the existing btrfs behavior. The existing btrfs behavior is that we can round the length down to avoid deduping partial EOF blocks, but we return the original length (i.e. lie) in bytes_deduped when we do that. I sort of thought about introducing a new copy_file_range flag that would just do deduplication and allow for opportunistic "dedup as much as you can" but ... meh. Maybe I'll just drop the patch instead; we can revisit that when anyone wants a better dedupe interface.> So something like this in fs.h: > > #define REMAP_FILE_ADVISORY_FLAGS REMAP_FILE_CAN_SHORTEN > > And then in the file system: > > if (flags & ~REMAP_FILE_ADVISORY_FLAGS) > -EINVAL; > > or > > if (flags & ~(REMAP_FILE_ADVISORY_FLAGS | REMAP_FILE_DEDUP)) > -EINVAL; > > should be all that is needed.Sounds good to me. --D