# include <liblustre.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/lustre_mds.h>
-#include <linux/lustre_dlm.h>
-#include <linux/lustre_cfg.h>
-#include <linux/obd_ost.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/lustre_quota.h>
+#include <obd_class.h>
+#include <lustre_mds.h>
+#include <lustre_dlm.h>
+#include <lustre_cfg.h>
+#include <obd_ost.h>
+#include <lustre_fsfilt.h>
+#include <lustre_quota.h>
#include "quota_internal.h"
#ifdef __KERNEL__
case Q_GETOQUOTA:
rc = mds_get_obd_quota(obd, oqctl);
break;
+ case LUSTRE_Q_INVALIDATE:
+ rc = mds_quota_invalidate(obd, oqctl);
+ break;
default:
CERROR("%s: unsupported mds_quotactl command: %d\n",
obd->obd_name, oqctl->qc_cmd);
int filter_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl)
{
struct obd_device *obd = exp->exp_obd;
+ struct obd_device_target *obt = &obd->u.obt;
struct lvfs_run_ctxt saved;
int rc = 0;
ENTRY;
switch (oqctl->qc_cmd) {
case Q_QUOTAON:
case Q_QUOTAOFF:
+ if (!atomic_dec_and_test(&obt->obt_quotachecking)) {
+ CDEBUG(D_INFO, "other people are doing quotacheck\n");
+ atomic_inc(&obt->obt_quotachecking);
+ rc = -EBUSY;
+ break;
+ }
case Q_GETOINFO:
case Q_GETOQUOTA:
case Q_GETQUOTA:
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
rc = fsfilt_quotactl(obd, obd->u.obt.obt_sb, oqctl);
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+
+ if (oqctl->qc_cmd == Q_QUOTAON || oqctl->qc_cmd == Q_QUOTAOFF) {
+ if (!rc)
+ obt->obt_qctxt.lqc_status =
+ (oqctl->qc_cmd == Q_QUOTAON) ? 1 : 0;
+ atomic_inc(&obt->obt_quotachecking);
+ }
+ break;
+ case Q_SETQUOTA:
+ /* currently, it is only used for nullifying the quota */
+ qctxt_wait_pending_dqacq(&obd->u.obt.obt_qctxt,
+ oqctl->qc_id, oqctl->qc_type, 1);
+
+ push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ rc = fsfilt_quotactl(obd, obd->u.obt.obt_sb, oqctl);
+
+ if (!rc) {
+ oqctl->qc_cmd = Q_SYNC;
+ fsfilt_quotactl(obd, obd->u.obt.obt_sb, oqctl);
+ oqctl->qc_cmd = Q_SETQUOTA;
+ }
+ pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
break;
case Q_INITQUOTA:
{
/* Initialize quota limit to MIN_QLIMIT */
LASSERT(oqctl->qc_dqblk.dqb_valid == QIF_BLIMITS);
- LASSERT(oqctl->qc_dqblk.dqb_bhardlimit == MIN_QLIMIT);
LASSERT(oqctl->qc_dqblk.dqb_bsoftlimit == 0);
/* There might be a pending dqacq/dqrel (which is going to
- * clear stale limits on slave). we should wait for it's
+ * clear stale limits on slave). we should wait for it's
* completion then initialize limits */
- qctxt_wait_pending_dqacq(&obd->u.obt.obt_qctxt,
+ qctxt_wait_pending_dqacq(&obd->u.obt.obt_qctxt,
oqctl->qc_id, oqctl->qc_type, 1);
+ if (!oqctl->qc_dqblk.dqb_bhardlimit)
+ goto adjust;
+
+ LASSERT(oqctl->qc_dqblk.dqb_bhardlimit == MIN_QLIMIT);
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
rc = fsfilt_quotactl(obd, obd->u.obt.obt_sb, oqctl);
if (rc)
RETURN(rc);
-
+adjust:
/* Trigger qunit pre-acquire */
if (oqctl->qc_type == USRQUOTA)
uid = oqctl->qc_id;
rc = qctxt_adjust_qunit(obd, &obd->u.obt.obt_qctxt,
uid, gid, 1, 0);
+ if (rc == -EDQUOT || rc == -EBUSY) {
+ CDEBUG(D_QUOTA, "rc: %d.\n", rc);
+ rc = 0;
+ }
+
break;
}
default:
{
struct ptlrpc_request *req;
struct obd_quotactl *oqc;
- int size = sizeof(*oqctl), opc, version;
- int rc;
+ int size[2] = { sizeof(struct ptlrpc_body), sizeof(*oqctl) };
+ int ver, opc, rc;
ENTRY;
if (!strcmp(exp->exp_obd->obd_type->typ_name, LUSTRE_MDC_NAME)) {
+ ver = LUSTRE_MDS_VERSION,
opc = MDS_QUOTACTL;
- version = LUSTRE_MDS_VERSION;
} else if (!strcmp(exp->exp_obd->obd_type->typ_name, LUSTRE_OSC_NAME)) {
+ ver = LUSTRE_OST_VERSION,
opc = OST_QUOTACTL;
- version = LUSTRE_OST_VERSION;
} else {
RETURN(-EINVAL);
}
- req = ptlrpc_prep_req(class_exp2cliimp(exp), version, opc, 1, &size,
- NULL);
+ req = ptlrpc_prep_req(class_exp2cliimp(exp), ver, opc, 2, size, NULL);
if (!req)
GOTO(out, rc = -ENOMEM);
- oqc = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*oqctl));
+ oqc = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*oqctl));
*oqc = *oqctl;
- req->rq_replen = lustre_msg_size(1, &size);
+ ptlrpc_req_set_repsize(req, 2, size);
rc = ptlrpc_queue_wait(req);
- if (!rc) {
- oqc = lustre_swab_repbuf(req, 0, sizeof (*oqc),
- lustre_swab_obd_quotactl);
- if (oqc == NULL) {
- CERROR ("Can't unpack obd_quotactl\n");
- GOTO(out, rc = -EPROTO);
- }
-
- *oqctl = *oqc;
+ 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);
}
+
+ *oqctl = *oqc;
+ EXIT;
out:
ptlrpc_req_finished(req);
- RETURN (rc);
+ return rc;
}
int lov_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl)
struct obd_device *obd = class_exp2obd(exp);
struct lov_obd *lov = &obd->u.lov;
__u64 curspace = 0;
- __u32 bhardlimit = 0;
+ __u64 bhardlimit = 0;
int i, rc = 0;
ENTRY;
if (oqctl->qc_cmd != Q_QUOTAON && oqctl->qc_cmd != Q_QUOTAOFF &&
- oqctl->qc_cmd != Q_GETOQUOTA && oqctl->qc_cmd != Q_INITQUOTA) {
+ oqctl->qc_cmd != Q_GETOQUOTA && oqctl->qc_cmd != Q_INITQUOTA &&
+ oqctl->qc_cmd != Q_SETQUOTA) {
CERROR("bad quota opc %x for lov obd", oqctl->qc_cmd);
RETURN(-EFAULT);
}
for (i = 0; i < lov->desc.ld_tgt_count; i++) {
int err;
- if (!lov->tgts[i].active) {
+ if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_active) {
if (oqctl->qc_cmd == Q_GETOQUOTA) {
CERROR("ost %d is inactive\n", i);
rc = -EIO;
- break;
} else {
CDEBUG(D_HA, "ost %d is inactive\n", i);
- continue;
}
+ continue;
}
- err = obd_quotactl(lov->tgts[i].ltd_exp, oqctl);
+ err = obd_quotactl(lov->lov_tgts[i]->ltd_exp, oqctl);
if (err) {
- if (lov->tgts[i].active && !rc)
+ if (lov->lov_tgts[i]->ltd_active && !rc)
rc = err;
continue;
}