i, &id_list);
#endif
if (rc) {
- CDEBUG(D_ERROR, "fail to get %s qids!\n",
+ CERROR("%s: failed to get %s qids\n", obd->obd_name,
i ? "group" : "user");
continue;
}
lqs->lqs_flags |= dqid->di_flag;
lqs_putref(lqs);
} else {
- CDEBUG(D_ERROR, "fail to create a lqs"
- "(%s id: %u)!\n", i ? "group" : "user",
+ CERROR("%s: failed to create a lqs for %sid %u"
+ "\n", obd->obd_name, i ? "g" : "u",
dqid->di_id);
}
do_gettimeofday(&work_start);
switch (oqctl->qc_cmd) {
case Q_QUOTAON:
- oqctl->qc_id = obt->obt_qfmt; /* override qfmt version */
rc = mds_quota_on(obd, oqctl);
- /* when quotaon, create lqs for every quota uid/gid b=18574 */
- build_lqs(obd);
break;
case Q_QUOTAOFF:
oqctl->qc_id = obt->obt_qfmt; /* override qfmt version */
do_gettimeofday(&work_start);
switch (oqctl->qc_cmd) {
- case Q_FINVALIDATE:
case Q_QUOTAON:
+ oqctl->qc_id = obt->obt_qfmt;
+ rc = generic_quota_on(obd, oqctl, 0);
+ break;
+ case Q_FINVALIDATE:
case Q_QUOTAOFF:
if (!atomic_dec_and_test(&obt->obt_quotachecking)) {
CDEBUG(D_INFO, "other people are doing quotacheck\n");
if (oqctl->qc_stat == QUOTA_RECOVERING)
quota_unbarrier(handle);
- if (oqctl->qc_cmd == Q_QUOTAON || oqctl->qc_cmd == Q_QUOTAOFF ||
+ if (oqctl->qc_cmd == Q_QUOTAOFF ||
oqctl->qc_cmd == Q_FINVALIDATE) {
- if (!rc && oqctl->qc_cmd == Q_QUOTAON)
- obt->obt_qctxt.lqc_flags |= UGQUOTA2LQC(oqctl->qc_type);
if (!rc && oqctl->qc_cmd == Q_QUOTAOFF)
obt->obt_qctxt.lqc_flags &= ~UGQUOTA2LQC(oqctl->qc_type);
atomic_inc(&obt->obt_quotachecking);
}
-
- /* when quotaon, create lqs for every quota uid/gid b=18574 */
- if (oqctl->qc_cmd == Q_QUOTAON)
- build_lqs(obd);
break;
case Q_SETQUOTA:
/* currently, it is only used for nullifying the quota */
lqs = quota_search_lqs(LQS_KEY(oqctl->qc_type, oqctl->qc_id),
qctxt, 0);
if (lqs == NULL || IS_ERR(lqs)){
- CDEBUG(D_ERROR, "fail to create lqs when setquota\n");
+ CERROR("fail to create lqs during setquota operation "
+ "for %sid %u\n", oqctl->qc_type ? "g" : "u",
+ oqctl->qc_id);
} else {
lqs->lqs_flags &= ~QB_SET;
lqs_putref(lqs);
lqs = quota_search_lqs(LQS_KEY(oqctl->qc_type, oqctl->qc_id),
qctxt, 1);
if (lqs == NULL || IS_ERR(lqs)){
- CDEBUG(D_ERROR, "fail to create lqs when setquota\n");
+ CERROR("fail to create lqs during setquota operation "
+ "for %sid %u\n", oqctl->qc_type ? "g" : "u",
+ oqctl->qc_id);
break;
} else {
lqs->lqs_flags |= QB_SET;
struct ptlrpc_request *req;
struct obd_quotactl *oqc;
__u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*oqctl) };
- int ver, opc, rc, resends = 0;
+ int ver, opc, rc;
ENTRY;
if (!strcmp(exp->exp_obd->obd_type->typ_name, LUSTRE_MDC_NAME)) {
RETURN(-EINVAL);
}
-restart_request:
-
req = ptlrpc_prep_req(class_exp2cliimp(exp), ver, opc, 2, size, NULL);
if (!req)
GOTO(out, rc = -ENOMEM);
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);
+ return rc;
+}
+
+struct lov_getquota_set_arg {
+ __u64 curspace;
+ __u64 bhardlimit;
+};
+
+static int lov_getquota_interpret(struct ptlrpc_request_set *rqset, void *data, int rc)
+{
+ struct lov_getquota_set_arg *set_arg = data;
+ struct ptlrpc_request *req;
+ struct list_head *pos;
+ struct obd_quotactl *oqc;
+
+ list_for_each(pos, &rqset->set_requests) {
+ req = list_entry(pos, struct ptlrpc_request, rq_set_chain);
+
+ if (req->rq_status)
+ continue;
+
+ oqc = NULL;
+ if (req->rq_repmsg)
+ oqc = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*oqc),
+ lustre_swab_obd_quotactl);
- if (client_quota_recoverable_error(rc)) {
- resends++;
- if (!client_quota_should_resend(resends, &exp->exp_obd->u.cli)) {
- CERROR("too many resend retries, returning error "
- "(cmd = %d, id = %u, type = %d)\n",
- oqctl->qc_cmd, oqctl->qc_id, oqctl->qc_type);
- RETURN(-EIO);
+ if (oqc == NULL) {
+ CERROR("Can't unpack obd_quotactl\n");
+ rc = -EPROTO;
+ continue;
}
- goto restart_request;
+ set_arg->curspace += oqc->qc_dqblk.dqb_curspace;
+ set_arg->bhardlimit += oqc->qc_dqblk.dqb_bhardlimit;
}
return rc;
{
struct obd_device *obd = class_exp2obd(exp);
struct lov_obd *lov = &obd->u.lov;
- __u64 curspace = 0;
- __u64 bhardlimit = 0;
- int i, rc = 0;
+ int i, rc = 0, rc1;
+ struct lov_getquota_set_arg set_arg = { 0 };
+ struct obd_export *ltd_exp;
+ struct ptlrpc_request_set *rqset;
+ __u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*oqctl) };
+
ENTRY;
if (oqctl->qc_cmd != LUSTRE_Q_QUOTAON &&
oqctl->qc_cmd != LUSTRE_Q_SETQUOTA &&
oqctl->qc_cmd != Q_FINVALIDATE) {
CERROR("bad quota opc %x for lov obd", oqctl->qc_cmd);
- RETURN(-EFAULT);
+ RETURN(-EINVAL);
}
+ rqset = ptlrpc_prep_set();
+ if (rqset == NULL)
+ RETURN(-ENOMEM);
+
obd_getref(obd);
+
for (i = 0; i < lov->desc.ld_tgt_count; i++) {
- int err;
+ struct ptlrpc_request *req;
+ struct obd_quotactl *oqc;
if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_active) {
if (oqctl->qc_cmd == Q_GETOQUOTA) {
continue;
}
- err = obd_quotactl(lov->lov_tgts[i]->ltd_exp, oqctl);
- if (err) {
- if (lov->lov_tgts[i]->ltd_active && !rc)
- rc = err;
- continue;
- }
+ ltd_exp = lov->lov_tgts[i]->ltd_exp;
- if (oqctl->qc_cmd == Q_GETOQUOTA) {
- curspace += oqctl->qc_dqblk.dqb_curspace;
- bhardlimit += oqctl->qc_dqblk.dqb_bhardlimit;
+ req = ptlrpc_prep_req(class_exp2cliimp(ltd_exp),
+ LUSTRE_OST_VERSION,
+ OST_QUOTACTL, 2, size, NULL);
+ if (!req) {
+ obd_putref(obd);
+ GOTO(out, rc = -ENOMEM);
}
+
+ oqc = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*oqctl));
+ *oqc = *oqctl;
+
+ ptlrpc_req_set_repsize(req, 2, size);
+ ptlrpc_at_set_req_timeout(req);
+ req->rq_no_resend = 1;
+ req->rq_no_delay = 1;
+
+ ptlrpc_set_add_req(rqset, req);
}
+
obd_putref(obd);
if (oqctl->qc_cmd == Q_GETOQUOTA) {
- oqctl->qc_dqblk.dqb_curspace = curspace;
- oqctl->qc_dqblk.dqb_bhardlimit = bhardlimit;
+ rqset->set_interpret = lov_getquota_interpret;
+ rqset->set_arg = &set_arg;
}
+ rc1 = ptlrpc_set_wait(rqset);
+ rc = rc1 ? rc1 : rc;
+
+out:
+ ptlrpc_set_destroy(rqset);
+ oqctl->qc_dqblk.dqb_curspace = set_arg.curspace;
+ oqctl->qc_dqblk.dqb_bhardlimit = set_arg.bhardlimit;
+
RETURN(rc);
}