[libvirt] [PATCH] storage: Attempt to refresh volume after successful wipe volume

John Ferlan jferlan at redhat.com
Wed Dec 2 20:22:38 UTC 2015


https://bugzilla.redhat.com/show_bug.cgi?id=1270709

When a volume wipe is successful, a volume refresh should be done afterwards
to update any volume data that may be used in future volume commands, such as
volume resize.  For a raw file volume, a wipe would truncate the file and
a followup volume resize the capacity may fail because the volume target
allocation isn't updated to reflect the wipe activity.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/storage/storage_driver.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index bbf21f6..2e59e39 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -2436,7 +2436,19 @@ storageVolWipePattern(virStorageVolPtr obj,
         goto cleanup;
     }
 
-    ret = backend->wipeVol(obj->conn, pool, vol, algorithm, flags);
+    if ((ret = backend->wipeVol(obj->conn, pool, vol, algorithm, flags)) < 0)
+        goto cleanup;
+
+    /* Best effort to refresh the volume data. If unsuccessful, we've already
+     * wiped the data so there's no going back on that. Best we can do is
+     * provide some details over what happened and move on
+     */
+    if (backend->refreshVol &&
+        backend->refreshVol(obj->conn, pool, vol) < 0) {
+        VIR_WARN("failed to refresh volume '%s' info after volume wipe",
+                 vol->name);
+        virResetLastError();
+    }
 
  cleanup:
     virStoragePoolObjUnlock(pool);
-- 
2.5.0




More information about the libvir-list mailing list