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