From ddb8e7b60ec60301dc16bcc045c41a2aa24eb179 Mon Sep 17 00:00:00 2001 From: tianzy Date: Fri, 25 Jul 2008 13:34:38 +0000 Subject: [PATCH] Branch b1_8 add quota statistics and sort out quota lproc code. b=15058 i=johann i=andrew.perepechko --- lustre/quota/quota_context.c | 66 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/lustre/quota/quota_context.c b/lustre/quota/quota_context.c index c9ff5e6a..ce80251 100644 --- a/lustre/quota/quota_context.c +++ b/lustre/quota/quota_context.c @@ -44,7 +44,7 @@ # define EXPORT_SYMTAB #endif -#define DEBUG_SUBSYSTEM S_MDS +#define DEBUG_SUBSYSTEM S_LQUOTA #include #include @@ -58,6 +58,7 @@ #include #include #include +#include #include "quota_internal.h" extern struct lustre_hash_operations lqs_hash_operations; @@ -755,9 +756,14 @@ schedule_dqacq(struct obd_device *obd, struct lustre_quota_ctxt *qctxt, int size[2] = { sizeof(struct ptlrpc_body), 0 }; struct obd_import *imp = NULL; struct lustre_qunit_size *lqs = NULL; + struct timeval work_start; + struct timeval work_end; + long timediff; int rc = 0; ENTRY; + LASSERT(opc == QUOTA_DQACQ || opc == QUOTA_DQREL); + do_gettimeofday(&work_start); if ((empty = alloc_qunit(qctxt, qdata, opc)) == NULL) RETURN(-ENOMEM); @@ -800,6 +806,16 @@ schedule_dqacq(struct obd_device *obd, struct lustre_quota_ctxt *qctxt, QDATA_SET_CHANGE_QS(qdata); rc = qctxt->lqc_handler(obd, qdata, opc); rc2 = dqacq_completion(obd, qctxt, qdata, rc, opc); + do_gettimeofday(&work_end); + timediff = cfs_timeval_sub(&work_end, &work_start, NULL); + if (opc == QUOTA_DQACQ) + lprocfs_counter_add(qctxt->lqc_stats, + wait ? LQUOTA_SYNC_ACQ : LQUOTA_ASYNC_ACQ, + timediff); + else + lprocfs_counter_add(qctxt->lqc_stats, + wait ? LQUOTA_SYNC_REL : LQUOTA_ASYNC_REL, + timediff); RETURN(rc ? rc : rc2); } @@ -878,6 +894,18 @@ wait_completion: qunit, rc); qunit_put(qunit); } + + do_gettimeofday(&work_end); + timediff = cfs_timeval_sub(&work_end, &work_start, NULL); + if (opc == QUOTA_DQACQ) + lprocfs_counter_add(qctxt->lqc_stats, + wait ? LQUOTA_SYNC_ACQ : LQUOTA_ASYNC_ACQ, + timediff); + else + lprocfs_counter_add(qctxt->lqc_stats, + wait ? LQUOTA_SYNC_REL : LQUOTA_ASYNC_REL, + timediff); + RETURN(rc); } @@ -925,9 +953,13 @@ qctxt_wait_pending_dqacq(struct lustre_quota_ctxt *qctxt, unsigned int id, { struct lustre_qunit *qunit = NULL; struct qunit_data qdata; + struct timeval work_start; + struct timeval work_end; + long timediff; struct l_wait_info lwi = { 0 }; ENTRY; + do_gettimeofday(&work_start); qdata.qd_id = id; qdata.qd_flags = type; if (isblk) @@ -951,14 +983,29 @@ qctxt_wait_pending_dqacq(struct lustre_quota_ctxt *qctxt, unsigned int id, CDEBUG(D_QUOTA, "qunit(%p) finishes waiting. (rc:%d)\n", qunit, qunit->lq_rc); qunit_put(qunit); + do_gettimeofday(&work_end); + timediff = cfs_timeval_sub(&work_end, &work_start, NULL); + lprocfs_counter_add(qctxt->lqc_stats, + isblk ? LQUOTA_WAIT_PENDING_BLK_QUOTA : + LQUOTA_WAIT_PENDING_INO_QUOTA, + timediff); + } else { + do_gettimeofday(&work_end); + timediff = cfs_timeval_sub(&work_end, &work_start, NULL); + lprocfs_counter_add(qctxt->lqc_stats, + isblk ? LQUOTA_NOWAIT_PENDING_BLK_QUOTA : + LQUOTA_NOWAIT_PENDING_INO_QUOTA, + timediff); } + RETURN(0); } int -qctxt_init(struct lustre_quota_ctxt *qctxt, struct super_block *sb, - dqacq_handler_t handler) +qctxt_init(struct obd_device *obd, dqacq_handler_t handler) { + struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt; + struct super_block *sb = obd->u.obt.obt_sb; int rc = 0; ENTRY; @@ -989,11 +1036,17 @@ qctxt_init(struct lustre_quota_ctxt *qctxt, struct super_block *sb, rc = lustre_hash_init(&LQC_HASH_BODY(qctxt), "LQS_HASH",128, &lqs_hash_operations); if (rc) { - CDEBUG(D_ERROR, "initialize hash lqs on ost error!\n"); + CDEBUG(D_ERROR, "initialize hash lqs for %s error!\n", + obd->obd_name); lustre_hash_exit(&LQC_HASH_BODY(qctxt)); } spin_unlock(&qctxt->lqc_lock); +#ifdef LPROCFS + if (lquota_proc_setup(obd, is_master(obd, qctxt, 0, 0))) + CERROR("initialize proc for %s error!\n", obd->obd_name); +#endif + RETURN(rc); } @@ -1030,6 +1083,11 @@ void qctxt_cleanup(struct lustre_quota_ctxt *qctxt, int force) lustre_hash_exit(&LQC_HASH_BODY(qctxt)); ptlrpcd_decref(); +#ifdef LPROCFS + if (lquota_proc_cleanup(qctxt)) + CERROR("cleanup proc error!\n"); +#endif + EXIT; } -- 1.8.3.1