From 6400d7efcb7da541b0083d8b1557d6070e4a36e0 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Mon, 4 Sep 2023 19:38:31 -0400 Subject: [PATCH] LU-13814 osc: begin converting queue_dio_pages This patch begins the lengthy process of converting osc_queue_dio_pages to use the page array rather than the lists. This will be a lengthy process because this ties in to the OSC extent and BRW code. Test-Parameters: trivial Test-Parameters: testlist=sanity-sec env=ONLY=52,59a,59b Signed-off-by: Patrick Farrell Change-Id: I788faa0748a88045d838fb530107938a639407d0 --- lustre/include/lustre_osc.h | 5 +++-- lustre/osc/osc_cache.c | 30 ++++++++++++++++++++++-------- lustre/osc/osc_io.c | 17 +++++++++++++---- 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/lustre/include/lustre_osc.h b/lustre/include/lustre_osc.h index f5745a0..c85716c 100644 --- a/lustre/include/lustre_osc.h +++ b/lustre/include/lustre_osc.h @@ -570,8 +570,9 @@ int osc_teardown_async_page(const struct lu_env *env, struct osc_object *obj, int osc_flush_async_page(const struct lu_env *env, struct cl_io *io, struct osc_page *ops); int osc_queue_dio_pages(const struct lu_env *env, struct cl_io *io, - struct osc_object *obj, struct list_head *list, - int brw_flags); + struct osc_object *obj, struct cl_dio_pages *cdp, + struct list_head *list, + int from_page, int to_page, int brw_flags); int osc_queue_sync_pages(const struct lu_env *env, struct cl_io *io, struct osc_object *obj, struct list_head *list, int brw_flags); diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c index 4c695c8..e2d0498 100644 --- a/lustre/osc/osc_cache.c +++ b/lustre/osc/osc_cache.c @@ -2530,20 +2530,24 @@ out: } int osc_queue_dio_pages(const struct lu_env *env, struct cl_io *io, - struct osc_object *obj, struct list_head *list, - int brw_flags) + struct osc_object *obj, struct cl_dio_pages *cdp, + struct list_head *list, + int from_page, int to_page, int brw_flags) { struct client_obd *cli = osc_cli(obj); struct osc_io *oio = osc_env_io(env); struct osc_async_page *oap; struct osc_extent *ext; struct osc_lock *oscl; + struct cl_page *page; + struct osc_page *opg; 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; + int i; ENTRY; if (brw_flags & OBD_BRW_READ) @@ -2551,9 +2555,13 @@ int osc_queue_dio_pages(const struct lu_env *env, struct cl_io *io, 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); + for (i = from_page; i <= to_page; i++) { + pgoff_t index; + + page = cdp->cdp_cl_pages[i]; + opg = osc_cl_page_osc(page, obj); + oap = &opg->ops_oap; + index = osc_index(opg); if (index > end) end = index; @@ -2568,9 +2576,11 @@ int osc_queue_dio_pages(const struct lu_env *env, struct cl_io *io, ext = osc_extent_alloc(obj); if (ext == NULL) { - struct osc_async_page *tmp; + for (i = from_page; i <= to_page; i++) { + page = cdp->cdp_cl_pages[i]; + opg = osc_cl_page_osc(page, obj); + oap = &opg->ops_oap; - list_for_each_entry_safe(oap, tmp, list, oap_pending_item) { list_del_init(&oap->oap_pending_item); osc_completion(env, obj, oap, crt, -ENOMEM); } @@ -2604,7 +2614,11 @@ int osc_queue_dio_pages(const struct lu_env *env, struct cl_io *io, CDEBUG(D_CACHE, "requesting %d bytes grant\n", grants); spin_lock(&cli->cl_loi_list_lock); if (osc_reserve_grant(cli, grants) == 0) { - list_for_each_entry(oap, list, oap_pending_item) { + for (i = from_page; i <= to_page; i++) { + page = cdp->cdp_cl_pages[i]; + opg = osc_cl_page_osc(page, obj); + oap = &opg->ops_oap; + osc_consume_write_grant(cli, &oap->oap_brw_page); } diff --git a/lustre/osc/osc_io.c b/lustre/osc/osc_io.c index bd504ff..20b912b 100644 --- a/lustre/osc/osc_io.c +++ b/lustre/osc/osc_io.c @@ -278,6 +278,8 @@ int __osc_dio_submit(const struct lu_env *env, struct cl_io *io, bool sync_queue = false; int result = 0; int brw_flags; + int from = -1; + int to = -1; int i = 0; LASSERT(qin->pl_nr > 0); @@ -307,6 +309,8 @@ int __osc_dio_submit(const struct lu_env *env, struct cl_io *io, opg = osc_cl_page_osc(page, osc); oap = &opg->ops_oap; + if (from == -1) + from = i; osc_page_submit(env, opg, crt, brw_flags); list_add_tail(&oap->oap_pending_item, &list); @@ -330,19 +334,24 @@ int __osc_dio_submit(const struct lu_env *env, struct cl_io *io, sync_queue = true; } + to = i; if (sync_queue) { - result = osc_queue_dio_pages(env, top_io, osc, &list, + result = osc_queue_dio_pages(env, top_io, osc, cdp, + &list, from, to, brw_flags); if (result < 0) break; + from = -1; queued = 0; sync_queue = false; } } - if (queued > 0) - result = osc_queue_dio_pages(env, top_io, osc, &list, - brw_flags); + if (queued > 0) { + LASSERT(to != -1); + result = osc_queue_dio_pages(env, top_io, osc, cdp, &list, + from, to, brw_flags); + } /* Update c/mtime for sync write. LU-7310 */ if (crt == CRT_WRITE && qout->pl_nr > 0 && result == 0) { -- 1.8.3.1