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