Run the fstrim command twice

resolves: RHEL-88508
This commit is contained in:
Richard W.M. Jones 2025-04-25 15:35:33 +01:00
parent f0aae59556
commit f021d89f94
3 changed files with 74 additions and 1 deletions

View File

@ -0,0 +1,38 @@
From 14b2ac2d5f087b0d8fc8c1e0451cae22af753734 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 25 Apr 2025 15:14:24 +0100
Subject: [PATCH] RHEL 9: daemon/fstrim.c: Run the fstrim command twice
Workaround for https://issues.redhat.com/browse/RHEL-88450
Fixes: https://issues.redhat.com/browse/RHEL-88508
Related: https://issues.redhat.com/browse/RHEL-88450
Thanks: Eric Sandeen
---
daemon/fstrim.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/daemon/fstrim.c b/daemon/fstrim.c
index f6869042..06707a7f 100644
--- a/daemon/fstrim.c
+++ b/daemon/fstrim.c
@@ -101,8 +101,19 @@ do_fstrim (const char *path,
ADD_ARG (argv, i, buf);
ADD_ARG (argv, i, NULL);
+ /* Run the command twice to workaround
+ * https://issues.redhat.com/browse/RHEL-88450
+ */
+ r = commandv (&out, &err, argv);
+ if (r == -1) goto error;
+ if (verbose)
+ fprintf (stderr, "%s\n", out);
+ free (out); out = NULL;
+ free (err); err = NULL;
+
r = commandv (&out, &err, argv);
if (r == -1) {
+ error:
/* If the error is about the kernel operation not being supported
* for this filesystem type, then return errno ENOTSUP here.
*/

View File

@ -0,0 +1,29 @@
From e9a7378d730477d6a548c18244ba0bde9c7dc93d Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 25 Apr 2025 15:24:43 +0100
Subject: [PATCH] daemon/fstrim.c: Issue sync_disks after fstrim
Thanks: Eric Sandeen
(cherry picked from commit e127edcafc95c75bf484bf2199eb746a392c58c0)
---
daemon/fstrim.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/daemon/fstrim.c b/daemon/fstrim.c
index 06707a7f..474ef72d 100644
--- a/daemon/fstrim.c
+++ b/daemon/fstrim.c
@@ -127,5 +127,13 @@ do_fstrim (const char *path,
if (verbose)
fprintf (stderr, "%s\n", out);
+ /* Sync the disks again. In practice we always call fstrim
+ * expecting that afterwards the results are visible in the qemu
+ * devices backing the guest. Depending on the Linux filesystem,
+ * fstrim may issue asynch discard requests, so it's not necessarily
+ * true that everything has been written out before this point.
+ */
+ sync_disks ();
+
return 0;
}

View File

@ -37,7 +37,7 @@ Summary: Access and modify virtual machine disk images
Name: libguestfs Name: libguestfs
Epoch: 1 Epoch: 1
Version: 1.54.0 Version: 1.54.0
Release: 6%{?dist} Release: 7%{?dist}
License: LGPL-2.1-or-later License: LGPL-2.1-or-later
# Build only for architectures that have a kernel # Build only for architectures that have a kernel
@ -102,6 +102,8 @@ Patch0024: 0024-generator-Fix-implementation-of-FUUID-for-OCaml-func.patch
Patch0025: 0025-Update-common-submodule.patch Patch0025: 0025-Update-common-submodule.patch
Patch0026: 0026-daemon-Rewrite-pvs-vgs-lvs-full-APIs-in-OCaml.patch Patch0026: 0026-daemon-Rewrite-pvs-vgs-lvs-full-APIs-in-OCaml.patch
Patch0027: 0027-daemon-inspect-Resolve-Ubuntu-22-dev-disk-by-id-dm-u.patch Patch0027: 0027-daemon-inspect-Resolve-Ubuntu-22-dev-disk-by-id-dm-u.patch
Patch0028: 0028-RHEL-9-daemon-fstrim.c-Run-the-fstrim-command-twice.patch
Patch0029: 0029-daemon-fstrim.c-Issue-sync_disks-after-fstrim.patch
BuildRequires: autoconf, automake, libtool, gettext-devel BuildRequires: autoconf, automake, libtool, gettext-devel
@ -1111,6 +1113,10 @@ rm ocaml/html/.gitignore
%changelog %changelog
* Fri Apr 25 2025 Richard W.M. Jones <rjones@redhat.com> - 1:1.54.0-7
- Run the fstrim command twice
resolves: RHEL-88508
* Wed Apr 16 2025 Richard W.M. Jones <rjones@redhat.com> - 1:1.54.0-6 * Wed Apr 16 2025 Richard W.M. Jones <rjones@redhat.com> - 1:1.54.0-6
- Fix virt-v2v conversion of split /usr Ubuntu 22+ - Fix virt-v2v conversion of split /usr Ubuntu 22+
resolves: RHEL-87493 resolves: RHEL-87493