Whamcloud - gitweb
9c6cd5d17dfde58a8e4a107ba303ec0c122a9f16
[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 };
183
184 #define QFILE_CHK               1
185 #define QFILE_RD_INFO           2
186 #define QFILE_WR_INFO           3
187 #define QFILE_INIT_INFO         4
188 #define QFILE_RD_DQUOT          5
189 #define QFILE_WR_DQUOT          6
190 #define QFILE_CONVERT           7
191
192 /* admin quotafile operations */
193 int lustre_check_quota_file(struct lustre_quota_info *lqi, int type);
194 int lustre_read_quota_info(struct lustre_quota_info *lqi, int type);
195 int lustre_write_quota_info(struct lustre_quota_info *lqi, int type);
196 int lustre_read_dquot(struct lustre_dquot *dquot);
197 int lustre_commit_dquot(struct lustre_dquot *dquot);
198 int lustre_init_quota_info(struct lustre_quota_info *lqi, int type);
199 int lustre_get_qids(struct file *file, struct inode *inode, int type,
200                     struct list_head *list);
201 int lustre_quota_convert(struct lustre_quota_info *lqi, int type);
202
203 #define LL_DQUOT_OFF(sb)    DQUOT_OFF(sb)
204
205 typedef int (*dqacq_handler_t) (struct obd_device * obd, struct qunit_data * qd,
206                                 int opc);
207
208 /* user quota is turned on on filter */
209 #define LQC_USRQUOTA_FLAG (1 << 0)
210 /* group quota is turned on on filter */
211 #define LQC_GRPQUOTA_FLAG (1 << 1)
212
213 #define UGQUOTA2LQC(id) ((Q_TYPEMATCH(id, USRQUOTA) ? LQC_USRQUOTA_FLAG : 0) | \
214                          (Q_TYPEMATCH(id, GRPQUOTA) ? LQC_GRPQUOTA_FLAG : 0))
215
216 struct lustre_quota_ctxt {
217         /** superblock this applies to */
218         struct super_block *lqc_sb;
219         /** obd_device_target for obt_rwsem */
220         struct obd_device_target *lqc_obt;
221         /** import used to send dqacq/dqrel RPC */
222         struct obd_import *lqc_import;
223         /** dqacq/dqrel RPC handler, only for quota master */
224         dqacq_handler_t lqc_handler;
225         /** quota flags */
226         unsigned long lqc_flags;
227         /** @{ */
228         unsigned long lqc_recovery:1,   /** Doing recovery */
229                       lqc_switch_qs:1,  /**
230                                          * the function of change qunit size
231                                          * 0:Off, 1:On
232                                          */
233                       lqc_valid:1,      /** this qctxt is valid or not */
234                       lqc_setup:1,      /**
235                                          * tell whether of not quota_type has
236                                          * been processed, so that the master
237                                          * knows when it can start processing
238                                          * incoming acq/rel quota requests
239                                          */
240                       lqc_immutable:1;  /**
241                                          * cannot be turned on/off on-fly;
242                                          * temporary used by SOM.
243                                          */
244         /** }@ */
245         /**
246          * original unit size of file quota and
247          * upper limitation for adjust file qunit
248          */
249         unsigned long lqc_iunit_sz;
250         /**
251          * Trigger dqacq when available file
252          * quota less than this value, trigger
253          * dqrel when available file quota
254          * more than this value + 1 iunit
255          */
256         unsigned long lqc_itune_sz;
257         /**
258          * original unit size of block quota and
259          * upper limitation for adjust block qunit
260          */
261         unsigned long lqc_bunit_sz;
262         /** See comment of lqc_itune_sz */
263         unsigned long lqc_btune_sz;
264         /** all lustre_qunit_size structures */
265         struct lustre_hash *lqc_lqs_hash;
266
267         /** @{ */
268         /**
269          * the values below are relative to how master change its qunit sizes
270          */
271         /**
272          * this affects the boundary of
273          * shrinking and enlarging qunit size. default=4
274          */
275         unsigned long lqc_cqs_boundary_factor;
276         /** the least value of block qunit */
277         unsigned long lqc_cqs_least_bunit;
278         /** the least value of inode qunit */
279         unsigned long lqc_cqs_least_iunit;
280         /**
281          * when enlarging, qunit size will
282          * mutilple it; when shrinking,
283          * qunit size will divide it
284          */
285         unsigned long lqc_cqs_qs_factor;
286         /**
287          * avoid ping-pong effect of
288          * adjusting qunit size. How many
289          * seconds must be waited between
290          * enlarging and shinking qunit
291          */
292         /** }@ */
293         int           lqc_switch_seconds;
294         /**
295          * when blk qunit reaches this value,
296          * later write reqs from client should be sync b=16642
297          */
298         int           lqc_sync_blk;
299         /** guard lqc_imp_valid now */
300         spinlock_t    lqc_lock;
301         /**
302          * when mds isn't connected, threads
303          * on osts who send the quota reqs
304          * with wait==1 will be put here b=14840
305          */
306         cfs_waitq_t   lqc_wait_for_qmaster;
307         struct proc_dir_entry *lqc_proc_dir;
308         /** lquota statistics */
309         struct lprocfs_stats  *lqc_stats;
310 };
311
312 #define QUOTA_MASTER_READY(qctxt)   (qctxt)->lqc_setup = 1
313 #define QUOTA_MASTER_UNREADY(qctxt) (qctxt)->lqc_setup = 0
314
315 struct lustre_qunit_size {
316         struct hlist_node lqs_hash; /** the hash entry */
317         unsigned int lqs_id;        /** id of user/group */
318         unsigned long lqs_flags;    /** is user/group; FULLBUF or LESSBUF */
319         unsigned long lqs_iunit_sz; /** Unit size of file quota currently */
320         /**
321          * Trigger dqacq when available file quota
322          * less than this value, trigger dqrel
323          * when more than this value + 1 iunit
324          */
325         unsigned long lqs_itune_sz;
326         unsigned long lqs_bunit_sz; /** Unit size of block quota currently */
327         unsigned long lqs_btune_sz; /** See comment of lqs itune sz */
328         /** the blocks reached ost and don't finish */
329         unsigned long lqs_bwrite_pending;
330         /** the inodes reached mds and don't finish */
331         unsigned long lqs_iwrite_pending;
332         /** when inodes are allocated/released, this value will record it */
333         long long lqs_ino_rec;
334         /** when blocks are allocated/released, this value will record it */
335         long long lqs_blk_rec;
336         atomic_t lqs_refcount;
337         cfs_time_t lqs_last_bshrink;   /** time of last block shrink */
338         cfs_time_t lqs_last_ishrink;   /** time of last inode shrink */
339         spinlock_t lqs_lock;
340         struct quota_adjust_qunit lqs_key; /** hash key */
341         struct lustre_quota_ctxt *lqs_ctxt; /** quota ctxt */
342 };
343
344 #define LQS_IS_GRP(lqs)    ((lqs)->lqs_flags & LQUOTA_FLAGS_GRP)
345 #define LQS_IS_ADJBLK(lqs) ((lqs)->lqs_flags & LQUOTA_FLAGS_ADJBLK)
346 #define LQS_IS_ADJINO(lqs) ((lqs)->lqs_flags & LQUOTA_FLAGS_ADJINO)
347
348 #define LQS_SET_GRP(lqs)    ((lqs)->lqs_flags |= LQUOTA_FLAGS_GRP)
349 #define LQS_SET_ADJBLK(lqs) ((lqs)->lqs_flags |= LQUOTA_FLAGS_ADJBLK)
350 #define LQS_SET_ADJINO(lqs) ((lqs)->lqs_flags |= LQUOTA_FLAGS_ADJINO)
351
352 static inline void lqs_getref(struct lustre_qunit_size *lqs)
353 {
354         atomic_inc(&lqs->lqs_refcount);
355         CDEBUG(D_QUOTA, "lqs=%p refcount %d\n",
356                lqs, atomic_read(&lqs->lqs_refcount));
357 }
358
359 static inline void lqs_putref(struct lustre_qunit_size *lqs)
360 {
361         LASSERT(atomic_read(&lqs->lqs_refcount) > 0);
362
363         /* killing last ref, let's let hash table kill it */
364         if (atomic_read(&lqs->lqs_refcount) == 1) {
365                 lustre_hash_del(lqs->lqs_ctxt->lqc_lqs_hash,
366                                 &lqs->lqs_key, &lqs->lqs_hash);
367                 OBD_FREE_PTR(lqs);
368         } else {
369                 atomic_dec(&lqs->lqs_refcount);
370                 CDEBUG(D_QUOTA, "lqs=%p refcount %d\n",
371                        lqs, atomic_read(&lqs->lqs_refcount));
372
373         }
374 }
375
376 static inline void lqs_initref(struct lustre_qunit_size *lqs)
377 {
378         atomic_set(&lqs->lqs_refcount, 0);
379 }
380
381 #else
382
383 struct lustre_quota_info {
384 };
385
386 struct lustre_quota_ctxt {
387 };
388
389 #define QUOTA_MASTER_READY(qctxt)
390 #define QUOTA_MASTER_UNREADY(qctxt)
391
392 #endif  /* !__KERNEL__ */
393
394 #else
395
396 #define LL_DQUOT_OFF(sb) do {} while(0)
397
398 struct lustre_quota_info {
399 };
400
401 struct lustre_quota_ctxt {
402 };
403
404 #endif /* !HAVE_QUOTA_SUPPORT */
405
406 /* If the (quota limit < qunit * slave count), the slave which can't
407  * acquire qunit should set it's local limit as MIN_QLIMIT */
408 #define MIN_QLIMIT      1
409
410 struct quotacheck_thread_args {
411         struct obd_export   *qta_exp;   /** obd export */
412         struct obd_device   *qta_obd;   /** obd device */
413         struct obd_quotactl  qta_oqctl; /** obd_quotactl args */
414         struct super_block  *qta_sb;    /** obd super block */
415         atomic_t            *qta_sem;   /** obt_quotachecking */
416 };
417
418 struct obd_trans_info;
419 typedef int (*quota_acquire)(struct obd_device *obd, const unsigned int id[],
420                              struct obd_trans_info *oti, int isblk);
421
422 typedef struct {
423         int (*quota_init) (void);
424         int (*quota_exit) (void);
425         int (*quota_setup) (struct obd_device *);
426         int (*quota_cleanup) (struct obd_device *);
427         /**
428          * For quota master, close admin quota files
429          */
430         int (*quota_fs_cleanup) (struct obd_device *);
431         int (*quota_ctl) (struct obd_device *, struct obd_export *,
432                           struct obd_quotactl *);
433         int (*quota_check) (struct obd_device *, struct obd_export *,
434                             struct obd_quotactl *);
435         int (*quota_recovery) (struct obd_device *);
436
437         /**
438          * For quota master/slave, adjust quota limit after fs operation
439          */
440         int (*quota_adjust) (struct obd_device *, const unsigned int[],
441                              const unsigned int[], int, int);
442
443         /**
444          * For quota slave, set import, trigger quota recovery,
445          * For quota master, set lqc_setup
446          */
447         int (*quota_setinfo) (struct obd_device *, void *);
448
449         /**
450          * For quota slave, clear import when relative import is invalid
451          */
452         int (*quota_clearinfo) (struct obd_export *, struct obd_device *);
453
454         /**
455          * For quota slave, set proper thread resoure capability
456          */
457         int (*quota_enforce) (struct obd_device *, unsigned int);
458
459         /**
460          * For quota slave, check whether specified uid/gid is over quota
461          */
462         int (*quota_getflag) (struct obd_device *, struct obdo *);
463
464 #ifdef __KERNEL__
465         /**
466          * For quota slave, acquire/release quota from master if needed
467          */
468         int (*quota_acquire) (struct obd_device *, const unsigned int [],
469                               struct obd_trans_info *, int);
470
471         /**
472          * For quota slave, check whether specified uid/gid's remaining quota
473          * can finish a block_write or inode_create rpc. It updates the pending
474          * record of block and inode, acquires quota if necessary
475          */
476         int (*quota_chkquota) (struct obd_device *, const unsigned int [],
477                                int [], int, quota_acquire,
478                                struct obd_trans_info *, int, struct inode *,
479                                int);
480
481         /**
482          * For quota client, the actions after the pending write is committed
483          */
484         int (*quota_pending_commit) (struct obd_device *, const unsigned int [],
485                                      int [], int);
486 #endif
487
488         /**
489          * For quota client, poll if the quota check done
490          */
491         int (*quota_poll_check) (struct obd_export *, struct if_quotacheck *);
492
493         /**
494          * For quota client, check whether specified uid/gid is over quota
495          */
496         int (*quota_chkdq) (struct client_obd *, const unsigned int []);
497
498         /**
499          * For quota client, set over quota flag for specifed uid/gid
500          */
501         int (*quota_setdq) (struct client_obd *, const unsigned int [],
502                             obd_flag, obd_flag);
503
504         /**
505          * For adjusting qunit size b=10600
506          */
507         int (*quota_adjust_qunit) (struct obd_export *exp,
508                                    struct quota_adjust_qunit *oqaq,
509                                    struct lustre_quota_ctxt *qctxt);
510
511 } quota_interface_t;
512
513 #define Q_COPY(out, in, member) (out)->member = (in)->member
514
515 #define QUOTA_OP(interface, op) interface->quota_ ## op
516
517 #define QUOTA_CHECK_OP(interface, op)                           \
518 do {                                                            \
519         if (!interface)                                         \
520                 RETURN(0);                                      \
521         if (!QUOTA_OP(interface, op)) {                         \
522                 CERROR("no quota operation: " #op "\n");        \
523                 RETURN(-EOPNOTSUPP);                            \
524         }                                                       \
525 } while(0)
526
527 static inline int lquota_init(quota_interface_t *interface)
528 {
529         int rc;
530         ENTRY;
531
532         QUOTA_CHECK_OP(interface, init);
533         rc = QUOTA_OP(interface, init)();
534         RETURN(rc);
535 }
536
537 static inline int lquota_exit(quota_interface_t *interface)
538 {
539         int rc;
540         ENTRY;
541
542         QUOTA_CHECK_OP(interface, exit);
543         rc = QUOTA_OP(interface, exit)();
544         RETURN(rc);
545 }
546
547 static inline int lquota_setup(quota_interface_t *interface,
548                                struct obd_device *obd)
549 {
550         int rc;
551         ENTRY;
552
553         QUOTA_CHECK_OP(interface, setup);
554         rc = QUOTA_OP(interface, setup)(obd);
555         RETURN(rc);
556 }
557
558 static inline int lquota_cleanup(quota_interface_t *interface,
559                                  struct obd_device *obd)
560 {
561         int rc;
562         ENTRY;
563
564         QUOTA_CHECK_OP(interface, cleanup);
565         rc = QUOTA_OP(interface, cleanup)(obd);
566         RETURN(rc);
567 }
568
569 static inline int lquota_fs_cleanup(quota_interface_t *interface,
570                                     struct obd_device *obd)
571 {
572         int rc;
573         ENTRY;
574
575         QUOTA_CHECK_OP(interface, fs_cleanup);
576         rc = QUOTA_OP(interface, fs_cleanup)(obd);
577         RETURN(rc);
578 }
579
580 static inline int lquota_recovery(quota_interface_t *interface,
581                                   struct obd_device *obd)
582 {
583         int rc;
584         ENTRY;
585
586         QUOTA_CHECK_OP(interface, recovery);
587         rc = QUOTA_OP(interface, recovery)(obd);
588         RETURN(rc);
589 }
590
591 static inline int lquota_check(quota_interface_t *interface,
592                                struct obd_device *obd,
593                                struct obd_export *exp,
594                                struct obd_quotactl *oqctl)
595 {
596         int rc;
597         ENTRY;
598
599         QUOTA_CHECK_OP(interface, check);
600         rc = QUOTA_OP(interface, check)(obd, exp, oqctl);
601         RETURN(rc);
602 }
603
604 static inline int lquota_ctl(quota_interface_t *interface,
605                              struct obd_device *obd,
606                              struct obd_quotactl *oqctl)
607 {
608         int rc;
609         ENTRY;
610
611         QUOTA_CHECK_OP(interface, ctl);
612         rc = QUOTA_OP(interface, ctl)(obd, NULL, oqctl);
613         RETURN(rc);
614 }
615
616 static inline int lquota_adjust(quota_interface_t *interface,
617                                 struct obd_device *obd,
618                                 const unsigned int qcids[],
619                                 const unsigned int qpids[],
620                                 int rc, int opc)
621 {
622         int ret;
623         ENTRY;
624
625         QUOTA_CHECK_OP(interface, adjust);
626         ret = QUOTA_OP(interface, adjust)(obd, qcids, qpids, rc, opc);
627         RETURN(ret);
628 }
629
630 static inline int lquota_chkdq(quota_interface_t *interface,
631                                struct client_obd *cli, const unsigned int qid[])
632 {
633         int rc;
634         ENTRY;
635
636         QUOTA_CHECK_OP(interface, chkdq);
637         rc = QUOTA_OP(interface, chkdq)(cli, qid);
638         RETURN(rc);
639 }
640
641 static inline int lquota_setdq(quota_interface_t *interface,
642                                struct client_obd *cli, const unsigned int qid[],
643                                obd_flag valid, obd_flag flags)
644 {
645         int rc;
646         ENTRY;
647
648         QUOTA_CHECK_OP(interface, setdq);
649         rc = QUOTA_OP(interface, setdq)(cli, qid, valid, flags);
650         RETURN(rc);
651 }
652
653 static inline int lquota_poll_check(quota_interface_t *interface,
654                                     struct obd_export *exp,
655                                     struct if_quotacheck *qchk)
656 {
657         int rc;
658         ENTRY;
659
660         QUOTA_CHECK_OP(interface, poll_check);
661         rc = QUOTA_OP(interface, poll_check)(exp, qchk);
662         RETURN(rc);
663 }
664
665 static inline int lquota_setinfo(quota_interface_t *interface,
666                                  struct obd_device *obd,
667                                  void *data)
668 {
669         int rc;
670         ENTRY;
671
672         QUOTA_CHECK_OP(interface, setinfo);
673         rc = QUOTA_OP(interface, setinfo)(obd, data);
674         RETURN(rc);
675 }
676
677 static inline int lquota_clearinfo(quota_interface_t *interface,
678                                    struct obd_export *exp,
679                                    struct obd_device *obd)
680 {
681         int rc;
682         ENTRY;
683
684         QUOTA_CHECK_OP(interface, clearinfo);
685         rc = QUOTA_OP(interface, clearinfo)(exp, obd);
686         RETURN(rc);
687 }
688
689 static inline int lquota_enforce(quota_interface_t *interface,
690                                  struct obd_device *obd,
691                                  unsigned int ignore)
692 {
693         int rc;
694         ENTRY;
695
696         QUOTA_CHECK_OP(interface, enforce);
697         rc = QUOTA_OP(interface, enforce)(obd, ignore);
698         RETURN(rc);
699 }
700
701 static inline int lquota_getflag(quota_interface_t *interface,
702                                  struct obd_device *obd, struct obdo *oa)
703 {
704         int rc;
705         ENTRY;
706
707         QUOTA_CHECK_OP(interface, getflag);
708         rc = QUOTA_OP(interface, getflag)(obd, oa);
709         RETURN(rc);
710 }
711
712 #ifdef __KERNEL__
713 static inline int lquota_chkquota(quota_interface_t *interface,
714                                   struct obd_device *obd,
715                                   const unsigned int id[], int pending[],
716                                   int count, struct obd_trans_info *oti,
717                                   int isblk, void *data, int frags)
718 {
719         int rc;
720         ENTRY;
721
722         QUOTA_CHECK_OP(interface, chkquota);
723         QUOTA_CHECK_OP(interface, acquire);
724         rc = QUOTA_OP(interface, chkquota)(obd, id, pending, count,
725                                            QUOTA_OP(interface, acquire), oti,
726                                            isblk, (struct inode *)data, frags);
727         RETURN(rc);
728 }
729
730 static inline int lquota_pending_commit(quota_interface_t *interface,
731                                         struct obd_device *obd,
732                                         const unsigned int id[],
733                                         int pending[], int isblk)
734 {
735         int rc;
736         ENTRY;
737
738         QUOTA_CHECK_OP(interface, pending_commit);
739         rc = QUOTA_OP(interface, pending_commit)(obd, id, pending, isblk);
740         RETURN(rc);
741 }
742 #endif
743
744 #ifndef __KERNEL__
745 extern quota_interface_t osc_quota_interface;
746 extern quota_interface_t lov_quota_interface;
747 extern quota_interface_t mdc_quota_interface;
748 extern quota_interface_t lmv_quota_interface;
749
750 #ifndef MAXQUOTAS
751 #define MAXQUOTAS 2
752 #endif
753
754 #ifndef USRQUOTA
755 #define USRQUOTA 0
756 #endif
757
758 #ifndef GRPQUOTA
759 #define GRPQUOTA 1
760 #endif
761
762 #endif
763
764 #define LUSTRE_ADMIN_QUOTAFILES_V2 {\
765         "admin_quotafile_v2.usr",       /** user admin quotafile */\
766         "admin_quotafile_v2.grp"        /** group admin quotafile */\
767 }
768
769 #endif /* _LUSTRE_QUOTA_H */