Whamcloud - gitweb
LU-10467 obdclass: convert waiting in cl_sync_io_wait().
[fs/lustre-release.git] / lustre / obdclass / cl_io.c
index 910d474..824aa6e 100644 (file)
@@ -1143,25 +1143,25 @@ EXPORT_SYMBOL(cl_sync_io_init_notify);
 int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor,
                    long timeout)
 {
-       struct l_wait_info lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(timeout),
-                                                 NULL, NULL, NULL);
-       int rc;
+       int rc = 0;
        ENTRY;
 
        LASSERT(timeout >= 0);
 
-       rc = l_wait_event(anchor->csi_waitq,
-                         atomic_read(&anchor->csi_sync_nr) == 0,
-                         &lwi);
-       if (rc < 0) {
+       if (timeout > 0 &&
+           wait_event_idle_timeout(anchor->csi_waitq,
+                                   atomic_read(&anchor->csi_sync_nr) == 0,
+                                   cfs_time_seconds(timeout)) == 0) {
+               rc = -ETIMEDOUT;
                CERROR("IO failed: %d, still wait for %d remaining entries\n",
                       rc, atomic_read(&anchor->csi_sync_nr));
+       }
 
-               wait_event_idle(anchor->csi_waitq,
-                               atomic_read(&anchor->csi_sync_nr) == 0);
-       } else {
+       wait_event_idle(anchor->csi_waitq,
+                       atomic_read(&anchor->csi_sync_nr) == 0);
+       if (!rc)
                rc = anchor->csi_sync_rc;
-       }
+
        /* We take the lock to ensure that cl_sync_io_note() has finished */
        spin_lock(&anchor->csi_waitq.lock);
        LASSERT(atomic_read(&anchor->csi_sync_nr) == 0);