diff --git a/SOURCES/0049-daemon-fstrim.c-Issue-sync_disks-after-fstrim.patch b/SOURCES/0049-daemon-fstrim.c-Issue-sync_disks-after-fstrim.patch new file mode 100644 index 0000000..474410c --- /dev/null +++ b/SOURCES/0049-daemon-fstrim.c-Issue-sync_disks-after-fstrim.patch @@ -0,0 +1,29 @@ +From 0349d30afcf1d345c1b4f9090447a561c944c8e5 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 f6869042..3928f8bb 100644 +--- a/daemon/fstrim.c ++++ b/daemon/fstrim.c +@@ -116,5 +116,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/SOURCES/0050-daemon-fstrim.c-Run-the-fstrim-command-twice.patch b/SOURCES/0050-daemon-fstrim.c-Run-the-fstrim-command-twice.patch new file mode 100644 index 0000000..c3013ca --- /dev/null +++ b/SOURCES/0050-daemon-fstrim.c-Run-the-fstrim-command-twice.patch @@ -0,0 +1,40 @@ +From 4c7c0bca7a433ad03cdbc9128f53a1904758f8fb Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Fri, 25 Apr 2025 15:14:24 +0100 +Subject: [PATCH] daemon/fstrim.c: Run the fstrim command twice + +In upstream kernels, for XFS, you may have to run fstrim twice for it +to be effective. + +Fixes: https://issues.redhat.com/browse/RHEL-88508 +Related: https://issues.redhat.com/browse/RHEL-88450 +Thanks: Eric Sandeen +(cherry picked from commit ca87485eea79d2c8943458f8f4ff12e72ce2eb0b) +--- + daemon/fstrim.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/daemon/fstrim.c b/daemon/fstrim.c +index 3928f8bb..474ef72d 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/SPECS/libguestfs.spec b/SPECS/libguestfs.spec index 831e242..53ce5c7 100644 --- a/SPECS/libguestfs.spec +++ b/SPECS/libguestfs.spec @@ -45,7 +45,7 @@ Summary: Access and modify virtual machine disk images Name: libguestfs Epoch: 1 Version: 1.50.2 -Release: 3%{?dist}.alma.1 +Release: 4%{?dist}.alma.1 License: LGPLv2+ # Build only for architectures that have a kernel @@ -139,6 +139,8 @@ Patch0045: 0045-generator-Fix-implementation-of-FUUID-for-OCaml-func.patch Patch0046: 0046-Update-common-submodule.patch Patch0047: 0047-daemon-Rewrite-pvs-vgs-lvs-full-APIs-in-OCaml.patch Patch0048: 0048-daemon-inspect-Resolve-Ubuntu-22-dev-disk-by-id-dm-u.patch +Patch0049: 0049-daemon-fstrim.c-Issue-sync_disks-after-fstrim.patch +Patch0050: 0050-daemon-fstrim.c-Run-the-fstrim-command-twice.patch %if 0%{patches_touch_autotools} BuildRequires: autoconf, automake, libtool, gettext-devel @@ -1148,10 +1150,14 @@ rm ocaml/html/.gitignore %changelog -* Mon May 05 2025 Eduard Abdullin - 1:1.50.2-3.alma.1 +* Tue May 06 2025 Eduard Abdullin - 1:1.50.2-4.alma.1 - Fix build for AlmaLinux - Avoid permission denied for yum/dnf cache +* Wed Apr 30 2025 Richard W.M. Jones - 1:1.50.2-4 +- Run the fstrim command twice to workaround RHEL 9.5 kernel trimming bug + resolves: RHEL-89045 + * Tue Apr 29 2025 Richard W.M. Jones - 1:1.50.2-3 - Fix virt-v2v conversion of split /usr Ubuntu 22+ resolves: RHEL-88803