Whamcloud - gitweb
LU-13814 osc: Remove most uses of oap_obj 72/52072/20
authorPatrick Farrell <pfarrell@whamcloud.com>
Fri, 23 Feb 2024 15:58:47 +0000 (10:58 -0500)
committerOleg Drokin <green@whamcloud.com>
Sat, 23 Mar 2024 05:48:25 +0000 (05:48 +0000)
Removing most uses of oap_obj makes it easier to do the
upcoming transient page cl_page removal.

Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: Ic8acaed2ce3c6831f9a0d2bd13d859b9c564efdd
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52072
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/include/lustre_osc.h
lustre/osc/osc_cache.c
lustre/osc/osc_io.c
lustre/osc/osc_page.c
lustre/osc/osc_request.c

index 3c21896..b2da558 100644 (file)
@@ -578,9 +578,11 @@ int osc_set_async_flags(struct osc_object *obj, struct osc_page *opg,
 int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops,
                        struct cl_page *page, loff_t offset);
 int osc_queue_async_io(const struct lu_env *env, struct cl_io *io,
-                      struct osc_page *ops, cl_commit_cbt cb);
-int osc_page_cache_add(const struct lu_env *env, struct osc_page *opg,
-                      struct cl_io *io, cl_commit_cbt cb);
+                      struct osc_object *osc, struct osc_page *ops,
+                      cl_commit_cbt cb);
+int osc_page_cache_add(const struct lu_env *env, struct osc_object *osc,
+                      struct osc_page *opg, struct cl_io *io,
+                      cl_commit_cbt cb);
 int osc_teardown_async_page(const struct lu_env *env, struct osc_object *obj,
                            struct osc_page *ops);
 int osc_flush_async_page(const struct lu_env *env, struct cl_io *io,
index 8a1dfd8..0f54582 100644 (file)
@@ -47,10 +47,11 @@ 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 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,
+static int osc_refresh_count(const struct lu_env *env, struct osc_object *osc,
                             struct osc_async_page *oap, int cmd);
 static int osc_io_unplug_async(const struct lu_env *env,
                               struct client_obd *cli, struct osc_object *osc);
@@ -831,6 +832,7 @@ int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext,
                      int sent, int rc)
 {
        struct client_obd *cli = osc_cli(ext->oe_obj);
+       struct osc_object *osc = ext->oe_obj;
        struct osc_async_page *oap;
        struct osc_async_page *tmp;
        int nr_pages = ext->oe_nr_pages;
@@ -859,7 +861,7 @@ int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext,
                }
 
                --ext->oe_nr_pages;
-               osc_ap_completion(env, cli, oap, sent, rc);
+               osc_ap_completion(env, cli, osc, oap, sent, rc);
        }
        EASSERT(ext->oe_nr_pages == 0, ext);
 
@@ -1113,7 +1115,8 @@ static int osc_extent_make_ready(const struct lu_env *env,
        /* the last page is the only one we need to refresh its count by
         * the size of file. */
        if (!(last->oap_async_flags & ASYNC_COUNT_STABLE)) {
-               int last_oap_count = osc_refresh_count(env, last, OBD_BRW_WRITE);
+               int last_oap_count = osc_refresh_count(env, obj, last,
+                                                      OBD_BRW_WRITE);
                LASSERTF(last_oap_count > 0,
                         "last_oap_count %d\n", last_oap_count);
                LASSERT(last->oap_page_off + last_oap_count <= PAGE_SIZE);
@@ -1262,12 +1265,12 @@ static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap,
        RETURN(result);
 }
 
-static int osc_refresh_count(const struct lu_env *env,
+static int osc_refresh_count(const struct lu_env *env, struct osc_object *osc,
                             struct osc_async_page *oap, int cmd)
 {
        struct osc_page  *opg = oap2osc_page(oap);
        pgoff_t index = osc_index(oap2osc(oap));
-       struct cl_object *obj = osc2cl(osc_page_object(opg));
+       struct cl_object *obj = osc2cl(osc);
        struct cl_attr   *attr = &osc_env_info(env)->oti_attr;
        int result;
        loff_t kms;
@@ -1292,8 +1295,8 @@ static int osc_refresh_count(const struct lu_env *env,
                return PAGE_SIZE;
 }
 
-static int osc_completion(const struct lu_env *env, struct osc_async_page *oap,
-                         int cmd, int rc)
+static int osc_completion(const struct lu_env *env, struct osc_object *osc,
+                         struct osc_async_page *oap, int cmd, int rc)
 {
        struct osc_page   *opg  = oap2osc_page(oap);
        struct cl_page    *page = oap2cl_page(oap);
@@ -1317,7 +1320,7 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap,
 
        /* statistic */
        if (rc == 0 && srvlock) {
-               struct lu_device *ld = osc_page_object(opg)->oo_cl.co_lu.lo_dev;
+               struct lu_device *ld = osc->oo_cl.co_lu.lo_dev;
                struct osc_stats *stats = &lu2osc_dev(ld)->osc_stats;
                size_t bytes = oap->oap_count;
 
@@ -1550,9 +1553,9 @@ static inline void cli_lock_after_unplug(struct client_obd *cli)
  * The process will be put into sleep if it's already run out of grant.
  */
 static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli,
-                          struct osc_async_page *oap, int bytes)
+                          struct osc_object *osc, struct osc_async_page *oap,
+                          int bytes)
 {
-       struct osc_object *osc = oap->oap_obj;
        struct lov_oinfo *loi = osc->oo_oinfo;
        int rc = -EDQUOT;
        int remain;
@@ -1759,16 +1762,15 @@ static int osc_list_maint(struct client_obd *cli, struct osc_object *osc)
  * 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)
 {
-       struct osc_object *osc = oap->oap_obj;
-
        ENTRY;
 
        /* As the transfer for this page is being done, clear the flags */
        oap->oap_async_flags = 0;
 
-       rc = osc_completion(env, oap, oap->oap_cmd, rc);
+       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);
@@ -2233,12 +2235,12 @@ 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, cl_commit_cbt cb)
+                      struct osc_object *osc, 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 osc_object     *osc = oap->oap_obj;
        struct client_obd     *cli = osc_cli(osc);
        struct pagevec        *pvec = &osc_env_info(env)->oti_pagevec;
        pgoff_t index;
@@ -2375,7 +2377,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io,
                }
 
                if (grants == 0) {
-                       rc = osc_enter_cache(env, cli, oap, tmp);
+                       rc = osc_enter_cache(env, cli, osc, oap, tmp);
                        if (rc == 0)
                                grants = tmp;
                }
@@ -2569,7 +2571,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, oap, 0, -ENOMEM);
+                       osc_ap_completion(env, cli, obj, oap, 0, -ENOMEM);
                }
                RETURN(-ENOMEM);
        }
