mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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 ca87485eea)
This commit is contained in:
@@ -101,8 +101,19 @@ do_fstrim (const char *path,
|
|||||||
ADD_ARG (argv, i, buf);
|
ADD_ARG (argv, i, buf);
|
||||||
ADD_ARG (argv, i, NULL);
|
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);
|
r = commandv (&out, &err, argv);
|
||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
|
error:
|
||||||
/* If the error is about the kernel operation not being supported
|
/* If the error is about the kernel operation not being supported
|
||||||
* for this filesystem type, then return errno ENOTSUP here.
|
* for this filesystem type, then return errno ENOTSUP here.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user