Use timeout parameter for directio
authorHannes Reinecke <hare@suse.de>
Tue, 3 May 2011 07:07:52 +0000 (09:07 +0200)
committerHannes Reinecke <hare@suse.de>
Tue, 3 May 2011 08:16:11 +0000 (10:16 +0200)
As checkers now have a timeout we should be using this one for
directio, too.

Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath/checkers/directio.c

index 6696b41..b517039 100644 (file)
@@ -117,7 +117,7 @@ void libcheck_free (struct checker * c)
 }
 
 static int
-check_state(int fd, struct directio_context *ct, int sync)
+check_state(int fd, struct directio_context *ct, int sync, int timeout_secs)
 {
        struct timespec timeout = { .tv_nsec = 5 };
        struct io_event event;
@@ -128,9 +128,9 @@ check_state(int fd, struct directio_context *ct, int sync)
        if (fstat(fd, &sb) == 0) {
                LOG(4, "called for %x", (unsigned) sb.st_rdev);
        }
-       if (sync) {
+       if (sync > 0) {
                LOG(4, "called in synchronous mode");
-               timeout.tv_sec  = ASYNC_TIMEOUT_SEC;
+               timeout.tv_sec  = timeout_secs;
                timeout.tv_nsec = 0;
        }
 
@@ -155,7 +155,7 @@ check_state(int fd, struct directio_context *ct, int sync)
                    strerror(errno));
                rc = PATH_UNCHECKED;
        } else if (r < 1L) {
-               if (ct->running > ASYNC_TIMEOUT_SEC || sync) {
+               if (ct->running > timeout_secs || sync) {
                        LOG(3, "abort check on timeout");
                        rc = PATH_DOWN;
                } else {
@@ -179,7 +179,7 @@ int libcheck_check (struct checker * c)
        if (!ct)
                return PATH_UNCHECKED;
 
-       ret = check_state(c->fd, ct, c->sync);
+       ret = check_state(c->fd, ct, c->sync, c->timeout);
 
        switch (ret)
        {