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