diff --git a/0028-RHEL-9-daemon-fstrim.c-Run-the-fstrim-command-twice.patch b/0028-RHEL-9-daemon-fstrim.c-Run-the-fstrim-command-twice.patch new file mode 100644 index 0000000..344f6c2 --- /dev/null +++ b/0028-RHEL-9-daemon-fstrim.c-Run-the-fstrim-command-twice.patch @@ -0,0 +1,38 @@ +From 14b2ac2d5f087b0d8fc8c1e0451cae22af753734 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +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. + */ diff --git a/0029-daemon-fstrim.c-Issue-sync_disks-after-fstrim.patch b/0029-daemon-fstrim.c-Issue-sync_disks-after-fstrim.patch new file mode 100644 index 0000000..1ca580e --- /dev/null +++ b/0029-daemon-fstrim.c-Issue-sync_disks-after-fstrim.patch @@ -0,0 +1,29 @@ +From e9a7378d730477d6a548c18244ba0bde9c7dc93d Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +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; + } diff --git a/libguestfs.spec b/libguestfs.spec index c739b6f..dba1d2d 100644 --- a/libguestfs.spec +++ b/libguestfs.spec @@ -37,7 +37,7 @@ Summary: Access and modify virtual machine disk images Name: libguestfs Epoch: 1 Version: 1.54.0 -Release: 6%{?dist} +Release: 7%{?dist} License: LGPL-2.1-or-later # 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 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 +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 @@ -1111,6 +1113,10 @@ rm ocaml/html/.gitignore %changelog +* Fri Apr 25 2025 Richard W.M. Jones - 1:1.54.0-7 +- Run the fstrim command twice + resolves: RHEL-88508 + * Wed Apr 16 2025 Richard W.M. Jones - 1:1.54.0-6 - Fix virt-v2v conversion of split /usr Ubuntu 22+ resolves: RHEL-87493