directio: Reset 'running' parameter
authorHannes Reinecke <hare@suse.de>
Fri, 18 Jun 2010 10:34:43 +0000 (12:34 +0200)
committerHannes Reinecke <hare@suse.de>
Tue, 3 May 2011 08:17:14 +0000 (10:17 +0200)
Upon failure the 'running' parameter is not updated correctly,
which might cause the directio checker to always report failure.

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

index b517039..46fe6a7 100644 (file)
@@ -12,7 +12,7 @@
 #include <sys/ioctl.h>
 #include <linux/fs.h>
 #include <errno.h>
-#include <asm/unistd.h>
+#include <unistd.h>
 #include <libaio.h>
 
 #include "checkers.h"
@@ -153,10 +153,22 @@ check_state(int fd, struct directio_context *ct, int sync, int timeout_secs)
        if (r < 0 ) {
                LOG(3, "async io getevents returned %li (errno=%s)", r,
                    strerror(errno));
+               ct->running = 0;
                rc = PATH_UNCHECKED;
        } else if (r < 1L) {
                if (ct->running > timeout_secs || sync) {
+                       struct iocb *ios[1] = { &ct->io };
+
                        LOG(3, "abort check on timeout");
+                       r = io_cancel(ct->ioctx, ios[0], &event);
+                       /*
+                        * Only reset ct->running if we really
+                        * could abort the pending I/O
+                        */
+                       if (r)
+                               LOG(3, "io_cancel error %i", errno);
+                       else
+                               ct->running = 0;
                        rc = PATH_DOWN;
                } else {
                        LOG(3, "async io pending");