From 5b2d0f9efd2634a07522ce0383d3a44d417f8f1e Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 28 Jan 2022 16:18:49 +0000 Subject: [PATCH] shared: Handle filesystems that don't support hole punching in COPY_HOLES --- src/shared/copy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/shared/copy.c b/src/shared/copy.c index a92cfc0f61..0941706356 100644 --- a/src/shared/copy.c +++ b/src/shared/copy.c @@ -119,9 +119,11 @@ static int create_hole(int fd, off_t size) { if (end < 0) return -errno; - /* If we're not at the end of the target file, punch a hole in the existing space using fallocate(). */ + /* If we're not at the end of the target file, try to punch a hole in the existing space using fallocate(). */ - if (offset < end && fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, offset, MIN(size, end - offset)) < 0) + if (offset < end && + fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, offset, MIN(size, end - offset)) < 0 && + !ERRNO_IS_NOT_SUPPORTED(errno)) return -errno; if (end - offset >= size) {