xref: /linux/include/uapi/linux/gfs2_ondisk.h (revision 65adc27375a85beb57c3869cedb2a410fad9c288)
1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2607ca46eSDavid Howells /*
3607ca46eSDavid Howells  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
4607ca46eSDavid Howells  * Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
5607ca46eSDavid Howells  *
6607ca46eSDavid Howells  * This copyrighted material is made available to anyone wishing to use,
7607ca46eSDavid Howells  * modify, copy, or redistribute it subject to the terms and conditions
8607ca46eSDavid Howells  * of the GNU General Public License v.2.
9607ca46eSDavid Howells  */
10607ca46eSDavid Howells 
11607ca46eSDavid Howells #ifndef __GFS2_ONDISK_DOT_H__
12607ca46eSDavid Howells #define __GFS2_ONDISK_DOT_H__
13607ca46eSDavid Howells 
14607ca46eSDavid Howells #include <linux/types.h>
15607ca46eSDavid Howells 
16607ca46eSDavid Howells #define GFS2_MAGIC		0x01161970
17607ca46eSDavid Howells #define GFS2_BASIC_BLOCK	512
18607ca46eSDavid Howells #define GFS2_BASIC_BLOCK_SHIFT	9
19607ca46eSDavid Howells 
20607ca46eSDavid Howells /* Lock numbers of the LM_TYPE_NONDISK type */
21607ca46eSDavid Howells 
22607ca46eSDavid Howells #define GFS2_MOUNT_LOCK		0
23607ca46eSDavid Howells #define GFS2_LIVE_LOCK		1
2424972557SBenjamin Marzinski #define GFS2_FREEZE_LOCK	2
25607ca46eSDavid Howells #define GFS2_RENAME_LOCK	3
26607ca46eSDavid Howells #define GFS2_CONTROL_LOCK	4
27607ca46eSDavid Howells #define GFS2_MOUNTED_LOCK	5
28607ca46eSDavid Howells 
29607ca46eSDavid Howells /* Format numbers for various metadata types */
30607ca46eSDavid Howells 
31607ca46eSDavid Howells #define GFS2_FORMAT_NONE	0
32607ca46eSDavid Howells #define GFS2_FORMAT_SB		100
33607ca46eSDavid Howells #define GFS2_FORMAT_RG		200
34607ca46eSDavid Howells #define GFS2_FORMAT_RB		300
35607ca46eSDavid Howells #define GFS2_FORMAT_DI		400
36607ca46eSDavid Howells #define GFS2_FORMAT_IN		500
37607ca46eSDavid Howells #define GFS2_FORMAT_LF		600
38607ca46eSDavid Howells #define GFS2_FORMAT_JD		700
39607ca46eSDavid Howells #define GFS2_FORMAT_LH		800
40607ca46eSDavid Howells #define GFS2_FORMAT_LD		900
41607ca46eSDavid Howells #define GFS2_FORMAT_LB		1000
42607ca46eSDavid Howells #define GFS2_FORMAT_EA		1600
43607ca46eSDavid Howells #define GFS2_FORMAT_ED		1700
44607ca46eSDavid Howells #define GFS2_FORMAT_QC		1400
45607ca46eSDavid Howells /* These are format numbers for entities contained in files */
46607ca46eSDavid Howells #define GFS2_FORMAT_RI		1100
47607ca46eSDavid Howells #define GFS2_FORMAT_DE		1200
48607ca46eSDavid Howells #define GFS2_FORMAT_QU		1500
49607ca46eSDavid Howells /* These are part of the superblock */
50607ca46eSDavid Howells #define GFS2_FORMAT_FS		1801
51607ca46eSDavid Howells #define GFS2_FORMAT_MULTI	1900
52607ca46eSDavid Howells 
53607ca46eSDavid Howells /*
54607ca46eSDavid Howells  * An on-disk inode number
55607ca46eSDavid Howells  */
56607ca46eSDavid Howells 
57607ca46eSDavid Howells struct gfs2_inum {
58607ca46eSDavid Howells 	__be64 no_formal_ino;
59607ca46eSDavid Howells 	__be64 no_addr;
60607ca46eSDavid Howells };
61607ca46eSDavid Howells 
62607ca46eSDavid Howells /*
63607ca46eSDavid Howells  * Generic metadata head structure
64607ca46eSDavid Howells  * Every inplace buffer logged in the journal must start with this.
65607ca46eSDavid Howells  */
66607ca46eSDavid Howells 
67607ca46eSDavid Howells #define GFS2_METATYPE_NONE	0
68607ca46eSDavid Howells #define GFS2_METATYPE_SB	1
69607ca46eSDavid Howells #define GFS2_METATYPE_RG	2
70607ca46eSDavid Howells #define GFS2_METATYPE_RB	3
71607ca46eSDavid Howells #define GFS2_METATYPE_DI	4
72607ca46eSDavid Howells #define GFS2_METATYPE_IN	5
73607ca46eSDavid Howells #define GFS2_METATYPE_LF	6
74607ca46eSDavid Howells #define GFS2_METATYPE_JD	7
75607ca46eSDavid Howells #define GFS2_METATYPE_LH	8
76607ca46eSDavid Howells #define GFS2_METATYPE_LD	9
77607ca46eSDavid Howells #define GFS2_METATYPE_LB	12
78607ca46eSDavid Howells #define GFS2_METATYPE_EA	10
79607ca46eSDavid Howells #define GFS2_METATYPE_ED	11
80607ca46eSDavid Howells #define GFS2_METATYPE_QC	14
81607ca46eSDavid Howells 
82607ca46eSDavid Howells struct gfs2_meta_header {
83607ca46eSDavid Howells 	__be32 mh_magic;
84607ca46eSDavid Howells 	__be32 mh_type;
85607ca46eSDavid Howells 	__be64 __pad0;		/* Was generation number in gfs1 */
86607ca46eSDavid Howells 	__be32 mh_format;
87607ca46eSDavid Howells 	/* This union is to keep userspace happy */
88607ca46eSDavid Howells 	union {
89607ca46eSDavid Howells 		__be32 mh_jid;		/* Was incarnation number in gfs1 */
90607ca46eSDavid Howells 		__be32 __pad1;
91607ca46eSDavid Howells 	};
92607ca46eSDavid Howells };
93607ca46eSDavid Howells 
94607ca46eSDavid Howells /*
95607ca46eSDavid Howells  * super-block structure
96607ca46eSDavid Howells  *
97607ca46eSDavid Howells  * It's probably good if SIZEOF_SB <= GFS2_BASIC_BLOCK (512 bytes)
98607ca46eSDavid Howells  *
99607ca46eSDavid Howells  * Order is important, need to be able to read old superblocks to do on-disk
100607ca46eSDavid Howells  * version upgrades.
101607ca46eSDavid Howells  */
102607ca46eSDavid Howells 
103607ca46eSDavid Howells /* Address of superblock in GFS2 basic blocks */
104607ca46eSDavid Howells #define GFS2_SB_ADDR		128
105607ca46eSDavid Howells 
106607ca46eSDavid Howells /* The lock number for the superblock (must be zero) */
107607ca46eSDavid Howells #define GFS2_SB_LOCK		0
108607ca46eSDavid Howells 
109607ca46eSDavid Howells /* Requirement:  GFS2_LOCKNAME_LEN % 8 == 0
110607ca46eSDavid Howells    Includes: the fencing zero at the end */
111607ca46eSDavid Howells #define GFS2_LOCKNAME_LEN	64
112607ca46eSDavid Howells 
113607ca46eSDavid Howells struct gfs2_sb {
114607ca46eSDavid Howells 	struct gfs2_meta_header sb_header;
115607ca46eSDavid Howells 
116607ca46eSDavid Howells 	__be32 sb_fs_format;
117607ca46eSDavid Howells 	__be32 sb_multihost_format;
118607ca46eSDavid Howells 	__u32  __pad0;	/* Was superblock flags in gfs1 */
119607ca46eSDavid Howells 
120607ca46eSDavid Howells 	__be32 sb_bsize;
121607ca46eSDavid Howells 	__be32 sb_bsize_shift;
122607ca46eSDavid Howells 	__u32 __pad1;	/* Was journal segment size in gfs1 */
123607ca46eSDavid Howells 
124607ca46eSDavid Howells 	struct gfs2_inum sb_master_dir; /* Was jindex dinode in gfs1 */
125607ca46eSDavid Howells 	struct gfs2_inum __pad2; /* Was rindex dinode in gfs1 */
126607ca46eSDavid Howells 	struct gfs2_inum sb_root_dir;
127607ca46eSDavid Howells 
128607ca46eSDavid Howells 	char sb_lockproto[GFS2_LOCKNAME_LEN];
129607ca46eSDavid Howells 	char sb_locktable[GFS2_LOCKNAME_LEN];
130607ca46eSDavid Howells 
131607ca46eSDavid Howells 	struct gfs2_inum __pad3; /* Was quota inode in gfs1 */
132607ca46eSDavid Howells 	struct gfs2_inum __pad4; /* Was licence inode in gfs1 */
133607ca46eSDavid Howells #define GFS2_HAS_UUID 1
134607ca46eSDavid Howells 	__u8 sb_uuid[16]; /* The UUID, maybe 0 for backwards compat */
135607ca46eSDavid Howells };
136607ca46eSDavid Howells 
137607ca46eSDavid Howells /*
138607ca46eSDavid Howells  * resource index structure
139607ca46eSDavid Howells  */
140607ca46eSDavid Howells 
141607ca46eSDavid Howells struct gfs2_rindex {
142607ca46eSDavid Howells 	__be64 ri_addr;	/* grp block disk address */
143607ca46eSDavid Howells 	__be32 ri_length;	/* length of rgrp header in fs blocks */
144607ca46eSDavid Howells 	__u32 __pad;
145607ca46eSDavid Howells 
146607ca46eSDavid Howells 	__be64 ri_data0;	/* first data location */
147607ca46eSDavid Howells 	__be32 ri_data;	/* num of data blocks in rgrp */
148607ca46eSDavid Howells 
149607ca46eSDavid Howells 	__be32 ri_bitbytes;	/* number of bytes in data bitmaps */
150607ca46eSDavid Howells 
151607ca46eSDavid Howells 	__u8 ri_reserved[64];
152607ca46eSDavid Howells };
153607ca46eSDavid Howells 
154607ca46eSDavid Howells /*
155607ca46eSDavid Howells  * resource group header structure
156607ca46eSDavid Howells  */
157607ca46eSDavid Howells 
158607ca46eSDavid Howells /* Number of blocks per byte in rgrp */
159607ca46eSDavid Howells #define GFS2_NBBY		4
160607ca46eSDavid Howells #define GFS2_BIT_SIZE		2
161607ca46eSDavid Howells #define GFS2_BIT_MASK		0x00000003
162607ca46eSDavid Howells 
163607ca46eSDavid Howells #define GFS2_BLKST_FREE		0
164607ca46eSDavid Howells #define GFS2_BLKST_USED		1
165607ca46eSDavid Howells #define GFS2_BLKST_UNLINKED	2
166607ca46eSDavid Howells #define GFS2_BLKST_DINODE	3
167607ca46eSDavid Howells 
168607ca46eSDavid Howells #define GFS2_RGF_JOURNAL	0x00000001
169607ca46eSDavid Howells #define GFS2_RGF_METAONLY	0x00000002
170607ca46eSDavid Howells #define GFS2_RGF_DATAONLY	0x00000004
171607ca46eSDavid Howells #define GFS2_RGF_NOALLOC	0x00000008
172607ca46eSDavid Howells #define GFS2_RGF_TRIMMED	0x00000010
173607ca46eSDavid Howells 
174607ca46eSDavid Howells struct gfs2_rgrp_lvb {
175607ca46eSDavid Howells 	__be32 rl_magic;
176607ca46eSDavid Howells 	__be32 rl_flags;
177607ca46eSDavid Howells 	__be32 rl_free;
178607ca46eSDavid Howells 	__be32 rl_dinodes;
179607ca46eSDavid Howells 	__be64 rl_igeneration;
180607ca46eSDavid Howells 	__be32 rl_unlinked;
181607ca46eSDavid Howells 	__be32 __pad;
182607ca46eSDavid Howells };
183607ca46eSDavid Howells 
184607ca46eSDavid Howells struct gfs2_rgrp {
185607ca46eSDavid Howells 	struct gfs2_meta_header rg_header;
186607ca46eSDavid Howells 
187607ca46eSDavid Howells 	__be32 rg_flags;
188607ca46eSDavid Howells 	__be32 rg_free;
189607ca46eSDavid Howells 	__be32 rg_dinodes;
190*65adc273SAndrew Price 	union {
191607ca46eSDavid Howells 		__be32 __pad;
192*65adc273SAndrew Price 		__be32 rg_skip; /* Distance to the next rgrp in fs blocks */
193*65adc273SAndrew Price 	};
194607ca46eSDavid Howells 	__be64 rg_igeneration;
195607ca46eSDavid Howells 
196607ca46eSDavid Howells 	__u8 rg_reserved[80]; /* Several fields from gfs1 now reserved */
197607ca46eSDavid Howells };
198607ca46eSDavid Howells 
199607ca46eSDavid Howells /*
200607ca46eSDavid Howells  * quota structure
201607ca46eSDavid Howells  */
202607ca46eSDavid Howells 
203607ca46eSDavid Howells struct gfs2_quota {
204607ca46eSDavid Howells 	__be64 qu_limit;
205607ca46eSDavid Howells 	__be64 qu_warn;
206607ca46eSDavid Howells 	__be64 qu_value;
207607ca46eSDavid Howells 	__u8 qu_reserved[64];
208607ca46eSDavid Howells };
209607ca46eSDavid Howells 
210607ca46eSDavid Howells /*
211607ca46eSDavid Howells  * dinode structure
212607ca46eSDavid Howells  */
213607ca46eSDavid Howells 
214607ca46eSDavid Howells #define GFS2_MAX_META_HEIGHT	10
215607ca46eSDavid Howells #define GFS2_DIR_MAX_DEPTH	17
216607ca46eSDavid Howells 
217607ca46eSDavid Howells #define DT2IF(dt) (((dt) << 12) & S_IFMT)
218607ca46eSDavid Howells #define IF2DT(sif) (((sif) & S_IFMT) >> 12)
219607ca46eSDavid Howells 
220607ca46eSDavid Howells enum {
221607ca46eSDavid Howells 	gfs2fl_Jdata		= 0,
222607ca46eSDavid Howells 	gfs2fl_ExHash		= 1,
223607ca46eSDavid Howells 	gfs2fl_Unused		= 2,
224607ca46eSDavid Howells 	gfs2fl_EaIndirect	= 3,
225607ca46eSDavid Howells 	gfs2fl_Directio		= 4,
226607ca46eSDavid Howells 	gfs2fl_Immutable	= 5,
227607ca46eSDavid Howells 	gfs2fl_AppendOnly	= 6,
228607ca46eSDavid Howells 	gfs2fl_NoAtime		= 7,
229607ca46eSDavid Howells 	gfs2fl_Sync		= 8,
230607ca46eSDavid Howells 	gfs2fl_System		= 9,
231607ca46eSDavid Howells 	gfs2fl_TopLevel		= 10,
232607ca46eSDavid Howells 	gfs2fl_TruncInProg	= 29,
233607ca46eSDavid Howells 	gfs2fl_InheritDirectio	= 30,
234607ca46eSDavid Howells 	gfs2fl_InheritJdata	= 31,
235607ca46eSDavid Howells };
236607ca46eSDavid Howells 
237607ca46eSDavid Howells /* Dinode flags */
238607ca46eSDavid Howells #define GFS2_DIF_JDATA			0x00000001
239607ca46eSDavid Howells #define GFS2_DIF_EXHASH			0x00000002
240607ca46eSDavid Howells #define GFS2_DIF_UNUSED			0x00000004  /* only in gfs1 */
241607ca46eSDavid Howells #define GFS2_DIF_EA_INDIRECT		0x00000008
242607ca46eSDavid Howells #define GFS2_DIF_DIRECTIO		0x00000010
243607ca46eSDavid Howells #define GFS2_DIF_IMMUTABLE		0x00000020
244607ca46eSDavid Howells #define GFS2_DIF_APPENDONLY		0x00000040
245607ca46eSDavid Howells #define GFS2_DIF_NOATIME		0x00000080
246607ca46eSDavid Howells #define GFS2_DIF_SYNC			0x00000100
247607ca46eSDavid Howells #define GFS2_DIF_SYSTEM			0x00000200 /* New in gfs2 */
248607ca46eSDavid Howells #define GFS2_DIF_TOPDIR			0x00000400 /* New in gfs2 */
249607ca46eSDavid Howells #define GFS2_DIF_TRUNC_IN_PROG		0x20000000 /* New in gfs2 */
250607ca46eSDavid Howells #define GFS2_DIF_INHERIT_DIRECTIO	0x40000000 /* only in gfs1 */
251607ca46eSDavid Howells #define GFS2_DIF_INHERIT_JDATA		0x80000000
252607ca46eSDavid Howells 
253607ca46eSDavid Howells struct gfs2_dinode {
254607ca46eSDavid Howells 	struct gfs2_meta_header di_header;
255607ca46eSDavid Howells 
256607ca46eSDavid Howells 	struct gfs2_inum di_num;
257607ca46eSDavid Howells 
258607ca46eSDavid Howells 	__be32 di_mode;	/* mode of file */
259607ca46eSDavid Howells 	__be32 di_uid;	/* owner's user id */
260607ca46eSDavid Howells 	__be32 di_gid;	/* owner's group id */
261607ca46eSDavid Howells 	__be32 di_nlink;	/* number of links to this file */
262607ca46eSDavid Howells 	__be64 di_size;	/* number of bytes in file */
263607ca46eSDavid Howells 	__be64 di_blocks;	/* number of blocks in file */
264607ca46eSDavid Howells 	__be64 di_atime;	/* time last accessed */
265607ca46eSDavid Howells 	__be64 di_mtime;	/* time last modified */
266607ca46eSDavid Howells 	__be64 di_ctime;	/* time last changed */
267607ca46eSDavid Howells 	__be32 di_major;	/* device major number */
268607ca46eSDavid Howells 	__be32 di_minor;	/* device minor number */
269607ca46eSDavid Howells 
270607ca46eSDavid Howells 	/* This section varies from gfs1. Padding added to align with
271607ca46eSDavid Howells          * remainder of dinode
272607ca46eSDavid Howells 	 */
273607ca46eSDavid Howells 	__be64 di_goal_meta;	/* rgrp to alloc from next */
274607ca46eSDavid Howells 	__be64 di_goal_data;	/* data block goal */
275607ca46eSDavid Howells 	__be64 di_generation;	/* generation number for NFS */
276607ca46eSDavid Howells 
277607ca46eSDavid Howells 	__be32 di_flags;	/* GFS2_DIF_... */
278607ca46eSDavid Howells 	__be32 di_payload_format;  /* GFS2_FORMAT_... */
279607ca46eSDavid Howells 	__u16 __pad1;	/* Was ditype in gfs1 */
280607ca46eSDavid Howells 	__be16 di_height;	/* height of metadata */
281607ca46eSDavid Howells 	__u32 __pad2;	/* Unused incarnation number from gfs1 */
282607ca46eSDavid Howells 
283607ca46eSDavid Howells 	/* These only apply to directories  */
284607ca46eSDavid Howells 	__u16 __pad3;	/* Padding */
285607ca46eSDavid Howells 	__be16 di_depth;	/* Number of bits in the table */
286607ca46eSDavid Howells 	__be32 di_entries;	/* The number of entries in the directory */
287607ca46eSDavid Howells 
288607ca46eSDavid Howells 	struct gfs2_inum __pad4; /* Unused even in current gfs1 */
289607ca46eSDavid Howells 
290607ca46eSDavid Howells 	__be64 di_eattr;	/* extended attribute block number */
291607ca46eSDavid Howells 	__be32 di_atime_nsec;   /* nsec portion of atime */
292607ca46eSDavid Howells 	__be32 di_mtime_nsec;   /* nsec portion of mtime */
293607ca46eSDavid Howells 	__be32 di_ctime_nsec;   /* nsec portion of ctime */
294607ca46eSDavid Howells 
295607ca46eSDavid Howells 	__u8 di_reserved[44];
296607ca46eSDavid Howells };
297607ca46eSDavid Howells 
298607ca46eSDavid Howells /*
299607ca46eSDavid Howells  * directory structure - many of these per directory file
300607ca46eSDavid Howells  */
301607ca46eSDavid Howells 
302607ca46eSDavid Howells #define GFS2_FNAMESIZE		255
303607ca46eSDavid Howells #define GFS2_DIRENT_SIZE(name_len) ((sizeof(struct gfs2_dirent) + (name_len) + 7) & ~7)
304471f3db2SBenjamin Marzinski #define GFS2_MIN_DIRENT_SIZE (GFS2_DIRENT_SIZE(1))
305471f3db2SBenjamin Marzinski 
306607ca46eSDavid Howells 
307607ca46eSDavid Howells struct gfs2_dirent {
308607ca46eSDavid Howells 	struct gfs2_inum de_inum;
309607ca46eSDavid Howells 	__be32 de_hash;
310607ca46eSDavid Howells 	__be16 de_rec_len;
311607ca46eSDavid Howells 	__be16 de_name_len;
312607ca46eSDavid Howells 	__be16 de_type;
31344aaada9SSteven Whitehouse 	__be16 de_rahead;
314471f3db2SBenjamin Marzinski 	union {
315471f3db2SBenjamin Marzinski 		__u8 __pad[12];
316471f3db2SBenjamin Marzinski 		struct {
317471f3db2SBenjamin Marzinski 			__u32 de_cookie; /* ondisk value not used */
318471f3db2SBenjamin Marzinski 			__u8 pad3[8];
31944aaada9SSteven Whitehouse 		};
32044aaada9SSteven Whitehouse 	};
321607ca46eSDavid Howells };
322607ca46eSDavid Howells 
323607ca46eSDavid Howells /*
324607ca46eSDavid Howells  * Header of leaf directory nodes
325607ca46eSDavid Howells  */
326607ca46eSDavid Howells 
327607ca46eSDavid Howells struct gfs2_leaf {
328607ca46eSDavid Howells 	struct gfs2_meta_header lf_header;
329607ca46eSDavid Howells 
330607ca46eSDavid Howells 	__be16 lf_depth;		/* Depth of leaf */
331607ca46eSDavid Howells 	__be16 lf_entries;		/* Number of dirents in leaf */
332607ca46eSDavid Howells 	__be32 lf_dirent_format;	/* Format of the dirents */
333607ca46eSDavid Howells 	__be64 lf_next;			/* Next leaf, if overflow */
334607ca46eSDavid Howells 
33501bcb0deSSteven Whitehouse 	union {
336607ca46eSDavid Howells 		__u8 lf_reserved[64];
33701bcb0deSSteven Whitehouse 		struct {
33801bcb0deSSteven Whitehouse 			__be64 lf_inode;	/* Dir inode number */
33901bcb0deSSteven Whitehouse 			__be32 lf_dist;		/* Dist from inode on chain */
34001bcb0deSSteven Whitehouse 			__be32 lf_nsec;		/* Last ins/del usecs */
34101bcb0deSSteven Whitehouse 			__be64 lf_sec;		/* Last ins/del in secs */
34201bcb0deSSteven Whitehouse 			__u8 lf_reserved2[40];
34301bcb0deSSteven Whitehouse 		};
34401bcb0deSSteven Whitehouse 	};
345607ca46eSDavid Howells };
346607ca46eSDavid Howells 
347607ca46eSDavid Howells /*
348607ca46eSDavid Howells  * Extended attribute header format
349607ca46eSDavid Howells  *
350607ca46eSDavid Howells  * This works in a similar way to dirents. There is a fixed size header
351607ca46eSDavid Howells  * followed by a variable length section made up of the name and the
352607ca46eSDavid Howells  * associated data. In the case of a "stuffed" entry, the value is
353607ca46eSDavid Howells  * inline directly after the name, the ea_num_ptrs entry will be
354607ca46eSDavid Howells  * zero in that case. For non-"stuffed" entries, there will be
355607ca46eSDavid Howells  * a set of pointers (aligned to 8 byte boundary) to the block(s)
356607ca46eSDavid Howells  * containing the value.
357607ca46eSDavid Howells  *
358607ca46eSDavid Howells  * The blocks containing the values and the blocks containing the
359607ca46eSDavid Howells  * extended attribute headers themselves all start with the common
360607ca46eSDavid Howells  * metadata header. Each inode, if it has extended attributes, will
361607ca46eSDavid Howells  * have either a single block containing the extended attribute headers
362607ca46eSDavid Howells  * or a single indirect block pointing to blocks containing the
363b2c8b3eaSSteven Whitehouse  * extended attribute headers.
364607ca46eSDavid Howells  *
365b2c8b3eaSSteven Whitehouse  * The maximum size of the data part of an extended attribute is 64k
366607ca46eSDavid Howells  * so the number of blocks required depends upon block size. Since the
367607ca46eSDavid Howells  * block size also determines the number of pointers in an indirect
368607ca46eSDavid Howells  * block, its a fairly complicated calculation to work out the maximum
369607ca46eSDavid Howells  * number of blocks that an inode may have relating to extended attributes.
370607ca46eSDavid Howells  *
371607ca46eSDavid Howells  */
372607ca46eSDavid Howells 
373607ca46eSDavid Howells #define GFS2_EA_MAX_NAME_LEN	255
374607ca46eSDavid Howells #define GFS2_EA_MAX_DATA_LEN	65536
375607ca46eSDavid Howells 
376607ca46eSDavid Howells #define GFS2_EATYPE_UNUSED	0
377607ca46eSDavid Howells #define GFS2_EATYPE_USR		1
378607ca46eSDavid Howells #define GFS2_EATYPE_SYS		2
379607ca46eSDavid Howells #define GFS2_EATYPE_SECURITY	3
380607ca46eSDavid Howells 
381607ca46eSDavid Howells #define GFS2_EATYPE_LAST	3
382607ca46eSDavid Howells #define GFS2_EATYPE_VALID(x)	((x) <= GFS2_EATYPE_LAST)
383607ca46eSDavid Howells 
384607ca46eSDavid Howells #define GFS2_EAFLAG_LAST	0x01	/* last ea in block */
385607ca46eSDavid Howells 
386607ca46eSDavid Howells struct gfs2_ea_header {
387607ca46eSDavid Howells 	__be32 ea_rec_len;
388607ca46eSDavid Howells 	__be32 ea_data_len;
389607ca46eSDavid Howells 	__u8 ea_name_len;	/* no NULL pointer after the string */
390607ca46eSDavid Howells 	__u8 ea_type;		/* GFS2_EATYPE_... */
391607ca46eSDavid Howells 	__u8 ea_flags;		/* GFS2_EAFLAG_... */
392607ca46eSDavid Howells 	__u8 ea_num_ptrs;
393607ca46eSDavid Howells 	__u32 __pad;
394607ca46eSDavid Howells };
395607ca46eSDavid Howells 
396607ca46eSDavid Howells /*
397607ca46eSDavid Howells  * Log header structure
398607ca46eSDavid Howells  */
399607ca46eSDavid Howells 
400607ca46eSDavid Howells #define GFS2_LOG_HEAD_UNMOUNT	0x00000001	/* log is clean */
401607ca46eSDavid Howells 
402607ca46eSDavid Howells struct gfs2_log_header {
403607ca46eSDavid Howells 	struct gfs2_meta_header lh_header;
404607ca46eSDavid Howells 
405607ca46eSDavid Howells 	__be64 lh_sequence;	/* Sequence number of this transaction */
406607ca46eSDavid Howells 	__be32 lh_flags;	/* GFS2_LOG_HEAD_... */
407607ca46eSDavid Howells 	__be32 lh_tail;		/* Block number of log tail */
408607ca46eSDavid Howells 	__be32 lh_blkno;
409607ca46eSDavid Howells 	__be32 lh_hash;
410607ca46eSDavid Howells };
411607ca46eSDavid Howells 
412607ca46eSDavid Howells /*
413607ca46eSDavid Howells  * Log type descriptor
414607ca46eSDavid Howells  */
415607ca46eSDavid Howells 
416607ca46eSDavid Howells #define GFS2_LOG_DESC_METADATA	300
417607ca46eSDavid Howells /* ld_data1 is the number of metadata blocks in the descriptor.
418607ca46eSDavid Howells    ld_data2 is unused. */
419607ca46eSDavid Howells 
420607ca46eSDavid Howells #define GFS2_LOG_DESC_REVOKE	301
421607ca46eSDavid Howells /* ld_data1 is the number of revoke blocks in the descriptor.
422607ca46eSDavid Howells    ld_data2 is unused. */
423607ca46eSDavid Howells 
424607ca46eSDavid Howells #define GFS2_LOG_DESC_JDATA	302
425607ca46eSDavid Howells /* ld_data1 is the number of data blocks in the descriptor.
426607ca46eSDavid Howells    ld_data2 is unused. */
427607ca46eSDavid Howells 
428607ca46eSDavid Howells struct gfs2_log_descriptor {
429607ca46eSDavid Howells 	struct gfs2_meta_header ld_header;
430607ca46eSDavid Howells 
431607ca46eSDavid Howells 	__be32 ld_type;		/* GFS2_LOG_DESC_... */
432607ca46eSDavid Howells 	__be32 ld_length;	/* Number of buffers in this chunk */
433607ca46eSDavid Howells 	__be32 ld_data1;	/* descriptor-specific field */
434607ca46eSDavid Howells 	__be32 ld_data2;	/* descriptor-specific field */
435607ca46eSDavid Howells 
436607ca46eSDavid Howells 	__u8 ld_reserved[32];
437607ca46eSDavid Howells };
438607ca46eSDavid Howells 
439607ca46eSDavid Howells /*
440607ca46eSDavid Howells  * Inum Range
441607ca46eSDavid Howells  * Describe a range of formal inode numbers allocated to
442607ca46eSDavid Howells  * one machine to assign to inodes.
443607ca46eSDavid Howells  */
444607ca46eSDavid Howells 
445607ca46eSDavid Howells #define GFS2_INUM_QUANTUM	1048576
446607ca46eSDavid Howells 
447607ca46eSDavid Howells struct gfs2_inum_range {
448607ca46eSDavid Howells 	__be64 ir_start;
449607ca46eSDavid Howells 	__be64 ir_length;
450607ca46eSDavid Howells };
451607ca46eSDavid Howells 
452607ca46eSDavid Howells /*
453607ca46eSDavid Howells  * Statfs change
454607ca46eSDavid Howells  * Describes an change to the pool of free and allocated
455607ca46eSDavid Howells  * blocks.
456607ca46eSDavid Howells  */
457607ca46eSDavid Howells 
458607ca46eSDavid Howells struct gfs2_statfs_change {
459607ca46eSDavid Howells 	__be64 sc_total;
460607ca46eSDavid Howells 	__be64 sc_free;
461607ca46eSDavid Howells 	__be64 sc_dinodes;
462607ca46eSDavid Howells };
463607ca46eSDavid Howells 
464607ca46eSDavid Howells /*
465607ca46eSDavid Howells  * Quota change
466607ca46eSDavid Howells  * Describes an allocation change for a particular
467607ca46eSDavid Howells  * user or group.
468607ca46eSDavid Howells  */
469607ca46eSDavid Howells 
470607ca46eSDavid Howells #define GFS2_QCF_USER		0x00000001
471607ca46eSDavid Howells 
472607ca46eSDavid Howells struct gfs2_quota_change {
473607ca46eSDavid Howells 	__be64 qc_change;
474607ca46eSDavid Howells 	__be32 qc_flags;	/* GFS2_QCF_... */
475607ca46eSDavid Howells 	__be32 qc_id;
476607ca46eSDavid Howells };
477607ca46eSDavid Howells 
478607ca46eSDavid Howells struct gfs2_quota_lvb {
479607ca46eSDavid Howells         __be32 qb_magic;
480607ca46eSDavid Howells         __u32 __pad;
481607ca46eSDavid Howells         __be64 qb_limit;      /* Hard limit of # blocks to alloc */
482607ca46eSDavid Howells         __be64 qb_warn;       /* Warn user when alloc is above this # */
483607ca46eSDavid Howells         __be64 qb_value;       /* Current # blocks allocated */
484607ca46eSDavid Howells };
485607ca46eSDavid Howells 
486607ca46eSDavid Howells #endif /* __GFS2_ONDISK_DOT_H__ */
487