From: Anna Schumaker Date: Thu, 12 Jan 2017 20:12:40 +0000 (-0600) Subject: xfs_io: Improvements to copy_range return code handling X-Git-Tag: v4.10.0-rc1~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43141802cdade027663044952f8d09f71d59faa4;p=thirdparty%2Fxfsprogs-dev.git xfs_io: Improvements to copy_range return code handling If copy_file_range() returns 0, then that means no data was copied. We should break out of the loop in this case to prevent looping indefinitely. Additionally, if an error is returned by copy_file_range() then we need to print out the string form to be used by error checking tests in xfstests. Signed-off-by: Anna Schumaker Reviewed-by: Carlos Maiolino Signed-off-by: Eric Sandeen --- diff --git a/io/copy_file_range.c b/io/copy_file_range.c index 88203e967..249c64907 100644 --- a/io/copy_file_range.c +++ b/io/copy_file_range.c @@ -49,8 +49,11 @@ copy_file_range(int fd, loff_t *src, loff_t *dst, size_t len) do { ret = syscall(__NR_copy_file_range, fd, src, file->fd, dst, len, 0); - if (ret == -1) + if (ret == -1) { + perror("copy_range"); return errno; + } else if (ret == 0) + break; len -= ret; } while (len > 0);