Whamcloud - gitweb
LU-13814 osc: cleanup osc_completion 41/52141/22
authorPatrick Farrell <pfarrell@whamcloud.com>
Mon, 28 Aug 2023 16:12:32 +0000 (12:12 -0400)
committerPatrick Farrell <pfarrell@whamcloud.com>
Tue, 26 Sep 2023 18:58:30 +0000 (14:58 -0400)
Removing oap_cmd usage in osc_completion makes it easier to
remove osc page usage for DIO.

There's also no need for the osc_ap_completion wrapper, so
remove it.

Test-Parameters: fortestonly
Test-Parameters: forjanitoronly
Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: Ie72eecded73b0444a51b0273bf8913bfaee001bd

lustre/osc/osc_cache.c

index 7c251e4..4c695c8 100644 (file)
@@ -46,9 +46,9 @@ static int extent_debug; /* set it to be true for more debug */
 static void osc_update_pending(struct osc_object *obj, int cmd, int delta);
 static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext,
                           enum osc_extent_state state);
-static void osc_ap_completion(const struct lu_env *env, struct client_obd *cli,
-                             struct osc_object *osc,
-                             struct osc_async_page *oap, int sent, int rc);
+static void osc_completion(const struct lu_env *env, struct osc_object *osc,
+                          struct osc_async_page *oap, enum cl_req_type crt,
+                          int rc);
 static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap,
                          int cmd);
 static int osc_refresh_count(const struct lu_env *env, struct osc_object *osc,
@@ -840,8 +840,14 @@ int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext,
        int blocksize = cli->cl_import->imp_obd->obd_osfs.os_bsize ? : 4096;
        loff_t last_off = 0;
        int last_count = -1;
+       enum cl_req_type crt;
        ENTRY;
 
+       if (ext->oe_rw == 0)
+               crt = CRT_WRITE;
+       else
+               crt = CRT_READ;
+
        OSC_EXTENT_DUMP(D_CACHE, ext, "extent finished.\n");
 
        ext->oe_rc = rc ?: ext->oe_nr_pages;
@@ -861,7 +867,7 @@ int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext,
                }
 
                --ext->oe_nr_pages;
-               osc_ap_completion(env, cli, osc, oap, sent, rc);
+               osc_completion(env, osc, oap, crt, rc);
        }
        EASSERT(ext->oe_nr_pages == 0, ext);
 
@@ -1295,32 +1301,35 @@ static int osc_refresh_count(const struct lu_env *env, struct osc_object *osc,
                return PAGE_SIZE;
 }
 
-static int osc_completion(const struct lu_env *env, struct osc_object *osc,
-                         struct osc_async_page *oap, int cmd, int rc)
+/* this must be called holding the loi list lock to give coverage to exit_cache,
+ * async_flag maintenance
+ */
+static void osc_completion(const struct lu_env *env, struct osc_object *osc,
+                          struct osc_async_page *oap, enum cl_req_type crt,
+                          int rc)
 {
        struct osc_page   *opg  = oap2osc_page(oap);
        struct cl_page    *page = oap2cl_page(oap);
-       enum cl_req_type   crt;
        int srvlock;
        int cptype = page->cp_type;
 
        ENTRY;
 
-       cmd &= ~OBD_BRW_NOQUOTA;
        if (cptype != CPT_TRANSIENT) {
+               /* As the transfer for this page is done, clear the flags */
+               oap->oap_async_flags = 0;
+
                LASSERTF(equi(page->cp_state == CPS_PAGEIN,
-                             cmd == OBD_BRW_READ),
-                        "cp_state:%u, cmd:%d\n", page->cp_state, cmd);
+                             crt == CRT_READ),
+                        "cp_state:%u, crt:%d\n", page->cp_state, crt);
                LASSERTF(equi(page->cp_state == CPS_PAGEOUT,
-                             cmd == OBD_BRW_WRITE),
-                       "cp_state:%u, cmd:%d\n", page->cp_state, cmd);
+                             crt == CRT_WRITE),
+                       "cp_state:%u, crt:%d\n", page->cp_state, crt);
                LASSERT(opg->ops_transfer_pinned);
                /* Clear opg->ops_transfer_pinned before VM lock is released.*/
                opg->ops_transfer_pinned = 0;
        }
 
