Whamcloud - gitweb
b=16098
[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  * 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 [sun.com URL with a
20  * copy of GPLv2].
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  * lustre/lvfs/lustre_quota_fmt.h
37  *
38  * Lustre administrative quota format
39  * from include/linux/quotaio_v2.h
40  */
41 #ifndef _LUSTRE_QUOTA_FMT_H
42 #define _LUSTRE_QUOTA_FMT_H
43
44 #include <linux/types.h>
45 #include <linux/quota.h>
46
47 /*
48  * Definitions of magics and versions of current quota files
49  * Same with quota v2's magic
50  */
51 #define LUSTRE_INITQMAGICS {\
52         0xd9c01f11,     /* USRQUOTA */\
53         0xd9c01927      /* GRPQUOTA */\
54 }
55
56 #define LUSTRE_INITQVERSIONS {\
57         0,              /* USRQUOTA */\
58         0               /* GRPQUOTA */\
59 }
60
61 /*
62  * The following structure defines the format of the disk quota file
63  * (as it appears on disk) - the file is a radix tree whose leaves point
64  * to blocks of these structures.
65  */
66 struct lustre_disk_dqblk {
67         __u32 dqb_id;           /* id this quota applies to */
68         __u32 dqb_ihardlimit;   /* absolute limit on allocated inodes */
69         __u32 dqb_isoftlimit;   /* preferred inode limit */
70         __u32 dqb_curinodes;    /* current # allocated inodes */
71         __u32 dqb_bhardlimit;   /* absolute limit on disk space (in QUOTABLOCK_SIZE) */
72         __u32 dqb_bsoftlimit;   /* preferred limit on disk space (in QUOTABLOCK_SIZE) */
73         __u64 dqb_curspace;     /* current space occupied (in bytes) */
74         __u64 dqb_btime;        /* time limit for excessive disk use */
75         __u64 dqb_itime;        /* time limit for excessive inode use */
76 };
77
78 /*
79  * Here are header structures as written on disk and their in-memory copies
80  */
81 /* First generic header */
82 struct lustre_disk_dqheader {
83         __u32 dqh_magic;        /* Magic number identifying file */
84         __u32 dqh_version;      /* File version */
85 };
86
87 /* Header with type and version specific information */
88 struct lustre_disk_dqinfo {
89         __u32 dqi_bgrace;       /* Time before block soft limit becomes hard limit */
90         __u32 dqi_igrace;       /* Time before inode soft limit becomes hard limit */
91         __u32 dqi_flags;        /* Flags for quotafile (DQF_*) */
92         __u32 dqi_blocks;       /* Number of blocks in file */
93         __u32 dqi_free_blk;     /* Number of first free block in the list */
94         __u32 dqi_free_entry;   /* Number of block with at least one free entry */
95 };
96
97 /*
98  *  Structure of header of block with quota structures. It is padded to 16 bytes so
99  *  there will be space for exactly 21 quota-entries in a block
100  */
101 struct lustre_disk_dqdbheader {
102         __u32 dqdh_next_free;   /* Number of next block with free entry */
103         __u32 dqdh_prev_free;   /* Number of previous block with free entry */
104         __u16 dqdh_entries;     /* Number of valid entries in block */
105         __u16 dqdh_pad1;
106         __u32 dqdh_pad2;
107 };
108
109 #ifdef LPROCFS
110 void lprocfs_quotfmt_test_init_vars(struct lprocfs_static_vars *lvars);
111 #else
112 static void lprocfs_quotfmt_test_init_vars(struct lprocfs_static_vars *lvars) {}
113 #endif
114
115 #define LUSTRE_DQINFOOFF        sizeof(struct lustre_disk_dqheader)     /* Offset of info header in file */
116 #define LUSTRE_DQBLKSIZE_BITS   10
117 #define LUSTRE_DQBLKSIZE        (1 << LUSTRE_DQBLKSIZE_BITS)    /* Size of block with quota structures */
118 #define LUSTRE_DQTREEOFF        1       /* Offset of tree in file in blocks */
119 #define LUSTRE_DQTREEDEPTH      4       /* Depth of quota tree */
120 #define LUSTRE_DQSTRINBLK       ((LUSTRE_DQBLKSIZE - sizeof(struct lustre_disk_dqdbheader)) / sizeof(struct lustre_disk_dqblk)) /* Number of entries in one blocks */
121
122 #endif                          /* lustre_quota_fmt.h */