X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fquota%2Flproc_quota.c;h=7e607f9f851f5b2cc21a37f00feadb6d98178742;hp=ba9492fbf637126e8ccbaa027d9bfbbbf36d8d68;hb=342caced07fdaca95d5ab4091e947116738ef69a;hpb=4138b92bbb3fe9e25b347ced0bf411c5c01ff460 diff --git a/lustre/quota/lproc_quota.c b/lustre/quota/lproc_quota.c index ba9492f..7e607f9 100644 --- a/lustre/quota/lproc_quota.c +++ b/lustre/quota/lproc_quota.c @@ -208,28 +208,25 @@ static int auto_quota_on(struct obd_device *obd, int type, struct obd_quotactl *oqctl; struct lvfs_run_ctxt saved; int rc = 0, id; - struct obd_device_target *obt; + struct obd_device_target *obt = &obd->u.obt; ENTRY; LASSERT(type == USRQUOTA || type == GRPQUOTA || type == UGQUOTA); - obt = &obd->u.obt; - OBD_ALLOC_PTR(oqctl); if (!oqctl) RETURN(-ENOMEM); - if (!atomic_dec_and_test(&obt->obt_quotachecking)) { - CDEBUG(D_INFO, "other people are doing quotacheck\n"); - atomic_inc(&obt->obt_quotachecking); - RETURN(-EBUSY); - } - + down(&obt->obt_quotachecking); id = UGQUOTA2LQC(type); /* quota already turned on */ - if ((obt->obt_qctxt.lqc_flags & id) == id) { - rc = 0; - goto out; + if ((obt->obt_qctxt.lqc_flags & id) == id) + GOTO(out, rc); + + if (obt->obt_qctxt.lqc_immutable) { + LCONSOLE_ERROR("Failed to turn Quota on, immutable mode " + "(is SOM enabled?)\n"); + GOTO(out, rc = -ECANCELED); } oqctl->qc_type = type; @@ -260,12 +257,12 @@ static int auto_quota_on(struct obd_device *obd, int type, } pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); + EXIT; out: - atomic_inc(&obt->obt_quotachecking); - + up(&obt->obt_quotachecking); OBD_FREE_PTR(oqctl); - RETURN(rc); + return rc; } int lprocfs_quota_wr_type(struct file *file, const char *buffer, @@ -308,8 +305,14 @@ int lprocfs_quota_wr_type(struct file *file, const char *buffer, } } - if (type != 0) - auto_quota_on(obd, type - 1, obt->obt_sb, is_mds); + if (type != 0) { + int rc = auto_quota_on(obd, type - 1, obt->obt_sb, is_mds); + + if (rc == 0) + build_lqs(obd); + else if (rc != -EALREADY) + return rc; + } return count; }