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