4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 021110-1307, USA
24 * Copyright (c) 2012, 2017, Intel Corporation.
25 * Use is subject to license terms.
27 * Author: Johann Lombardi <johann.lombardi@intel.com>
28 * Author: Niu Yawei <yawei.niu@intel.com>
31 #define DEBUG_SUBSYSTEM S_LQUOTA
33 #include <obd_class.h>
34 #include "qmt_internal.h"
37 * Retrieve quota settings for a given identifier.
39 * \param env - is the environment passed by the caller
40 * \param qmt - is the quota master target
41 * \param pool_id - is the 16-bit pool identifier
42 * \param restype - is the pool type, either block (i.e. LQUOTA_RES_DT) or inode
43 * (i.e. LQUOTA_RES_MD)
44 * \param qtype - is the quota type
45 * \param id - is the quota indentifier for which we want to acces quota
47 * \param hard - is the output variable where to copy the hard limit
48 * \param soft - is the output variable where to copy the soft limit
49 * \param time - is the output variable where to copy the grace time
51 static int qmt_get(const struct lu_env *env, struct qmt_device *qmt,
52 __u16 pool_id, __u8 restype, __u8 qtype, union lquota_id *id,
53 __u64 *hard, __u64 *soft, __u64 *time, bool is_default)
55 struct lquota_entry *lqe;
58 LASSERT(!is_default || id->qid_uid == 0);
60 /* look-up lqe structure containing quota settings */
61 lqe = qmt_pool_lqe_lookup(env, qmt, pool_id, restype, qtype, id);
65 /* copy quota settings */
67 LQUOTA_DEBUG(lqe, "fetch settings");
69 *hard = lqe->lqe_hardlimit;
71 *soft = lqe->lqe_softlimit;
73 *time = lqe->lqe_gracetime;
74 if (lqe->lqe_is_default)
75 *time |= (__u64)LQUOTA_FLAG_DEFAULT <<
84 struct qmt_entry_iter_data {
85 const struct lu_env *qeid_env;
86 struct qmt_device *qeid_qmt;
89 static int qmt_entry_iter_cb(struct cfs_hash *hs, struct cfs_hash_bd *bd,
90 struct hlist_node *hnode, void *d)
92 struct qmt_entry_iter_data *iter = (struct qmt_entry_iter_data *)d;
93 struct lquota_entry *lqe;
95 lqe = hlist_entry(hnode, struct lquota_entry, lqe_hash);
96 LASSERT(atomic_read(&lqe->lqe_ref) > 0);
98 if (lqe->lqe_id.qid_uid == 0 || !lqe->lqe_is_default)
101 return qmt_set_with_lqe(iter->qeid_env, iter->qeid_qmt, lqe, 0, 0, 0, 0,
106 * Update quota settings for a given lqe.
108 * \param env - is the environment passed by the caller
109 * \param qmt - is the quota master target
110 * \param lqe - is the lquota_entry for which we want to modify quota
112 * \param hard - is the new hard limit
113 * \param soft - is the new soft limit
114 * \param time - is the new grace time
115 * \param valid - is the list of settings to change
116 * \param is_default - true for default quota setting
117 * \param is_updated - true if the lqe is updated and no need to write back
120 int qmt_set_with_lqe(const struct lu_env *env, struct qmt_device *qmt,
121 struct lquota_entry *lqe, __u64 hard, __u64 soft,
122 __u64 time, __u32 valid, bool is_default, bool is_updated)
124 struct qmt_thread_info *qti = qmt_info(env);
125 struct thandle *th = NULL;
128 bool dirtied = false;
132 /* need to write back to global quota file? */
134 /* allocate & start transaction with enough credits to update
135 * quota settings in the global index file */
136 th = qmt_trans_start(env, lqe, &qti->qti_restore);
138 GOTO(out_nolock, rc = PTR_ERR(th));
141 now = ktime_get_real_seconds();
144 LQUOTA_DEBUG(lqe, "changing quota settings valid:%x hard:%llu soft:"
145 "%llu time:%llu", valid, hard, soft, time);
147 if (is_default && lqe->lqe_id.qid_uid != 0) {
148 LQUOTA_DEBUG(lqe, "set qid %llu to use default quota setting",
149 lqe->lqe_id.qid_uid);
151 qmt_lqe_set_default(env, lqe->lqe_site->lqs_parent, lqe, false);
155 if ((valid & QIF_TIMES) != 0 && lqe->lqe_gracetime != time) {
156 /* change time settings */
157 lqe->lqe_gracetime = time;
161 if ((valid & QIF_LIMITS) != 0 &&
162 (lqe->lqe_hardlimit != hard || lqe->lqe_softlimit != soft)) {
163 rc = qmt_validate_limits(lqe, hard, soft);
167 /* change quota limits */
168 lqe->lqe_hardlimit = hard;
169 lqe->lqe_softlimit = soft;
172 /* recompute qunit in case it was never initialized */
173 qmt_revalidate(env, lqe);
175 /* clear grace time */
176 if (lqe->lqe_softlimit == 0 ||
177 lqe->lqe_granted <= lqe->lqe_softlimit)
178 /* no soft limit or below soft limit, let's clear grace
180 lqe->lqe_gracetime = 0;
181 else if ((valid & QIF_TIMES) == 0)
182 /* set grace only if user hasn't provided his own */
183 lqe->lqe_gracetime = now + qmt_lqe_grace(lqe);
185 /* change enforced status based on new parameters */
186 if (lqe->lqe_id.qid_uid == 0 || (lqe->lqe_hardlimit == 0 &&
187 lqe->lqe_softlimit == 0))
188 lqe->lqe_enforced = false;
190 lqe->lqe_enforced = true;
196 if (!is_default && lqe->lqe_is_default) {
197 LQUOTA_DEBUG(lqe, "the qid %llu has been set quota"
198 " explicitly, clear the default flag",
199 lqe->lqe_id.qid_uid);
201 qmt_lqe_clear_default(lqe);
205 /* write new quota settings to disk */
206 rc = qmt_glb_write(env, th, lqe, LQUOTA_BUMP_VER, &ver);
208 /* restore initial quota settings */
209 qmt_restore(lqe, &qti->qti_restore);
213 ver = dt_version_get(env, LQE_GLB_OBJ(lqe));
216 /* compute new qunit value now that we have modified the quota
218 qmt_adjust_qunit(env, lqe);
220 /* clear/set edquot flag as needed */
221 qmt_adjust_edquot(lqe, now);
225 lqe_write_unlock(lqe);
228 if (th != NULL && !IS_ERR(th))
229 dt_trans_stop(env, qmt->qmt_child, th);
231 if (rc == 0 && dirtied) {
232 qmt_glb_lock_notify(env, lqe, ver);
233 if (lqe->lqe_id.qid_uid == 0) {
234 struct qmt_entry_iter_data iter_data;
236 LQUOTA_DEBUG(lqe, "notify all lqe with default quota");
237 iter_data.qeid_env = env;
238 iter_data.qeid_qmt = qmt;
239 cfs_hash_for_each_safe(lqe->lqe_site->lqs_hash,
240 qmt_entry_iter_cb, &iter_data);
248 * Update quota settings for a given identifier.
250 * \param env - is the environment passed by the caller
251 * \param qmt - is the quota master target
252 * \param pool_id - is the 16-bit pool identifier
253 * \param restype - is the pool type, either block (i.e. LQUOTA_RES_DT) or
254 * inode (i.e. LQUOTA_RES_MD)
255 * \param qtype - is the quota type
256 * \param id - is the quota indentifier for which we want to modify
258 * \param hard - is the new hard limit
259 * \param soft - is the new soft limit
260 * \param time - is the new grace time
261 * \param valid - is the list of settings to change
262 * \param is_default - true for default quota setting
263 * \param is_updated - true if the lqe is updated and no need to write back
265 static int qmt_set(const struct lu_env *env, struct qmt_device *qmt,
266 __u16 pool_id, __u8 restype, __u8 qtype,
267 union lquota_id *id, __u64 hard, __u64 soft, __u64 time,
268 __u32 valid, bool is_default, bool is_updated)
270 struct lquota_entry *lqe;
274 /* look-up quota entry associated with this ID */
275 lqe = qmt_pool_lqe_lookup(env, qmt, pool_id, restype, qtype, id);
277 RETURN(PTR_ERR(lqe));
279 rc = qmt_set_with_lqe(env, qmt, lqe, hard, soft, time, valid,
280 is_default, is_updated);
287 * Handle quotactl request.
289 * \param env - is the environment passed by the caller
290 * \param ld - is the lu device associated with the qmt
291 * \param oqctl - is the quotactl request
293 static int qmt_quotactl(const struct lu_env *env, struct lu_device *ld,
294 struct obd_quotactl *oqctl)
296 struct qmt_thread_info *qti = qmt_info(env);
297 union lquota_id *id = &qti->qti_id;
298 struct qmt_device *qmt = lu2qmt_dev(ld);
299 struct obd_dqblk *dqb = &oqctl->qc_dqblk;
301 bool is_default = false;
304 LASSERT(qmt != NULL);
306 if (oqctl->qc_type >= LL_MAXQUOTAS)
307 /* invalid quota type */
310 switch (oqctl->qc_cmd) {
312 case Q_GETINFO: /* read grace times */
313 /* Global grace time is stored in quota settings of ID 0. */
316 /* read inode grace time */
317 rc = qmt_get(env, qmt, 0, LQUOTA_RES_MD, oqctl->qc_type, id,
318 NULL, NULL, &oqctl->qc_dqinfo.dqi_igrace, false);
322 /* read block grace time */
323 rc = qmt_get(env, qmt, 0, LQUOTA_RES_DT, oqctl->qc_type, id,
324 NULL, NULL, &oqctl->qc_dqinfo.dqi_bgrace, false);
327 case Q_SETINFO: /* modify grace times */
328 /* setinfo should be using dqi->dqi_valid, but lfs incorrectly
329 * sets the valid flags in dqb->dqb_valid instead, try to live
332 /* Global grace time is stored in quota settings of ID 0. */
335 if ((dqb->dqb_valid & QIF_ITIME) != 0) {
336 /* set inode grace time */
337 rc = qmt_set(env, qmt, 0, LQUOTA_RES_MD, oqctl->qc_type,
338 id, 0, 0, oqctl->qc_dqinfo.dqi_igrace,
339 QIF_TIMES, false, false);
344 if ((dqb->dqb_valid & QIF_BTIME) != 0)
345 /* set block grace time */
346 rc = qmt_set(env, qmt, 0, LQUOTA_RES_DT, oqctl->qc_type,
347 id, 0, 0, oqctl->qc_dqinfo.dqi_bgrace,
348 QIF_TIMES, false, false);
351 case LUSTRE_Q_GETDEFAULT:
354 case Q_GETQUOTA: /* consult quota limit */
355 /* extract quota ID from quotactl request */
356 id->qid_uid = oqctl->qc_id;
358 /* look-up inode quota settings */
359 rc = qmt_get(env, qmt, 0, LQUOTA_RES_MD, oqctl->qc_type, id,
360 &dqb->dqb_ihardlimit, &dqb->dqb_isoftlimit,
361 &dqb->dqb_itime, is_default);
365 dqb->dqb_valid |= QIF_ILIMITS | QIF_ITIME;
366 /* master isn't aware of actual inode usage */
367 dqb->dqb_curinodes = 0;
369 /* look-up block quota settings */
370 rc = qmt_get(env, qmt, 0, LQUOTA_RES_DT, oqctl->qc_type, id,
371 &dqb->dqb_bhardlimit, &dqb->dqb_bsoftlimit,
372 &dqb->dqb_btime, is_default);
376 dqb->dqb_valid |= QIF_BLIMITS | QIF_BTIME;
377 /* master doesn't know the actual block usage */
378 dqb->dqb_curspace = 0;
381 case LUSTRE_Q_SETDEFAULT:
384 case Q_SETQUOTA: /* change quota limits */
385 /* extract quota ID from quotactl request */
386 id->qid_uid = oqctl->qc_id;
388 if ((dqb->dqb_valid & QIF_IFLAGS) != 0) {
389 /* update inode quota settings */
390 rc = qmt_set(env, qmt, 0, LQUOTA_RES_MD, oqctl->qc_type,
391 id, dqb->dqb_ihardlimit,
392 dqb->dqb_isoftlimit, dqb->dqb_itime,
393 dqb->dqb_valid & QIF_IFLAGS, is_default,
399 if ((dqb->dqb_valid & QIF_BFLAGS) != 0)
400 /* update block quota settings */
401 rc = qmt_set(env, qmt, 0, LQUOTA_RES_DT, oqctl->qc_type,
402 id, dqb->dqb_bhardlimit,
403 dqb->dqb_bsoftlimit, dqb->dqb_btime,
404 dqb->dqb_valid & QIF_BFLAGS, is_default,
409 CERROR("%s: unsupported quotactl command: %d\n",
410 qmt->qmt_svname, oqctl->qc_cmd);
418 * Helper function to handle quota request from slave.
420 * \param env - is the environment passed by the caller
421 * \param lqe - is the lquota_entry subject to the quota request
422 * \param qmt - is the master device
423 * \param uuid - is the uuid associated with the slave
424 * \param qb_flags - are the quota request flags as packed in the quota_body
425 * \param qb_count - is the amount of quota space the slave wants to
427 * \param qb_usage - is the current space usage on the slave
428 * \param repbody - is the quota_body of reply
430 * \retval 0 : success
431 * \retval -EDQUOT : out of quota
432 * -EINPROGRESS : inform client to retry write/create
433 * -ve : other appropriate errors
435 int qmt_dqacq0(const struct lu_env *env, struct lquota_entry *lqe,
436 struct qmt_device *qmt, struct obd_uuid *uuid, __u32 qb_flags,
437 __u64 qb_count, __u64 qb_usage, struct quota_body *repbody)
439 struct qmt_thread_info *qti = qmt_info(env);
441 struct dt_object *slv_obj = NULL;
442 __u64 slv_granted, slv_granted_bck;
443 struct thandle *th = NULL;
447 LASSERT(uuid != NULL);
449 /* initialize reply */
450 memset(repbody, 0, sizeof(*repbody));
451 memcpy(&repbody->qb_id, &lqe->lqe_id, sizeof(repbody->qb_id));
453 if (OBD_FAIL_CHECK(OBD_FAIL_QUOTA_RECOVERABLE_ERR))
454 RETURN(-cfs_fail_val);
456 /* look-up index file associated with acquiring slave */
457 slv_obj = lquota_disk_slv_find(env, qmt->qmt_child, LQE_ROOT(lqe),
458 lu_object_fid(&LQE_GLB_OBJ(lqe)->do_lu),
461 GOTO(out, rc = PTR_ERR(slv_obj));
463 /* pack slave fid in reply just for sanity check */
464 memcpy(&repbody->qb_slv_fid, lu_object_fid(&slv_obj->do_lu),
465 sizeof(struct lu_fid));
467 /* allocate & start transaction with enough credits to update
468 * global & slave indexes */
469 th = qmt_trans_start_with_slv(env, lqe, slv_obj, &qti->qti_restore);
471 GOTO(out, rc = PTR_ERR(th));
474 LQUOTA_DEBUG(lqe, "dqacq starts uuid:%s flags:0x%x wanted:%llu"
475 " usage:%llu", obd_uuid2str(uuid), qb_flags, qb_count,
478 /* Legal race, limits have been removed on master, but slave didn't
479 * receive the change yet. Just return EINPROGRESS until the slave gets
481 if (!lqe->lqe_enforced && !req_is_rel(qb_flags))
482 GOTO(out_locked, rc = -ESRCH);
484 /* recompute qunit in case it was never initialized */
485 qmt_revalidate(env, lqe);
487 /* slave just wants to acquire per-ID lock */
488 if (req_is_acq(qb_flags) && qb_count == 0)
489 GOTO(out_locked, rc = 0);
491 /* fetch how much quota space is already granted to this slave */
492 rc = qmt_slv_read(env, lqe, slv_obj, &slv_granted);
494 LQUOTA_ERROR(lqe, "Failed to get granted for slave %s, rc=%d",
495 obd_uuid2str(uuid), rc);
496 GOTO(out_locked, rc);
498 /* recall how much space this slave currently owns in order to restore
499 * it in case of failure */
500 slv_granted_bck = slv_granted;
502 /* record current time for soft limit & grace time management */
503 now = ktime_get_real_seconds();
505 if (req_is_rel(qb_flags)) {
506 /* Slave would like to release quota space */
507 if (slv_granted < qb_count ||
508 lqe->lqe_granted < qb_count) {
509 /* can't release more than granted */
510 LQUOTA_ERROR(lqe, "Release too much! uuid:%s release:"
511 "%llu granted:%llu, total:%llu",
512 obd_uuid2str(uuid), qb_count,
513 slv_granted, lqe->lqe_granted);
514 GOTO(out_locked, rc = -EINVAL);
517 repbody->qb_count = qb_count;
518 /* put released space back to global pool */
519 QMT_REL(lqe, slv_granted, qb_count);
520 GOTO(out_write, rc = 0);
523 if (req_has_rep(qb_flags) && slv_granted < qb_usage) {
524 /* Slave is reporting space usage in quota request and it turns
525 * out to be using more quota space than owned, so we adjust
526 * granted space regardless of the current state of affairs */
527 repbody->qb_count = qb_usage - slv_granted;
528 QMT_GRANT(lqe, slv_granted, repbody->qb_count);
531 if (!req_is_acq(qb_flags) && !req_is_preacq(qb_flags))
532 GOTO(out_write, rc = 0);
534 qmt_adjust_edquot(lqe, now);
536 /* no hope to claim further space back */
537 GOTO(out_write, rc = -EDQUOT);
539 if (qmt_space_exhausted(lqe, now)) {
540 /* might have some free space once rebalancing is completed */
541 rc = req_is_acq(qb_flags) ? -EINPROGRESS : -EDQUOT;
545 if (req_is_preacq(qb_flags)) {
546 /* slave would like to pre-acquire quota space. To do so, it
547 * reports in qb_count how much spare quota space it owns and we
548 * can grant back quota space which is consistent with qunit
551 if (qb_count >= lqe->lqe_qunit)
552 /* slave already own the maximum it should */
553 GOTO(out_write, rc = 0);
555 count = qmt_alloc_expand(lqe, slv_granted, qb_count);
557 GOTO(out_write, rc = -EDQUOT);
559 repbody->qb_count += count;
560 QMT_GRANT(lqe, slv_granted, count);
561 GOTO(out_write, rc = 0);
564 /* processing acquire request with clients waiting */
565 if (lqe->lqe_hardlimit != 0 &&
566 lqe->lqe_granted + qb_count > lqe->lqe_hardlimit) {
567 /* cannot grant as much as asked, but can still afford to grant
568 * some quota space back */
569 count = lqe->lqe_hardlimit - lqe->lqe_granted;
570 repbody->qb_count += count;
571 QMT_GRANT(lqe, slv_granted, count);
572 GOTO(out_write, rc = 0);
575 /* Whouhou! we can satisfy the slave request! */
576 repbody->qb_count += qb_count;
577 QMT_GRANT(lqe, slv_granted, qb_count);
579 /* Try to expand the acquired count for DQACQ */
580 count = qmt_alloc_expand(lqe, slv_granted, 0);
582 /* can even grant more than asked, it is like xmas ... */
583 repbody->qb_count += count;
584 QMT_GRANT(lqe, slv_granted, count);
585 GOTO(out_write, rc = 0);
588 GOTO(out_write, rc = 0);
590 if (repbody->qb_count == 0)
591 GOTO(out_locked, rc);
593 /* start/stop grace timer if required */
594 if (lqe->lqe_softlimit != 0) {
595 if (lqe->lqe_granted > lqe->lqe_softlimit &&
596 lqe->lqe_gracetime == 0)
597 /* first time over soft limit, let's start grace
599 lqe->lqe_gracetime = now + qmt_lqe_grace(lqe);
600 else if (lqe->lqe_granted <= lqe->lqe_softlimit &&
601 lqe->lqe_gracetime != 0)
602 /* Clear grace timer */
603 lqe->lqe_gracetime = 0;
606 /* Update slave index first since it is easier to roll back */
607 ret = qmt_slv_write(env, th, lqe, slv_obj, LQUOTA_BUMP_VER,
608 &repbody->qb_slv_ver, slv_granted);
610 /* restore initial quota settings */
611 qmt_restore(lqe, &qti->qti_restore);
613 repbody->qb_count = 0;
614 GOTO(out_locked, rc = ret);
617 /* Update global index, no version bump needed */
618 ret = qmt_glb_write(env, th, lqe, 0, NULL);
621 /* restore initial quota settings */
622 qmt_restore(lqe, &qti->qti_restore);
624 repbody->qb_count = 0;
626 /* restore previous granted value */
627 ret = qmt_slv_write(env, th, lqe, slv_obj, 0, NULL,
630 LQUOTA_ERROR(lqe, "failed to restore initial slave "
631 "value rc:%d ret%d", rc, ret);
634 qmt_adjust_edquot(lqe, now);
635 GOTO(out_locked, rc);
638 /* Total granted has been changed, let's try to adjust the qunit
639 * size according to the total granted & limits. */
640 qmt_adjust_qunit(env, lqe);
642 /* clear/set edquot flag and notify slaves via glimpse if needed */
643 qmt_adjust_edquot(lqe, now);
645 LQUOTA_DEBUG(lqe, "dqacq ends count:%llu ver:%llu rc:%d",
646 repbody->qb_count, repbody->qb_slv_ver, rc);
647 lqe_write_unlock(lqe);
649 if (th != NULL && !IS_ERR(th))
650 dt_trans_stop(env, qmt->qmt_child, th);
652 if (slv_obj != NULL && !IS_ERR(slv_obj))
653 dt_object_put(env, slv_obj);
655 if ((req_is_acq(qb_flags) || req_is_preacq(qb_flags)) &&
656 OBD_FAIL_CHECK(OBD_FAIL_QUOTA_EDQUOT)) {
657 /* introduce inconsistency between granted value in slave index
658 * and slave index copy of slave */
659 repbody->qb_count = 0;
667 * Handle quota request from slave.
669 * \param env - is the environment passed by the caller
670 * \param ld - is the lu device associated with the qmt
671 * \param req - is the quota acquire request
673 static int qmt_dqacq(const struct lu_env *env, struct lu_device *ld,
674 struct ptlrpc_request *req)
676 struct qmt_device *qmt = lu2qmt_dev(ld);
677 struct quota_body *qbody, *repbody;
678 struct obd_uuid *uuid;
679 struct ldlm_lock *lock;
680 struct lquota_entry *lqe;
681 int pool_id, pool_type, qtype;
685 qbody = req_capsule_client_get(&req->rq_pill, &RMF_QUOTA_BODY);
687 RETURN(err_serious(-EPROTO));
689 repbody = req_capsule_server_get(&req->rq_pill, &RMF_QUOTA_BODY);
691 RETURN(err_serious(-EFAULT));
693 /* verify if global lock is stale */
694 if (!lustre_handle_is_used(&qbody->qb_glb_lockh))
697 lock = ldlm_handle2lock(&qbody->qb_glb_lockh);
702 uuid = &req->rq_export->exp_client_uuid;
704 if (req_is_rel(qbody->qb_flags) + req_is_acq(qbody->qb_flags) +
705 req_is_preacq(qbody->qb_flags) > 1) {
706 CERROR("%s: malformed quota request with conflicting flags set "
707 "(%x) from slave %s\n", qmt->qmt_svname,
708 qbody->qb_flags, obd_uuid2str(uuid));
712 if (req_is_acq(qbody->qb_flags) || req_is_preacq(qbody->qb_flags)) {
713 /* acquire and pre-acquire should use a valid ID lock */
715 if (!lustre_handle_is_used(&qbody->qb_lockh))
718 lock = ldlm_handle2lock(&qbody->qb_lockh);
720 /* no lock associated with this handle */
723 LDLM_DEBUG(lock, "%sacquire request",
724 req_is_preacq(qbody->qb_flags) ? "pre" : "");
726 if (!obd_uuid_equals(&lock->l_export->exp_client_uuid, uuid)) {
727 /* sorry, no way to cheat ... */
732 if (ldlm_is_ast_sent(lock)) {
733 struct ptlrpc_service_part *svc;
736 svc = req->rq_rqbd->rqbd_svcpt;
737 timeout = at_est2timeout(at_get(&svc->scp_at_estimate));
738 timeout += (ldlm_bl_timeout(lock) >> 1);
740 /* lock is being cancelled, prolong timeout */
741 ldlm_refresh_waiting_lock(lock, timeout);
746 /* extract pool & quota information from global index FID packed in the
748 rc = lquota_extract_fid(&qbody->qb_fid, &pool_id, &pool_type, &qtype);
752 /* Find the quota entry associated with the quota id */
753 lqe = qmt_pool_lqe_lookup(env, qmt, pool_id, pool_type, qtype,
756 RETURN(PTR_ERR(lqe));
758 /* process quota request */
759 rc = qmt_dqacq0(env, lqe, qmt, uuid, qbody->qb_flags, qbody->qb_count,
760 qbody->qb_usage, repbody);
762 if (lustre_handle_is_used(&qbody->qb_lockh))
763 /* return current qunit value only to slaves owning an per-ID
764 * quota lock. For enqueue, the qunit value will be returned in
766 repbody->qb_qunit = lqe->lqe_qunit;
771 /* Vector of quota request handlers. This vector is used by the MDT to forward
772 * requests to the quota master. */
773 struct qmt_handlers qmt_hdls = {
774 /* quota request handlers */
775 .qmth_quotactl = qmt_quotactl,
776 .qmth_dqacq = qmt_dqacq,
779 .qmth_intent_policy = qmt_intent_policy,
780 .qmth_lvbo_init = qmt_lvbo_init,
781 .qmth_lvbo_update = qmt_lvbo_update,
782 .qmth_lvbo_size = qmt_lvbo_size,
783 .qmth_lvbo_fill = qmt_lvbo_fill,
784 .qmth_lvbo_free = qmt_lvbo_free,
786 EXPORT_SYMBOL(qmt_hdls);