Whamcloud - gitweb
Branch b1_6
authorfanyong <fanyong>
Sat, 25 Apr 2009 10:58:38 +0000 (10:58 +0000)
committerfanyong <fanyong>
Sat, 25 Apr 2009 10:58:38 +0000 (10:58 +0000)
b=19171
i=tianzy
i=robert.read

Hold obd reference count when quota recovery.

lustre/include/obd.h
lustre/include/obd_class.h
lustre/lov/lov_internal.h
lustre/lov/lov_log.c
lustre/lov/lov_obd.c
lustre/lov/lov_qos.c
lustre/mds/handler.c
lustre/mds/mds_lov.c
lustre/obdclass/lprocfs_status.c
lustre/quota/quota_ctl.c
lustre/quota/quota_master.c

index 241c86d..a8d10b4 100644 (file)
@@ -1171,6 +1171,8 @@ struct obd_ops {
                                        obd_lock_cancel_cb cb);
         int (*o_unregister_lock_cancel_cb)(struct obd_device *obd,
                                          obd_lock_cancel_cb cb);
+        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
index feb74a7..007d3ce 100644 (file)
@@ -730,6 +730,26 @@ static inline int obd_ping(struct obd_export *exp)
         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;
index f38e2e9..9003b8b 100644 (file)
@@ -37,6 +37,7 @@
 #ifndef LOV_INTERNAL_H
 #define LOV_INTERNAL_H
 
+#include <obd_class.h>
 #include <lustre/lustre_user.h>
 
 struct lov_lock_handles {
@@ -259,8 +260,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,
index d4964b0..a19f535 100644 (file)
@@ -136,7 +136,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;
@@ -157,7 +157,7 @@ static int lov_llog_origin_connect(struct llog_ctxt *ctxt,
                                 err = rc;
                 }
         }
-        lov_putref(obd);
+        obd_putref(obd);
 
         RETURN(err);
 }
@@ -175,7 +175,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 = 
@@ -194,7 +194,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);
 }
 
@@ -227,7 +227,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;
@@ -245,7 +245,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) {
index 98c2383..39cf266 100644 (file)
@@ -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);
@@ -227,7 +227,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
@@ -247,7 +247,7 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched,
                                 break;
                         }
                 }
-                lov_putref(obd);
+                obd_putref(obd);
         }
 
         RETURN(rc);
@@ -396,7 +396,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))
@@ -420,7 +420,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);
 }
@@ -508,14 +508,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 */
@@ -540,7 +540,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)
@@ -578,7 +578,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);
 }
 
@@ -671,7 +671,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)
@@ -691,7 +691,7 @@ out:
                        obd_uuid2str(&tgt->ltd_uuid));
                 lov_del_target(obd, index, 0, 0);
         }
-        lov_putref(obd);
+        obd_putref(obd);
         RETURN(rc);
 }
 
@@ -710,7 +710,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);
@@ -731,9 +731,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);
 }
@@ -1032,7 +1032,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;
@@ -1073,7 +1073,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);
@@ -1144,7 +1144,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)) {
@@ -1170,7 +1170,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);
 }
 
@@ -1205,7 +1205,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);
@@ -1235,7 +1235,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);
 }
 
@@ -2790,7 +2790,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 {
@@ -2865,7 +2865,7 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen,
 
         rc = -EINVAL;
 out:
-        lov_putref(obddev);
+        obd_putref(obddev);
         RETURN(rc);
 }
 
@@ -2889,7 +2889,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)) {
@@ -2934,7 +2934,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)
@@ -3198,6 +3198,8 @@ struct obd_ops lov_obd_ops = {
         .o_unregister_page_removal_cb = lov_obd_unregister_page_removal_cb,
         .o_register_lock_cancel_cb = lov_obd_register_lock_cancel_cb,
         .o_unregister_lock_cancel_cb = lov_obd_unregister_lock_cancel_cb,
+        .o_getref              = lov_getref,
+        .o_putref              = lov_putref,
 };
 
 static quota_interface_t *quota_interface;
index c7c3aa2..b64d7ff 100644 (file)
@@ -682,7 +682,7 @@ static int alloc_qos(struct obd_export *exp, int *idx_arr, int *stripe_cnt,
         if (stripe_cnt_min < 1)
                 RETURN(-EINVAL);
 
-        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,
@@ -820,7 +820,7 @@ out:
         if (rc == -EAGAIN)
                 rc = alloc_rr(lov, idx_arr, stripe_cnt, flags);
 
-        lov_putref(exp->exp_obd);
+        obd_putref(exp->exp_obd);
         RETURN(rc);
 }
 
index 62deb68..e436249 100644 (file)
@@ -2309,7 +2309,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);
index f1c17d7..8118130 100644 (file)
@@ -1092,7 +1092,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);
 }
index c6388a0..077fb25 100644 (file)
@@ -1256,6 +1256,8 @@ void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats)
         LPROCFS_OBD_OP_INIT(num_private_stats,stats,unregister_page_removal_cb);
         LPROCFS_OBD_OP_INIT(num_private_stats, stats, register_lock_cancel_cb);
         LPROCFS_OBD_OP_INIT(num_private_stats, stats,unregister_lock_cancel_cb);
+        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)
index 95c33c3..9fa1604 100644 (file)
@@ -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;
index 64c1dc7..328a940 100644 (file)
@@ -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);
 }