Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / lvfs / lustre_quota_fmt.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Lustre administrative quota format
5  *
6  * from
7  * include/linux/quotaio_v2.h
8  */
9 #ifndef _LUSTRE_QUOTA_FMT_H
10 #define _LUSTRE_QUOTA_FMT_H
11
12 #include <linux/types.h>
13 #include <linux/quota.h>
14
15 /*
16  * Definitions of magics and versions of current quota files
17  * Same with quota v2's magic
18  */
19 #define LUSTRE_INITQMAGICS {\
20         0xd9c01f11,     /* USRQUOTA */\
21         0xd9c01927      /* GRPQUOTA */\
22 }
23
24 #define LUSTRE_INITQVERSIONS {\
25         0,              /* USRQUOTA */\
26         0               /* GRPQUOTA */\
27 }
28
29 /*
30  * The following structure defines the format of the disk quota file
31  * (as it appears on disk) - the file is a radix tree whose leaves point
32  * to blocks of these structures.
33  */
34 struct lustre_disk_dqblk {
35         __u32 dqb_id;           /* id this quota applies to */
36         __u32 dqb_ihardlimit;   /* absolute limit on allocated inodes */
37         __u32 dqb_isoftlimit;   /* preferred inode limit */
38         __u32 dqb_curinodes;    /* current # allocated inodes */
39         __u32 dqb_bhardlimit;   /* absolute limit on disk space (in QUOTABLOCK_SIZE) */
40         __u32 dqb_bsoftlimit;   /* preferred limit on disk space (in QUOTABLOCK_SIZE) */
41         __u64 dqb_curspace;     /* current space occupied (in bytes) */
42         __u64 dqb_btime;        /* time limit for excessive disk use */
43         __u64 dqb_itime;        /* time limit for excessive inode use */
44 };
45
46 /*
47  * Here are header structures as written on disk and their in-memory copies
48  */
49 /* First generic header */
50 struct lustre_disk_dqheader {
51         __u32 dqh_magic;        /* Magic number identifying file */
52         __u32 dqh_version;      /* File version */
53 };
54
55 /* Header with type and version specific information */
56 struct lustre_disk_dqinfo {
57         __u32 dqi_bgrace;       /* Time before block soft limit becomes hard limit */
58         __u32 dqi_igrace;       /* Time before inode soft limit becomes hard limit */
59         __u32 dqi_flags;        /* Flags for quotafile (DQF_*) */
60         __u32 dqi_blocks;       /* Number of blocks in file */
61         __u32 dqi_free_blk;     /* Number of first free block in the list */
62         __u32 dqi_free_entry;   /* Number of block with at least one free entry */
63 };
64
65 /*
66  *  Structure of header of block with quota structures. It is padded to 16 bytes so
67  *  there will be space for exactly 21 quota-entries in a block
68  */
69 struct lustre_disk_dqdbheader {
70         __u32 dqdh_next_free;   /* Number of next block with free entry */
71         __u32 dqdh_prev_free;   /* Number of previous block with free entry */
72         __u16 dqdh_entries;     /* Number of valid entries in block */
73         __u16 dqdh_pad1;
74         __u32 dqdh_pad2;
75 };
76
77 #define LUSTRE_DQINFOOFF        sizeof(struct lustre_disk_dqheader)     /* Offset of info header in file */
78 #define LUSTRE_DQBLKSIZE_BITS   10
79 #define LUSTRE_DQBLKSIZE        (1 << LUSTRE_DQBLKSIZE_BITS)    /* Size of block with quota structures */
80 #define LUSTRE_DQTREEOFF        1       /* Offset of tree in file in blocks */
81 #define LUSTRE_DQTREEDEPTH      4       /* Depth of quota tree */
82 #define LUSTRE_DQSTRINBLK       ((LUSTRE_DQBLKSIZE - sizeof(struct lustre_disk_dqdbheader)) / sizeof(struct lustre_disk_dqblk)) /* Number of entries in one blocks */
83
84 #endif                          /* lustre_quota_fmt.h */