diff mbox series

[07/15] vfs: skip zero-length dedupe requests

Message ID 153870032167.29072.11158511021942868400.stgit@magnolia (mailing list archive)
State Superseded, archived
Headers show
Series fs: fixes for serious clone/dedupe problems | expand

Commit Message

Darrick J. Wong Oct. 5, 2018, 12:45 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Don't bother calling the filesystem for a zero-length dedupe request;
we can return zero and exit.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/read_write.c |    5 +++++
 1 file changed, 5 insertions(+)

Comments

Amir Goldstein Oct. 5, 2018, 8:39 a.m. UTC | #1
On Fri, Oct 5, 2018 at 3:46 AM Darrick J. Wong <darrick.wong@oracle.com> wrote:
>
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> Don't bother calling the filesystem for a zero-length dedupe request;
> we can return zero and exit.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  fs/read_write.c |    5 +++++
>  1 file changed, 5 insertions(+)
>
>
> diff --git a/fs/read_write.c b/fs/read_write.c
> index 973d3da78c09..99b2f809180c 100644
> --- a/fs/read_write.c
> +++ b/fs/read_write.c
> @@ -1966,6 +1966,11 @@ int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos,
>         if (!dst_file->f_op->dedupe_file_range)
>                 goto out_drop_write;
>
> +       if (len == 0) {
> +               ret = 0;
> +               goto out_drop_write;
> +       }
> +
>         ret = dst_file->f_op->dedupe_file_range(src_file, src_pos,
>                                                 dst_file, dst_pos, len);

I suppose it is best to let user get the same errors he would get
before this change rather than skipping zero length copy at
vfs_dedupe_file_range() level, so looks fine.

Thanks,
Amir.
Christoph Hellwig Oct. 6, 2018, 10:39 a.m. UTC | #2
On Thu, Oct 04, 2018 at 05:45:21PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Don't bother calling the filesystem for a zero-length dedupe request;
> we can return zero and exit.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/fs/read_write.c b/fs/read_write.c
index 973d3da78c09..99b2f809180c 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1966,6 +1966,11 @@  int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos,
 	if (!dst_file->f_op->dedupe_file_range)
 		goto out_drop_write;
 
+	if (len == 0) {
+		ret = 0;
+		goto out_drop_write;
+	}
+
 	ret = dst_file->f_op->dedupe_file_range(src_file, src_pos,
 						dst_file, dst_pos, len);
 out_drop_write: