1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
38 # define EXPORT_SYMTAB
40 #define DEBUG_SUBSYSTEM S_LQUOTA
43 # include <linux/version.h>
44 # include <linux/module.h>
45 # include <linux/init.h>
46 # include <linux/fs.h>
47 # include <linux/jbd.h>
48 # if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
49 # include <linux/smp_lock.h>
50 # include <linux/buffer_head.h>
51 # include <linux/workqueue.h>
52 # include <linux/mount.h>
54 # include <linux/locks.h>
56 #else /* __KERNEL__ */
57 # include <liblustre.h>
60 #include <obd_class.h>
61 #include <lustre_mds.h>
62 #include <lustre_dlm.h>
63 #include <lustre_cfg.h>
65 #include <lustre_fsfilt.h>
66 #include <lustre_quota.h>
67 #include <lprocfs_status.h>
68 #include "quota_internal.h"
72 #ifdef HAVE_QUOTA_SUPPORT
74 static cfs_time_t last_print = 0;
75 static spinlock_t last_print_lock = SPIN_LOCK_UNLOCKED;
77 static int filter_quota_setup(struct obd_device *obd)
80 struct obd_device_target *obt = &obd->u.obt;
83 init_rwsem(&obt->obt_rwsem);
84 obt->obt_qfmt = LUSTRE_QUOTA_V2;
85 atomic_set(&obt->obt_quotachecking, 1);
86 rc = qctxt_init(obd, NULL);
88 CERROR("initialize quota context failed! (rc:%d)\n", rc);
93 static int filter_quota_cleanup(struct obd_device *obd)
96 qctxt_cleanup(&obd->u.obt.obt_qctxt, 0);
100 static int filter_quota_setinfo(struct obd_device *obd, void *data)
102 struct obd_export *exp = data;
103 struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt;
104 struct obd_import *imp;
107 /* setup the quota context import */
108 spin_lock(&qctxt->lqc_lock);
109 qctxt->lqc_import = exp->exp_imp_reverse;
110 spin_unlock(&qctxt->lqc_lock);
111 CDEBUG(D_QUOTA, "%s: lqc_import(%p) of obd(%p) is reactivated now, \n",
112 obd->obd_name,exp->exp_imp_reverse, obd);
114 /* make imp's connect flags equal relative exp's connect flags
115 * adding it to avoid the scan export list
117 imp = qctxt->lqc_import;
119 imp->imp_connect_data.ocd_connect_flags |=
120 (exp->exp_connect_flags &
121 (OBD_CONNECT_QUOTA64 | OBD_CONNECT_CHANGE_QS));
123 cfs_waitq_signal(&qctxt->lqc_wait_for_qmaster);
124 /* start quota slave recovery thread. (release high limits) */
125 qslave_start_recovery(obd, qctxt);
129 static int filter_quota_clearinfo(struct obd_export *exp, struct obd_device *obd)
131 struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt;
134 /* lquota may be not set up before destroying export, b=14896 */
135 if (!obd->obd_set_up)
138 /* when exp->exp_imp_reverse is destroyed, the corresponding lqc_import
139 * should be invalid b=12374 */
140 if (qctxt->lqc_import && qctxt->lqc_import == exp->exp_imp_reverse) {
141 spin_lock(&qctxt->lqc_lock);
142 qctxt->lqc_import = NULL;
143 spin_unlock(&qctxt->lqc_lock);
144 CDEBUG(D_QUOTA, "%s: lqc_import of obd(%p) is invalid now.\n",
150 static int filter_quota_enforce(struct obd_device *obd, unsigned int ignore)
154 if (!sb_any_quota_enabled(obd->u.obt.obt_sb))
158 CDEBUG(D_QUOTA, "blocks will be written with ignoring quota.\n");
159 cfs_cap_raise(CFS_CAP_SYS_RESOURCE);
161 cfs_cap_lower(CFS_CAP_SYS_RESOURCE);
167 static int filter_quota_getflag(struct obd_device *obd, struct obdo *oa)
169 struct obd_device_target *obt = &obd->u.obt;
170 struct lustre_quota_ctxt *qctxt = &obt->obt_qctxt;
171 int err, cnt, rc = 0;
172 struct obd_quotactl *oqctl;
175 if (!sb_any_quota_enabled(obt->obt_sb))
178 OBD_ALLOC_PTR(oqctl);
180 CERROR("Not enough memory!");
184 /* set over quota flags for a uid/gid */
185 oa->o_valid |= OBD_MD_FLUSRQUOTA | OBD_MD_FLGRPQUOTA;
186 oa->o_flags &= ~(OBD_FL_NO_USRQUOTA | OBD_FL_NO_GRPQUOTA);
188 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
189 struct quota_adjust_qunit oqaq_tmp;
190 struct lustre_qunit_size *lqs = NULL;
192 oqaq_tmp.qaq_flags = cnt;
193 oqaq_tmp.qaq_id = (cnt == USRQUOTA) ? oa->o_uid : oa->o_gid;
195 quota_search_lqs(NULL, &oqaq_tmp, qctxt, &lqs);
197 spin_lock(&lqs->lqs_lock);
198 if (lqs->lqs_bunit_sz <= qctxt->lqc_sync_blk) {
199 oa->o_flags |= (cnt == USRQUOTA) ?
200 OBD_FL_NO_USRQUOTA : OBD_FL_NO_GRPQUOTA;
201 spin_unlock(&lqs->lqs_lock);
202 CDEBUG(D_QUOTA, "set sync flag: bunit(%lu), "
203 "sync_blk(%d)\n", lqs->lqs_bunit_sz,
204 qctxt->lqc_sync_blk);
205 /* this is for quota_search_lqs */
209 spin_unlock(&lqs->lqs_lock);
210 /* this is for quota_search_lqs */
214 memset(oqctl, 0, sizeof(*oqctl));
216 oqctl->qc_cmd = Q_GETQUOTA;
217 oqctl->qc_type = cnt;
218 oqctl->qc_id = (cnt == USRQUOTA) ? oa->o_uid : oa->o_gid;
219 err = fsfilt_quotactl(obd, obt->obt_sb, oqctl);
223 oa->o_valid &= ~((cnt == USRQUOTA) ? OBD_MD_FLUSRQUOTA :
228 if (oqctl->qc_dqblk.dqb_bhardlimit &&
229 (toqb(oqctl->qc_dqblk.dqb_curspace) >=
230 oqctl->qc_dqblk.dqb_bhardlimit))
231 oa->o_flags |= (cnt == USRQUOTA) ?
232 OBD_FL_NO_USRQUOTA : OBD_FL_NO_GRPQUOTA;
239 * check whether the left quota of certain uid and gid can satisfy a block_write
240 * or inode_create rpc. When need to acquire quota, return QUOTA_RET_ACQUOTA
242 static int quota_check_common(struct obd_device *obd, unsigned int uid,
243 unsigned int gid, int count, int cycle, int isblk,
244 struct inode *inode, int frags, int *pending)
246 struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt;
248 __u32 id[MAXQUOTAS] = { uid, gid };
249 struct qunit_data qdata[MAXQUOTAS];
251 int rc = 0, rc2[2] = { 0, 0 };
254 CLASSERT(MAXQUOTAS < 4);
255 if (!sb_any_quota_enabled(qctxt->lqc_sb))
258 spin_lock(&qctxt->lqc_lock);
259 if (!qctxt->lqc_valid){
260 spin_unlock(&qctxt->lqc_lock);
263 spin_unlock(&qctxt->lqc_lock);
265 for (i = 0; i < MAXQUOTAS; i++) {
266 struct lustre_qunit_size *lqs = NULL;
268 qdata[i].qd_id = id[i];
269 qdata[i].qd_flags = i;
271 QDATA_SET_BLK(&qdata[i]);
272 qdata[i].qd_count = 0;
274 /* ignore root user */
275 if (qdata[i].qd_id == 0 && !QDATA_IS_GRP(&qdata[i]))
278 quota_search_lqs(&qdata[i], NULL, qctxt, &lqs);
282 rc2[i] = compute_remquota(obd, qctxt, &qdata[i], isblk);
283 spin_lock(&lqs->lqs_lock);
286 *pending = count * CFS_PAGE_SIZE;
287 /* in order to complete this write, we need extra
288 * meta blocks. This function can get it through
289 * data needed to be written b=16542 */
292 rc = fsfilt_get_mblk(obd, qctxt->lqc_sb,
301 lqs->lqs_bwrite_pending += *pending;
304 lqs->lqs_iwrite_pending += *pending;
307 if (rc2[i] == QUOTA_RET_OK) {
308 if (isblk && qdata[i].qd_count < lqs->lqs_bwrite_pending)
309 rc2[i] = QUOTA_RET_ACQUOTA;
310 if (!isblk && qdata[i].qd_count <
311 lqs->lqs_iwrite_pending)
312 rc2[i] = QUOTA_RET_ACQUOTA;
314 spin_unlock(&lqs->lqs_lock);
315 CDEBUG(D_QUOTA, "count: %d, lqs pending: %lu, qd_count: "LPU64
316 ", metablocks: %d, isblk: %d, pending: %d.\n", count,
317 isblk ? lqs->lqs_bwrite_pending : lqs->lqs_iwrite_pending,
318 qdata[i].qd_count, mb, isblk, *pending);
320 /* When cycle is zero, lqs_*_pending will be changed. We will
321 * get reference of the lqs here and put reference of lqs in
322 * quota_pending_commit b=14784 */
326 /* this is for quota_search_lqs */
330 if (rc2[0] == QUOTA_RET_ACQUOTA || rc2[1] == QUOTA_RET_ACQUOTA)
331 RETURN(QUOTA_RET_ACQUOTA);
336 static int quota_chk_acq_common(struct obd_device *obd, unsigned int uid,
337 unsigned int gid, int count, int *pending,
338 quota_acquire acquire,
339 struct obd_trans_info *oti, int isblk,
340 struct inode *inode, int frags)
342 struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt;
343 struct timeval work_start;
344 struct timeval work_end;
346 struct l_wait_info lwi = { 0 };
347 int rc = 0, cycle = 0, count_err = 1;
350 CDEBUG(D_QUOTA, "check quota for %s\n", obd->obd_name);
352 /* Unfortunately, if quota master is too busy to handle the
353 * pre-dqacq in time and quota hash on ost is used up, we
354 * have to wait for the completion of in flight dqacq/dqrel,
355 * in order to get enough quota for write b=12588 */
356 do_gettimeofday(&work_start);
357 while ((rc = quota_check_common(obd, uid, gid, count, cycle, isblk,
358 inode, frags, pending)) &
361 spin_lock(&qctxt->lqc_lock);
362 if (!qctxt->lqc_import && oti) {
363 spin_unlock(&qctxt->lqc_lock);
365 LASSERT(oti && oti->oti_thread &&
366 oti->oti_thread->t_watchdog);
368 lc_watchdog_disable(oti->oti_thread->t_watchdog);
369 CDEBUG(D_QUOTA, "sleep for quota master\n");
370 l_wait_event(qctxt->lqc_wait_for_qmaster, check_qm(qctxt),
372 CDEBUG(D_QUOTA, "wake up when quota master is back\n");
373 lc_watchdog_touch(oti->oti_thread->t_watchdog);
375 spin_unlock(&qctxt->lqc_lock);
380 OBD_FAIL_TIMEOUT(OBD_FAIL_OST_HOLD_WRITE_RPC, 90);
381 /* after acquire(), we should run quota_check_common again
382 * so that we confirm there are enough quota to finish write */
383 rc = acquire(obd, uid, gid, oti, isblk);
385 /* please reference to dqacq_completion for the below */
386 /* a new request is finished, try again */
388 CDEBUG(D_QUOTA, "finish a quota req, try again\n");
392 /* it is out of quota already */
394 CDEBUG(D_QUOTA, "out of quota, return -EDQUOT\n");
398 /* -EBUSY and others, wait a second and try again */
401 struct l_wait_info lwi;
403 if (oti && oti->oti_thread && oti->oti_thread->t_watchdog)
404 lc_watchdog_touch(oti->oti_thread->t_watchdog);
405 CDEBUG(D_QUOTA, "rc: %d, count_err: %d\n", rc,
408 init_waitqueue_head(&waitq);
409 lwi = LWI_TIMEOUT(cfs_time_seconds(min(cycle, 10)), NULL,
411 l_wait_event(waitq, 0, &lwi);
414 if (rc < 0 || cycle % 10 == 2) {
415 spin_lock(&last_print_lock);
416 if (last_print == 0 ||
417 cfs_time_before((last_print + cfs_time_seconds(30)),
418 cfs_time_current())) {
419 last_print = cfs_time_current();
420 spin_unlock(&last_print_lock);
421 CWARN("still haven't managed to acquire quota "
422 "space from the quota master after %d "
423 "retries (err=%d, rc=%d)\n",
424 cycle, count_err - 1, rc);
426 spin_unlock(&last_print_lock);
430 CDEBUG(D_QUOTA, "recheck quota with rc: %d, cycle: %d\n", rc,
433 do_gettimeofday(&work_end);
434 timediff = cfs_timeval_sub(&work_end, &work_start, NULL);
435 lprocfs_counter_add(qctxt->lqc_stats,
436 isblk ? LQUOTA_WAIT_FOR_CHK_BLK :
437 LQUOTA_WAIT_FOR_CHK_INO,
444 * when a block_write or inode_create rpc is finished, adjust the record for
445 * pending blocks and inodes
447 static int quota_pending_commit(struct obd_device *obd, unsigned int uid,
448 unsigned int gid, int pending, int isblk)
450 struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt;
451 struct timeval work_start;
452 struct timeval work_end;
455 __u32 id[MAXQUOTAS] = { uid, gid };
456 struct qunit_data qdata[MAXQUOTAS];
459 CDEBUG(D_QUOTA, "commit pending quota for %s\n", obd->obd_name);
460 CLASSERT(MAXQUOTAS < 4);
461 if (!sb_any_quota_enabled(qctxt->lqc_sb))
464 do_gettimeofday(&work_start);
465 for (i = 0; i < MAXQUOTAS; i++) {
466 struct lustre_qunit_size *lqs = NULL;
468 qdata[i].qd_id = id[i];
469 qdata[i].qd_flags = i;
471 QDATA_SET_BLK(&qdata[i]);
472 qdata[i].qd_count = 0;
474 if (qdata[i].qd_id == 0 && !QDATA_IS_GRP(&qdata[i]))
477 quota_search_lqs(&qdata[i], NULL, qctxt, &lqs);
480 spin_lock(&lqs->lqs_lock);
482 if (lqs->lqs_bwrite_pending >= pending) {
483 lqs->lqs_bwrite_pending -= pending;
484 spin_unlock(&lqs->lqs_lock);
487 spin_unlock(&lqs->lqs_lock);
489 "there are too many blocks!\n");
492 if (lqs->lqs_iwrite_pending >= pending) {
493 lqs->lqs_iwrite_pending -= pending;
494 spin_unlock(&lqs->lqs_lock);
497 spin_unlock(&lqs->lqs_lock);
499 "there are too many files!\n");
502 CDEBUG(D_QUOTA, "lqs pending: %lu, pending: %d, "
504 isblk ? lqs->lqs_bwrite_pending :
505 lqs->lqs_iwrite_pending, pending, isblk);
508 /* When lqs_*_pening is changed back, we'll putref lqs
514 do_gettimeofday(&work_end);
515 timediff = cfs_timeval_sub(&work_end, &work_start, NULL);
516 lprocfs_counter_add(qctxt->lqc_stats,
517 isblk ? LQUOTA_WAIT_FOR_COMMIT_BLK :
518 LQUOTA_WAIT_FOR_COMMIT_INO,
524 static int mds_quota_init(void)
526 return lustre_dquot_init();
529 static int mds_quota_exit(void)
535 static int mds_quota_setup(struct obd_device *obd)
537 struct obd_device_target *obt = &obd->u.obt;
538 struct mds_obd *mds = &obd->u.mds;
542 if (unlikely(mds->mds_quota)) {
543 CWARN("try to reinitialize quota context!\n");
547 init_rwsem(&obt->obt_rwsem);
548 obt->obt_qfmt = LUSTRE_QUOTA_V2;
549 mds->mds_quota_info.qi_version = LUSTRE_QUOTA_V2;
550 atomic_set(&obt->obt_quotachecking, 1);
551 /* initialize quota master and quota context */
552 sema_init(&mds->mds_qonoff_sem, 1);
553 rc = qctxt_init(obd, dqacq_handler);
555 CERROR("initialize quota context failed! (rc:%d)\n", rc);
562 static int mds_quota_cleanup(struct obd_device *obd)
565 if (unlikely(!obd->u.mds.mds_quota))
568 qctxt_cleanup(&obd->u.obt.obt_qctxt, 0);
572 static int mds_quota_setinfo(struct obd_device *obd, void *data)
574 struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt;
577 if (unlikely(!obd->u.mds.mds_quota))
581 QUOTA_MASTER_READY(qctxt);
583 QUOTA_MASTER_UNREADY(qctxt);
587 static int mds_quota_fs_cleanup(struct obd_device *obd)
589 struct mds_obd *mds = &obd->u.mds;
590 struct obd_quotactl oqctl;
593 if (unlikely(!mds->mds_quota))
597 memset(&oqctl, 0, sizeof(oqctl));
598 oqctl.qc_type = UGQUOTA;
600 down(&mds->mds_qonoff_sem);
601 mds_admin_quota_off(obd, &oqctl);
602 up(&mds->mds_qonoff_sem);
606 static int quota_acquire_common(struct obd_device *obd, unsigned int uid,
607 unsigned int gid, struct obd_trans_info *oti,
610 struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt;
614 rc = qctxt_adjust_qunit(obd, qctxt, uid, gid, isblk, 1, oti);
618 #endif /* HAVE_QUOTA_SUPPORT */
619 #endif /* __KERNEL__ */
621 struct osc_quota_info {
622 struct list_head oqi_hash; /* hash list */
623 struct client_obd *oqi_cli; /* osc obd */
624 unsigned int oqi_id; /* uid/gid of a file */
625 short oqi_type; /* quota type */
628 spinlock_t qinfo_list_lock = SPIN_LOCK_UNLOCKED;
630 static struct list_head qinfo_hash[NR_DQHASH];
631 /* SLAB cache for client quota context */
632 cfs_mem_cache_t *qinfo_cachep = NULL;
634 static inline int hashfn(struct client_obd *cli, unsigned long id, int type)
635 __attribute__((__const__));
637 static inline int hashfn(struct client_obd *cli, unsigned long id, int type)
639 unsigned long tmp = ((unsigned long)cli>>6) ^ id;
640 tmp = (tmp * (MAXQUOTAS - type)) % NR_DQHASH;
644 /* caller must hold qinfo_list_lock */
645 static inline void insert_qinfo_hash(struct osc_quota_info *oqi)
647 struct list_head *head = qinfo_hash +
648 hashfn(oqi->oqi_cli, oqi->oqi_id, oqi->oqi_type);
650 LASSERT_SPIN_LOCKED(&qinfo_list_lock);
651 list_add(&oqi->oqi_hash, head);
654 /* caller must hold qinfo_list_lock */
655 static inline void remove_qinfo_hash(struct osc_quota_info *oqi)
657 LASSERT_SPIN_LOCKED(&qinfo_list_lock);
658 list_del_init(&oqi->oqi_hash);
661 /* caller must hold qinfo_list_lock */
662 static inline struct osc_quota_info *find_qinfo(struct client_obd *cli,
663 unsigned int id, int type)
665 unsigned int hashent = hashfn(cli, id, type);
666 struct osc_quota_info *oqi;
669 LASSERT_SPIN_LOCKED(&qinfo_list_lock);
670 list_for_each_entry(oqi, &qinfo_hash[hashent], oqi_hash) {
671 if (oqi->oqi_cli == cli &&
672 oqi->oqi_id == id && oqi->oqi_type == type)
678 static struct osc_quota_info *alloc_qinfo(struct client_obd *cli,
679 unsigned int id, int type)
681 struct osc_quota_info *oqi;
684 OBD_SLAB_ALLOC(oqi, qinfo_cachep, CFS_ALLOC_STD, sizeof(*oqi));
688 CFS_INIT_LIST_HEAD(&oqi->oqi_hash);
691 oqi->oqi_type = type;
696 static void free_qinfo(struct osc_quota_info *oqi)
698 OBD_SLAB_FREE(oqi, qinfo_cachep, sizeof(*oqi));
701 int osc_quota_chkdq(struct client_obd *cli, unsigned int uid, unsigned int gid)
704 int cnt, rc = QUOTA_OK;
707 spin_lock(&qinfo_list_lock);
708 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
709 struct osc_quota_info *oqi = NULL;
711 id = (cnt == USRQUOTA) ? uid : gid;
712 oqi = find_qinfo(cli, id, cnt);
718 spin_unlock(&qinfo_list_lock);
723 int osc_quota_setdq(struct client_obd *cli, unsigned int uid, unsigned int gid,
724 obd_flag valid, obd_flag flags)
732 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
733 struct osc_quota_info *oqi, *old;
735 if (!(valid & ((cnt == USRQUOTA) ?
736 OBD_MD_FLUSRQUOTA : OBD_MD_FLGRPQUOTA)))
739 id = (cnt == USRQUOTA) ? uid : gid;
740 noquota = (cnt == USRQUOTA) ?
741 (flags & OBD_FL_NO_USRQUOTA) : (flags & OBD_FL_NO_GRPQUOTA);
743 oqi = alloc_qinfo(cli, id, cnt);
745 spin_lock(&qinfo_list_lock);
747 old = find_qinfo(cli, id, cnt);
749 remove_qinfo_hash(old);
750 else if (!old && noquota)
751 insert_qinfo_hash(oqi);
753 spin_unlock(&qinfo_list_lock);
760 CERROR("not enough mem!\n");
769 int osc_quota_cleanup(struct obd_device *obd)
771 struct client_obd *cli = &obd->u.cli;
772 struct osc_quota_info *oqi, *n;
776 spin_lock(&qinfo_list_lock);
777 for (i = 0; i < NR_DQHASH; i++) {
778 list_for_each_entry_safe(oqi, n, &qinfo_hash[i], oqi_hash) {
779 if (oqi->oqi_cli != cli)
781 remove_qinfo_hash(oqi);
785 spin_unlock(&qinfo_list_lock);
790 int osc_quota_init(void)
795 LASSERT(qinfo_cachep == NULL);
796 qinfo_cachep = cfs_mem_cache_create("osc_quota_info",
797 sizeof(struct osc_quota_info),
802 for (i = 0; i < NR_DQHASH; i++)
803 CFS_INIT_LIST_HEAD(qinfo_hash + i);
808 int osc_quota_exit(void)
810 struct osc_quota_info *oqi, *n;
814 spin_lock(&qinfo_list_lock);
815 for (i = 0; i < NR_DQHASH; i++) {
816 list_for_each_entry_safe(oqi, n, &qinfo_hash[i], oqi_hash) {
817 remove_qinfo_hash(oqi);
821 spin_unlock(&qinfo_list_lock);
823 rc = cfs_mem_cache_destroy(qinfo_cachep);
824 LASSERTF(rc == 0, "couldn't destory qinfo_cachep slab\n");
831 #ifdef HAVE_QUOTA_SUPPORT
832 quota_interface_t mds_quota_interface = {
833 .quota_init = mds_quota_init,
834 .quota_exit = mds_quota_exit,
835 .quota_setup = mds_quota_setup,
836 .quota_cleanup = mds_quota_cleanup,
837 .quota_check = target_quota_check,
838 .quota_ctl = mds_quota_ctl,
839 .quota_setinfo = mds_quota_setinfo,
840 .quota_fs_cleanup = mds_quota_fs_cleanup,
841 .quota_recovery = mds_quota_recovery,
842 .quota_adjust = mds_quota_adjust,
843 .quota_chkquota = quota_chk_acq_common,
844 .quota_acquire = quota_acquire_common,
845 .quota_pending_commit = quota_pending_commit,
848 quota_interface_t filter_quota_interface = {
849 .quota_setup = filter_quota_setup,
850 .quota_cleanup = filter_quota_cleanup,
851 .quota_check = target_quota_check,
852 .quota_ctl = filter_quota_ctl,
853 .quota_setinfo = filter_quota_setinfo,
854 .quota_clearinfo = filter_quota_clearinfo,
855 .quota_enforce = filter_quota_enforce,
856 .quota_getflag = filter_quota_getflag,
857 .quota_acquire = quota_acquire_common,
858 .quota_adjust = filter_quota_adjust,
859 .quota_chkquota = quota_chk_acq_common,
860 .quota_adjust_qunit = filter_quota_adjust_qunit,
861 .quota_pending_commit = quota_pending_commit,
864 #endif /* __KERNEL__ */
866 quota_interface_t mdc_quota_interface = {
867 .quota_ctl = client_quota_ctl,
868 .quota_check = client_quota_check,
869 .quota_poll_check = client_quota_poll_check,
872 quota_interface_t lmv_quota_interface = {
873 .quota_ctl = lmv_quota_ctl,
874 .quota_check = lmv_quota_check,
877 quota_interface_t osc_quota_interface = {
878 .quota_ctl = client_quota_ctl,
879 .quota_check = client_quota_check,
880 .quota_poll_check = client_quota_poll_check,
881 .quota_init = osc_quota_init,
882 .quota_exit = osc_quota_exit,
883 .quota_chkdq = osc_quota_chkdq,
884 .quota_setdq = osc_quota_setdq,
885 .quota_cleanup = osc_quota_cleanup,
886 .quota_adjust_qunit = client_quota_adjust_qunit,
889 quota_interface_t lov_quota_interface = {
890 .quota_ctl = lov_quota_ctl,
891 .quota_check = lov_quota_check,
892 .quota_adjust_qunit = lov_quota_adjust_qunit,
897 cfs_proc_dir_entry_t *lquota_type_proc_dir = NULL;
899 static int __init init_lustre_quota(void)
901 #ifdef HAVE_QUOTA_SUPPORT
904 lquota_type_proc_dir = lprocfs_register(OBD_LQUOTA_DEVICENAME,
907 if (IS_ERR(lquota_type_proc_dir)) {
908 CERROR("LProcFS failed in lquota-init\n");
909 rc = PTR_ERR(lquota_type_proc_dir);
913 rc = qunit_cache_init();
917 PORTAL_SYMBOL_REGISTER(filter_quota_interface);
918 PORTAL_SYMBOL_REGISTER(mds_quota_interface);
920 PORTAL_SYMBOL_REGISTER(mdc_quota_interface);
921 PORTAL_SYMBOL_REGISTER(lmv_quota_interface);
922 PORTAL_SYMBOL_REGISTER(osc_quota_interface);
923 PORTAL_SYMBOL_REGISTER(lov_quota_interface);
927 static void /*__exit*/ exit_lustre_quota(void)
929 PORTAL_SYMBOL_UNREGISTER(mdc_quota_interface);
930 PORTAL_SYMBOL_UNREGISTER(lmv_quota_interface);
931 PORTAL_SYMBOL_UNREGISTER(osc_quota_interface);
932 PORTAL_SYMBOL_UNREGISTER(lov_quota_interface);
933 #ifdef HAVE_QUOTA_SUPPORT
934 PORTAL_SYMBOL_UNREGISTER(filter_quota_interface);
935 PORTAL_SYMBOL_UNREGISTER(mds_quota_interface);
937 qunit_cache_cleanup();
939 if (lquota_type_proc_dir)
940 lprocfs_remove(&lquota_type_proc_dir);
944 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
945 MODULE_DESCRIPTION("Lustre Quota");
946 MODULE_LICENSE("GPL");
948 cfs_module(lquota, "1.0.0", init_lustre_quota, exit_lustre_quota);
950 #ifdef HAVE_QUOTA_SUPPORT
951 EXPORT_SYMBOL(mds_quota_interface);
952 EXPORT_SYMBOL(filter_quota_interface);
954 EXPORT_SYMBOL(mdc_quota_interface);
955 EXPORT_SYMBOL(lmv_quota_interface);
956 EXPORT_SYMBOL(osc_quota_interface);
957 EXPORT_SYMBOL(lov_quota_interface);
958 #endif /* __KERNEL */