Whamcloud - gitweb
LU-2779 osc: osc_extent_wait() shouldn't be interruptible
[fs/lustre-release.git] / lustre / osc / osc_cache.c
index bd7a674..d11ff0e 100644 (file)
@@ -120,7 +120,7 @@ static const char *oes_strings[] = {
                /* ----- part 2 ----- */                                      \
                __ext->oe_grants, __ext->oe_nr_pages,                         \
                list_empty_marker(&__ext->oe_pages),                          \
-               cfs_waitq_active(&__ext->oe_waitq) ? '+' : '-',               \
+               waitqueue_active(&__ext->oe_waitq) ? '+' : '-',               \
                __ext->oe_osclock, __ext->oe_mppr, __ext->oe_owner,           \
                /* ----- part 4 ----- */                                      \
                ## __VA_ARGS__);                                              \
@@ -302,7 +302,7 @@ static void osc_extent_state_set(struct osc_extent *ext, int state)
 
        /* TODO: validate the state machine */
        ext->oe_state = state;
-       cfs_waitq_broadcast(&ext->oe_waitq);
+       wake_up_all(&ext->oe_waitq);
 }
 
 static struct osc_extent *osc_extent_alloc(struct osc_object *obj)
@@ -320,7 +320,7 @@ static struct osc_extent *osc_extent_alloc(struct osc_object *obj)
        CFS_INIT_LIST_HEAD(&ext->oe_link);
        ext->oe_state = OES_INV;
        CFS_INIT_LIST_HEAD(&ext->oe_pages);
-       cfs_waitq_init(&ext->oe_waitq);
+       init_waitqueue_head(&ext->oe_waitq);
        ext->oe_osclock = NULL;
 
        return ext;
@@ -896,7 +896,7 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext,
                        "%s: wait ext to %d timedout, recovery in progress?\n",
                        osc_export(obj)->exp_obd->obd_name, state);
 
-               lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
+               lwi = LWI_INTR(NULL, NULL);
                rc = l_wait_event(ext->oe_waitq, extent_wait_cb(ext, state),
                                  &lwi);
        }
@@ -1079,7 +1079,9 @@ static int osc_extent_make_ready(const struct lu_env *env,
                last->oap_count = osc_refresh_count(env, last, OBD_BRW_WRITE);
                LASSERT(last->oap_count > 0);
                LASSERT(last->oap_page_off + last->oap_count <= PAGE_CACHE_SIZE);
+               spin_lock(&last->oap_lock);
                last->oap_async_flags |= ASYNC_COUNT_STABLE;
+               spin_unlock(&last->oap_lock);
        }
 
        /* for the rest of pages, we don't need to call osf_refresh_count()
@@ -1087,7 +1089,9 @@ static int osc_extent_make_ready(const struct lu_env *env,
        cfs_list_for_each_entry(oap, &ext->oe_pages, oap_pending_item) {
                if (!(oap->oap_async_flags & ASYNC_COUNT_STABLE)) {
                        oap->oap_count = PAGE_CACHE_SIZE - oap->oap_page_off;
+                       spin_lock(&oap->oap_lock);
                        oap->oap_async_flags |= ASYNC_COUNT_STABLE;
+                       spin_unlock(&oap->oap_lock);
                }
        }
 
@@ -1532,7 +1536,7 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli,
         * RPC size will be.
         * The exiting condition is no avail grants and no dirty pages caching,
         * that really means there is no space on the OST. */
-       cfs_waitq_init(&ocw.ocw_waitq);
+       init_waitqueue_head(&ocw.ocw_waitq);
        ocw.ocw_oap   = oap;
        ocw.ocw_grant = bytes;
        while (cli->cl_dirty > 0 || cli->cl_w_in_flight > 0) {
@@ -1551,13 +1555,24 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli,
 
                /* l_wait_event is interrupted by signal, or timed out */
                if (rc < 0) {
-                       if (rc == -ETIMEDOUT) {
+                       switch (rc) {
+                       case -ETIMEDOUT:
                                OSC_DUMP_GRANT(D_ERROR, cli,
                                                "try to reserve %d.\n", bytes);
                                osc_extent_tree_dump(D_ERROR, osc);
                                rc = -EDQUOT;
+                               break;
+                       case -EINTR:
+                               /* Ensures restartability - LU-3581 */
+                               rc = -ERESTARTSYS;
+                               break;
+                       default:
+                               CDEBUG(D_CACHE, "%s: event for cache space @"
+                                      " %p never arrived due to %d\n",
+                                      cli->cl_import->imp_obd->obd_name,
+                                      &ocw, rc);
+                               break;
                        }
-
                        cfs_list_del_init(&ocw.ocw_entry);
                        GOTO(out, rc);
                }
@@ -1607,7 +1622,7 @@ wakeup:
                CDEBUG(D_CACHE, "wake up %p for oap %p, avail grant %ld, %d\n",
                       ocw, ocw->ocw_oap, cli->cl_avail_grant, ocw->ocw_rc);
 
-               cfs_waitq_signal(&ocw->ocw_waitq);
+               wake_up(&ocw->ocw_waitq);
        }
 
        EXIT;
@@ -2262,6 +2277,8 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io,
        oap->oap_cmd = cmd;
        oap->oap_page_off = ops->ops_from;
        oap->oap_count = ops->ops_to - ops->ops_from;
+       /* No need to hold a lock here,
+        * since this page is not in any list yet. */
        oap->oap_async_flags = 0;
        oap->oap_brw_flags = brw_flags;