Whamcloud - gitweb
87651190a060956cd52c928e9166346f5d812239
[fs/lustre-release.git] / lustre / quota / quota_interface.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  lustre/quota/quota_interface.c
5  *
6  *  Copyright (c) 2001-2005 Cluster File Systems, Inc.
7  *
8  *   This file is part of Lustre, http://www.lustre.org.
9  *
10  *   No redistribution or use is permitted outside of Cluster File Systems, Inc.
11  *
12  */
13 #ifndef EXPORT_SYMTAB
14 # define EXPORT_SYMTAB
15 #endif
16 #define DEBUG_SUBSYSTEM S_MDS
17
18 #ifdef __KERNEL__
19 # include <linux/version.h>
20 # include <linux/module.h>
21 # include <linux/init.h>
22 # include <linux/fs.h>
23 # include <linux/jbd.h>
24 # include <linux/ext3_fs.h>
25 # if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
26 #  include <linux/smp_lock.h>
27 #  include <linux/buffer_head.h>
28 #  include <linux/workqueue.h>
29 #  include <linux/mount.h>
30 # else
31 #  include <linux/locks.h>
32 # endif
33 #else /* __KERNEL__ */
34 # include <liblustre.h>
35 #endif
36
37 #include <obd_class.h>
38 #include <lustre_mds.h>
39 #include <lustre_dlm.h>
40 #include <lustre_cfg.h>
41 #include <obd_ost.h>
42 #include <lustre_fsfilt.h>
43 #include <lustre_quota.h>
44 #include <lprocfs_status.h>
45 #include "quota_internal.h"
46
47
48 #ifdef __KERNEL__
49
50 /* quota proc file handling functions */
51 #ifdef LPROCFS
52 int lprocfs_rd_bunit(char *page, char **start, off_t off, int count, 
53                      int *eof, void *data)
54 {
55         struct obd_device *obd = (struct obd_device *)data;
56         LASSERT(obd != NULL);
57
58         return snprintf(page, count, "%lu\n", 
59                         obd->u.obt.obt_qctxt.lqc_bunit_sz);
60 }
61 EXPORT_SYMBOL(lprocfs_rd_bunit);
62
63 int lprocfs_rd_iunit(char *page, char **start, off_t off, int count, 
64                      int *eof, void *data)
65 {
66         struct obd_device *obd = (struct obd_device *)data;
67         LASSERT(obd != NULL);
68
69         return snprintf(page, count, "%lu\n", 
70                         obd->u.obt.obt_qctxt.lqc_iunit_sz);
71 }
72 EXPORT_SYMBOL(lprocfs_rd_iunit);
73
74 int lprocfs_wr_bunit(struct file *file, const char *buffer,
75                      unsigned long count, void *data)
76 {
77         struct obd_device *obd = (struct obd_device *)data;
78         int val, rc;
79         LASSERT(obd != NULL);
80
81         rc = lprocfs_write_helper(buffer, count, &val);
82         if (rc)
83                 return rc;
84
85         if (val % QUOTABLOCK_SIZE ||
86             val <= obd->u.obt.obt_qctxt.lqc_btune_sz)
87                 return -EINVAL;
88
89         obd->u.obt.obt_qctxt.lqc_bunit_sz = val;
90         return count;
91 }
92 EXPORT_SYMBOL(lprocfs_wr_bunit);
93
94 int lprocfs_wr_iunit(struct file *file, const char *buffer,
95                      unsigned long count, void *data)
96 {
97         struct obd_device *obd = (struct obd_device *)data;
98         int val, rc;
99         LASSERT(obd != NULL);
100
101         rc = lprocfs_write_helper(buffer, count, &val);
102         if (rc)
103                 return rc;
104
105         if (val <= obd->u.obt.obt_qctxt.lqc_itune_sz)
106                 return -EINVAL;
107
108         obd->u.obt.obt_qctxt.lqc_iunit_sz = val;
109         return count;
110 }
111 EXPORT_SYMBOL(lprocfs_wr_iunit);
112
113 int lprocfs_rd_btune(char *page, char **start, off_t off, int count, 
114                      int *eof, void *data)
115 {
116         struct obd_device *obd = (struct obd_device *)data;
117         LASSERT(obd != NULL);
118
119         return snprintf(page, count, "%lu\n", 
120                         obd->u.obt.obt_qctxt.lqc_btune_sz);
121 }
122 EXPORT_SYMBOL(lprocfs_rd_btune);
123
124 int lprocfs_rd_itune(char *page, char **start, off_t off, int count, 
125                      int *eof, void *data)
126 {
127         struct obd_device *obd = (struct obd_device *)data;
128         LASSERT(obd != NULL);
129
130         return snprintf(page, count, "%lu\n", 
131                         obd->u.obt.obt_qctxt.lqc_itune_sz);
132 }
133 EXPORT_SYMBOL(lprocfs_rd_itune);
134
135 int lprocfs_wr_btune(struct file *file, const char *buffer,
136                      unsigned long count, void *data)
137 {
138         struct obd_device *obd = (struct obd_device *)data;
139         int val, rc;
140         LASSERT(obd != NULL);
141
142         rc = lprocfs_write_helper(buffer, count, &val);
143         if (rc)
144                 return rc;
145         
146         if (val <= QUOTABLOCK_SIZE * MIN_QLIMIT || val % QUOTABLOCK_SIZE || 
147             val >= obd->u.obt.obt_qctxt.lqc_bunit_sz)
148                 return -EINVAL;
149
150         obd->u.obt.obt_qctxt.lqc_btune_sz = val;
151         return count;
152 }
153 EXPORT_SYMBOL(lprocfs_wr_btune);
154
155 int lprocfs_wr_itune(struct file *file, const char *buffer,
156                      unsigned long count, void *data)
157 {
158         struct obd_device *obd = (struct obd_device *)data;
159         int val, rc;
160         LASSERT(obd != NULL);
161
162         rc = lprocfs_write_helper(buffer, count, &val);
163         if (rc)
164                 return rc;
165         
166         if (val <= MIN_QLIMIT || 
167             val >= obd->u.obt.obt_qctxt.lqc_iunit_sz)
168                 return -EINVAL;
169
170         obd->u.obt.obt_qctxt.lqc_itune_sz = val;
171         return count;
172 }
173 EXPORT_SYMBOL(lprocfs_wr_itune);
174
175 #define USER_QUOTA      1
176 #define GROUP_QUOTA     2
177
178 #define MAX_STYPE_SIZE  4
179 int lprocfs_rd_type(char *page, char **start, off_t off, int count, 
180                     int *eof, void *data)
181 {
182         struct obd_device *obd = (struct obd_device *)data;
183         char stype[MAX_STYPE_SIZE + 1] = "";
184         int type = obd->u.obt.obt_qctxt.lqc_atype;
185         LASSERT(obd != NULL);
186
187         if (type == 0) {
188                 strcpy(stype, "off");
189         } else {
190                 if (type & USER_QUOTA)
191                         strcat(stype, "u");
192                 if (type & GROUP_QUOTA)
193                         strcat(stype, "g");
194         }
195         
196         return snprintf(page, count, "%s\n", stype);
197 }
198 EXPORT_SYMBOL(lprocfs_rd_type);
199
200 static int auto_quota_on(struct obd_device *obd, int type, 
201                          struct super_block *sb, int is_master)
202 {
203         struct obd_quotactl *oqctl;
204         struct lvfs_run_ctxt saved;
205         int rc;
206         ENTRY;
207
208         LASSERT(type == USRQUOTA || type == GRPQUOTA || type == UGQUOTA);
209
210         /* quota already turned on */
211         if (obd->u.obt.obt_qctxt.lqc_status)
212                 RETURN(0);
213
214         OBD_ALLOC_PTR(oqctl);
215         if (!oqctl)
216                 RETURN(-ENOMEM);
217
218         oqctl->qc_type = type;
219         oqctl->qc_cmd = Q_QUOTAON;
220         oqctl->qc_id = QFMT_LDISKFS;
221
222         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
223
224         if (!is_master)
225                 goto local_quota;
226
227         /* turn on cluster wide quota */
228         rc = mds_admin_quota_on(obd, oqctl);
229         if (rc) {
230                 CDEBUG(rc == -ENOENT ? D_QUOTA : D_ERROR, 
231                        "auto-enable admin quota failed. rc=%d\n", rc);
232                 GOTO(out_pop, rc);
233         }
234 local_quota:
235         /* turn on local quota */
236         rc = fsfilt_quotactl(obd, sb, oqctl);
237         if (rc) {
238                 CDEBUG(rc == -ENOENT ? D_QUOTA : D_ERROR, 
239                        "auto-enable local quota failed. rc=%d\n", rc);
240                 if (is_master)
241                         mds_quota_off(obd, oqctl);
242         } else {
243                 obd->u.obt.obt_qctxt.lqc_status = 1;
244         }
245 out_pop:
246         pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
247
248         OBD_FREE_PTR(oqctl);
249         RETURN(rc);
250 }
251
252 int lprocfs_wr_type(struct file *file, const char *buffer,
253                     unsigned long count, void *data)
254 {
255         struct obd_device *obd = (struct obd_device *)data;
256         struct obd_device_target *obt = &obd->u.obt;
257         int type = 0;
258         char stype[MAX_STYPE_SIZE + 1] = "";
259         LASSERT(obd != NULL);
260
261         if (copy_from_user(stype, buffer, MAX_STYPE_SIZE))
262                 return -EFAULT;
263
264         if (strchr(stype, 'u'))
265                 type |= USER_QUOTA;
266         if (strchr(stype, 'g'))
267                 type |= GROUP_QUOTA;
268         
269         obt->obt_qctxt.lqc_atype = type;
270
271         if (type == 0)
272                 return count;
273
274         if (!strcmp(obd->obd_type->typ_name, LUSTRE_MDS_NAME))
275                 auto_quota_on(obd, type - 1, obt->obt_sb, 1);
276         else if (!strcmp(obd->obd_type->typ_name, LUSTRE_OST_NAME))
277                 auto_quota_on(obd, type - 1, obt->obt_sb, 0);
278         else 
279                 return -EFAULT;
280
281         return count;
282 }
283 EXPORT_SYMBOL(lprocfs_wr_type);
284 #endif /* LPROCFS */
285
286 static int filter_quota_setup(struct obd_device *obd)
287 {
288         int rc = 0;
289         struct obd_device_target *obt = &obd->u.obt;
290         ENTRY;
291
292         atomic_set(&obt->obt_quotachecking, 1);
293         rc = qctxt_init(&obt->obt_qctxt, obt->obt_sb, NULL);
294         if (rc) {
295                 CERROR("initialize quota context failed! (rc:%d)\n", rc);
296                 RETURN(rc);
297         }
298         RETURN(rc);
299 }
300
301 static int filter_quota_cleanup(struct obd_device *obd)
302 {
303         qctxt_cleanup(&obd->u.obt.obt_qctxt, 0);
304         return 0;
305 }
306
307 static int filter_quota_setinfo(struct obd_export *exp, struct obd_device *obd)
308 {
309         struct obd_import *imp;
310
311         /* setup the quota context import */
312         obd->u.obt.obt_qctxt.lqc_import = exp->exp_imp_reverse;
313
314         /* make imp's connect flags equal relative exp's connect flags 
315          * adding it to avoid the scan export list
316          */
317         imp = exp->exp_imp_reverse;
318         if (imp)
319                 imp->imp_connect_data.ocd_connect_flags |= 
320                         (exp->exp_connect_flags & OBD_CONNECT_QUOTA64);
321
322         /* start quota slave recovery thread. (release high limits) */
323         qslave_start_recovery(obd, &obd->u.obt.obt_qctxt);
324         return 0;
325 }
326 static int filter_quota_enforce(struct obd_device *obd, unsigned int ignore)
327 {
328         ENTRY;
329
330         if (!sb_any_quota_enabled(obd->u.obt.obt_sb))
331                 RETURN(0);
332
333         if (ignore)
334                 cap_raise(current->cap_effective, CAP_SYS_RESOURCE);
335         else
336                 cap_lower(current->cap_effective, CAP_SYS_RESOURCE);
337
338         RETURN(0);
339 }
340
341 static int filter_quota_getflag(struct obd_device *obd, struct obdo *oa)
342 {
343         struct obd_device_target *obt = &obd->u.obt;
344         int err, cnt, rc = 0;
345         struct obd_quotactl *oqctl;
346         ENTRY;
347
348         if (!sb_any_quota_enabled(obt->obt_sb))
349                 RETURN(0);
350
351         oa->o_flags &= ~(OBD_FL_NO_USRQUOTA | OBD_FL_NO_GRPQUOTA);
352
353         OBD_ALLOC_PTR(oqctl);
354         if (!oqctl) {
355                 CERROR("Not enough memory!");
356                 RETURN(-ENOMEM);
357         }
358
359         for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
360                 memset(oqctl, 0, sizeof(*oqctl));
361
362                 oqctl->qc_cmd = Q_GETQUOTA;
363                 oqctl->qc_type = cnt;
364                 oqctl->qc_id = (cnt == USRQUOTA) ? oa->o_uid : oa->o_gid;
365                 err = fsfilt_quotactl(obd, obt->obt_sb, oqctl);
366                 if (err) {
367                         if (!rc)
368                                 rc = err;
369                         continue;
370                 }
371
372                 /* set over quota flags for a uid/gid */
373                 oa->o_valid |= (cnt == USRQUOTA) ?
374                                OBD_MD_FLUSRQUOTA : OBD_MD_FLGRPQUOTA;
375                 if (oqctl->qc_dqblk.dqb_bhardlimit &&
376                    (toqb(oqctl->qc_dqblk.dqb_curspace) > 
377                     oqctl->qc_dqblk.dqb_bhardlimit))
378                         oa->o_flags |= (cnt == USRQUOTA) ? 
379                                 OBD_FL_NO_USRQUOTA : OBD_FL_NO_GRPQUOTA;
380         }
381         OBD_FREE_PTR(oqctl);
382         RETURN(rc);
383 }
384
385 static int filter_quota_acquire(struct obd_device *obd, unsigned int uid, 
386                                 unsigned int gid)
387 {
388         struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt;
389         int rc;
390         ENTRY;
391
392         rc = qctxt_adjust_qunit(obd, qctxt, uid, gid, 1, 1);
393         RETURN(rc == -EAGAIN);
394 }
395
396 static int mds_quota_init(void)
397 {
398         return lustre_dquot_init();
399 }
400
401 static int mds_quota_exit(void)
402 {
403         lustre_dquot_exit();
404         return 0;
405 }
406
407 static int mds_quota_setup(struct obd_device *obd)
408 {
409         struct obd_device_target *obt = &obd->u.obt;
410         struct mds_obd *mds = &obd->u.mds;
411         int rc;
412         ENTRY;
413
414         atomic_set(&obt->obt_quotachecking, 1);
415         /* initialize quota master and quota context */
416         sema_init(&mds->mds_qonoff_sem, 1);
417         rc = qctxt_init(&obt->obt_qctxt, obt->obt_sb, dqacq_handler);
418         if (rc) {
419                 CERROR("initialize quota context failed! (rc:%d)\n", rc);
420                 RETURN(rc);
421         }
422         RETURN(rc);
423 }
424
425 static int mds_quota_cleanup(struct obd_device *obd)
426 {
427         qctxt_cleanup(&obd->u.obt.obt_qctxt, 0);
428         RETURN(0);
429 }
430
431 static int mds_quota_fs_cleanup(struct obd_device *obd)
432 {
433         struct mds_obd *mds = &obd->u.mds;
434         int i;
435         ENTRY;
436
437         /* close admin quota files */
438         down(&mds->mds_qonoff_sem);
439         for (i = 0; i < MAXQUOTAS; i++) {
440                 if (mds->mds_quota_info.qi_files[i]) {
441                         filp_close(mds->mds_quota_info.qi_files[i], 0);
442                         mds->mds_quota_info.qi_files[i] = NULL;
443                 }
444         }
445         up(&mds->mds_qonoff_sem);
446         RETURN(0);
447 }
448 #endif /* __KERNEL__ */
449
450 struct osc_quota_info {
451         struct list_head        oqi_hash;       /* hash list */
452         struct client_obd      *oqi_cli;        /* osc obd */
453         unsigned int            oqi_id;         /* uid/gid of a file */
454         short                   oqi_type;       /* quota type */
455 };
456
457 spinlock_t qinfo_list_lock = SPIN_LOCK_UNLOCKED;
458
459 static struct list_head qinfo_hash[NR_DQHASH];
460 /* SLAB cache for client quota context */
461 cfs_mem_cache_t *qinfo_cachep = NULL;
462
463 static inline int hashfn(struct client_obd *cli, unsigned long id, int type)
464                          __attribute__((__const__));
465
466 static inline int hashfn(struct client_obd *cli, unsigned long id, int type)
467 {
468         unsigned long tmp = ((unsigned long)cli>>6) ^ id;
469         tmp = (tmp * (MAXQUOTAS - type)) % NR_DQHASH;
470         return tmp;
471 }
472
473 /* caller must hold qinfo_list_lock */
474 static inline void insert_qinfo_hash(struct osc_quota_info *oqi)
475 {
476         struct list_head *head = qinfo_hash + 
477                 hashfn(oqi->oqi_cli, oqi->oqi_id, oqi->oqi_type);
478
479         LASSERT_SPIN_LOCKED(&qinfo_list_lock);
480         list_add(&oqi->oqi_hash, head);
481 }
482
483 /* caller must hold qinfo_list_lock */
484 static inline void remove_qinfo_hash(struct osc_quota_info *oqi)
485 {
486         LASSERT_SPIN_LOCKED(&qinfo_list_lock);
487         list_del_init(&oqi->oqi_hash);
488 }
489
490 /* caller must hold qinfo_list_lock */
491 static inline struct osc_quota_info *find_qinfo(struct client_obd *cli,
492                                                 unsigned int id, int type)
493 {
494         unsigned int hashent = hashfn(cli, id, type);
495         struct osc_quota_info *oqi;
496
497         LASSERT_SPIN_LOCKED(&qinfo_list_lock);
498         list_for_each_entry(oqi, &qinfo_hash[hashent], oqi_hash) {
499                 if (oqi->oqi_cli == cli &&
500                     oqi->oqi_id == id && oqi->oqi_type == type)
501                         return oqi;
502         }
503         return NULL;
504 }
505
506 static struct osc_quota_info *alloc_qinfo(struct client_obd *cli,
507                                           unsigned int id, int type)
508 {
509         struct osc_quota_info *oqi;
510         ENTRY;
511
512         OBD_SLAB_ALLOC(oqi, qinfo_cachep, CFS_ALLOC_STD, sizeof(*oqi));
513         if(!oqi)
514                 RETURN(NULL);
515
516         INIT_LIST_HEAD(&oqi->oqi_hash);
517         oqi->oqi_cli = cli;
518         oqi->oqi_id = id;
519         oqi->oqi_type = type;
520
521         RETURN(oqi);
522 }
523
524 static void free_qinfo(struct osc_quota_info *oqi)
525 {
526         OBD_SLAB_FREE(oqi, qinfo_cachep, sizeof(*oqi));
527 }
528
529 int osc_quota_chkdq(struct client_obd *cli, 
530                     unsigned int uid, unsigned int gid)
531 {
532         unsigned int id;
533         int cnt, rc = QUOTA_OK;
534         ENTRY;
535
536         spin_lock(&qinfo_list_lock);
537         for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
538                 struct osc_quota_info *oqi = NULL;
539
540                 id = (cnt == USRQUOTA) ? uid : gid;
541                 oqi = find_qinfo(cli, id, cnt);
542                 if (oqi) {
543                         rc = NO_QUOTA;
544                         break;
545                 }
546         }
547         spin_unlock(&qinfo_list_lock);
548
549         RETURN(rc);
550 }
551
552 int osc_quota_setdq(struct client_obd *cli, 
553                     unsigned int uid, unsigned int gid,
554                     obd_flag valid, obd_flag flags)
555 {
556         unsigned int id;
557         obd_flag noquota;
558         int cnt, rc = 0;
559         ENTRY;
560
561
562         for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
563                 struct osc_quota_info *oqi, *old;
564
565                 if (!(valid & ((cnt == USRQUOTA) ? 
566                     OBD_MD_FLUSRQUOTA : OBD_MD_FLGRPQUOTA)))
567                         continue;
568
569                 id = (cnt == USRQUOTA) ? uid : gid;
570                 noquota = (cnt == USRQUOTA) ? 
571                     (flags & OBD_FL_NO_USRQUOTA) : (flags & OBD_FL_NO_GRPQUOTA);
572
573                 oqi = alloc_qinfo(cli, id, cnt);
574                 if (oqi) {
575                         spin_lock(&qinfo_list_lock);
576
577                         old = find_qinfo(cli, id, cnt);
578                         if (old && !noquota)
579                                 remove_qinfo_hash(old);
580                         else if (!old && noquota)
581                                 insert_qinfo_hash(oqi);
582
583                         spin_unlock(&qinfo_list_lock);
584
585                         if (old || !noquota)
586                                 free_qinfo(oqi);
587                         if (old && !noquota)
588                                 free_qinfo(old);
589                 } else {
590                         CERROR("not enough mem!\n");
591                         rc = -ENOMEM;
592                         break;
593                 }
594         }
595
596         RETURN(rc);
597 }
598
599 int osc_quota_cleanup(struct obd_device *obd)
600 {
601         struct client_obd *cli = &obd->u.cli;
602         struct osc_quota_info *oqi, *n;
603         int i;
604         ENTRY;
605
606         spin_lock(&qinfo_list_lock);
607         for (i = 0; i < NR_DQHASH; i++) {
608                 list_for_each_entry_safe(oqi, n, &qinfo_hash[i], oqi_hash) {
609                         if (oqi->oqi_cli != cli)
610                                 continue;
611                         remove_qinfo_hash(oqi);
612                         free_qinfo(oqi);
613                 }
614         }
615         spin_unlock(&qinfo_list_lock);
616
617         RETURN(0);
618 }
619
620 int osc_quota_init(void)
621 {
622         int i;
623         ENTRY;
624
625         LASSERT(qinfo_cachep == NULL);
626         qinfo_cachep = cfs_mem_cache_create("osc_quota_info",
627                                          sizeof(struct osc_quota_info),
628                                          0, 0);
629         if (!qinfo_cachep)
630                 RETURN(-ENOMEM);
631
632         for (i = 0; i < NR_DQHASH; i++)
633                 INIT_LIST_HEAD(qinfo_hash + i);
634
635         RETURN(0);
636 }
637
638 int osc_quota_exit(void)
639 {
640         struct osc_quota_info *oqi, *n;
641         int i, rc;
642         ENTRY;
643
644         spin_lock(&qinfo_list_lock);
645         for (i = 0; i < NR_DQHASH; i++) {
646                 list_for_each_entry_safe(oqi, n, &qinfo_hash[i], oqi_hash) {
647                         remove_qinfo_hash(oqi);
648                         free_qinfo(oqi);
649                 }
650         }
651         spin_unlock(&qinfo_list_lock);
652
653         rc = cfs_mem_cache_destroy(qinfo_cachep);
654         LASSERTF(rc == 0, "couldn't destory qinfo_cachep slab\n");
655         qinfo_cachep = NULL;
656
657         RETURN(0);
658 }
659
660 #ifdef __KERNEL__
661 quota_interface_t mds_quota_interface = {
662         .quota_init     = mds_quota_init,
663         .quota_exit     = mds_quota_exit,
664         .quota_setup    = mds_quota_setup,
665         .quota_cleanup  = mds_quota_cleanup,
666         .quota_check    = target_quota_check,
667         .quota_ctl      = mds_quota_ctl,
668         .quota_fs_cleanup       =mds_quota_fs_cleanup,
669         .quota_recovery = mds_quota_recovery,
670         .quota_adjust   = mds_quota_adjust,
671 };
672
673 quota_interface_t filter_quota_interface = {
674         .quota_setup    = filter_quota_setup,
675         .quota_cleanup  = filter_quota_cleanup,
676         .quota_check    = target_quota_check,
677         .quota_ctl      = filter_quota_ctl,
678         .quota_setinfo  = filter_quota_setinfo,
679         .quota_enforce  = filter_quota_enforce,
680         .quota_getflag  = filter_quota_getflag,
681         .quota_acquire  = filter_quota_acquire,
682         .quota_adjust   = filter_quota_adjust,
683 };
684 #endif /* __KERNEL__ */
685
686 quota_interface_t mdc_quota_interface = {
687         .quota_ctl      = client_quota_ctl,
688         .quota_check    = client_quota_check,
689         .quota_poll_check = client_quota_poll_check,
690 };
691
692 quota_interface_t osc_quota_interface = {
693         .quota_ctl      = client_quota_ctl,
694         .quota_check    = client_quota_check,
695         .quota_poll_check = client_quota_poll_check,
696         .quota_init     = osc_quota_init,
697         .quota_exit     = osc_quota_exit,
698         .quota_chkdq    = osc_quota_chkdq,
699         .quota_setdq    = osc_quota_setdq,
700         .quota_cleanup  = osc_quota_cleanup,
701 };
702
703 quota_interface_t lov_quota_interface = {
704         .quota_check    = lov_quota_check,
705         .quota_ctl      = lov_quota_ctl,
706 };
707
708 #ifdef __KERNEL__
709 static int __init init_lustre_quota(void)
710 {
711         int rc = qunit_cache_init();
712         if (rc)
713                 return rc;
714         PORTAL_SYMBOL_REGISTER(filter_quota_interface);
715         PORTAL_SYMBOL_REGISTER(mds_quota_interface);
716         PORTAL_SYMBOL_REGISTER(mdc_quota_interface);
717         PORTAL_SYMBOL_REGISTER(osc_quota_interface);
718         PORTAL_SYMBOL_REGISTER(lov_quota_interface);
719         return 0;
720 }
721
722 static void /*__exit*/ exit_lustre_quota(void)
723 {
724         PORTAL_SYMBOL_UNREGISTER(filter_quota_interface);
725         PORTAL_SYMBOL_UNREGISTER(mds_quota_interface);
726         PORTAL_SYMBOL_UNREGISTER(mdc_quota_interface);
727         PORTAL_SYMBOL_UNREGISTER(osc_quota_interface);
728         PORTAL_SYMBOL_UNREGISTER(lov_quota_interface);
729
730         qunit_cache_cleanup();
731 }
732
733 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
734 MODULE_DESCRIPTION("Lustre Quota");
735 MODULE_LICENSE("GPL");
736
737 cfs_module(lquota, "1.0.0", init_lustre_quota, exit_lustre_quota);
738
739 EXPORT_SYMBOL(mds_quota_interface);
740 EXPORT_SYMBOL(filter_quota_interface);
741 EXPORT_SYMBOL(mdc_quota_interface);
742 EXPORT_SYMBOL(osc_quota_interface);
743 EXPORT_SYMBOL(lov_quota_interface);
744 #endif /* __KERNEL */