4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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
24 * Copyright (c) 2012, Intel Corporation.
25 * Use is subject to license terms.
27 * Lustre ldiskfs quota format
28 * from include/linux/quotaio_v2.h
30 #ifndef _OSD_QUOTA_FMT_H
31 #define _OSD_QUOTA_FMT_H
33 #include <linux/types.h>
34 #include <linux/quota.h>
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.
41 struct lustre_disk_dqblk_v2 {
42 __u32 dqb_id; /**< id this quota applies to */
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) */
49 /**< preferred limit on disk space (in QUOTABLOCK_SIZE) */
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 */
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))
63 * Here are header structures as written on disk and their in-memory copies
65 /* First generic header */
66 struct lustre_disk_dqheader {
67 __u32 dqh_magic; /* Magic number identifying file */
68 __u32 dqh_version; /* File version */
71 /* Header with type and version specific information */
72 struct lustre_disk_dqinfo {
73 /* Time before block soft limit becomes hard limit */
75 /* Time before inode soft limit becomes hard limit */
77 /* Flags for quotafile (DQF_*) */
79 /* Number of blocks in file */
81 /* Number of first free block in the list */
83 /* Number of block with at least one free entry */
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
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 */
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
109 #define GETIDINDEX(id, depth) (((id) >> \
110 ((LUSTRE_DQTREEDEPTH - (depth) - 1) * 8)) & \
112 #endif /* osd_quota_fmt.h */