Whamcloud - gitweb
LU-13124 scrub: check for multiple linked file
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_quota_fmt.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 021110-1307, USA
20  *
21  * GPL HEADER END
22  */
23 /*
24  * Copyright (c) 2012, 2014, Intel Corporation.
25  * Use is subject to license terms.
26  *
27  * Lustre ldiskfs quota format
28  * from include/linux/quotaio_v2.h
29  */
30 #ifndef _OSD_QUOTA_FMT_H
31 #define _OSD_QUOTA_FMT_H
32
33 #include <linux/types.h>
34 #include <linux/quota.h>
35
36 /*
37  * The following structure defines the format of the disk quota file
38  * (as it appears on disk) - the file is a radix tree whose leaves point
39  * to blocks of these structures. for the version 2.
40  */
41 struct lustre_disk_dqblk_v2 {
42         __u32 dqb_id;         /**< id this quota applies to */
43         __u32 padding;
44         __u64 dqb_ihardlimit; /**< absolute limit on allocated inodes */
45         __u64 dqb_isoftlimit; /**< preferred inode limit */
46         __u64 dqb_curinodes;  /**< current # allocated inodes */
47         /**< absolute limit on disk space (in QUOTABLOCK_SIZE) */
48         __u64 dqb_bhardlimit;
49         /**< preferred limit on disk space (in QUOTABLOCK_SIZE) */
50         __u64 dqb_bsoftlimit;
51         __u64 dqb_curspace;   /**< current space occupied (in bytes) */
52         s64     dqb_btime;      /**< time limit for excessive disk use */
53         s64     dqb_itime;      /**< time limit for excessive inode use */
54 };
55
56 /* Number of entries in one blocks(14 entries) */
57 #define LUSTRE_DQSTRINBLK \
58                 ((LUSTRE_DQBLKSIZE - sizeof(struct lustre_disk_dqdbheader)) \
59                  / sizeof(struct lustre_disk_dqblk_v2))
60 #define GETENTRIES(buf) (((char *)buf)+sizeof(struct lustre_disk_dqdbheader))
61
62 /*
63  * Here are header structures as written on disk and their in-memory copies
64  */
65 /* First generic header */
66 struct lustre_disk_dqheader {
67         __u32 dqh_magic; /* Magic number identifying file */
68         __u32 dqh_version; /* File version */
69 };
70
71 /* Header with type and version specific information */
72 struct lustre_disk_dqinfo {
73         /* Time before block soft limit becomes hard limit */
74         __u32 dqi_bgrace;
75         /* Time before inode soft limit becomes hard limit */
76         __u32 dqi_igrace;
77         /* Flags for quotafile (DQF_*) */
78         __u32 dqi_flags;
79         /* Number of blocks in file */
80         __u32 dqi_blocks;
81         /* Number of first free block in the list */
82         __u32 dqi_free_blk;
83         /* Number of block with at least one free entry */
84         __u32 dqi_free_entry;
85 };
86
87 /*
88  *  Structure of header of block with quota structures. It is padded to
89  *  16 bytes so there will be space for exactly 21 quota-entries in a block
90  */
91 struct lustre_disk_dqdbheader {
92         __u32 dqdh_next_free; /* Number of next block with free entry */
93         __u32 dqdh_prev_free; /* Number of previous block with free entry */
94         __u16 dqdh_entries;   /* Number of valid entries in block */
95         __u16 dqdh_pad1;
96         __u32 dqdh_pad2;
97 };
98
99 /* Offset of info header in file */
100 #define LUSTRE_DQINFOOFF        sizeof(struct lustre_disk_dqheader)
101 #define LUSTRE_DQBLKSIZE_BITS   10
102 /* Size of block with quota structures */
103 #define LUSTRE_DQBLKSIZE        (1 << LUSTRE_DQBLKSIZE_BITS)
104 /* Offset of tree in file in blocks */
105 #define LUSTRE_DQTREEOFF        1
106 /* Depth of quota tree */
107 #define LUSTRE_DQTREEDEPTH      4
108
109 #define GETIDINDEX(id, depth)   (((id) >> \
110                                 ((LUSTRE_DQTREEDEPTH - (depth) - 1) * 8)) & \
111                                 0xff)
112 #endif /* osd_quota_fmt.h */