-       crt = cmd == OBD_BRW_READ ? CRT_READ : CRT_WRITE;
-
        srvlock = oap->oap_brw_flags & OBD_BRW_SRVLOCK;
 
        /* statistic */
@@ -1349,7 +1358,8 @@ static int osc_completion(const struct lu_env *env, struct osc_object *osc,
        if (cptype != CPT_TRANSIENT)
                cl_page_put(env, page);
 
-       RETURN(0);
+       EXIT;
+       return;
 }
 
 #define OSC_DUMP_GRANT(mask, cli, fmt, args...) do {                   \
@@ -1764,26 +1774,6 @@ static int osc_list_maint(struct client_obd *cli, struct osc_object *osc)
        return is_ready;
 }
 
-/* this must be called holding the loi list lock to give coverage to exit_cache,
- * async_flag maintenance
- */
-static void osc_ap_completion(const struct lu_env *env, struct client_obd *cli,
-                             struct osc_object *osc,
-                             struct osc_async_page *oap, int sent, int rc)
-{
-       ENTRY;
-
-       /* As the transfer for this page is being done, clear the flags */
-       oap->oap_async_flags = 0;
-
-       rc = osc_completion(env, osc, oap, oap->oap_cmd, rc);
-       if (rc)
-               CERROR("completion on oap %p obj %p returns %d.\n",
-                      oap, osc, rc);
-
-       EXIT;
-}
-
 struct extent_rpc_data {
        struct list_head        *erd_rpc_list;
        unsigned int            erd_page_count;
@@ -2551,11 +2541,16 @@ int osc_queue_dio_pages(const struct lu_env *env, struct cl_io *io,
        int mppr = cli->cl_max_pages_per_rpc;
        pgoff_t start = CL_PAGE_EOF;
        bool can_merge = true;
+       enum cl_req_type crt;
        int page_count = 0;
        pgoff_t end = 0;
-
        ENTRY;
 
+       if (brw_flags & OBD_BRW_READ)
+               crt = CRT_READ;
+       else
+               crt = CRT_WRITE;
+
        list_for_each_entry(oap, list, oap_pending_item) {
                struct osc_page *opg = oap2osc_page(oap);
                pgoff_t index = osc_index(opg);
@@ -2577,7 +2572,7 @@ int osc_queue_dio_pages(const struct lu_env *env, struct cl_io *io,
 
                list_for_each_entry_safe(oap, tmp, list, oap_pending_item) {
                        list_del_init(&oap->oap_pending_item);
-                       osc_ap_completion(env, cli, obj, oap, 0, -ENOMEM);
+                       osc_completion(env, obj, oap, crt, -ENOMEM);
                }
                RETURN(-ENOMEM);
        }
@@ -2666,8 +2661,14 @@ int osc_queue_sync_pages(const struct lu_env *env, struct cl_io *io,
        pgoff_t start      = CL_PAGE_EOF;
        pgoff_t end        = 0;
        struct osc_lock *oscl;
+       enum cl_req_type crt;
        ENTRY;
 
+       if (brw_flags & OBD_BRW_READ)
+               crt = CRT_READ;
+       else
+               crt = CRT_WRITE;
+
        list_for_each_entry(oap, list, oap_pending_item) {
                struct osc_page *opg = oap2osc_page(oap);
                pgoff_t index = osc_index(opg);
@@ -2689,7 +2690,7 @@ int osc_queue_sync_pages(const struct lu_env *env, struct cl_io *io,
 
                list_for_each_entry_safe(oap, tmp, list, oap_pending_item) {
                        list_del_init(&oap->oap_pending_item);
-                       osc_ap_completion(env, cli, obj, oap, 0, -ENOMEM);
+                       osc_completion(env, obj, oap, crt, -ENOMEM);
                }
                RETURN(-ENOMEM);
        }