Return-Path: Received: from userp2130.oracle.com ([156.151.31.86]:58042 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729014AbeJKXcQ (ORCPT ); Thu, 11 Oct 2018 19:32:16 -0400 Date: Thu, 11 Oct 2018 09:04:11 -0700 From: "Darrick J. Wong" To: Amir Goldstein Cc: Dave Chinner , Eric Sandeen , Linux NFS Mailing List , linux-cifs@vger.kernel.org, overlayfs , linux-xfs , Linux MM , Linux Btrfs , linux-fsdevel , ocfs2-devel@oss.oracle.com Subject: Re: [PATCH 17/25] vfs: enable remap callers that can handle short operations Message-ID: <20181011160411.GA28243@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> <153923126628.5546.3484461137192547927.stgit@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: Sender: linux-nfs-owner@vger.kernel.org List-ID: On Thu, Oct 11, 2018 at 08:15:42AM +0300, Amir Goldstein wrote: > On Thu, Oct 11, 2018 at 7:14 AM Darrick J. Wong wrote: > > > > From: Darrick J. Wong > > > > Plumb in a remap flag that enables the filesystem remap handler to > > shorten remapping requests for callers that can handle it. Now > > copy_file_range can report partial success (in case we run up against > > alignment problems, resource limits, etc.). > > > > Signed-off-by: Darrick J. Wong > > Reviewed-by: Amir Goldstein > > --- > > fs/read_write.c | 15 +++++++++------ > > include/linux/fs.h | 7 +++++-- > > mm/filemap.c | 16 ++++++++++++---- > > 3 files changed, 26 insertions(+), 12 deletions(-) > > > > > > diff --git a/fs/read_write.c b/fs/read_write.c > > index 6ec908f9a69b..3713893b7e38 100644 > > --- a/fs/read_write.c > > +++ b/fs/read_write.c > > @@ -1593,7 +1593,8 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, > > > > cloned = file_in->f_op->remap_file_range(file_in, pos_in, > > file_out, pos_out, > > - min_t(loff_t, MAX_RW_COUNT, len), 0); > > + min_t(loff_t, MAX_RW_COUNT, len), > > + RFR_CAN_SHORTEN); > > if (cloned > 0) { > > ret = cloned; > > goto done; > > @@ -1804,16 +1805,18 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, > > * If the user is attempting to remap a partial EOF block and > > * it's inside the destination EOF then reject it. > > * > > - * We don't support shortening requests, so we can only reject > > - * them. > > + * If possible, shorten the request instead of rejecting it. > > */ > > if (is_dedupe) > > ret = -EBADE; > > else if (pos_out + *len < i_size_read(inode_out)) > > ret = -EINVAL; > > > > - if (ret) > > - return ret; > > + if (ret) { > > + if (!(remap_flags & RFR_CAN_SHORTEN)) > > + return ret; > > + *len &= ~blkmask; > > + } > > } > > > > return 1; > > @@ -2112,7 +2115,7 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) > > > > deduped = vfs_dedupe_file_range_one(file, off, dst_file, > > info->dest_offset, len, > > - 0); > > + RFR_CAN_SHORTEN); > > You did not update WARN_ON_ONCE in vfs_dedupe_file_range_one() > to allow this flag and did not mention dedupe in commit message. > Was that change intentional in this patch? > > After RFR_SHORT_DEDUPE patch the end result in fine. Heh, oops, sorry about that. I'll reissue the patch with the two corrections. --D > Thanks, > Amir.