|
|
1072c8 |
From 8c339c3535728179acc94deb5b922aebcfac9ab6 Mon Sep 17 00:00:00 2001
|
|
|
1072c8 |
From: Thomas Huth <thuth@redhat.com>
|
|
|
1072c8 |
Date: Thu, 3 Jun 2021 16:13:34 -0400
|
|
|
1072c8 |
Subject: [PATCH 2/4] block/file-posix: Fix problem with fallocate(PUNCH_HOLE)
|
|
|
1072c8 |
on GPFS
|
|
|
1072c8 |
|
|
|
1072c8 |
RH-Author: Thomas Huth <thuth@redhat.com>
|
|
|
1072c8 |
Message-id: <20210603161334.607005-2-thuth@redhat.com>
|
|
|
1072c8 |
Patchwork-id: 101673
|
|
|
1072c8 |
O-Subject: [RHEL-8.5.0 qemu-kvm PATCH 1/1] block/file-posix: Fix problem with fallocate(PUNCH_HOLE) on GPFS
|
|
|
1072c8 |
Bugzilla: 1944861
|
|
|
1072c8 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
1072c8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
1072c8 |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
1072c8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
1072c8 |
|
|
|
1072c8 |
A customer reported that running
|
|
|
1072c8 |
|
|
|
1072c8 |
qemu-img convert -t none -O qcow2 -f qcow2 input.qcow2 output.qcow2
|
|
|
1072c8 |
|
|
|
1072c8 |
fails for them with the following error message when the images are
|
|
|
1072c8 |
stored on a GPFS file system :
|
|
|
1072c8 |
|
|
|
1072c8 |
qemu-img: error while writing sector 0: Invalid argument
|
|
|
1072c8 |
|
|
|
1072c8 |
After analyzing the strace output, it seems like the problem is in
|
|
|
1072c8 |
handle_aiocb_write_zeroes(): The call to fallocate(FALLOC_FL_PUNCH_HOLE)
|
|
|
1072c8 |
returns EINVAL, which can apparently happen if the file system has
|
|
|
1072c8 |
a different idea of the granularity of the operation. It's arguably
|
|
|
1072c8 |
a bug in GPFS, since the PUNCH_HOLE mode should not result in EINVAL
|
|
|
1072c8 |
according to the man-page of fallocate(), but the file system is out
|
|
|
1072c8 |
there in production and so we have to deal with it. In commit 294682cc3a
|
|
|
1072c8 |
("block: workaround for unaligned byte range in fallocate()") we also
|
|
|
1072c8 |
already applied the a work-around for the same problem to the earlier
|
|
|
1072c8 |
fallocate(FALLOC_FL_ZERO_RANGE) call, so do it now similar with the
|
|
|
1072c8 |
PUNCH_HOLE call. But instead of silently catching and returning
|
|
|
1072c8 |
-ENOTSUP (which causes the caller to fall back to writing zeroes),
|
|
|
1072c8 |
let's rather inform the user once about the buggy file system and
|
|
|
1072c8 |
try the other fallback instead.
|
|
|
1072c8 |
|
|
|
1072c8 |
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
|
|
1072c8 |
Message-Id: <20210527172020.847617-2-thuth@redhat.com>
|
|
|
1072c8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
1072c8 |
(cherry picked from commit 73ebf29729d1a40feaa9f8ab8951b6ee6dbfbede)
|
|
|
1072c8 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1944861
|
|
|
1072c8 |
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
|
|
1072c8 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
1072c8 |
---
|
|
|
1072c8 |
block/file-posix.c | 11 +++++++++++
|
|
|
1072c8 |
1 file changed, 11 insertions(+)
|
|
|
1072c8 |
|
|
|
1072c8 |
diff --git a/block/file-posix.c b/block/file-posix.c
|
|
|
1072c8 |
index 62a463229f..371572f1b0 100644
|
|
|
1072c8 |
--- a/block/file-posix.c
|
|
|
1072c8 |
+++ b/block/file-posix.c
|
|
|
1072c8 |
@@ -1587,6 +1587,17 @@ static int handle_aiocb_write_zeroes(void *opaque)
|
|
|
1072c8 |
return ret;
|
|
|
1072c8 |
}
|
|
|
1072c8 |
s->has_fallocate = false;
|
|
|
1072c8 |
+ } else if (ret == -EINVAL) {
|
|
|
1072c8 |
+ /*
|
|
|
1072c8 |
+ * Some file systems like older versions of GPFS do not like un-
|
|
|
1072c8 |
+ * aligned byte ranges, and return EINVAL in such a case, though
|
|
|
1072c8 |
+ * they should not do it according to the man-page of fallocate().
|
|
|
1072c8 |
+ * Warn about the bad filesystem and try the final fallback instead.
|
|
|
1072c8 |
+ */
|
|
|
1072c8 |
+ warn_report_once("Your file system is misbehaving: "
|
|
|
1072c8 |
+ "fallocate(FALLOC_FL_PUNCH_HOLE) returned EINVAL. "
|
|
|
1072c8 |
+ "Please report this bug to your file sytem "
|
|
|
1072c8 |
+ "vendor.");
|
|
|
1072c8 |
} else if (ret != -ENOTSUP) {
|
|
|
1072c8 |
return ret;
|
|
|
1072c8 |
} else {
|
|
|
1072c8 |
--
|
|
|
1072c8 |
2.27.0
|
|
|
1072c8 |
|