Whamcloud - gitweb
b=17167 libcfs: ensure all libcfs exported symbols to have cfs_ prefix
[fs/lustre-release.git] / lustre / include / lustre_quota.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
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.
11  *
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).
17  *
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
21  *
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
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36
37 #ifndef _LUSTRE_QUOTA_H
38 #define _LUSTRE_QUOTA_H
39
40 #if defined(__linux__)
41 #include <linux/lustre_quota.h>
42 #elif defined(__APPLE__)
43 #include <darwin/lustre_quota.h>
44 #elif defined(__WINNT__)
45 #include <winnt/lustre_quota.h>
46 #else
47 #error Unsupported operating system.
48 #endif
49
50 #include <lustre_net.h>
51 #include <lustre/lustre_idl.h>
52 #include <lvfs.h>
53 #include <obd_support.h>
54
55 struct obd_device;
56 struct client_obd;
57
58 #ifndef NR_DQHASH
59 #define NR_DQHASH 45
60 #endif
61
62 #ifndef QUOTABLOCK_BITS
63 #define QUOTABLOCK_BITS 10
64 #endif
65
66 #ifndef QUOTABLOCK_SIZE
67 #define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
68 #endif
69
70 #ifndef toqb
71 #define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS)
72 #endif
73
74 #ifdef HAVE_QUOTA_SUPPORT
75
76 #ifndef MAX_IQ_TIME
77 #define MAX_IQ_TIME  604800     /* (7*24*60*60) 1 week */
78 #endif
79
80 #ifndef MAX_DQ_TIME
81 #define MAX_DQ_TIME  604800     /* (7*24*60*60) 1 week */
82 #endif
83
84 #ifdef __KERNEL__
85
86 #ifdef LPROCFS
87 enum {
88         LQUOTA_FIRST_STAT = 0,
89         /** @{ */
90         /**
91          * these four are for measuring quota requests, for both of
92          * quota master and quota slaves
93          */
94         LQUOTA_SYNC_ACQ = LQUOTA_FIRST_STAT,
95         LQUOTA_SYNC_REL,
96         LQUOTA_ASYNC_ACQ,
97         LQUOTA_ASYNC_REL,
98         /** }@ */
99         /** @{ */
100         /**
101          * these four measure how much time I/O threads spend on dealing
102          * with quota before and after writing data or creating files,
103          * only for quota slaves(lquota_chkquota and lquota_pending_commit)
104          */
105         LQUOTA_WAIT_FOR_CHK_BLK,
106         LQUOTA_WAIT_FOR_CHK_INO,
107         LQUOTA_WAIT_FOR_COMMIT_BLK,
108         LQUOTA_WAIT_FOR_COMMIT_INO,
109         /** }@ */
110         /** @{ */
111         /**
112          * these two are for measuring time waiting return of quota reqs
113          * (qctxt_wait_pending_dqacq), only for quota salves
114          */
115         LQUOTA_WAIT_PENDING_BLK_QUOTA,
116         LQUOTA_WAIT_PENDING_INO_QUOTA,
117         /** }@ */
118         /** @{ */
119         /**
120          * these two are for those when they are calling
121          * qctxt_wait_pending_dqacq, the quota req has returned already,
122          * only for quota salves
123          */
124         LQUOTA_NOWAIT_PENDING_BLK_QUOTA,
125         LQUOTA_NOWAIT_PENDING_INO_QUOTA,
126         /** }@ */
127         /** @{ */
128         /**
129          * these are for quota ctl
130          */
131         LQUOTA_QUOTA_CTL,
132         /** }@ */
133         /** @{ */
134         /**
135          * these are for adjust quota qunit, for both of
136          * quota master and quota slaves
137          */
138         LQUOTA_ADJUST_QUNIT,
139         LQUOTA_LAST_STAT
140         /** }@ */
141 };
142 #endif  /* LPROCFS */
143
144 /* structures to access admin quotafile */
145 struct lustre_mem_dqinfo {
146         unsigned int dqi_bgrace;
147         unsigned int dqi_igrace;
148         unsigned long dqi_flags;
149         unsigned int dqi_blocks;
150         unsigned int dqi_free_blk;
151         unsigned int dqi_free_entry;
152 };
153
154 struct lustre_quota_info {
155         struct file *qi_files[MAXQUOTAS];
156         struct lustre_mem_dqinfo qi_info[MAXQUOTAS];
157         lustre_quota_version_t qi_version;
158 };
159
160 #define DQ_STATUS_AVAIL         0x0     /* Available dquot */
161 #define DQ_STATUS_SET           0x01    /* Sombody is setting dquot */
162 #define DQ_STATUS_RECOVERY      0x02    /* dquot is in recovery */
163
164 struct lustre_mem_dqblk {
165         __u64 dqb_bhardlimit;   /**< absolute limit on disk blks alloc */
166         __u64 dqb_bsoftlimit;   /**< preferred limit on disk blks */
167         __u64 dqb_curspace;     /**< current used space */
168         __u64 dqb_ihardlimit;   /**< absolute limit on allocated inodes */
169         __u64 dqb_isoftlimit;   /**< preferred inode limit */
170         __u64 dqb_curinodes;    /**< current # allocated inodes */
171         time_t dqb_btime;       /**< time limit for excessive disk use */
172         time_t dqb_itime;       /**< time limit for excessive inode use */
173 };
174
175 struct lustre_dquot {
176         /** Hash list in memory, protect by dquot_hash_lock */
177         cfs_list_t dq_hash;
178         /** Protect the data in lustre_dquot */
179         cfs_semaphore_t dq_sem;
180         /** Use count */
181         int dq_refcnt;
182         /** Pointer of quota info it belongs to */
183         struct lustre_quota_info *dq_info;
184         /** Offset of dquot on disk */
185         loff_t dq_off;
186         /** ID this applies to (uid, gid) */
187         unsigned int dq_id;
188         /** Type fo quota (USRQUOTA, GRPQUOUTA) */
189         int dq_type;
190         /** See DQ_STATUS_ */
191         unsigned short dq_status;
192         /** See DQ_ in quota.h */
193         unsigned long dq_flags;
194         /** Diskquota usage */
195         struct lustre_mem_dqblk dq_dqb;
196 };
197
198 struct dquot_id {
199         cfs_list_t              di_link;
200         __u32                   di_id;
201         __u32                   di_flag;
202 };
203 /* set inode quota limitation on a quota uid/gid */
204 #define QI_SET                (1 << 30)
205 /* set block quota limitation on a quota uid/gid */
206 #define QB_SET                (1 << 31)
207
208 #define QFILE_CHK               1
209 #define QFILE_RD_INFO           2
210 #define QFILE_WR_INFO           3
211 #define QFILE_INIT_INFO         4
212 #define QFILE_RD_DQUOT          5
213 #define QFILE_WR_DQUOT          6
214 #define QFILE_CONVERT           7
215
216 /* admin quotafile operations */
217 int lustre_check_quota_file(struct lustre_quota_info *lqi, int type);
218 int lustre_read_quota_info(struct lustre_quota_info *lqi, int type);
219 int lustre_write_quota_info(struct lustre_quota_info *lqi, int type);
220 int lustre_read_dquot(struct lustre_dquot *dquot);
221 int lustre_commit_dquot(struct lustre_dquot *dquot);
222 int lustre_init_quota_info(struct lustre_quota_info *lqi, int type);
223 int lustre_get_qids(struct file *file, struct inode *inode, int type,
224                     cfs_list_t *list);
225 int lustre_quota_convert(struct lustre_quota_info *lqi, int type);
226
227 typedef int (*dqacq_handler_t) (struct obd_device * obd, struct qunit_data * qd,
228                                 int opc);
229
230 /*
231 #ifdef HAVE_VFS_DQ_OFF
232 #define LL_DQUOT_OFF(sb, remount)    vfs_dq_off(sb, remount)
233 #else
234 #define LL_DQUOT_OFF(sb, remount)    DQUOT_OFF(sb)
235 #endif
236 */
237
238 #define LL_DQUOT_OFF(sb)    DQUOT_OFF(sb)
239
240
241 /* user quota is turned on on filter */
242 #define LQC_USRQUOTA_FLAG (1 << 0)
243 /* group quota is turned on on filter */
244 #define LQC_GRPQUOTA_FLAG (1 << 1)
245
246 #define UGQUOTA2LQC(id) ((Q_TYPEMATCH(id, USRQUOTA) ? LQC_USRQUOTA_FLAG : 0) | \
247                          (Q_TYPEMATCH(id, GRPQUOTA) ? LQC_GRPQUOTA_FLAG : 0))
248
249 struct lustre_quota_ctxt {
250         /** superblock this applies to */
251         struct super_block *lqc_sb;
252         /** obd_device_target for obt_rwsem */
253         struct obd_device_target *lqc_obt;
254         /** import used to send dqacq/dqrel RPC */
255         struct obd_import *lqc_import;
256         /** dqacq/dqrel RPC handler, only for quota master */
257         dqacq_handler_t lqc_handler;
258         /** quota flags */
259         unsigned long lqc_flags;
260         /** @{ */
261         unsigned long lqc_recovery:1,   /** Doing recovery */
262                       lqc_switch_qs:1,  /**
263                                          * the function of change qunit size
264                                          * 0:Off, 1:On
265                                          */
266                       lqc_valid:1,      /** this qctxt is valid or not */
267                       lqc_setup:1,      /**
268                                          * tell whether of not quota_type has
269                                          * been processed, so that the master
270                                          * knows when it can start processing
271                                          * incoming acq/rel quota requests
272                                          */
273                       lqc_immutable:1;  /**
274                                          * cannot be turned on/off on-fly;
275                                          * temporary used by SOM.
276                                          */
277         /** }@ */
278         /**
279          * original unit size of file quota and
280          * upper limitation for adjust file qunit
281          */
282         unsigned long lqc_iunit_sz;
283         /**
284          * Trigger dqacq when available file
285          * quota less than this value, trigger
286          * dqrel when available file quota
287          * more than this value + 1 iunit
288          */
289         unsigned long lqc_itune_sz;
290         /**
291          * original unit size of block quota and
292          * upper limitation for adjust block qunit
293          */
294         unsigned long lqc_bunit_sz;
295         /** See comment of lqc_itune_sz */
296         unsigned long lqc_btune_sz;
297         /** all lustre_qunit_size structures */
298         cfs_hash_t   *lqc_lqs_hash;
299
300         /** @{ */
301         /**
302          * the values below are relative to how master change its qunit sizes
303          */
304         /**
305          * this affects the boundary of
306          * shrinking and enlarging qunit size. default=4
307          */
308         unsigned long lqc_cqs_boundary_factor;
309         /** the least value of block qunit */
310         unsigned long lqc_cqs_least_bunit;
311         /** the least value of inode qunit */
312         unsigned long lqc_cqs_least_iunit;
313         /**
314          * when enlarging, qunit size will
315          * mutilple it; when shrinking,
316          * qunit size will divide it
317          */
318         unsigned long lqc_cqs_qs_factor;
319         /**
320          * avoid ping-pong effect of
321          * adjusting qunit size. How many
322          * seconds must be waited between
323          * enlarging and shinking qunit
324          */
325         /** }@ */
326         int           lqc_switch_seconds;
327         /**
328          * when blk qunit reaches this value,
329          * later write reqs from client should be sync b=16642
330          */
331         int           lqc_sync_blk;
332         /** guard lqc_imp_valid now */
333         cfs_spinlock_t lqc_lock;
334         /**
335          * when mds isn't connected, threads
336          * on osts who send the quota reqs
337          * with wait==1 will be put here b=14840
338          */
339         cfs_waitq_t   lqc_wait_for_qmaster;
340         struct proc_dir_entry *lqc_proc_dir;
341         /** lquota statistics */
342         struct lprocfs_stats  *lqc_stats;
343         /** the number of used hashed lqs */
344         cfs_atomic_t  lqc_lqs;
345         /** no lqs are in use */
346         cfs_waitq_t   lqc_lqs_waitq;
347 };
348
349 #define QUOTA_MASTER_READY(qctxt)   (qctxt)->lqc_setup = 1
350 #define QUOTA_MASTER_UNREADY(qctxt) (qctxt)->lqc_setup = 0
351
352 struct lustre_qunit_size {
353         cfs_hlist_node_t lqs_hash; /** the hash entry */
354         unsigned int lqs_id;        /** id of user/group */
355         unsigned long lqs_flags;    /** 31st bit is QB_SET, 30th bit is QI_SET
356                                      * other bits are same as LQUOTA_FLAGS_*
357                                      */
358         unsigned long lqs_iunit_sz; /** Unit size of file quota currently */
359         /**
360          * Trigger dqacq when available file quota
361          * less than this value, trigger dqrel
362          * when more than this value + 1 iunit
363          */
364         unsigned long lqs_itune_sz;
365         unsigned long lqs_bunit_sz; /** Unit size of block quota currently */
366         unsigned long lqs_btune_sz; /** See comment of lqs itune sz */
367         /** the blocks reached ost and don't finish */
368         unsigned long lqs_bwrite_pending;
369         /** the inodes reached mds and don't finish */
370         unsigned long lqs_iwrite_pending;
371         /** when inodes are allocated/released, this value will record it */
372         long long lqs_ino_rec;
373         /** when blocks are allocated/released, this value will record it */
374         long long lqs_blk_rec;
375         cfs_atomic_t lqs_refcount;
376         cfs_time_t lqs_last_bshrink;   /** time of last block shrink */
377         cfs_time_t lqs_last_ishrink;   /** time of last inode shrink */
378         cfs_spinlock_t lqs_lock;
379         unsigned long long lqs_key;    /** hash key */
380         struct lustre_quota_ctxt *lqs_ctxt; /** quota ctxt */
381 };
382
383 #define LQS_IS_GRP(lqs)    ((lqs)->lqs_flags & LQUOTA_FLAGS_GRP)
384 #define LQS_IS_ADJBLK(lqs) ((lqs)->lqs_flags & LQUOTA_FLAGS_ADJBLK)
385 #define LQS_IS_ADJINO(lqs) ((lqs)->lqs_flags & LQUOTA_FLAGS_ADJINO)
386
387 #define LQS_SET_GRP(lqs)    ((lqs)->lqs_flags |= LQUOTA_FLAGS_GRP)
388 #define LQS_SET_ADJBLK(lqs) ((lqs)->lqs_flags |= LQUOTA_FLAGS_ADJBLK)
389 #define LQS_SET_ADJINO(lqs) ((lqs)->lqs_flags |= LQUOTA_FLAGS_ADJINO)
390
391 /* In the hash for lustre_qunit_size, the key is decided by
392  * grp_or_usr and uid/gid, in here, I combine these two values,
393  * which will make comparing easier and more efficient */
394 #define LQS_KEY(is_grp, id)  ((is_grp ? 1ULL << 32: 0) + id)
395 #define LQS_KEY_ID(key)      (key & 0xffffffff)
396 #define LQS_KEY_GRP(key)     (key >> 32)
397
398 static inline void __lqs_getref(struct lustre_qunit_size *lqs)
399 {
400         int count = cfs_atomic_inc_return(&lqs->lqs_refcount);
401
402         if (count == 2) /* quota_create_lqs */
403                 cfs_atomic_inc(&lqs->lqs_ctxt->lqc_lqs);
404         CDEBUG(D_INFO, "lqs=%p refcount %d\n", lqs, count);
405 }
406
407 static inline void lqs_getref(struct lustre_qunit_size *lqs)
408 {
409         __lqs_getref(lqs);
410 }
411
412 static inline void __lqs_putref(struct lustre_qunit_size *lqs)
413 {
414         LASSERT(cfs_atomic_read(&lqs->lqs_refcount) > 0);
415
416         if (cfs_atomic_dec_return(&lqs->lqs_refcount) == 1)
417                 if (cfs_atomic_dec_and_test(&lqs->lqs_ctxt->lqc_lqs))
418                         cfs_waitq_signal(&lqs->lqs_ctxt->lqc_lqs_waitq);
419         CDEBUG(D_INFO, "lqs=%p refcount %d\n",
420                lqs, cfs_atomic_read(&lqs->lqs_refcount));
421 }
422
423 static inline void lqs_putref(struct lustre_qunit_size *lqs)
424 {
425         __lqs_putref(lqs);
426 }
427
428 static inline void lqs_initref(struct lustre_qunit_size *lqs)
429 {
430         cfs_atomic_set(&lqs->lqs_refcount, 0);
431 }
432
433 #else
434
435 struct lustre_quota_info {
436 };
437
438 struct lustre_quota_ctxt {
439 };
440
441 #define QUOTA_MASTER_READY(qctxt)
442 #define QUOTA_MASTER_UNREADY(qctxt)
443
444 #endif  /* !__KERNEL__ */
445
446 #else
447
448 #define LL_DQUOT_OFF(sb, remount) do {} while(0)
449
450 struct lustre_quota_info {
451 };
452
453 struct lustre_quota_ctxt {
454 };
455
456 #endif /* !HAVE_QUOTA_SUPPORT */
457
458 /* If the (quota limit < qunit * slave count), the slave which can't
459  * acquire qunit should set it's local limit as MIN_QLIMIT */
460 #define MIN_QLIMIT      1
461
462 struct quotacheck_thread_args {
463         struct obd_export   *qta_exp;   /** obd export */
464         struct obd_device   *qta_obd;   /** obd device */
465         struct obd_quotactl  qta_oqctl; /** obd_quotactl args */
466         struct super_block  *qta_sb;    /** obd super block */
467         cfs_semaphore_t     *qta_sem;   /** obt_quotachecking */
468 };
469
470 struct obd_trans_info;
471 typedef int (*quota_acquire)(struct obd_device *obd, const unsigned int id[],
472                              struct obd_trans_info *oti, int isblk);
473
474 typedef struct {
475         int (*quota_init) (void);
476         int (*quota_exit) (void);
477         int (*quota_setup) (struct obd_device *);
478         int (*quota_cleanup) (struct obd_device *);
479         /**
480          * For quota master, close admin quota files
481          */
482         int (*quota_fs_cleanup) (struct obd_device *);
483         int (*quota_ctl) (struct obd_device *, struct obd_export *,
484                           struct obd_quotactl *);
485         int (*quota_check) (struct obd_device *, struct obd_export *,
486                             struct obd_quotactl *);
487         int (*quota_recovery) (struct obd_device *);
488
489         /**
490          * For quota master/slave, adjust quota limit after fs operation
491          */
492         int (*quota_adjust) (struct obd_device *, const unsigned int[],
493                              const unsigned int[], int, int);
494
495         /**
496          * For quota slave, set import, trigger quota recovery,
497          * For quota master, set lqc_setup
498          */
499         int (*quota_setinfo) (struct obd_device *, void *);
500
501         /**
502          * For quota slave, clear import when relative import is invalid
503          */
504         int (*quota_clearinfo) (struct obd_export *, struct obd_device *);
505
506         /**
507          * For quota slave, set proper thread resoure capability
508          */
509         int (*quota_enforce) (struct obd_device *, unsigned int);
510
511         /**
512          * For quota slave, check whether specified uid/gid is over quota
513          */
514         int (*quota_getflag) (struct obd_device *, struct obdo *);
515
516 #ifdef __KERNEL__
517         /**
518          * For quota slave, acquire/release quota from master if needed
519          */
520         int (*quota_acquire) (struct obd_device *, const unsigned int [],
521                               struct obd_trans_info *, int);
522
523         /**
524          * For quota slave, check whether specified uid/gid's remaining quota
525          * can finish a block_write or inode_create rpc. It updates the pending
526          * record of block and inode, acquires quota if necessary
527          */
528         int (*quota_chkquota) (struct obd_device *, struct obd_export *,
529                                const unsigned int [], int [],
530                                int, quota_acquire, struct obd_trans_info *,
531                                int, struct inode *, int);
532
533         /**
534          * For quota client, the actions after the pending write is committed
535          */
536         int (*quota_pending_commit) (struct obd_device *, const unsigned int [],
537                                      int [], int);
538 #endif
539
540         /**
541          * For quota client, poll if the quota check done
542          */
543         int (*quota_poll_check) (struct obd_export *, struct if_quotacheck *);
544
545         /**
546          * For quota client, check whether specified uid/gid is over quota
547          */
548         int (*quota_chkdq) (struct client_obd *, const unsigned int []);
549
550         /**
551          * For quota client, set over quota flag for specifed uid/gid
552          */
553         int (*quota_setdq) (struct client_obd *, const unsigned int [],
554                             obd_flag, obd_flag);
555
556         /**
557          * For adjusting qunit size b=10600
558          */
559         int (*quota_adjust_qunit) (struct obd_export *exp,
560                                    struct quota_adjust_qunit *oqaq,
561                                    struct lustre_quota_ctxt *qctxt);
562
563 } quota_interface_t;
564
565 #define Q_COPY(out, in, member) (out)->member = (in)->member
566
567 #define QUOTA_OP(interface, op) interface->quota_ ## op
568
569 #define QUOTA_CHECK_OP(interface, op)                           \
570 do {                                                            \
571         if (!interface)                                         \
572                 RETURN(0);                                      \
573         if (!QUOTA_OP(interface, op)) {                         \
574                 CERROR("no quota operation: " #op "\n");        \
575                 RETURN(-EOPNOTSUPP);                            \
576         }                                                       \
577 } while(0)
578
579 static inline int lquota_init(quota_interface_t *interface)
580 {
581         int rc;
582         ENTRY;
583
584         QUOTA_CHECK_OP(interface, init);
585         rc = QUOTA_OP(interface, init)();
586         RETURN(rc);
587 }
588
589 static inline int lquota_exit(quota_interface_t *interface)
590 {
591         int rc;
592         ENTRY;
593
594         QUOTA_CHECK_OP(interface, exit);
595         rc = QUOTA_OP(interface, exit)();
596         RETURN(rc);
597 }
598
599 static inline int lquota_setup(quota_interface_t *interface,
600                                struct obd_device *obd)
601 {
602         int rc;
603         ENTRY;
604
605         QUOTA_CHECK_OP(interface, setup);
606         rc = QUOTA_OP(interface, setup)(obd);
607         RETURN(rc);
608 }
609
610 static inline int lquota_cleanup(quota_interface_t *interface,
611                                  struct obd_device *obd)
612 {
613         int rc;
614         ENTRY;
615
616         QUOTA_CHECK_OP(interface, cleanup);
617         rc = QUOTA_OP(interface, cleanup)(obd);
618         RETURN(rc);
619 }
620
621 static inline int lquota_fs_cleanup(quota_interface_t *interface,
622                                     struct obd_device *obd)
623 {
624         int rc;
625         ENTRY;
626
627         QUOTA_CHECK_OP(interface, fs_cleanup);
628         rc = QUOTA_OP(interface, fs_cleanup)(obd);
629         RETURN(rc);
630 }
631
632 static inline int lquota_recovery(quota_interface_t *interface,
633                                   struct obd_device *obd)
634 {
635         int rc;
636         ENTRY;
637
638         QUOTA_CHECK_OP(interface, recovery);
639         rc = QUOTA_OP(interface, recovery)(obd);
640         RETURN(rc);
641 }
642
643 static inline int lquota_check(quota_interface_t *interface,
644                                struct obd_device *obd,
645                                struct obd_export *exp,
646                                struct obd_quotactl *oqctl)
647 {
648         int rc;
649         ENTRY;
650
651         QUOTA_CHECK_OP(interface, check);
652         rc = QUOTA_OP(interface, check)(obd, exp, oqctl);
653         RETURN(rc);
654 }
655
656 static inline int lquota_ctl(quota_interface_t *interface,
657                              struct obd_device *obd,
658                              struct obd_quotactl *oqctl)
659 {
660         int rc;
661         ENTRY;
662
663         QUOTA_CHECK_OP(interface, ctl);
664         rc = QUOTA_OP(interface, ctl)(obd, NULL, oqctl);
665         RETURN(rc);
666 }
667
668 static inline int lquota_adjust(quota_interface_t *interface,
669                                 struct obd_device *obd,
670                                 const unsigned int qcids[],
671                                 const unsigned int qpids[],
672                                 int rc, int opc)
673 {
674         int ret;
675         ENTRY;
676
677         QUOTA_CHECK_OP(interface, adjust);
678         ret = QUOTA_OP(interface, adjust)(obd, qcids, qpids, rc, opc);
679         RETURN(ret);
680 }
681
682 static inline int lquota_chkdq(quota_interface_t *interface,
683                                struct client_obd *cli, const unsigned int qid[])
684 {
685         int rc;
686         ENTRY;
687
688         QUOTA_CHECK_OP(interface, chkdq);
689         rc = QUOTA_OP(interface, chkdq)(cli, qid);
690         RETURN(rc);
691 }
692
693 static inline int lquota_setdq(quota_interface_t *interface,
694                                struct client_obd *cli, const unsigned int qid[],
695                                obd_flag valid, obd_flag flags)
696 {
697         int rc;
698         ENTRY;
699
700         QUOTA_CHECK_OP(interface, setdq);
701         rc = QUOTA_OP(interface, setdq)(cli, qid, valid, flags);
702         RETURN(rc);
703 }
704
705 static inline int lquota_poll_check(quota_interface_t *interface,
706                                     struct obd_export *exp,
707                                     struct if_quotacheck *qchk)
708 {
709         int rc;
710         ENTRY;
711
712         QUOTA_CHECK_OP(interface, poll_check);
713         rc = QUOTA_OP(interface, poll_check)(exp, qchk);
714         RETURN(rc);
715 }
716
717 static inline int lquota_setinfo(quota_interface_t *interface,
718                                  struct obd_device *obd,
719                                  void *data)
720 {
721         int rc;
722         ENTRY;
723
724         QUOTA_CHECK_OP(interface, setinfo);
725         rc = QUOTA_OP(interface, setinfo)(obd, data);
726         RETURN(rc);
727 }
728
729 static inline int lquota_clearinfo(quota_interface_t *interface,
730                                    struct obd_export *exp,
731                                    struct obd_device *obd)
732 {
733         int rc;
734         ENTRY;
735
736         QUOTA_CHECK_OP(interface, clearinfo);
737         rc = QUOTA_OP(interface, clearinfo)(exp, obd);
738         RETURN(rc);
739 }
740
741 static inline int lquota_enforce(quota_interface_t *interface,
742                                  struct obd_device *obd,
743                                  unsigned int ignore)
744 {
745         int rc;
746         ENTRY;
747
748         QUOTA_CHECK_OP(interface, enforce);
749         rc = QUOTA_OP(interface, enforce)(obd, ignore);
750         RETURN(rc);
751 }
752
753 static inline int lquota_getflag(quota_interface_t *interface,
754                                  struct obd_device *obd, struct obdo *oa)
755 {
756         int rc;
757         ENTRY;
758
759         QUOTA_CHECK_OP(interface, getflag);
760         rc = QUOTA_OP(interface, getflag)(obd, oa);
761         RETURN(rc);
762 }
763
764 #ifdef __KERNEL__
765 static inline int lquota_chkquota(quota_interface_t *interface,
766                                   struct obd_device *obd,
767                                   struct obd_export *exp,
768                                   const unsigned int id[], int pending[],
769                                   int count, struct obd_trans_info *oti,
770                                   int isblk, void *data, int frags)
771 {
772         int rc;
773         ENTRY;
774
775         QUOTA_CHECK_OP(interface, chkquota);
776         QUOTA_CHECK_OP(interface, acquire);
777         rc = QUOTA_OP(interface, chkquota)(obd, exp, id, pending, count,
778                                            QUOTA_OP(interface, acquire), oti,
779                                            isblk, (struct inode *)data, frags);
780         RETURN(rc);
781 }
782
783 static inline int lquota_pending_commit(quota_interface_t *interface,
784                                         struct obd_device *obd,
785                                         const unsigned int id[],
786                                         int pending[], int isblk)
787 {
788         int rc;
789         ENTRY;
790
791         QUOTA_CHECK_OP(interface, pending_commit);
792         rc = QUOTA_OP(interface, pending_commit)(obd, id, pending, isblk);
793         RETURN(rc);
794 }
795 #endif
796
797 #ifndef __KERNEL__
798 extern quota_interface_t osc_quota_interface;
799 extern quota_interface_t lov_quota_interface;
800 extern quota_interface_t mdc_quota_interface;
801 extern quota_interface_t lmv_quota_interface;
802
803 #ifndef MAXQUOTAS
804 #define MAXQUOTAS 2
805 #endif
806
807 #ifndef USRQUOTA
808 #define USRQUOTA 0
809 #endif
810
811 #ifndef GRPQUOTA
812 #define GRPQUOTA 1
813 #endif
814
815 #endif
816
817 #define LUSTRE_ADMIN_QUOTAFILES_V2 {\
818         "admin_quotafile_v2.usr",       /** user admin quotafile */\
819         "admin_quotafile_v2.grp"        /** group admin quotafile */\
820 }
821
822 #endif /* _LUSTRE_QUOTA_H */