index 7021e41..2ce268f 100644 (file)
@@ -174,7 +174,6 @@ int osc_io_submit(const struct lu_env *env, const struct cl_io_slice *ios,
 
                opg = osc_cl_page_osc(page, osc);
                oap = &opg->ops_oap;
-               LASSERT(osc == oap->oap_obj);
 
                if (!list_empty(&oap->oap_pending_item) ||
                    !list_empty(&oap->oap_rpc_item)) {
@@ -336,9 +335,6 @@ int osc_io_commit_async(const struct lu_env *env,
                opg = osc_cl_page_osc(page, osc);
                oap = &opg->ops_oap;
 
-               LASSERTF(osc == oap->oap_obj,
-                        "obj mismatch: %px / %px\n", osc, oap->oap_obj);
-
                if (!list_empty(&oap->oap_rpc_item)) {
                        CDEBUG(D_CACHE, "Busy oap %p page %p for submit.\n",
                               oap, opg);
@@ -348,7 +344,7 @@ int osc_io_commit_async(const struct lu_env *env,
 
                /* The page may be already in dirty cache. */
                if (list_empty(&oap->oap_pending_item)) {
-                       result = osc_page_cache_add(env, opg, io, cb);
+                       result = osc_page_cache_add(env, osc, opg, io, cb);
                        if (result != 0)
                                break;
                }
index ec89059..0bb3bf3 100644 (file)
@@ -86,14 +86,15 @@ static void osc_page_transfer_add(const struct lu_env *env,
        osc_lru_use(osc_cli(obj), opg);
 }
 
-int osc_page_cache_add(const struct lu_env *env, struct osc_page *opg,
-                      struct cl_io *io, cl_commit_cbt cb)
+int osc_page_cache_add(const struct lu_env *env, struct osc_object *osc,
+                      struct osc_page *opg, struct cl_io *io,
+                      cl_commit_cbt cb)
 {
        int result;
        ENTRY;
 
        osc_page_transfer_get(opg, "transfer\0cache");
-       result = osc_queue_async_io(env, io, opg, cb);
+       result = osc_queue_async_io(env, io, osc, opg, cb);
        if (result != 0)
                osc_page_transfer_put(env, opg);
        else
index b075297..b48e3bd 100644 (file)
@@ -2538,6 +2538,8 @@ static int brw_interpret(const struct lu_env *env,
 
        ENTRY;
 
+       ext = list_first_entry(&aa->aa_exts, struct osc_extent, oe_link);
+
        rc = osc_brw_fini_request(req, rc);
        CDEBUG(D_INODE, "request %p aa %p rc %d\n", req, aa, rc);
 
@@ -2572,7 +2574,7 @@ static int brw_interpret(const struct lu_env *env,
        }
 
        last = brw_page2oap(aa->aa_ppga[aa->aa_page_count - 1]);
-       obj = osc2cl(last->oap_obj);
+       obj = osc2cl(ext->oe_obj);
        loi = cl2osc(obj)->oo_oinfo;
 
        if (rc == 0) {