From ce069b9aa77d859754da1cf2980df4f307ea1bff Mon Sep 17 00:00:00 2001 From: fanyong Date: Sat, 25 Apr 2009 10:57:01 +0000 Subject: [PATCH] Branch b1_8 b=19171 i=tianzy i=robert.read Hold obd reference count when quota recovery. --- lustre/include/obd.h | 3 +++ lustre/include/obd_class.h | 20 ++++++++++++++++ lustre/lov/lov_internal.h | 3 +-- lustre/lov/lov_log.c | 12 +++++----- lustre/lov/lov_obd.c | 50 ++++++++++++++++++++-------------------- lustre/lov/lov_pool.c | 8 +++---- lustre/lov/lov_qos.c | 4 ++-- lustre/mds/handler.c | 3 ++- lustre/mds/mds_lov.c | 3 ++- lustre/obdclass/lprocfs_status.c | 2 ++ lustre/quota/quota_ctl.c | 2 ++ lustre/quota/quota_master.c | 6 +++-- 12 files changed, 73 insertions(+), 43 deletions(-) diff --git a/lustre/include/obd.h b/lustre/include/obd.h index cc65ca9..8101b35 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -1267,6 +1267,9 @@ 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. diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 459e470..8088f0d 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -807,6 +807,26 @@ static inline int obd_pool_rem(struct obd_device *obd, char *poolname, char *ost RETURN(rc); } +static inline void obd_getref(struct obd_device *obd) +{ + ENTRY; + if (OBT(obd) && OBP(obd, getref)) { + OBD_COUNTER_INCREMENT(obd, getref); + OBP(obd, getref)(obd); + } + EXIT; +} + +static inline void obd_putref(struct obd_device *obd) +{ + ENTRY; + if (OBT(obd) && 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_internal.h b/lustre/lov/lov_internal.h index f19e5dd..c6da00c 100644 --- a/lustre/lov/lov_internal.h +++ b/lustre/lov/lov_internal.h @@ -37,6 +37,7 @@ #ifndef LOV_INTERNAL_H #define LOV_INTERNAL_H +#include #include struct lov_lock_handles { @@ -260,8 +261,6 @@ void lov_fix_desc_stripe_count(__u32 *val); void lov_fix_desc_pattern(__u32 *val); void lov_fix_desc_qos_maxage(__u32 *val); int lov_get_stripecnt(struct lov_obd *lov, __u32 stripe_count); -void lov_getref(struct obd_device *obd); -void lov_putref(struct obd_device *obd); /* lov_log.c */ int lov_llog_init(struct obd_device *obd, struct obd_device *tgt, diff --git a/lustre/lov/lov_log.c b/lustre/lov/lov_log.c index 2271253..44c881e 100644 --- a/lustre/lov/lov_log.c +++ b/lustre/lov/lov_log.c @@ -142,7 +142,7 @@ static int lov_llog_origin_connect(struct llog_ctxt *ctxt, int i, rc = 0, err = 0; ENTRY; - lov_getref(obd); + obd_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { struct obd_device *child; struct llog_ctxt *cctxt; @@ -163,7 +163,7 @@ static int lov_llog_origin_connect(struct llog_ctxt *ctxt, err = rc; } } - lov_putref(obd); + obd_putref(obd); RETURN(err); } @@ -181,7 +181,7 @@ static int lov_llog_repl_cancel(struct llog_ctxt *ctxt, struct lov_stripe_md *ls LASSERT(count == lsm->lsm_stripe_count); lov = &obd->u.lov; - lov_getref(obd); + obd_getref(obd); for (i = 0; i < count; i++, cookies++) { struct lov_oinfo *loi = lsm->lsm_oinfo[i]; struct obd_device *child = @@ -200,7 +200,7 @@ static int lov_llog_repl_cancel(struct llog_ctxt *ctxt, struct lov_stripe_md *ls rc = err; } } - lov_putref(obd); + obd_putref(obd); RETURN(rc); } @@ -233,7 +233,7 @@ int lov_llog_init(struct obd_device *obd, struct obd_device *tgt, if (rc) GOTO(err_cleanup, rc); - lov_getref(obd); + obd_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count ; i++) { if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_active) continue; @@ -251,7 +251,7 @@ int lov_llog_init(struct obd_device *obd, struct obd_device *tgt, err = rc; } } - lov_putref(obd); + obd_putref(obd); GOTO(err_cleanup, err); err_cleanup: if (err) { diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 4c76dae..bfeab55 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -71,7 +71,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. */ -void lov_getref(struct obd_device *obd) +static void lov_getref(struct obd_device *obd) { struct lov_obd *lov = &obd->u.lov; @@ -84,7 +84,7 @@ void lov_getref(struct obd_device *obd) static void __lov_del_obd(struct obd_device *obd, struct lov_tgt_desc *tgt); -void lov_putref(struct obd_device *obd) +static void lov_putref(struct obd_device *obd) { struct lov_obd *lov = &obd->u.lov; CFS_LIST_HEAD(kill); @@ -228,7 +228,7 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, (ev == OBD_NOTIFY_SYNC_NONBLOCK)) data = &i; - lov_getref(obd); + obd_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { /* don't send sync event if target not @@ -248,7 +248,7 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, break; } } - lov_putref(obd); + obd_putref(obd); } RETURN(rc); @@ -397,7 +397,7 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd, if (data) lov->lov_ocd = *data; - lov_getref(obd); + obd_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { tgt = lov->lov_tgts[i]; if (!tgt || obd_uuid_empty(&tgt->ltd_uuid)) @@ -421,7 +421,7 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd, obd->obd_name, rc); } } - lov_putref(obd); + obd_putref(obd); RETURN(0); } @@ -509,14 +509,14 @@ static int lov_disconnect(struct obd_export *exp) /* Let's hold another reference so lov_del_obd doesn't spin through putref every time */ - lov_getref(obd); + obd_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { if (lov->lov_tgts[i] && lov->lov_tgts[i]->ltd_exp) { /* Disconnection is the last we know about an obd */ lov_del_target(obd, i, 0, lov->lov_tgts[i]->ltd_gen); } } - lov_putref(obd); + obd_putref(obd); out: rc = class_disconnect(exp); /* bz 9811 */ @@ -541,7 +541,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 (activate=%d)\n", lov, uuid->uuid, activate); - lov_getref(obd); + obd_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { tgt = lov->lov_tgts[i]; if (!tgt || !tgt->ltd_exp) @@ -579,7 +579,7 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid, lov->lov_tgts[i]->ltd_qos.ltq_penalty = 0; out: - lov_putref(obd); + obd_putref(obd); RETURN(i); } @@ -679,7 +679,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, RETURN(0); } - lov_getref(obd); + obd_getref(obd); rc = lov_connect_obd(obd, index, active, &lov->lov_ocd); if (rc) @@ -699,7 +699,7 @@ out: CERROR("connect or notify failed (%d) for %s\n", rc, obd_uuid2str(&tgt->ltd_uuid)); } - lov_putref(obd); + obd_putref(obd); RETURN(rc); } @@ -718,7 +718,7 @@ static int lov_del_target(struct obd_device *obd, __u32 index, RETURN(-EINVAL); } - lov_getref(obd); + obd_getref(obd); if (!lov->lov_tgts[index]) { CERROR("LOV target at index %d is not setup.\n", index); @@ -739,9 +739,9 @@ static 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 lov_putref */ + /* we really delete it from obd_putref */ out: - lov_putref(obd); + obd_putref(obd); RETURN(rc); } @@ -1082,7 +1082,7 @@ static int lov_clear_orphans(struct obd_export *export, struct obdo *src_oa, ost_uuid->uuid); } - lov_getref(export->exp_obd); + obd_getref(export->exp_obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { struct lov_stripe_md obj_md; struct lov_stripe_md *obj_mdp = &obj_md; @@ -1123,7 +1123,7 @@ static int lov_clear_orphans(struct obd_export *export, struct obdo *src_oa, if (ost_uuid) break; } - lov_putref(export->exp_obd); + obd_putref(export->exp_obd); OBDO_FREE(tmp_oa); RETURN(rc); @@ -1194,7 +1194,7 @@ static int lov_create(struct obd_export *exp, struct obdo *src_oa, if (!lov->desc.ld_active_tgt_count) RETURN(-EIO); - lov_getref(exp->exp_obd); + obd_getref(exp->exp_obd); /* Recreate a specific object id at the given OST index */ if ((src_oa->o_valid & OBD_MD_FLFLAGS) && (src_oa->o_flags & OBD_FL_RECREATE_OBJS)) { @@ -1220,7 +1220,7 @@ static int lov_create(struct obd_export *exp, struct obdo *src_oa, } rc = lov_fini_create_set(set, ea); out: - lov_putref(exp->exp_obd); + obd_putref(exp->exp_obd); RETURN(rc); } @@ -1256,7 +1256,7 @@ static int lov_destroy(struct obd_export *exp, struct obdo *oa, } lov = &exp->exp_obd->u.lov; - lov_getref(exp->exp_obd); + obd_getref(exp->exp_obd); rc = lov_prep_destroy_set(exp, &oinfo, oa, lsm, oti, &set); if (rc) GOTO(out, rc); @@ -1286,7 +1286,7 @@ static int lov_destroy(struct obd_export *exp, struct obdo *oa, } err = lov_fini_destroy_set(set); out: - lov_putref(exp->exp_obd); + obd_putref(exp->exp_obd); RETURN(rc ? rc : err); } @@ -2863,7 +2863,7 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen, if (!vallen || !val) RETURN(-EFAULT); - lov_getref(obddev); + obd_getref(obddev); if (KEY_IS(KEY_LOCK_TO_STRIPE)) { struct { @@ -2937,7 +2937,7 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen, rc = -EINVAL; out: - lov_putref(obddev); + obd_putref(obddev); RETURN(rc); } @@ -2961,7 +2961,7 @@ static int lov_set_info_async(struct obd_export *exp, obd_count keylen, RETURN(-ENOMEM); } - lov_getref(obddev); + obd_getref(obddev); count = lov->desc.ld_tgt_count; if (KEY_IS(KEY_NEXT_ID)) { @@ -3006,7 +3006,7 @@ static int lov_set_info_async(struct obd_export *exp, obd_count keylen, if (!rc) rc = err; } - lov_putref(obddev); + obd_putref(obddev); if (no_set) { err = ptlrpc_set_wait(set); if (!rc) diff --git a/lustre/lov/lov_pool.c b/lustre/lov/lov_pool.c index b81ee16..e15504c 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) obd_str2uuid(&ost_uuid, ostname); /* search ost in lov array */ - lov_getref(obd); + obd_getref(obd); for (lov_idx = 0; lov_idx < lov->desc.ld_tgt_count; lov_idx++) { if (!lov->lov_tgts[lov_idx]) continue; @@ -567,7 +567,7 @@ int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname) rc = 0; EXIT; out: - lov_putref(obd); + obd_putref(obd); lov_pool_putref(pool); return rc; } @@ -591,7 +591,7 @@ int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname) obd_str2uuid(&ost_uuid, ostname); /* search ost in lov array, to get index */ - lov_getref(obd); + obd_getref(obd); for (lov_idx = 0; lov_idx < lov->desc.ld_tgt_count; lov_idx++) { if (!lov->lov_tgts[lov_idx]) continue; @@ -613,7 +613,7 @@ int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname) rc = 0; EXIT; out: - lov_putref(obd); + obd_putref(obd); lov_pool_putref(pool); return rc; } diff --git a/lustre/lov/lov_qos.c b/lustre/lov/lov_qos.c index 9df2597..fe76e91 100644 --- a/lustre/lov/lov_qos.c +++ b/lustre/lov/lov_qos.c @@ -752,7 +752,7 @@ static int alloc_qos(struct obd_export *exp, int *idx_arr, int *stripe_cnt, lqr = &(pool->pool_rr); } - lov_getref(exp->exp_obd); + obd_getref(exp->exp_obd); /* wait for fresh statfs info if needed, the rpcs are sent in * lov_create() */ qos_statfs_update(exp->exp_obd, @@ -907,7 +907,7 @@ out: if (rc == -EAGAIN) rc = alloc_rr(lov, idx_arr, stripe_cnt, poolname, flags); - lov_putref(exp->exp_obd); + obd_putref(exp->exp_obd); RETURN(rc); } diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index a5006b9..7d4396d 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -2257,7 +2257,8 @@ int mds_postrecov(struct obd_device *obd) OBD_NOTIFY_SYNC, NULL); /* quota recovery */ - lquota_recovery(mds_quota_interface_ref, obd); + if (likely(obd->obd_stopping == 0)) + lquota_recovery(mds_quota_interface_ref, obd); out: RETURN(rc); diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c index b945eb5..c9270ab 100644 --- a/lustre/mds/mds_lov.c +++ b/lustre/mds/mds_lov.c @@ -1160,7 +1160,8 @@ int mds_notify(struct obd_device *obd, struct obd_device *watched, rc = mds_lov_start_synchronize(obd, watched, data, !(ev == OBD_NOTIFY_SYNC)); - lquota_recovery(mds_quota_interface_ref, obd); + if (likely(obd->obd_stopping == 0)) + lquota_recovery(mds_quota_interface_ref, obd); RETURN(rc); } diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 5e1b73b..f0ad1d4 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -1398,6 +1398,8 @@ void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats) 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); } void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats) diff --git a/lustre/quota/quota_ctl.c b/lustre/quota/quota_ctl.c index 95c33c3..9fa1604 100644 --- a/lustre/quota/quota_ctl.c +++ b/lustre/quota/quota_ctl.c @@ -325,6 +325,7 @@ int lov_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl) RETURN(-EFAULT); } + obd_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { int err; @@ -350,6 +351,7 @@ int lov_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl) bhardlimit += oqctl->qc_dqblk.dqb_bhardlimit; } } + obd_putref(obd); if (oqctl->qc_cmd == Q_GETOQUOTA) { oqctl->qc_dqblk.dqb_curspace = curspace; diff --git a/lustre/quota/quota_master.c b/lustre/quota/quota_master.c index 8982dcc..0e7c3ed 100644 --- a/lustre/quota/quota_master.c +++ b/lustre/quota/quota_master.c @@ -1588,17 +1588,18 @@ static int qmaster_recovery_main(void *arg) { struct qmaster_recov_thread_data *data = arg; struct obd_device *obd = data->obd; + struct mds_obd *mds = &obd->u.mds; + struct lustre_quota_info *qinfo = &mds->mds_quota_info; int rc = 0; unsigned short type; ENTRY; ptlrpc_daemonize("qmaster_recovd"); + class_incref(obd); complete(&data->comp); for (type = USRQUOTA; type < MAXQUOTAS; type++) { - struct mds_obd *mds = &obd->u.mds; - struct lustre_quota_info *qinfo = &mds->mds_quota_info; struct list_head id_list; struct dquot_id *dqid, *tmp; @@ -1628,6 +1629,7 @@ free: kfree(dqid); } } + class_decref(obd); RETURN(rc); } -- 1.8.3.1