From: Patrick Farrell Date: Mon, 4 Sep 2023 23:45:25 +0000 (-0400) Subject: LU-13814 osc: add osc_dio_completion X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=e9b7c56e2ee0bf343b43f521fefb385f4843f180;p=fs%2Flustre-release.git LU-13814 osc: add osc_dio_completion Specialize osc_completion to add the osc_dio_completion version. Test-Parameters: fortestonly Test-Parameters: forjanitoronly Signed-off-by: Patrick Farrell Change-Id: I4d202165ee6c4f50338b6a9381aa476b969d3593 --- diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c index 03e644c..6ce34c3 100644 --- a/lustre/osc/osc_cache.c +++ b/lustre/osc/osc_cache.c @@ -49,6 +49,9 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, 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 void osc_dio_completion(const struct lu_env *env, struct osc_object *osc, + struct osc_async_page *oap, enum cl_req_type crt, + int brw_flags, 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, @@ -867,7 +870,11 @@ int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext, } --ext->oe_nr_pages; - osc_completion(env, osc, oap, crt, rc); + if (ext->oe_odp.odp_cdp) + osc_dio_completion(env, osc, oap, crt, + ext->oe_odp.odp_brw_flags, rc); + else + osc_completion(env, osc, oap, crt, rc); } EASSERT(ext->oe_nr_pages == 0, ext); @@ -1301,36 +1308,16 @@ static int osc_refresh_count(const struct lu_env *env, struct osc_object *osc, return PAGE_SIZE; } -/* 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) +static void osc_dio_completion(const struct lu_env *env, struct osc_object *osc, + struct osc_async_page *oap, enum cl_req_type crt, + int brw_flags, int rc) { - struct osc_page *opg = oap2osc_page(oap); - struct cl_page *page = oap2cl_page(oap); + struct cl_page *page = oap2cl_page(oap); int srvlock; - int cptype = page->cp_type; ENTRY; - 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, - crt == CRT_READ), - "cp_state:%u, crt:%d\n", page->cp_state, crt); - LASSERTF(equi(page->cp_state == CPS_PAGEOUT, - 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; - } - - srvlock = oap->oap_brw_flags & OBD_BRW_SRVLOCK; + srvlock = brw_flags & OBD_BRW_SRVLOCK; /* statistic */ if (rc == 0 && srvlock) { @@ -1344,6 +1331,39 @@ static void osc_completion(const struct lu_env *env, struct osc_object *osc, stats->os_lockless_writes += bytes; } + /* for transient pages, the last reference can be destroyed by + * cl_page_complete, so do not reference the page after this + */ + cl_page_complete(env, page, crt, rc); + + EXIT; +} + +/* 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); + + ENTRY; + + /* As the transfer for this page is done, clear the flags */ + oap->oap_async_flags = 0; + + LASSERTF(equi(page->cp_state == CPS_PAGEIN, + crt == CRT_READ), + "cp_state:%u, crt:%d\n", page->cp_state, crt); + LASSERTF(equi(page->cp_state == CPS_PAGEOUT, + 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; + /* * This has to be the last operation with the page, as locks are * released in cl_page_completion() and nothing except for the @@ -1351,12 +1371,8 @@ static void osc_completion(const struct lu_env *env, struct osc_object *osc, */ lu_ref_del(&page->cp_reference, "transfer", page); - /* for transient pages, the last reference can be destroyed by - * cl_page_complete, so do not reference the page after this - */ cl_page_complete(env, page, crt, rc); - if (cptype != CPT_TRANSIENT) - cl_page_put(env, page); + cl_page_put(env, page); EXIT; return; @@ -2576,7 +2592,8 @@ int osc_queue_dio_pages(const struct lu_env *env, struct cl_io *io, oap = &opg->ops_oap; list_del_init(&oap->oap_pending_item); - osc_completion(env, obj, oap, crt, -ENOMEM); + osc_dio_completion(env, obj, oap, crt, brw_flags, + -ENOMEM); } RETURN(-ENOMEM); }