From c1cab789aaa25bbb4062208aeb2822fde3007cd4 Mon Sep 17 00:00:00 2001 From: Li Dongyang Date: Thu, 21 Mar 2019 14:05:14 +1100 Subject: [PATCH] LU-12093 osc: don't check capability for every page We check CFS_CAP_SYS_RESOURCE for every page during the io. This is expensive on apparmor enabled systems, we can only do that once for the entire io and use the result when submitting the pages. Don't init the oap_brw_flags during osc_page_init(), the flag will be set in either osc_queue_async_io() or osc_page_submit(). Signed-off-by: Li Dongyang Change-Id: I0e664f43ce31c276b33476fdff11794185ab0a3b Reviewed-on: https://review.whamcloud.com/34478 Reviewed-by: Patrick Farrell Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Gu Zheng Reviewed-by: Oleg Drokin --- lustre/include/lustre_osc.h | 4 +++- lustre/osc/osc_cache.c | 5 +---- lustre/osc/osc_io.c | 6 ++++-- lustre/osc/osc_page.c | 3 ++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lustre/include/lustre_osc.h b/lustre/include/lustre_osc.h index 3c9ebef..32a2c63 100644 --- a/lustre/include/lustre_osc.h +++ b/lustre/include/lustre_osc.h @@ -135,7 +135,9 @@ struct osc_io { /** true if this io is lockless. */ unsigned int oi_lockless:1, /** true if this io is counted as active IO */ - oi_is_active:1; + oi_is_active:1, + /** true if this io has CAP_SYS_RESOURCE */ + oi_cap_sys_resource:1; /** how many LRU pages are reserved for this IO */ unsigned long oi_lru_reserved; diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c index 9984fc1..3e179c1 100644 --- a/lustre/osc/osc_cache.c +++ b/lustre/osc/osc_cache.c @@ -2336,9 +2336,6 @@ int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops, oap->oap_obj_off = offset; LASSERT(!(offset & ~PAGE_MASK)); - if (cfs_capable(CFS_CAP_SYS_RESOURCE)) - oap->oap_brw_flags = OBD_BRW_NOQUOTA; - INIT_LIST_HEAD(&oap->oap_pending_item); INIT_LIST_HEAD(&oap->oap_rpc_item); @@ -2378,7 +2375,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, /* Set the OBD_BRW_SRVLOCK before the page is queued. */ brw_flags |= ops->ops_srvlock ? OBD_BRW_SRVLOCK : 0; - if (cfs_capable(CFS_CAP_SYS_RESOURCE)) { + if (oio->oi_cap_sys_resource) { brw_flags |= OBD_BRW_NOQUOTA; cmd |= OBD_BRW_NOQUOTA; } diff --git a/lustre/osc/osc_io.c b/lustre/osc/osc_io.c index 8fef8f6..25e6239 100644 --- a/lustre/osc/osc_io.c +++ b/lustre/osc/osc_io.c @@ -357,18 +357,20 @@ int osc_io_iter_init(const struct lu_env *env, const struct cl_io_slice *ios) { struct osc_object *osc = cl2osc(ios->cis_obj); struct obd_import *imp = osc_cli(osc)->cl_import; + struct osc_io *oio = osc_env_io(env); int rc = -EIO; spin_lock(&imp->imp_lock); if (likely(!imp->imp_invalid)) { - struct osc_io *oio = osc_env_io(env); - atomic_inc(&osc->oo_nr_ios); oio->oi_is_active = 1; rc = 0; } spin_unlock(&imp->imp_lock); + if (cfs_capable(CFS_CAP_SYS_RESOURCE)) + oio->oi_cap_sys_resource = 1; + return rc; } EXPORT_SYMBOL(osc_io_iter_init); diff --git a/lustre/osc/osc_page.c b/lustre/osc/osc_page.c index cd4107b..7a7dc1d 100644 --- a/lustre/osc/osc_page.c +++ b/lustre/osc/osc_page.c @@ -327,6 +327,7 @@ EXPORT_SYMBOL(osc_page_init); void osc_page_submit(const struct lu_env *env, struct osc_page *opg, enum cl_req_type crt, int brw_flags) { + struct osc_io *oio = osc_env_io(env); struct osc_async_page *oap = &opg->ops_oap; LASSERTF(oap->oap_magic == OAP_MAGIC, "Bad oap magic: oap %p, " @@ -339,7 +340,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg, oap->oap_count = opg->ops_to - opg->ops_from; oap->oap_brw_flags = OBD_BRW_SYNC | brw_flags; - if (cfs_capable(CFS_CAP_SYS_RESOURCE)) { + if (oio->oi_cap_sys_resource) { oap->oap_brw_flags |= OBD_BRW_NOQUOTA; oap->oap_cmd |= OBD_BRW_NOQUOTA; } -- 1.8.3.1