From 7adbe8983430527de48c4b8c75f34b01557b041a Mon Sep 17 00:00:00 2001 From: Andrew Perepechko Date: Mon, 1 Mar 2010 19:27:44 +0300 Subject: [PATCH] b=21816 return approximate block/inode usage when OSTs are down Really return approximate block/inode usage when OSTs are down. The old version erroneously skipped oqctl copying on error which prevented this from working properly. i=Johann Lombardi i=ZhiYong Tian --- lustre/ChangeLog | 5 +++++ lustre/quota/quota_ctl.c | 14 +++++++------- lustre/quota/quota_master.c | 37 +++++++++++++++++++++---------------- lustre/utils/lfs.c | 7 +++++-- 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index 943a714..b1ddb7d 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -13,6 +13,11 @@ tbd Oracle, Inc. lock before replay feature (bug 16774) are disabled by default. Severity : normal +Bugzilla : 21816 +Description: lfs quota failed when OSTs are down +Details : really return approximate block/inode usage when OSTs are down + +Severity : normal Bugzilla : 21829 Description: llobdstat fix and enhancement Details : add a counter to set a limit to how many samples will be returned diff --git a/lustre/quota/quota_ctl.c b/lustre/quota/quota_ctl.c index 518ccbd..84cd244 100644 --- a/lustre/quota/quota_ctl.c +++ b/lustre/quota/quota_ctl.c @@ -374,16 +374,16 @@ int client_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl) GOTO(out, rc); } - oqc = NULL; - if (req->rq_repmsg) + if (req->rq_repmsg) { oqc = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*oqc), lustre_swab_obd_quotactl); - if (oqc == NULL) { - CERROR ("Can't unpack obd_quotactl\n"); - GOTO(out, rc = -EPROTO); + if (oqc != NULL) { + *oqctl = *oqc; + } else { + CERROR ("Can't unpack obd_quotactl\n"); + rc = -EPROTO; + } } - - *oqctl = *oqc; EXIT; out: ptlrpc_req_finished(req); diff --git a/lustre/quota/quota_master.c b/lustre/quota/quota_master.c index ea9b353..d755e4b 100644 --- a/lustre/quota/quota_master.c +++ b/lustre/quota/quota_master.c @@ -1474,7 +1474,8 @@ static int mds_get_space(struct obd_device *obd, struct obd_quotactl *oqctl) { struct obd_quotactl *soqc; struct lvfs_run_ctxt saved; - int rc, rc1; + __u64 curspace; + int rc; ENTRY; OBD_ALLOC_PTR(soqc); @@ -1486,25 +1487,26 @@ static int mds_get_space(struct obd_device *obd, struct obd_quotactl *oqctl) soqc->qc_type = oqctl->qc_type; rc = obd_quotactl(obd->u.mds.mds_lov_exp, soqc); + if (rc) + goto out; - oqctl->qc_dqblk.dqb_curspace = soqc->qc_dqblk.dqb_curspace; + curspace = soqc->qc_dqblk.dqb_curspace; push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); soqc->qc_dqblk.dqb_curspace = 0; - rc1 = fsfilt_quotactl(obd, obd->u.obt.obt_sb, soqc); + rc = fsfilt_quotactl(obd, obd->u.obt.obt_sb, soqc); pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); + if (rc) + goto out; - oqctl->qc_dqblk.dqb_curinodes += soqc->qc_dqblk.dqb_curinodes; - if (!rc1) - oqctl->qc_dqblk.dqb_valid |= QIF_INODES; - oqctl->qc_dqblk.dqb_curspace += soqc->qc_dqblk.dqb_curspace; - if (!rc && !rc1) - oqctl->qc_dqblk.dqb_valid |= QIF_USAGE; + oqctl->qc_dqblk.dqb_curinodes = soqc->qc_dqblk.dqb_curinodes; + oqctl->qc_dqblk.dqb_valid |= QIF_INODES; + oqctl->qc_dqblk.dqb_curspace = curspace + soqc->qc_dqblk.dqb_curspace; + oqctl->qc_dqblk.dqb_valid |= QIF_USAGE; +out: OBD_FREE_PTR(soqc); - if (!rc) - rc = rc1; RETURN(rc); } @@ -1538,17 +1540,20 @@ int mds_get_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl) dqblk->dqb_btime = dquot->dq_dqb.dqb_btime; dqblk->dqb_itime = dquot->dq_dqb.dqb_itime; dqblk->dqb_valid |= QIF_LIMITS | QIF_TIMES; + /* mds_get_space will hopefully update stats to more accurate values */ + dqblk->dqb_curinodes = dquot->dq_dqb.dqb_curinodes; + dqblk->dqb_curspace = dquot->dq_dqb.dqb_curspace; up(&dquot->dq_sem); lustre_dqput(dquot); up(&mds->mds_qonoff_sem); - /* the usages in admin quota file is inaccurate */ - dqblk->dqb_curinodes = 0; - dqblk->dqb_curspace = 0; - rc = mds_get_space(obd, oqctl); + /* if mds_get_space fails we still return rc=0, but the unset + * QIF_INODES and QIF_USAGE will signal that the data are inaccurate */ + mds_get_space(obd, oqctl); + EXIT; - return rc; + return 0; out: up(&mds->mds_qonoff_sem); return rc; diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index aae44ca..db86ad8 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -2160,7 +2160,7 @@ static int lfs_quota(int argc, char **argv) .qc_type = UGQUOTA }; char *obd_type = (char *)qctl.obd_type; char *obd_uuid = (char *)qctl.obd_uuid.uuid; - int rc, rc1 = 0, rc2 = 0, rc3 = 0, verbose = 0; + int rc, rc1 = 0, rc2 = 0, rc3 = 0, verbose = 0, inacc; int pass = 0; char *endptr; @@ -2255,6 +2255,9 @@ ug_output: if (*obd_uuid) mnt = ""; + inacc = (qctl.qc_cmd == LUSTRE_Q_GETQUOTA) && + ((qctl.qc_dqblk.dqb_valid & (QIF_LIMITS|QIF_USAGE)) != (QIF_LIMITS|QIF_USAGE)); + print_quota(mnt, &qctl, GENERAL_QUOTA_INFO); if (!*obd_uuid && qctl.qc_cmd != LUSTRE_Q_GETINFO && verbose) { @@ -2262,7 +2265,7 @@ ug_output: rc3 = print_lov_quota(mnt, &qctl); } - if (rc1 || rc2 || rc3) + if (rc1 || rc2 || rc3 || inacc) printf("Some errors happened when getting quota info. " "Some devices may be not working or deactivated. " "The data in \"[]\" is inaccurate.\n"); -- 1.8.3.1