From 27194a339768ec34de52f4e00d3fca36f7e65058 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 5 Aug 2016 12:20:00 +0100
Subject: [PATCH] sparsify: Warn instead of error if a filesystem cannot be
fstrimmed (RHBZ#1364347).
Thanks: Xianghua Chen
(cherry picked from commit 4d5335a56d709fdd4357ab9ae04ba0a758b12fe9)
---
sparsify/in_place.ml | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/sparsify/in_place.ml b/sparsify/in_place.ml
index 5cd03ef..e2ee9d9 100644
--- a/sparsify/in_place.ml
+++ b/sparsify/in_place.ml
@@ -89,7 +89,14 @@ let run disk format ignores machine_readable zeroes =
if mounted then (
message (f_"Trimming %s") fs;
- g#fstrim "/"
+ try g#fstrim "/"
+ with G.Error msg as exn ->
+ if g#last_errno () = G.Errno.errno_ENOTSUP then (
+ let vfs_type = try g#vfs_type fs with _ -> "unknown" in
+ warning (f_"fstrim operation is not supported on %s (%s). Suppress this warning using '--ignore %s', or use copying mode instead.")
+ fs vfs_type fs
+ )
+ else raise exn
) else (
let is_linux_x86_swap =
(* Look for the signature for Linux swap on i386.
--
1.8.3.1