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 restype - is the pool type, either block (i.e. LQUOTA_RES_DT) or inode
42 * (i.e. LQUOTA_RES_MD)
43 * \param qtype - is the quota type
44 * \param id - is the quota indentifier for which we want to acces quota
46 * \param hard - is the output variable where to copy the hard limit
47 * \param soft - is the output variable where to copy the soft limit
48 * \param time - is the output variable where to copy the grace time
50 static int qmt_get(const struct lu_env *env, struct qmt_device *qmt,
51 __u8 restype, __u8 qtype, union lquota_id *id,
52 __u64 *hard, __u64 *soft, __u64 *time, bool is_default)
54 struct lquota_entry *lqe;
57 LASSERT(!is_default || id->qid_uid == 0);
59 /* look-up lqe structure containing quota settings */
60 lqe = qmt_pool_lqe_lookup(env, qmt, restype, qtype, id);
64 /* copy quota settings */
66 LQUOTA_DEBUG(lqe, "fetch settings");
68 *hard = lqe->lqe_hardlimit;
70 *soft = lqe->lqe_softlimit;
72 *time = lqe->lqe_gracetime;
73 if (lqe->lqe_is_default)
74 *time |= (__u64)LQUOTA_FLAG_DEFAULT <<
83 struct qmt_entry_iter_data {
84 const struct lu_env *qeid_env;
85 struct qmt_device *qeid_qmt;
88 static int qmt_entry_iter_cb(struct cfs_hash *hs, struct cfs_hash_bd *bd,
89 struct hlist_node *hnode, void *d)
91 struct qmt_entry_iter_data *iter = (struct qmt_entry_iter_data *)d;
92 struct lquota_entry *lqe;
94 lqe = hlist_entry(hnode, struct lquota_entry, lqe_hash);
95 LASSERT(atomic_read(&lqe->lqe_ref) > 0);
97 if (lqe->lqe_id.qid_uid == 0 || !lqe->lqe_is_default)
100 return qmt_set_with_lqe(iter->qeid_env, iter->qeid_qmt, lqe, 0, 0, 0, 0,
105 * Update quota settings for a given lqe.
107 * \param env - is the environment passed by the caller
108 * \param qmt - is the quota master target
109 * \param lqe - is the lquota_entry for which we want to modify quota
111 * \param hard - is the new hard limit
112 * \param soft - is the new soft limit
113 * \param time - is the new grace time
114 * \param valid - is the list of settings to change
115 * \param is_default - true for default quota setting
116 * \param is_updated - true if the lqe is updated and no need to write back
119 int qmt_set_with_lqe(const struct lu_env *env, struct qmt_device *qmt,
120 struct lquota_entry *lqe, __u64 hard, __u64 soft,
121 __u64 time, __u32 valid, bool is_default, bool is_updated)
123 struct qmt_thread_info *qti = qmt_info(env);
124 struct thandle *th = NULL;
127 bool dirtied = false;
131 /* need to write back to global quota file? */
133 /* allocate & start transaction with enough credits to update
134 * quota settings in the global index file */
135 th = qmt_trans_start(env, lqe, &qti->qti_restore);
137 GOTO(out_nolock, rc = PTR_ERR(th));
140 now = ktime_get_real_seconds();
143 LQUOTA_DEBUG(lqe, "changing quota settings valid:%x hard:%llu soft:"
144 "%llu time:%llu", valid, hard, soft, time);
146 if (is_default && lqe->lqe_id.qid_uid != 0) {
147 LQUOTA_DEBUG(lqe, "set qid %llu to use default quota setting",
148 lqe->lqe_id.qid_uid);
150 qmt_lqe_set_default(env, lqe->lqe_site->lqs_parent, lqe, false);
154 if ((valid & QIF_TIMES) != 0 && lqe->lqe_gracetime != time) {
155 /* change time settings */
156 lqe->lqe_gracetime = time;
160 if ((valid & QIF_LIMITS) != 0 &&
161 (lqe->lqe_hardlimit != hard || lqe->lqe_softlimit != soft)) {
162 rc = qmt_validate_limits(lqe, hard, soft);
166 /* change quota limits */
167 lqe->lqe_hardlimit = hard;
168 lqe->lqe_softlimit = soft;
171 /* recompute qunit in case it was never initialized */
172 qmt_revalidate(env, lqe);
174 /* clear grace time */
175 if (lqe->lqe_softlimit == 0 ||
176 lqe->lqe_granted <= lqe->lqe_softlimit)
177 /* no soft limit or below soft limit, let's clear grace
179 lqe->lqe_gracetime = 0;
180 else if ((valid & QIF_TIMES) == 0)
181 /* set grace only if user hasn't provided his own */
182 lqe->lqe_gracetime = now + qmt_lqe_grace(lqe);
184 /* change enforced status based on new parameters */
185 if (lqe->lqe_id.qid_uid == 0 || (lqe->lqe_hardlimit == 0 &&
186 lqe->lqe_softlimit == 0))
187 lqe->lqe_enforced = false;
189 lqe->lqe_enforced = true;
195 if (!is_default && lqe->lqe_is_default) {
196 LQUOTA_DEBUG(lqe, "the qid %llu has been set quota"
197 " explicitly, clear the default flag",
198 lqe->lqe_id.qid_uid);
200 qmt_lqe_clear_default(lqe);
204 /* write new quota settings to disk */
205 rc = qmt_glb_write(env, th, lqe, LQUOTA_BUMP_VER, &ver);
207 /* restore initial quota settings */
208 qmt_restore(lqe, &qti->qti_restore);
212 ver = dt_version_get(env, LQE_GLB_OBJ(lqe));
215 /* compute new qunit value now that we have modified the quota
217 qmt_adjust_qunit(env, lqe);
219 /* clear/set edquot flag as needed */
220 qmt_adjust_edquot(lqe, now);
224 lqe_write_unlock(lqe);
227 if (th != NULL && !IS_ERR(th))
228 dt_trans_stop(env, qmt->qmt_child, th);
230 if (rc == 0 && dirtied) {
231 qmt_glb_lock_notify(env, lqe, ver);
232 if (lqe->lqe_id.qid_uid == 0) {
233 struct qmt_entry_iter_data iter_data;
235 LQUOTA_DEBUG(lqe, "notify all lqe with default quota");
236 iter_data.qeid_env = env;
237 iter_data.qeid_qmt = qmt;
238 cfs_hash_for_each_safe(lqe->lqe_site->lqs_hash,
239 qmt_entry_iter_cb, &iter_data);
247 * Update quota settings for a given identifier.
249 * \param env - is the environment passed by the caller
250 * \param qmt - is the quota master target
251 * \param restype - is the pool type, either block (i.e. LQUOTA_RES_DT) or
252 * inode (i.e. LQUOTA_RES_MD)
253 * \param qtype - is the quota type
254 * \param id - is the quota indentifier for which we want to modify
256 * \param hard - is the new hard limit
257 * \param soft - is the new soft limit
258 * \param time - is the new grace time
259 * \param valid - is the list of settings to change
260 * \param is_default - true for default quota setting
261 * \param is_updated - true if the lqe is updated and no need to write back
263 static int qmt_set(const struct lu_env *env, struct qmt_device *qmt,
264 __u8 restype, __u8 qtype, union lquota_id *id,
265 __u64 hard, __u64 soft, __u64 time, __u32 valid,
266 bool is_default, bool is_updated)
268 struct lquota_entry *lqe;
272 /* look-up quota entry associated with this ID */
273 lqe = qmt_pool_lqe_lookup(env, qmt, restype, qtype, id);
275 RETURN(PTR_ERR(lqe));
277 rc = qmt_set_with_lqe(env, qmt, lqe, hard, soft, time, valid,
278 is_default, is_updated);
285 * Handle quotactl request.
287 * \param env - is the environment passed by the caller
288 * \param ld - is the lu device associated with the qmt
289 * \param oqctl - is the quotactl request
291 static int qmt_quotactl(const struct lu_env *env, struct lu_device *ld,
292 struct obd_quotactl *oqctl)
294 struct qmt_thread_info *qti = qmt_info(env);
295 union lquota_id *id = &qti->qti_id;
296 struct qmt_device *qmt = lu2qmt_dev(ld);
297 struct obd_dqblk *dqb = &oqctl->qc_dqblk;
299 bool is_default = false;
302 LASSERT(qmt != NULL);
304 if (oqctl->qc_type >= LL_MAXQUOTAS)
305 /* invalid quota type */
308 switch (oqctl->qc_cmd) {
310 case Q_GETINFO: /* read grace times */
311 /* Global grace time is stored in quota settings of ID 0. */
314 /* read inode grace time */
315 rc = qmt_get(env, qmt, LQUOTA_RES_MD, oqctl->qc_type, id,
316 NULL, NULL, &oqctl->qc_dqinfo.dqi_igrace, false);
320 /* read block grace time */
321 rc = qmt_get(env, qmt, LQUOTA_RES_DT, oqctl->qc_type, id,
322 NULL, NULL, &oqctl->qc_dqinfo.dqi_bgrace, false);
325 case Q_SETINFO: /* modify grace times */
326 /* setinfo should be using dqi->dqi_valid, but lfs incorrectly
327 * sets the valid flags in dqb->dqb_valid instead, try to live
330 /* Global grace time is stored in quota settings of ID 0. */
333 if ((dqb->dqb_valid & QIF_ITIME) != 0) {
334 /* set inode grace time */
335 rc = qmt_set(env, qmt, LQUOTA_RES_MD, oqctl->qc_type,
336 id, 0, 0, oqctl->qc_dqinfo.dqi_igrace,
337 QIF_TIMES, false, false);
342 if ((dqb->dqb_valid & QIF_BTIME) != 0)
343 /* set block grace time */
344 rc = qmt_set(env, qmt, LQUOTA_RES_DT, oqctl->qc_type,
345 id, 0, 0, oqctl->qc_dqinfo.dqi_bgrace,
346 QIF_TIMES, false, false);
349 case LUSTRE_Q_GETDEFAULT:
352 case Q_GETQUOTA: /* consult quota limit */
353 /* extract quota ID from quotactl request */
354 id->qid_uid = oqctl->qc_id;
356 /* look-up inode quota settings */
357 rc = qmt_get(env, qmt, LQUOTA_RES_MD, oqctl->qc_type, id,
358 &dqb->dqb_ihardlimit, &dqb->dqb_isoftlimit,
359 &dqb->dqb_itime, is_default);
363 dqb->dqb_valid |= QIF_ILIMITS | QIF_ITIME;
364 /* master isn't aware of actual inode usage */
365 dqb->dqb_curinodes = 0;
367 /* look-up block quota settings */
368 rc = qmt_get(env, qmt, LQUOTA_RES_DT, oqctl->qc_type, id,
369 &dqb->dqb_bhardlimit, &dqb->dqb_bsoftlimit,
370 &dqb->dqb_btime, is_default);
374 dqb->dqb_valid |= QIF_BLIMITS | QIF_BTIME;
375 /* master doesn't know the actual block usage */
376 dqb->dqb_curspace = 0;
379 case LUSTRE_Q_SETDEFAULT:
382 case Q_SETQUOTA: /* change quota limits */
383 /* extract quota ID from quotactl request */
384 id->qid_uid = oqctl->qc_id;
386 if ((dqb->dqb_valid & QIF_IFLAGS) != 0) {
387 /* update inode quota settings */
388 rc = qmt_set(env, qmt, LQUOTA_RES_MD, oqctl->qc_type,
389 id, dqb->dqb_ihardlimit,
390 dqb->dqb_isoftlimit, dqb->dqb_itime,
391 dqb->dqb_valid & QIF_IFLAGS, is_default,
397 if ((dqb->dqb_valid & QIF_BFLAGS) != 0)
398 /* update block quota settings */
399 rc = qmt_set(env, qmt, LQUOTA_RES_DT, oqctl->qc_type,
400 id, dqb->dqb_bhardlimit,
401 dqb->dqb_bsoftlimit, dqb->dqb_btime,
402 dqb->dqb_valid & QIF_BFLAGS, is_default,
407 CERROR("%s: unsupported quotactl command: %d\n",
408 qmt->qmt_svname, oqctl->qc_cmd);
416 * Helper function to handle quota request from slave.
418 * \param env - is the environment passed by the caller
419 * \param lqe - is the lquota_entry subject to the quota request
420 * \param qmt - is the master device
421 * \param uuid - is the uuid associated with the slave
422 * \param qb_flags - are the quota request flags as packed in the quota_body
423 * \param qb_count - is the amount of quota space the slave wants to
425 * \param qb_usage - is the current space usage on the slave
426 * \param repbody - is the quota_body of reply
428 * \retval 0 : success
429 * \retval -EDQUOT : out of quota
430 * -EINPROGRESS : inform client to retry write/create
431 * -ve : other appropriate errors
433 int qmt_dqacq0(const struct lu_env *env, struct lquota_entry *lqe,
434 struct qmt_device *qmt, struct obd_uuid *uuid, __u32 qb_flags,
435 __u64 qb_count, __u64 qb_usage, struct quota_body *repbody)
437 struct qmt_thread_info *qti = qmt_info(env);
439 struct dt_object *slv_obj = NULL;
440 __u64 slv_granted, slv_granted_bck;
441 struct thandle *th = NULL;
445 LASSERT(uuid != NULL);
447 /* initialize reply */
448 memset(repbody, 0, sizeof(*repbody));
449 memcpy(&repbody->qb_id, &lqe->lqe_id, sizeof(repbody->qb_id));
451 if (OBD_FAIL_CHECK(OBD_FAIL_QUOTA_RECOVERABLE_ERR))
452 RETURN(-cfs_fail_val);
454 /* look-up index file associated with acquiring slave */
455 slv_obj = lquota_disk_slv_find(env, qmt->qmt_child, LQE_ROOT(lqe),
456 lu_object_fid(&LQE_GLB_OBJ(lqe)->do_lu),
459 GOTO(out, rc = PTR_ERR(slv_obj));
461 /* pack slave fid in reply just for sanity check */
462 memcpy(&repbody->qb_slv_fid, lu_object_fid(&slv_obj->do_lu),
463 sizeof(struct lu_fid));
465 /* allocate & start transaction with enough credits to update
466 * global & slave indexes */
467 th = qmt_trans_start_with_slv(env, lqe, slv_obj, &qti->qti_restore);
469 GOTO(out, rc = PTR_ERR(th));
472 LQUOTA_DEBUG(lqe, "dqacq starts uuid:%s flags:0x%x wanted:%llu"
473 " usage:%llu", obd_uuid2str(uuid), qb_flags, qb_count,
476 /* Legal race, limits have been removed on master, but slave didn't
477 * receive the change yet. Just return EINPROGRESS until the slave gets
479 if (!lqe->lqe_enforced && !req_is_rel(qb_flags))
480 GOTO(out_locked, rc = -ESRCH);
482 /* recompute qunit in case it was never initialized */
483 qmt_revalidate(env, lqe);
485 /* slave just wants to acquire per-ID lock */
486 if (req_is_acq(qb_flags) && qb_count == 0)
487 GOTO(out_locked, rc = 0);
489 /* fetch how much quota space is already granted to this slave */
490 rc = qmt_slv_read(env, lqe, slv_obj, &slv_granted);
492 LQUOTA_ERROR(lqe, "Failed to get granted for slave %s, rc=%d",
493 obd_uuid2str(uuid), rc);
494 GOTO(out_locked, rc);
496 /* recall how much space this slave currently owns in order to restore
497 * it in case of failure */
498 slv_granted_bck = slv_granted;
500 /* record current time for soft limit & grace time management */
501 now = ktime_get_real_seconds();
503 if (req_is_rel(qb_flags)) {
504 /* Slave would like to release quota space */
505 if (slv_granted < qb_count ||
506 lqe->lqe_granted < qb_count) {
507 /* can't release more than granted */
508 LQUOTA_ERROR(lqe, "Release too much! uuid:%s release:"
509 "%llu granted:%llu, total:%llu",
510 obd_uuid2str(uuid), qb_count,
511 slv_granted, lqe->lqe_granted);
512 GOTO(out_locked, rc = -EINVAL);
515 repbody->qb_count = qb_count;
516 /* put released space back to global pool */
517 QMT_REL(lqe, slv_granted, qb_count);
518 GOTO(out_write, rc = 0);
521 if (req_has_rep(qb_flags) && slv_granted < qb_usage) {
522 /* Slave is reporting space usage in quota request and it turns
523 * out to be using more quota space than owned, so we adjust
524 * granted space regardless of the current state of affairs */
525 repbody->qb_count = qb_usage - slv_granted;
526 QMT_GRANT(lqe, slv_granted, repbody->qb_count);
529 if (!req_is_acq(qb_flags) && !req_is_preacq(qb_flags))
530 GOTO(out_write, rc = 0);
532 qmt_adjust_edquot(lqe, now);
534 /* no hope to claim further space back */
535 GOTO(out_write, rc = -EDQUOT);
537 if (qmt_space_exhausted(lqe, now)) {
538 /* might have some free space once rebalancing is completed */
539 rc = req_is_acq(qb_flags) ? -EINPROGRESS : -EDQUOT;
543 if (req_is_preacq(qb_flags)) {
544 /* slave would like to pre-acquire quota space. To do so, it
545 * reports in qb_count how much spare quota space it owns and we
546 * can grant back quota space which is consistent with qunit
549 if (qb_count >= lqe->lqe_qunit)
550 /* slave already own the maximum it should */
551 GOTO(out_write, rc = 0);
553 count = qmt_alloc_expand(lqe, slv_granted, qb_count);
555 GOTO(out_write, rc = -EDQUOT);
557 repbody->qb_count += count;
558 QMT_GRANT(lqe, slv_granted, count);
559 GOTO(out_write, rc = 0);
562 /* processing acquire request with clients waiting */
563 if (lqe->lqe_hardlimit != 0 &&
564 lqe->lqe_granted + qb_count > lqe->lqe_hardlimit) {
565 /* cannot grant as much as asked, but can still afford to grant
566 * some quota space back */
567 count = lqe->lqe_hardlimit - lqe->lqe_granted;
568 repbody->qb_count += count;
569 QMT_GRANT(lqe, slv_granted, count);
570 GOTO(out_write, rc = 0);
573 /* Whouhou! we can satisfy the slave request! */
574 repbody->qb_count += qb_count;
575 QMT_GRANT(lqe, slv_granted, qb_count);
577 /* Try to expand the acquired count for DQACQ */
578 count = qmt_alloc_expand(lqe, slv_granted, 0);
580 /* can even grant more than asked, it is like xmas ... */
581 repbody->qb_count += count;
582 QMT_GRANT(lqe, slv_granted, count);
583 GOTO(out_write, rc = 0);
586 GOTO(out_write, rc = 0);
588 if (repbody->qb_count == 0)
589 GOTO(out_locked, rc);
591 /* start/stop grace timer if required */
592 if (lqe->lqe_softlimit != 0) {
593 if (lqe->lqe_granted > lqe->lqe_softlimit &&
594 lqe->lqe_gracetime == 0)
595 /* first time over soft limit, let's start grace
597 lqe->lqe_gracetime = now + qmt_lqe_grace(lqe);
598 else if (lqe->lqe_granted <= lqe->lqe_softlimit &&
599 lqe->lqe_gracetime != 0)
600 /* Clear grace timer */
601 lqe->lqe_gracetime = 0;
604 /* Update slave index first since it is easier to roll back */
605 ret = qmt_slv_write(env, th, lqe, slv_obj, LQUOTA_BUMP_VER,
606 &repbody->qb_slv_ver, slv_granted);
608 /* restore initial quota settings */
609 qmt_restore(lqe, &qti->qti_restore);
611 repbody->qb_count = 0;
612 GOTO(out_locked, rc = ret);
615 /* Update global index, no version bump needed */
616 ret = qmt_glb_write(env, th, lqe, 0, NULL);
619 /* restore initial quota settings */
620 qmt_restore(lqe, &qti->qti_restore);
622 repbody->qb_count = 0;
624 /* restore previous granted value */
625 ret = qmt_slv_write(env, th, lqe, slv_obj, 0, NULL,
628 LQUOTA_ERROR(lqe, "failed to restore initial slave "
629 "value rc:%d ret%d", rc, ret);
632 qmt_adjust_edquot(lqe, now);
633 GOTO(out_locked, rc);
636 /* Total granted has been changed, let's try to adjust the qunit
637 * size according to the total granted & limits. */
638 qmt_adjust_qunit(env, lqe);
640 /* clear/set edquot flag and notify slaves via glimpse if needed */
641 qmt_adjust_edquot(lqe, now);
643 LQUOTA_DEBUG(lqe, "dqacq ends count:%llu ver:%llu rc:%d",
644 repbody->qb_count, repbody->qb_slv_ver, rc);
645 lqe_write_unlock(lqe);
647 if (th != NULL && !IS_ERR(th))
648 dt_trans_stop(env, qmt->qmt_child, th);
650 if (slv_obj != NULL && !IS_ERR(slv_obj))
651 dt_object_put(env, slv_obj);
653 if ((req_is_acq(qb_flags) || req_is_preacq(qb_flags)) &&
654 OBD_FAIL_CHECK(OBD_FAIL_QUOTA_EDQUOT)) {
655 /* introduce inconsistency between granted value in slave index
656 * and slave index copy of slave */
657 repbody->qb_count = 0;
665 * Handle quota request from slave.
667 * \param env - is the environment passed by the caller
668 * \param ld - is the lu device associated with the qmt
669 * \param req - is the quota acquire request
671 static int qmt_dqacq(const struct lu_env *env, struct lu_device *ld,
672 struct ptlrpc_request *req)
674 struct qmt_device *qmt = lu2qmt_dev(ld);
675 struct quota_body *qbody, *repbody;
676 struct obd_uuid *uuid;
677 struct ldlm_lock *lock;
678 struct lquota_entry *lqe;
679 int pool_type, qtype;
683 qbody = req_capsule_client_get(&req->rq_pill, &RMF_QUOTA_BODY);
685 RETURN(err_serious(-EPROTO));
687 repbody = req_capsule_server_get(&req->rq_pill, &RMF_QUOTA_BODY);
689 RETURN(err_serious(-EFAULT));
691 /* verify if global lock is stale */
692 if (!lustre_handle_is_used(&qbody->qb_glb_lockh))
695 lock = ldlm_handle2lock(&qbody->qb_glb_lockh);
700 uuid = &req->rq_export->exp_client_uuid;
702 if (req_is_rel(qbody->qb_flags) + req_is_acq(qbody->qb_flags) +
703 req_is_preacq(qbody->qb_flags) > 1) {
704 CERROR("%s: malformed quota request with conflicting flags set "
705 "(%x) from slave %s\n", qmt->qmt_svname,
706 qbody->qb_flags, obd_uuid2str(uuid));
710 if (req_is_acq(qbody->qb_flags) || req_is_preacq(qbody->qb_flags)) {
711 /* acquire and pre-acquire should use a valid ID lock */
713 if (!lustre_handle_is_used(&qbody->qb_lockh))
716 lock = ldlm_handle2lock(&qbody->qb_lockh);
718 /* no lock associated with this handle */
721 LDLM_DEBUG(lock, "%sacquire request",
722 req_is_preacq(qbody->qb_flags) ? "pre" : "");
724 if (!obd_uuid_equals(&lock->l_export->exp_client_uuid, uuid)) {
725 /* sorry, no way to cheat ... */
730 if (ldlm_is_ast_sent(lock)) {
731 struct ptlrpc_service_part *svc;
734 svc = req->rq_rqbd->rqbd_svcpt;
735 timeout = at_est2timeout(at_get(&svc->scp_at_estimate));
736 timeout += (ldlm_bl_timeout(lock) >> 1);
738 /* lock is being cancelled, prolong timeout */
739 ldlm_refresh_waiting_lock(lock, timeout);
744 /* extract quota information from global index FID packed in the
746 rc = lquota_extract_fid(&qbody->qb_fid, &pool_type, &qtype);
750 /* Find the quota entry associated with the quota id */
751 lqe = qmt_pool_lqe_lookup(env, qmt, pool_type, qtype,
754 RETURN(PTR_ERR(lqe));
756 /* process quota request */
757 rc = qmt_dqacq0(env, lqe, qmt, uuid, qbody->qb_flags, qbody->qb_count,
758 qbody->qb_usage, repbody);
760 if (lustre_handle_is_used(&qbody->qb_lockh))
761 /* return current qunit value only to slaves owning an per-ID
762 * quota lock. For enqueue, the qunit value will be returned in
764 repbody->qb_qunit = lqe->lqe_qunit;
769 /* Vector of quota request handlers. This vector is used by the MDT to forward
770 * requests to the quota master. */
771 struct qmt_handlers qmt_hdls = {
772 /* quota request handlers */
773 .qmth_quotactl = qmt_quotactl,
774 .qmth_dqacq = qmt_dqacq,
777 .qmth_intent_policy = qmt_intent_policy,
778 .qmth_lvbo_init = qmt_lvbo_init,
779 .qmth_lvbo_update = qmt_lvbo_update,
780 .qmth_lvbo_size = qmt_lvbo_size,
781 .qmth_lvbo_fill = qmt_lvbo_fill,
782 .qmth_lvbo_free = qmt_lvbo_free,
784 EXPORT_SYMBOL(qmt_hdls);