Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
b=20591 fix race on obd_device::md_stats
[fs/lustre-release.git]
/
lustre
/
quota
/
lproc_quota.c
diff --git
a/lustre/quota/lproc_quota.c
b/lustre/quota/lproc_quota.c
index
93a2882
..
a64d7a9
100644
(file)
--- a/
lustre/quota/lproc_quota.c
+++ b/
lustre/quota/lproc_quota.c
@@
-207,34
+207,28
@@
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;
+ int rc = 0, rc1 = 0, id;
+ struct obd_device_target *obt = &obd->u.obt;
+ struct lustre_quota_ctxt *qctxt = &obt->obt_qctxt;
+ struct mds_obd *mds = NULL;
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
;
+
GOTO(out, rc = -ECANCELED)
;
}
oqctl->qc_type = type;
@@
-242,35
+236,54
@@
static int auto_quota_on(struct obd_device *obd, int type,
oqctl->qc_id = obt->obt_qfmt;
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- if (is_master) {
- struct mds_obd *mds = &obd->u.mds;
+ if (is_master) {
+ mds = &obd->u.mds;
down(&mds->mds_qonoff_sem);
/* turn on cluster wide quota */
- rc = mds_admin_quota_on(obd, oqctl);
- if (rc
)
- CDEBUG(rc == -ENOENT ? D_QUOTA : D_ERROR,
- "auto-enable admin quota failed. rc=%d\n", rc);
-
up(&mds->mds_qonoff_sem
);
-
+ rc
1
= mds_admin_quota_on(obd, oqctl);
+ if (rc
1 && rc1 != -EALREADY) {
+ CDEBUG(rc
1
== -ENOENT ? D_QUOTA : D_ERROR,
+ "auto-enable admin quota failed. rc=%d\n", rc
1
);
+
GOTO(out_ctxt, rc1
);
+ }
}
+
+ /* turn on local quota */
+ rc = fsfilt_quotactl(obd, sb, oqctl);
if (!rc) {
- /* turn on local quota */
- rc = fsfilt_quotactl(obd, sb, oqctl);
- if (rc)
- CDEBUG(rc == -ENOENT ? D_QUOTA : D_ERROR,
- "auto-enable local quota failed. rc=%d\n", rc);
- else
- obt->obt_qctxt.lqc_flags |= UGQUOTA2LQC(type);
+ obt->obt_qctxt.lqc_flags |= UGQUOTA2LQC(type);
+ build_lqs(obd);
+ } else if (rc == -EBUSY && quota_is_on(qctxt, oqctl)) {
+ CWARN("%s: mds local quota[%d] is on already\n",
+ obd->obd_name, oqctl->qc_type);
+ rc = -EALREADY;
+ } else {
+ CDEBUG(rc == -ENOENT ? D_QUOTA : D_ERROR,
+ "auto-enable local quota failed. rc=%d\n", rc);
+ if (rc1 == -EALREADY) {
+ oqctl->qc_cmd = Q_QUOTAOFF;
+ mds_admin_quota_off(obd, oqctl);
+ }
+ if (rc == -ENOENT)
+ CWARN("%s: quotaon failed because quota files don't "
+ "exist, please run quotacheck firstly\n",
+ obd->obd_name);
+
+ GOTO(out_ctxt, rc);
}
+ EXIT;
+
+out_ctxt:
+ if (mds != NULL)
+ up(&mds->mds_qonoff_sem);
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
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,
@@
-314,8
+327,10
@@
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);
- build_lqs(obd);
+ int rc = auto_quota_on(obd, type - 1, obt->obt_sb, is_mds);
+
+ if (rc && rc != -EALREADY && rc != -ENOENT)
+ return rc;
}
return count;