From 48df66be72c948ab5428a073e52a45ac4252d612 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Mon, 10 Sep 2018 17:22:46 -0600 Subject: [PATCH] LU-10899 osc: move obdo_cache to OSC code The obdo_cache slab is only used by the OSC code today, so it does not need to be allocated in obdclass on servers. Move it to only be allocated when the OSC module is loaded. Rename obdo_cachep to osc_obdo_kmem to match other slab caches created by the OSC. Signed-off-by: Andreas Dilger Change-Id: I6f70adb1f5d0e76c72d797a65b413df1533ebbe5 Reviewed-on: https://review.whamcloud.com/33141 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin --- lustre/include/lustre_osc.h | 1 + lustre/include/obd_class.h | 14 -------------- lustre/obdclass/genops.c | 12 ------------ lustre/osc/osc_dev.c | 12 ++++++++---- lustre/osc/osc_request.c | 36 ++++++++++++++++++------------------ 5 files changed, 27 insertions(+), 48 deletions(-) diff --git a/lustre/include/lustre_osc.h b/lustre/include/lustre_osc.h index 3fb2d33..ae7a602 100644 --- a/lustre/include/lustre_osc.h +++ b/lustre/include/lustre_osc.h @@ -566,6 +566,7 @@ extern struct kmem_cache *osc_thread_kmem; extern struct kmem_cache *osc_session_kmem; extern struct kmem_cache *osc_extent_kmem; extern struct kmem_cache *osc_quota_kmem; +extern struct kmem_cache *osc_obdo_kmem; extern struct lu_context_key osc_key; extern struct lu_context_key osc_session_key; diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 3c9af4c..863249d 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -1774,20 +1774,6 @@ static inline int md_unpackmd(struct obd_export *exp, extern int obd_init_caches(void); extern void obd_cleanup_caches(void); -/* support routines */ -extern struct kmem_cache *obdo_cachep; - -#define OBDO_ALLOC(ptr) \ -do { \ - OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, GFP_NOFS); \ -} while(0) - -#define OBDO_FREE(ptr) \ -do { \ - OBD_SLAB_FREE_PTR((ptr), obdo_cachep); \ -} while(0) - - typedef int (*register_lwp_cb)(void *data); struct lwp_register_item { diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 5803557..a7d816e 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -52,8 +52,6 @@ DEFINE_RWLOCK(obd_dev_lock); static struct obd_device *obd_devs[MAX_OBD_DEVICES]; static struct kmem_cache *obd_device_cachep; -struct kmem_cache *obdo_cachep; -EXPORT_SYMBOL(obdo_cachep); static struct workqueue_struct *zombie_wq; @@ -902,10 +900,6 @@ void obd_cleanup_caches(void) kmem_cache_destroy(obd_device_cachep); obd_device_cachep = NULL; } - if (obdo_cachep) { - kmem_cache_destroy(obdo_cachep); - obdo_cachep = NULL; - } EXIT; } @@ -922,12 +916,6 @@ int obd_init_caches(void) if (!obd_device_cachep) GOTO(out, rc = -ENOMEM); - LASSERT(obdo_cachep == NULL); - obdo_cachep = kmem_cache_create("ll_obdo_cache", sizeof(struct obdo), - 0, 0, NULL); - if (!obdo_cachep) - GOTO(out, rc = -ENOMEM); - RETURN(0); out: obd_cleanup_caches(); diff --git a/lustre/osc/osc_dev.c b/lustre/osc/osc_dev.c index 1b4acca..cbddab5 100644 --- a/lustre/osc/osc_dev.c +++ b/lustre/osc/osc_dev.c @@ -54,9 +54,8 @@ EXPORT_SYMBOL(osc_object_kmem); struct kmem_cache *osc_thread_kmem; struct kmem_cache *osc_session_kmem; struct kmem_cache *osc_extent_kmem; -EXPORT_SYMBOL(osc_extent_kmem); struct kmem_cache *osc_quota_kmem; -EXPORT_SYMBOL(osc_quota_kmem); +struct kmem_cache *osc_obdo_kmem; struct lu_kmem_descr osc_caches[] = { { @@ -90,8 +89,13 @@ struct lu_kmem_descr osc_caches[] = { .ckd_size = sizeof(struct osc_quota_info) }, { - .ckd_cache = NULL - } + .ckd_cache = &osc_obdo_kmem, + .ckd_name = "osc_obdo_kmem", + .ckd_size = sizeof(struct obdo) + }, + { + .ckd_cache = NULL + } }; /***************************************************************************** diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 1ac295b8..3ca65ba 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -740,24 +740,24 @@ struct grant_thread_data { static struct grant_thread_data client_gtd; static int osc_shrink_grant_interpret(const struct lu_env *env, - struct ptlrpc_request *req, - void *aa, int rc) + struct ptlrpc_request *req, + void *aa, int rc) { - struct client_obd *cli = &req->rq_import->imp_obd->u.cli; - struct obdo *oa = ((struct osc_grant_args *)aa)->aa_oa; - struct ost_body *body; + struct client_obd *cli = &req->rq_import->imp_obd->u.cli; + struct obdo *oa = ((struct osc_grant_args *)aa)->aa_oa; + struct ost_body *body; - if (rc != 0) { - __osc_update_grant(cli, oa->o_grant); - GOTO(out, rc); - } + if (rc != 0) { + __osc_update_grant(cli, oa->o_grant); + GOTO(out, rc); + } - body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); - LASSERT(body); - osc_update_grant(cli, body); + body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); + LASSERT(body); + osc_update_grant(cli, body); out: - OBDO_FREE(oa); - return rc; + OBD_SLAB_FREE_PTR(oa, osc_obdo_kmem); + return rc; } static void osc_shrink_grant_local(struct client_obd *cli, struct obdo *oa) @@ -2099,7 +2099,7 @@ static int brw_interpret(const struct lu_env *env, cl_object_attr_update(env, obj, attr, valid); cl_object_attr_unlock(obj); } - OBDO_FREE(aa->aa_oa); + OBD_SLAB_FREE_PTR(aa->aa_oa, osc_obdo_kmem); if (lustre_msg_get_opc(req->rq_reqmsg) == OST_WRITE && rc == 0) osc_inc_unstable_pages(req); @@ -2204,7 +2204,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, if (pga == NULL) GOTO(out, rc = -ENOMEM); - OBDO_ALLOC(oa); + OBD_SLAB_ALLOC_PTR_GFP(oa, osc_obdo_kmem, GFP_NOFS); if (oa == NULL) GOTO(out, rc = -ENOMEM); @@ -2332,7 +2332,7 @@ out: LASSERT(req == NULL); if (oa) - OBDO_FREE(oa); + OBD_SLAB_FREE_PTR(oa, osc_obdo_kmem); if (pga) OBD_FREE(pga, sizeof(*pga) * page_count); /* this should happen rarely and is pretty bad, it makes the @@ -2944,7 +2944,7 @@ int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); aa = ptlrpc_req_async_args(req); - OBDO_ALLOC(oa); + OBD_SLAB_ALLOC_PTR_GFP(oa, osc_obdo_kmem, GFP_NOFS); if (!oa) { ptlrpc_req_finished(req); RETURN(-ENOMEM); -- 1.8.3.1