Whamcloud - gitweb
LU-9679 modules: Use LIST_HEAD for declaring list_heads
[fs/lustre-release.git] / lustre / osc / osc_cache.c
index 041abf5..891d560 100644 (file)
@@ -220,6 +220,7 @@ static int osc_extent_sanity_check0(struct osc_extent *ext,
                        GOTO(out, rc = 60);
                if (ext->oe_fsync_wait && !ext->oe_urgent && !ext->oe_hp)
                        GOTO(out, rc = 65);
+               /* fallthrough */
        default:
                if (atomic_read(&ext->oe_users) > 0)
                        GOTO(out, rc = 70);
@@ -960,9 +961,8 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext,
                        "%s: wait ext to %u timedout, recovery in progress?\n",
                        cli_name(osc_cli(obj)), state);
 
-               lwi = LWI_INTR(NULL, NULL);
-               rc = l_wait_event(ext->oe_waitq, extent_wait_cb(ext, state),
-                                 &lwi);
+               wait_event_idle(ext->oe_waitq, extent_wait_cb(ext, state));
+               rc = 0;
        }
        if (rc == 0 && ext->oe_rc < 0)
                rc = ext->oe_rc;
@@ -2085,7 +2085,7 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli,
                   struct osc_object *osc)
 __must_hold(osc)
 {
-       struct list_head   rpclist = LIST_HEAD_INIT(rpclist);
+       LIST_HEAD(rpclist);
        struct osc_extent *ext;
        struct osc_extent *tmp;
        struct osc_extent *first = NULL;
@@ -2161,7 +2161,7 @@ __must_hold(osc)
 {
        struct osc_extent *ext;
        struct osc_extent *next;
-       struct list_head rpclist = LIST_HEAD_INIT(rpclist);
+       LIST_HEAD(rpclist);
        struct extent_rpc_data data = {
                .erd_rpc_list   = &rpclist,
                .erd_page_count = 0,
@@ -2355,13 +2355,14 @@ int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops,
 EXPORT_SYMBOL(osc_prep_async_page);
 
 int osc_queue_async_io(const struct lu_env *env, struct cl_io *io,
-                      struct osc_page *ops)
+                      struct osc_page *ops, cl_commit_cbt cb)
 {
        struct osc_io *oio = osc_env_io(env);
        struct osc_extent     *ext = NULL;
        struct osc_async_page *oap = &ops->ops_oap;
        struct client_obd     *cli = oap->oap_cli;
        struct osc_object     *osc = oap->oap_obj;
+       struct pagevec        *pvec = &osc_env_info(env)->oti_pagevec;
        pgoff_t index;
        unsigned int tmp;
        unsigned int grants = 0;
@@ -2480,7 +2481,14 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io,
 
                rc = 0;
                if (grants == 0) {
-                       /* we haven't allocated grant for this page. */
+                       /* We haven't allocated grant for this page, and we
+                        * must not hold a page lock while we do enter_cache,
+                        * so we must mark dirty & unlock any pages in the
+                        * write commit pagevec. */
+                       if (pagevec_count(pvec)) {
+                               cb(env, io, pvec);
+                               pagevec_reinit(pvec);
+                       }
                        rc = osc_enter_cache(env, cli, oap, tmp);
                        if (rc == 0)
                                grants = tmp;
@@ -2786,7 +2794,7 @@ int osc_cache_truncate_start(const struct lu_env *env, struct osc_object *obj,
        struct osc_extent *ext;
        struct osc_extent *waiting = NULL;
        pgoff_t index;
-       struct list_head list = LIST_HEAD_INIT(list);
+       LIST_HEAD(list);
        int result = 0;
        bool partial;
        ENTRY;
@@ -3004,7 +3012,7 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj,
                              pgoff_t start, pgoff_t end, int hp, int discard)
 {
        struct osc_extent *ext;
-       struct list_head discard_list = LIST_HEAD_INIT(discard_list);
+       LIST_HEAD(discard_list);
        bool unplug = false;
        int result = 0;
        ENTRY;
@@ -3037,17 +3045,25 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj,
                                        list_move_tail(&ext->oe_link, list);
                                unplug = true;
                        } else {
+                               struct client_obd *cli = osc_cli(obj);
+                               int pcc_bits = cli->cl_chunkbits - PAGE_SHIFT;
+                               pgoff_t align_by = (1 << pcc_bits);
+                               pgoff_t a_start = round_down(start, align_by);
+                               pgoff_t a_end = round_up(end, align_by);
+
+                               /* overflow case */
+                               if (end && !a_end)
+                                       a_end = CL_PAGE_EOF;
                                /* the only discarder is lock cancelling, so
-                                * [start, end] must contain this extent.
-                                * However, with DOM, osc extent alignment may
-                                * cause the first extent to start before the
-                                * OST portion of the layout.  This is never
-                                * accessed for i/o, but the unused portion
-                                * will not be covered by the sync request,
-                                * so we cannot assert in that case. */
-                               EASSERT(ergo(!(ext == first_extent(obj)),
-                                       ext->oe_start >= start &&
-                                       ext->oe_end <= end), ext);
+                                * [start, end], aligned by chunk size, must
+                                * contain this extent */
+                               LASSERTF(ext->oe_start >= a_start &&
+                                        ext->oe_end <= a_end,
+                                        "ext [%lu, %lu] reg [%lu, %lu] "
+                                        "orig [%lu %lu] align %lu bits "
+                                        "%d\n", ext->oe_start, ext->oe_end,
+                                        a_start, a_end, start, end,
+                                        align_by, pcc_bits);
                                osc_extent_state_set(ext, OES_LOCKING);
                                ext->oe_owner = current;
                                list_move_tail(&ext->oe_link,