* GPL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*/
/*
ENTRY;
LASSERT(mds);
+ cfs_down_read(&mds->mds_qonoff_sem);
dquot = lustre_dqget(obd, info, id, type);
if (IS_ERR(dquot))
RETURN(PTR_ERR(dquot));
+ cfs_up_read(&mds->mds_qonoff_sem);
OBD_ALLOC_PTR(oqaq);
if (!oqaq)
GOTO(out, rc = -ENOMEM);
/* only when block qunit is reduced, boardcast to osts */
if ((adjust_res & LQS_BLK_DECREASE) && QAQ_IS_ADJBLK(oqaq))
- rc = obd_quota_adjust_qunit(mds->mds_osc_exp, oqaq, qctxt);
+ rc = obd_quota_adjust_qunit(mds->mds_lov_exp, oqaq, qctxt);
out:
lustre_dqput(dquot);
if (OBD_FAIL_CHECK(OBD_FAIL_OBD_DQACQ))
RETURN(-EIO);
+ cfs_down_write(&mds->mds_qonoff_sem);
dquot = lustre_dqget(obd, info, qdata->qd_id, QDATA_IS_GRP(qdata));
- if (IS_ERR(dquot))
+ if (IS_ERR(dquot)) {
+ cfs_up_write(&mds->mds_qonoff_sem);
RETURN(PTR_ERR(dquot));
+ }
DQUOT_DEBUG(dquot, "get dquot in dqacq_handler\n");
QINFO_DEBUG(dquot->dq_info, "get dquot in dqadq_handler\n");
- cfs_down(&mds->mds_qonoff_sem);
cfs_down(&dquot->dq_sem);
if (dquot->dq_status & DQ_STATUS_RECOVERY) {
EXIT;
out:
cfs_up(&dquot->dq_sem);
- cfs_up(&mds->mds_qonoff_sem);
+ cfs_up_write(&mds->mds_qonoff_sem);
lustre_dqput(dquot);
if (rc != -EDQUOT)
dqacq_adjust_qunit_sz(obd, qdata->qd_id, QDATA_IS_GRP(qdata),
QDATA_IS_BLK(qdata));
-
lqs = quota_search_lqs(LQS_KEY(QDATA_IS_GRP(qdata), qdata->qd_id),
qctxt, 0);
if (lqs == NULL || IS_ERR(lqs)) {
cfs_down(&obt->obt_quotachecking);
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- cfs_down(&mds->mds_qonoff_sem);
+ cfs_down_write(&mds->mds_qonoff_sem);
for (i = 0; i < MAXQUOTAS; i++) {
struct file *fp;
filp_close(fp, 0);
}
- cfs_up(&mds->mds_qonoff_sem);
+ cfs_up_write(&mds->mds_qonoff_sem);
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
cfs_up(&obt->obt_quotachecking);
RETURN(rc ? : rc1);
if (obt->obt_qctxt.lqc_flags & UGQUOTA2LQC(oqctl->qc_type))
GOTO(out, rc = -EBUSY);
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- cfs_down(&mds->mds_qonoff_sem);
+ cfs_down_write(&mds->mds_qonoff_sem);
oqctl->qc_cmd = Q_FINVALIDATE;
rc = fsfilt_quotactl(obd, obd->u.obt.obt_sb, oqctl);
if (!rc)
- rc = obd_quotactl(mds->mds_osc_exp, oqctl);
+ rc = obd_quotactl(mds->mds_lov_exp, oqctl);
- cfs_up(&mds->mds_qonoff_sem);
+ cfs_up_write(&mds->mds_qonoff_sem);
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
out:
cfs_up(&obt->obt_quotachecking);
LASSERT(qinfo->qi_version == LUSTRE_QUOTA_V2);
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-
- cfs_down(&mds->mds_qonoff_sem);
+ cfs_down_write(&mds->mds_qonoff_sem);
for (i = 0; i < MAXQUOTAS && !rc; i++) {
struct file *fp;
}
qinfo->qi_files[i] = fp;
rc = fsfilt_quotainfo(obd, qinfo, i, QFILE_CHK);
- qinfo->qi_files[i] = 0;
+ qinfo->qi_files[i] = NULL;
filp_close(fp, 0);
}
else
filp_close(fp, 0);
qinfo->qi_files[i] = NULL;
}
- cfs_up(&mds->mds_qonoff_sem);
+ cfs_up_write(&mds->mds_qonoff_sem);
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
RETURN(rc);
}
RETURN(-EINVAL);
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- cfs_down(&mds->mds_qonoff_sem);
+ cfs_down_write(&mds->mds_qonoff_sem);
/* close admin quota files */
rc2 = mds_admin_quota_off(obd, oqctl);
if (rc2 && rc2 != -EALREADY) {
GOTO(out, rc1);
}
- rc = obd_quotactl(mds->mds_osc_exp, oqctl);
+ rc = obd_quotactl(mds->mds_lov_exp, oqctl);
if (rc && rc != -EALREADY) {
CWARN("mds remote quota[%d] is failed to be off for %d\n",
oqctl->qc_type, rc);
EXIT;
out:
- cfs_up(&mds->mds_qonoff_sem);
+ cfs_up_write(&mds->mds_qonoff_sem);
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
return rc ? : (rc1 ? : rc2);
}
oqctl->qc_type != GRPQUOTA)
RETURN(-EINVAL);
- cfs_down(&mds->mds_qonoff_sem);
+ cfs_down_write(&mds->mds_qonoff_sem);
if (qinfo->qi_files[oqctl->qc_type] == NULL) {
CWARN("quota[%u] is off\n", oqctl->qc_type);
GOTO(out, rc = -ESRCH);
EXIT;
out:
- cfs_up(&mds->mds_qonoff_sem);
+ cfs_up_write(&mds->mds_qonoff_sem);
return rc;
}
oqctl->qc_type != GRPQUOTA)
RETURN(-EINVAL);
- cfs_down(&mds->mds_qonoff_sem);
+ cfs_down_read(&mds->mds_qonoff_sem);
if (qinfo->qi_files[oqctl->qc_type] == NULL) {
CWARN("quota[%u] is off\n", oqctl->qc_type);
GOTO(out, rc = -ESRCH);
EXIT;
out:
- cfs_up(&mds->mds_qonoff_sem);
+ cfs_up_read(&mds->mds_qonoff_sem);
return rc;
}
id[GRPQUOTA] = oqctl->qc_id;
/* initialize all slave's limit */
- rc = obd_quotactl(mds->mds_osc_exp, ioqc);
+ rc = obd_quotactl(mds->mds_lov_exp, ioqc);
rc = qctxt_adjust_qunit(obd, &obd->u.obt.obt_qctxt, id, 1, 0, NULL);
if (rc == -EDQUOT || rc == -EBUSY) {
/* adjust remote lqs */
if (QAQ_IS_ADJBLK(qaq)) {
- rc = obd_quota_adjust_qunit(obd->u.mds.mds_osc_exp, qaq, qctxt);
+ rc = obd_quota_adjust_qunit(obd->u.mds.mds_lov_exp, qaq, qctxt);
if (rc < 0)
CERROR("adjust slaves' qunit size failed!(rc=%d)\n", rc);
{
struct mds_obd *mds = &obd->u.mds;
struct lustre_quota_ctxt *qctxt = &mds->mds_obt.obt_qctxt;
- struct obd_device *lov_obd = class_exp2obd(mds->mds_osc_exp);
+ struct obd_device *lov_obd = class_exp2obd(mds->mds_lov_exp);
struct lov_obd *lov = &lov_obd->u.lov;
struct quota_adjust_qunit *oqaq = NULL;
struct lustre_quota_info *qinfo = &mds->mds_quota_info;
OBD_ALLOC_PTR(oqaq);
if (!oqaq)
RETURN(-ENOMEM);
- cfs_down(&mds->mds_qonoff_sem);
+
+ cfs_down_write(&mds->mds_qonoff_sem);
init_oqaq(oqaq, qctxt, oqctl->qc_id, oqctl->qc_type);
if (qinfo->qi_files[oqctl->qc_type] == NULL) {
goto out;
}
- cfs_up(&mds->mds_qonoff_sem);
-
+ cfs_up_write(&mds->mds_qonoff_sem);
adjust_lqs(obd, oqaq);
orig_set = ihardlimit || isoftlimit;
}
revoke_out:
- cfs_down(&mds->mds_qonoff_sem);
+ cfs_down_write(&mds->mds_qonoff_sem);
cfs_down(&dquot->dq_sem);
if (rc) {
/* cancel previous setting */
lustre_dqput(dquot);
EXIT;
out_sem:
- cfs_up(&mds->mds_qonoff_sem);
+ cfs_up_write(&mds->mds_qonoff_sem);
if (oqaq)
OBD_FREE_PTR(oqaq);
/* get block usage from OSS */
soqc->qc_dqblk.dqb_curspace = 0;
- rc = obd_quotactl(obd->u.mds.mds_osc_exp, soqc);
+ rc = obd_quotactl(obd->u.mds.mds_lov_exp, soqc);
if (!rc || rc == -EREMOTEIO) {
oqctl->qc_dqblk.dqb_curspace = soqc->qc_dqblk.dqb_curspace;
oqctl->qc_dqblk.dqb_valid |= QIF_SPACE;
oqctl->qc_type != GRPQUOTA)
RETURN(-EINVAL);
- cfs_down(&mds->mds_qonoff_sem);
+ cfs_down_read(&mds->mds_qonoff_sem);
dqblk->dqb_valid = 0;
if (qinfo->qi_files[oqctl->qc_type] == NULL) {
CWARN("quota[%u] is off\n", oqctl->qc_type);
cfs_up(&dquot->dq_sem);
lustre_dqput(dquot);
- cfs_up(&mds->mds_qonoff_sem);
+ cfs_up_read(&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);
- EXIT;
- return rc;
+
+ /*
+ * Querying of curinodes and/or curspace may have failed, administrative
+ * quota data are likely to be better approximation to the real usage in
+ * this case.
+ */
+ if (!(dqblk->dqb_valid & QIF_INODES) && dquot->dq_dqb.dqb_curinodes > 0)
+ dqblk->dqb_curinodes = dquot->dq_dqb.dqb_curinodes;
+
+ if (!(dqblk->dqb_valid & QIF_SPACE) && dquot->dq_dqb.dqb_curspace > 0)
+ dqblk->dqb_curspace = dquot->dq_dqb.dqb_curspace;
+
+ RETURN(rc);
+
out:
- cfs_up(&mds->mds_qonoff_sem);
+ cfs_up_read(&mds->mds_qonoff_sem);
return rc;
}
cfs_up(&dquot->dq_sem);
+ /* release mds_qonoff_sem during obd_quotactl ops here */
+ cfs_up_write(&mds->mds_qonoff_sem);
+
/* get real bhardlimit from all slaves. */
qctl->qc_cmd = Q_GETOQUOTA;
qctl->qc_type = type;
qctl->qc_id = id;
qctl->qc_stat = QUOTA_RECOVERING;
- rc = obd_quotactl(mds->mds_osc_exp, qctl);
+ rc = obd_quotactl(mds->mds_lov_exp, qctl);
+ cfs_down_write(&mds->mds_qonoff_sem);
if (rc)
GOTO(out, rc);
total_limits = qctl->qc_dqblk.dqb_bhardlimit;
total_limits += qctl->qc_dqblk.dqb_bhardlimit;
/* amend the usage of the administrative quotafile */
- cfs_down(&mds->mds_qonoff_sem);
cfs_down(&dquot->dq_sem);
dquot->dq_dqb.dqb_curspace = total_limits << QUOTABLOCK_BITS;
CERROR("write dquot failed! (rc:%d)\n", rc);
cfs_up(&dquot->dq_sem);
- cfs_up(&mds->mds_qonoff_sem);
EXIT;
out:
cfs_down(&dquot->dq_sem);
/* for mds */
class_incref(obd, "qmaster_recovd_mds", obd);
/* for lov */
- class_incref(mds->mds_osc_obd, "qmaster_recovd_lov", mds->mds_osc_obd);
+ class_incref(mds->mds_lov_obd, "qmaster_recovd_lov", mds->mds_lov_obd);
cfs_complete(&data->comp);
+ cfs_down_write(&mds->mds_qonoff_sem);
for (type = USRQUOTA; type < MAXQUOTAS; type++) {
cfs_list_t id_list;
struct dquot_id *dqid, *tmp;
- cfs_down(&mds->mds_qonoff_sem);
- if (qinfo->qi_files[type] == NULL) {
- cfs_up(&mds->mds_qonoff_sem);
+ if (qinfo->qi_files[type] == NULL)
continue;
- }
+
CFS_INIT_LIST_HEAD(&id_list);
rc = fsfilt_qids(obd, qinfo->qi_files[type], NULL, type,
&id_list);
- cfs_up(&mds->mds_qonoff_sem);
-
if (rc)
CERROR("error get ids from admin quotafile.(%d)\n", rc);
OBD_FREE_PTR(dqid);
}
}
- class_decref(mds->mds_osc_obd, "qmaster_recovd_lov", mds->mds_osc_obd);
+ cfs_up_write(&mds->mds_qonoff_sem);
+ class_decref(mds->mds_lov_obd, "qmaster_recovd_lov", mds->mds_lov_obd);
class_decref(obd, "qmaster_recovd_mds", obd);
RETURN(rc);
}