Blob Blame History Raw
From 2e9687c784cd19f6ac1c426d7578de65e55025c9 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 12 Aug 2016 10:34:54 +0100
Subject: [PATCH] v2v: Add -o discard option when fstrimming.

This *may* be required by some filesystems in order for fstrim to
work.  I'm not actually sure if this is true, but it's what
virt-sparsify --in-place does, and that utility has been tested a lot
more in regards to trimming.

(cherry picked from commit dd22e376c4ec8fd7c78c78f94c60bb763ddcf08f)
---
 v2v/v2v.ml | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 21f8d77..561317c 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -421,7 +421,10 @@ and do_fstrim g no_trim inspect =
   List.iter (
     fun dev ->
       g#umount_all ();
-      let mounted = try g#mount dev "/"; true with G.Error _ -> false in
+      let mounted =
+        try g#mount_options "discard" dev "/"; true
+        with G.Error _ -> false in
+
       if mounted then (
         try g#fstrim "/"
         with G.Error msg ->
-- 
1.8.3.1