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