From 0aeb8c251e852784451140f137faa361e04bfcc5 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Thu, 17 May 2018 11:36:23 -0500 Subject: [PATCH] LU-11051 obd: remove obd_{get,put}ref() obd_getref() and obd_putref() are only used in the lov layer and only implemented by the lov layer. So they can be removed in favor of direct calls. Rename lov_{get,put}ref() to lov_tgts_{get,put}ref() since they do not manage references on the lov device but on its targets array. Signed-off-by: John L. Hammond Change-Id: I0f48eaf4bb42b81b2155c599f361a17dd7bb1ae3 Reviewed-on: https://review.whamcloud.com/32529 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lustre/include/obd.h | 6 ---- lustre/include/obd_class.h | 20 -------------- lustre/lov/lov_dev.c | 12 ++++---- lustre/lov/lov_internal.h | 2 ++ lustre/lov/lov_obd.c | 49 ++++++++++++++++----------------- lustre/lov/lov_pool.c | 18 ++++++------ lustre/lov/lov_request.c | 5 ++-- lustre/obdclass/lprocfs_status_server.c | 8 ++---- 8 files changed, 48 insertions(+), 72 deletions(-) diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 8098418..e0db77c 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -985,12 +985,6 @@ struct obd_ops { char *ostname); int (*o_pool_rem)(struct obd_device *obd, char *poolname, char *ostname); - void (*o_getref)(struct obd_device *obd); - void (*o_putref)(struct obd_device *obd); - /* - * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line - * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c. - * Also, add a wrapper function in include/linux/obd_class.h. */ }; /* lmv structures */ diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index cd5f833..45660f7 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -1047,26 +1047,6 @@ static inline int obd_pool_rem(struct obd_device *obd, char *poolname, RETURN(rc); } -static inline void obd_getref(struct obd_device *obd) -{ - ENTRY; - if (obd->obd_type && OBP(obd, getref)) { - OBD_COUNTER_INCREMENT(obd, getref); - OBP(obd, getref)(obd); - } - EXIT; -} - -static inline void obd_putref(struct obd_device *obd) -{ - ENTRY; - if (obd->obd_type && OBP(obd, putref)) { - OBD_COUNTER_INCREMENT(obd, putref); - OBP(obd, putref)(obd); - } - EXIT; -} - static inline int obd_init_export(struct obd_export *exp) { int rc = 0; diff --git a/lustre/lov/lov_dev.c b/lustre/lov/lov_dev.c index acd868a..52f022f 100644 --- a/lustre/lov/lov_dev.c +++ b/lustre/lov/lov_dev.c @@ -331,7 +331,7 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, int rc; ENTRY; - obd_getref(obd); + lov_tgts_getref(obd); tgt = obd->u.lov.lov_tgts[index]; LASSERT(tgt != NULL); @@ -356,8 +356,10 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, rc = PTR_ERR(cl); } } - obd_putref(obd); - RETURN(rc); + + lov_tgts_putref(obd); + + RETURN(rc); } /** @@ -449,7 +451,7 @@ static int lov_process_config(const struct lu_env *env, int gen; u32 index; - obd_getref(obd); + lov_tgts_getref(obd); cmd = cfg->lcfg_command; @@ -492,7 +494,7 @@ static int lov_process_config(const struct lu_env *env, } } out: - obd_putref(obd); + lov_tgts_putref(obd); RETURN(rc); } diff --git a/lustre/lov/lov_internal.h b/lustre/lov/lov_internal.h index 0c4cb57..7e87fad 100644 --- a/lustre/lov/lov_internal.h +++ b/lustre/lov/lov_internal.h @@ -271,6 +271,8 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, int lov_fini_statfs_set(struct lov_request_set *set); /* lov_obd.c */ +void lov_tgts_getref(struct obd_device *obd); +void lov_tgts_putref(struct obd_device *obd); void lov_stripe_lock(struct lov_stripe_md *md); void lov_stripe_unlock(struct lov_stripe_md *md); void lov_fix_desc(struct lov_desc *desc); diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 45c57fc..9bdeab9 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -57,7 +57,7 @@ /* Keep a refcount of lov->tgt usage to prevent racing with addition/deletion. Any function that expects lov_tgts to remain stationary must take a ref. */ -static void lov_getref(struct obd_device *obd) +void lov_tgts_getref(struct obd_device *obd) { struct lov_obd *lov = &obd->u.lov; @@ -70,7 +70,7 @@ static void lov_getref(struct obd_device *obd) static void __lov_del_obd(struct obd_device *obd, struct lov_tgt_desc *tgt); -static void lov_putref(struct obd_device *obd) +void lov_tgts_putref(struct obd_device *obd) { struct lov_obd *lov = &obd->u.lov; @@ -223,7 +223,7 @@ static int lov_connect(const struct lu_env *env, if (data) lov->lov_ocd = *data; - obd_getref(obd); + lov_tgts_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { tgt = lov->lov_tgts[i]; @@ -247,9 +247,10 @@ static int lov_connect(const struct lu_env *env, obd->obd_name, rc); } } - obd_putref(obd); - RETURN(0); + lov_tgts_putref(obd); + + RETURN(0); } static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) @@ -321,7 +322,7 @@ static int lov_disconnect(struct obd_export *exp) } /* hold another ref so lov_del_obd() doesn't spin in putref each time */ - obd_getref(obd); + lov_tgts_getref(obd); for (index = 0; index < lov->desc.ld_tgt_count; index++) { if (lov->lov_tgts[index] && lov->lov_tgts[index]->ltd_exp) { @@ -330,7 +331,7 @@ static int lov_disconnect(struct obd_export *exp) lov->lov_tgts[index]->ltd_gen); } } - obd_putref(obd); + lov_tgts_putref(obd); out: rc = class_disconnect(exp); /* bz 9811 */ @@ -355,7 +356,7 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid, CDEBUG(D_INFO, "Searching in lov %p for uuid %s event(%d)\n", lov, uuid->uuid, ev); - obd_getref(obd); + lov_tgts_getref(obd); for (index = 0; index < lov->desc.ld_tgt_count; index++) { tgt = lov->lov_tgts[index]; if (!tgt) @@ -422,7 +423,7 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid, } out: - obd_putref(obd); + lov_tgts_putref(obd); RETURN(index); } @@ -570,7 +571,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, RETURN(0); } - obd_getref(obd); + lov_tgts_getref(obd); rc = lov_connect_obd(obd, index, active, &lov->lov_ocd); if (rc) @@ -598,7 +599,7 @@ out: obd->obd_name, obd_uuid2str(&tgt->ltd_uuid), rc); lov_del_target(obd, index, NULL, 0); } - obd_putref(obd); + lov_tgts_putref(obd); RETURN(rc); } @@ -619,7 +620,7 @@ int lov_del_target(struct obd_device *obd, u32 index, /* to make sure there's no ongoing lov_notify() now */ down_write(&lov->lov_notify_lock); - obd_getref(obd); + lov_tgts_getref(obd); if (!lov->lov_tgts[index]) { CERROR("LOV target at index %d is not setup.\n", index); @@ -640,12 +641,12 @@ int lov_del_target(struct obd_device *obd, u32 index, lov->lov_tgts[index]->ltd_reap = 1; lov->lov_death_row++; - /* we really delete it from obd_putref */ + /* we really delete it from lov_tgts_putref() */ out: - obd_putref(obd); + lov_tgts_putref(obd); up_write(&lov->lov_notify_lock); - RETURN(rc); + RETURN(rc); } static void __lov_del_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) @@ -813,7 +814,7 @@ static int lov_cleanup(struct obd_device *obd) lprocfs_obd_cleanup(obd); if (lov->lov_tgts) { int i; - obd_getref(obd); + lov_tgts_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { if (!lov->lov_tgts[i]) continue; @@ -830,7 +831,7 @@ static int lov_cleanup(struct obd_device *obd) atomic_read(&lov->lov_refcount)); lov_del_target(obd, i, NULL, 0); } - obd_putref(obd); + lov_tgts_putref(obd); OBD_FREE(lov->lov_tgts, sizeof(*lov->lov_tgts) * lov->lov_tgt_size); lov->lov_tgt_size = 0; @@ -1162,7 +1163,7 @@ static int lov_get_info(const struct lu_env *env, struct obd_export *exp, if (vallen == NULL || val == NULL) RETURN(-EFAULT); - obd_getref(obddev); + lov_tgts_getref(obddev); if (KEY_IS(KEY_MAX_EASIZE)) { u32 max_stripe_count = min_t(u32, ld->ld_active_tgt_count, @@ -1180,7 +1181,7 @@ static int lov_get_info(const struct lu_env *env, struct obd_export *exp, rc = -EINVAL; } - obd_putref(obddev); + lov_tgts_putref(obddev); RETURN(rc); } @@ -1207,7 +1208,7 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, RETURN(-ENOMEM); } - obd_getref(obddev); + lov_tgts_getref(obddev); if (KEY_IS(KEY_CHECKSUM)) { do_inactive = true; @@ -1250,7 +1251,7 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, rc = err; } - obd_putref(obddev); + lov_tgts_putref(obddev); if (no_set) { err = ptlrpc_set_wait(set); if (rc == 0) @@ -1295,7 +1296,7 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp, } /* for lov tgt */ - obd_getref(obd); + lov_tgts_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { int err; @@ -1327,7 +1328,7 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp, bhardlimit += oqctl->qc_dqblk.dqb_bhardlimit; } } - obd_putref(obd); + lov_tgts_putref(obd); if (oqctl->qc_cmd == Q_GETOQUOTA) { oqctl->qc_dqblk.dqb_curspace = curspace; @@ -1351,8 +1352,6 @@ static struct obd_ops lov_obd_ops = { .o_pool_rem = lov_pool_remove, .o_pool_add = lov_pool_add, .o_pool_del = lov_pool_del, - .o_getref = lov_getref, - .o_putref = lov_putref, .o_quotactl = lov_quotactl, }; diff --git a/lustre/lov/lov_pool.c b/lustre/lov/lov_pool.c index 20d0fb2..466c394 100644 --- a/lustre/lov/lov_pool.c +++ b/lustre/lov/lov_pool.c @@ -544,7 +544,7 @@ int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname) /* search ost in lov array */ - obd_getref(obd); + lov_tgts_getref(obd); for (lov_idx = 0; lov_idx < lov->desc.ld_tgt_count; lov_idx++) { if (!lov->lov_tgts[lov_idx]) continue; @@ -565,9 +565,10 @@ int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname) EXIT; out: - obd_putref(obd); - lov_pool_putref(pool); - return rc; + lov_tgts_putref(obd); + lov_pool_putref(pool); + + return rc; } int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname) @@ -587,7 +588,7 @@ int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname) obd_str2uuid(&ost_uuid, ostname); - obd_getref(obd); + lov_tgts_getref(obd); /* search ost in lov array, to get index */ for (lov_idx = 0; lov_idx < lov->desc.ld_tgt_count; lov_idx++) { if (!lov->lov_tgts[lov_idx]) @@ -609,7 +610,8 @@ int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname) EXIT; out: - obd_putref(obd); - lov_pool_putref(pool); - return rc; + lov_tgts_putref(obd); + lov_pool_putref(pool); + + return rc; } diff --git a/lustre/lov/lov_request.c b/lustre/lov/lov_request.c index a7baa12..6da1912 100644 --- a/lustre/lov/lov_request.c +++ b/lustre/lov/lov_request.c @@ -289,7 +289,7 @@ static int cb_statfs_update(void *cookie, int rc) if (rc) GOTO(out, rc); - obd_getref(lovobd); + lov_tgts_getref(lovobd); tgt = lov->lov_tgts[lovreq->rq_idx]; if (!tgt || !tgt->ltd_active) GOTO(out_update, rc); @@ -303,8 +303,7 @@ static int cb_statfs_update(void *cookie, int rc) out_update: lov_update_statfs(osfs, lov_sfs, success); - obd_putref(lovobd); - + lov_tgts_putref(lovobd); out: RETURN(0); } diff --git a/lustre/obdclass/lprocfs_status_server.c b/lustre/obdclass/lprocfs_status_server.c index b4d0dd6..8e378ba 100644 --- a/lustre/obdclass/lprocfs_status_server.c +++ b/lustre/obdclass/lprocfs_status_server.c @@ -628,13 +628,11 @@ void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats) LPROCFS_OBD_OP_INIT(num_private_stats, stats, quotactl); LPROCFS_OBD_OP_INIT(num_private_stats, stats, ping); LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_new); - LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_rem); - LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_add); LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_del); - LPROCFS_OBD_OP_INIT(num_private_stats, stats, getref); - LPROCFS_OBD_OP_INIT(num_private_stats, stats, putref); + LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_add); + LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_rem); - CLASSERT(NUM_OBD_STATS == OBD_COUNTER_OFFSET(putref) + 1); + CLASSERT(NUM_OBD_STATS == OBD_COUNTER_OFFSET(pool_rem) + 1); } EXPORT_SYMBOL(lprocfs_init_ops_stats); -- 1.8.3.1