Skip to contentSkip to conversation

xfs_io: Improvements to copy_range return code handling

PATCH Superseded Anna Schumaker 2 participants 2 messages Dec 8, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 io/copy_file_range.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
io/copy_file_range.c +4 -1
index eddc634..161bdcf 100644
@@ -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) {
+			fprintf(stderr, _("copy_range: %s\n"), strerror(errno));
 			return errno;
+		} else if (ret == 0)
+			break;
 		len -= ret;
 	} while (len > 0);
 
Signature · 1 line
2.10.2
#1 lore raw
Quoted 18 lines · Anna Schumaker

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.

---
 io/copy_file_range.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
io/copy_file_range.c +0 -0
index eddc634..161bdcf 100644

io/copy_file_range.c copy_file_range(int fd, loff_t *src, loff_t *dst, size_t len) · line 53

Quoted 6 lines
io/copy_file_range.c +2 -1
@@ -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) {
+			fprintf(stderr, _("copy_range: %s\n"), strerror(errno));

perror("copy_range")?

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]