-
-int lquota_proc_setup(struct obd_device *obd, int is_master)
-{
- struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt;
- int rc = 0;
- ENTRY;
-
- LASSERT(lquota_type_proc_dir && obd);
- qctxt->lqc_proc_dir = lprocfs_register(obd->obd_name,
- lquota_type_proc_dir,
- lprocfs_quota_common_vars, obd);
- if (IS_ERR(qctxt->lqc_proc_dir)) {
- rc = PTR_ERR(qctxt->lqc_proc_dir);
- CERROR("%s: error %d setting up lprocfs\n",
- obd->obd_name, rc);
- qctxt->lqc_proc_dir = NULL;
- GOTO(out, rc);
- }
-
- if (is_master) {
- rc = lprocfs_add_vars(qctxt->lqc_proc_dir,
- lprocfs_quota_master_vars, obd);
- if (rc) {
- CERROR("%s: error %d setting up lprocfs for "
- "quota master\n", obd->obd_name, rc);
- GOTO(out_free_proc, rc);
- }
- }
-
- qctxt->lqc_stats = lprocfs_alloc_stats(LQUOTA_LAST_STAT -
- LQUOTA_FIRST_STAT, 0);
- if (!qctxt->lqc_stats)
- GOTO(out_free_proc, rc = -ENOMEM);
-
- lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_SYNC_ACQ,
- LPROCFS_CNTR_AVGMINMAX, "sync_acq_req", "us");
- lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_SYNC_REL,
- LPROCFS_CNTR_AVGMINMAX, "sync_rel_req", "us");
- lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_ASYNC_ACQ,
- LPROCFS_CNTR_AVGMINMAX, "async_acq_req", "us");
- lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_ASYNC_REL,
- LPROCFS_CNTR_AVGMINMAX, "async_rel_req", "us");
-
- lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_WAIT_FOR_CHK_BLK,
- LPROCFS_CNTR_AVGMINMAX,
- "wait_for_blk_quota(lquota_chkquota)", "us");
- lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_WAIT_FOR_CHK_INO,
- LPROCFS_CNTR_AVGMINMAX,
- "wait_for_ino_quota(lquota_chkquota)", "us");
- lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_WAIT_FOR_COMMIT_BLK,
- LPROCFS_CNTR_AVGMINMAX,
- "wait_for_blk_quota(lquota_pending_commit)",
- "us");
- lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_WAIT_FOR_COMMIT_INO,
- LPROCFS_CNTR_AVGMINMAX,
- "wait_for_ino_quota(lquota_pending_commit)",
- "us");
-
- lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_WAIT_PENDING_BLK_QUOTA,
- LPROCFS_CNTR_AVGMINMAX,
- "wait_for_pending_blk_quota_req"
- "(qctxt_wait_pending_dqacq)", "us");
- lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_WAIT_PENDING_INO_QUOTA,
- LPROCFS_CNTR_AVGMINMAX,
- "wait_for_pending_ino_quota_req"
- "(qctxt_wait_pending_dqacq)", "us");
- lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_NOWAIT_PENDING_BLK_QUOTA,
- LPROCFS_CNTR_AVGMINMAX,
- "nowait_for_pending_blk_quota_req"
- "(qctxt_wait_pending_dqacq)", "us");
- lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_NOWAIT_PENDING_INO_QUOTA,
- LPROCFS_CNTR_AVGMINMAX,
- "nowait_for_pending_ino_quota_req"
- "(qctxt_wait_pending_dqacq)", "us");
-
- lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_QUOTA_CTL,
- LPROCFS_CNTR_AVGMINMAX, "quota_ctl", "us");
- lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_ADJUST_QUNIT,
- LPROCFS_CNTR_AVGMINMAX, "adjust_qunit", "us");
-
- lprocfs_register_stats(qctxt->lqc_proc_dir, "stats", qctxt->lqc_stats);
-
- RETURN(rc);
-
-out_free_proc:
- lprocfs_remove(&qctxt->lqc_proc_dir);
-out:
- RETURN(rc);
-}
-
-int lquota_proc_cleanup(struct lustre_quota_ctxt *qctxt)
-{
- if (!qctxt || !qctxt->lqc_proc_dir)
- return -EINVAL;
-
- if (qctxt->lqc_stats != NULL)
- lprocfs_free_stats(&qctxt->lqc_stats);
-
- lprocfs_remove(&qctxt->lqc_proc_dir);
- return 0;
-}
-