[PATCH] storage: Add timeout for iscsi volume's stable path discovery

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It might need some time till the LUN's stable path shows up on
initiator host, and although the time window is not foreseeable,
as a better than nothing fix, this patch adds timeout for the
stable path discovery process.
---
 src/storage/storage_backend.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 1d32232..e159bd2 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -1347,6 +1347,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
     struct dirent *dent;
     char *stablepath;
     int opentries = 0;
+    int retry = 0;
 
     /* Short circuit if pool has no target, or if its /dev */
     if (pool->def->target.path == NULL ||
@@ -1355,7 +1356,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
         goto ret_strdup;
 
     /* Skip whole thing for a pool which isn't in /dev
-     * so we don't mess will filesystem/dir based pools
+     * so we don't mess filesystem/dir based pools
      */
     if (!STRPREFIX(pool->def->target.path, "/dev"))
         goto ret_strdup;
@@ -1384,8 +1385,12 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
     /* The pool is pointing somewhere like /dev/disk/by-path
      * or /dev/disk/by-id, so we need to check all symlinks in
      * the target directory and figure out which one points
-     * to this device node
+     * to this device node.
+     *
+     * And it might need some time till the stabe path shows
+     * up, so add timeout to retry here.
      */
+ retry:
     while ((dent = readdir(dh)) != NULL) {
         if (dent->d_name[0] == '.')
             continue;
@@ -1406,6 +1411,11 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
         VIR_FREE(stablepath);
     }
 
+    if (++retry < 100) {
+        usleep(100 * 1000);
+        goto retry;
+    }
+
     closedir(dh);
 
  ret_strdup:
-- 
1.7.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]