blob: bb37218a7978c028a6a87b6e515961d5a9667bfd [file] [log] [blame]
Mark Fashehccd979b2005-12-15 14:31:24 -08001/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * ocfs2_fs.h
5 *
6 * On-disk structures for OCFS2.
7 *
8 * Copyright (C) 2002, 2004 Oracle. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public
12 * License, version 2, as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 021110-1307, USA.
23 */
24
25#ifndef _OCFS2_FS_H
26#define _OCFS2_FS_H
27
28/* Version */
29#define OCFS2_MAJOR_REV_LEVEL 0
30#define OCFS2_MINOR_REV_LEVEL 90
31
32/*
33 * An OCFS2 volume starts this way:
34 * Sector 0: Valid ocfs1_vol_disk_hdr that cleanly fails to mount OCFS.
35 * Sector 1: Valid ocfs1_vol_label that cleanly fails to mount OCFS.
36 * Block OCFS2_SUPER_BLOCK_BLKNO: OCFS2 superblock.
37 *
38 * All other structures are found from the superblock information.
39 *
40 * OCFS2_SUPER_BLOCK_BLKNO is in blocks, not sectors. eg, for a
41 * blocksize of 2K, it is 4096 bytes into disk.
42 */
43#define OCFS2_SUPER_BLOCK_BLKNO 2
44
45/*
46 * Cluster size limits. The maximum is kept arbitrarily at 1 MB, and could
47 * grow if needed.
48 */
49#define OCFS2_MIN_CLUSTERSIZE 4096
50#define OCFS2_MAX_CLUSTERSIZE 1048576
51
52/*
53 * Blocks cannot be bigger than clusters, so the maximum blocksize is the
54 * minimum cluster size.
55 */
56#define OCFS2_MIN_BLOCKSIZE 512
57#define OCFS2_MAX_BLOCKSIZE OCFS2_MIN_CLUSTERSIZE
58
59/* Filesystem magic number */
60#define OCFS2_SUPER_MAGIC 0x7461636f
61
62/* Object signatures */
63#define OCFS2_SUPER_BLOCK_SIGNATURE "OCFSV2"
64#define OCFS2_INODE_SIGNATURE "INODE01"
65#define OCFS2_EXTENT_BLOCK_SIGNATURE "EXBLK01"
66#define OCFS2_GROUP_DESC_SIGNATURE "GROUP01"
Tao Ma5a7bc8e2008-08-18 17:38:46 +080067#define OCFS2_XATTR_BLOCK_SIGNATURE "XATTR01"
Mark Fasheh87d35a72008-12-10 17:36:25 -080068#define OCFS2_DIR_TRAILER_SIGNATURE "DIRTRL1"
Mark Fasheh9b7895e2008-11-12 16:27:44 -080069#define OCFS2_DX_ROOT_SIGNATURE "DXDIR01"
70#define OCFS2_DX_LEAF_SIGNATURE "DXLEAF1"
Tao Ma721f69c2009-08-18 11:17:49 +080071#define OCFS2_REFCOUNT_BLOCK_SIGNATURE "REFCNT1"
Mark Fashehccd979b2005-12-15 14:31:24 -080072
73/* Compatibility flags */
74#define OCFS2_HAS_COMPAT_FEATURE(sb,mask) \
75 ( OCFS2_SB(sb)->s_feature_compat & (mask) )
76#define OCFS2_HAS_RO_COMPAT_FEATURE(sb,mask) \
77 ( OCFS2_SB(sb)->s_feature_ro_compat & (mask) )
78#define OCFS2_HAS_INCOMPAT_FEATURE(sb,mask) \
79 ( OCFS2_SB(sb)->s_feature_incompat & (mask) )
80#define OCFS2_SET_COMPAT_FEATURE(sb,mask) \
81 OCFS2_SB(sb)->s_feature_compat |= (mask)
82#define OCFS2_SET_RO_COMPAT_FEATURE(sb,mask) \
83 OCFS2_SB(sb)->s_feature_ro_compat |= (mask)
84#define OCFS2_SET_INCOMPAT_FEATURE(sb,mask) \
85 OCFS2_SB(sb)->s_feature_incompat |= (mask)
86#define OCFS2_CLEAR_COMPAT_FEATURE(sb,mask) \
87 OCFS2_SB(sb)->s_feature_compat &= ~(mask)
88#define OCFS2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
89 OCFS2_SB(sb)->s_feature_ro_compat &= ~(mask)
90#define OCFS2_CLEAR_INCOMPAT_FEATURE(sb,mask) \
91 OCFS2_SB(sb)->s_feature_incompat &= ~(mask)
92
Joel Beckera9772182008-12-16 18:10:18 -080093#define OCFS2_FEATURE_COMPAT_SUPP (OCFS2_FEATURE_COMPAT_BACKUP_SB \
94 | OCFS2_FEATURE_COMPAT_JBD2_SB)
Mark Fashehdcd05382007-01-16 11:32:23 -080095#define OCFS2_FEATURE_INCOMPAT_SUPP (OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT \
Mark Fasheh15b1e362007-09-07 13:58:15 -070096 | OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC \
Joel Becker386a2ef2008-02-01 12:06:54 -080097 | OCFS2_FEATURE_INCOMPAT_INLINE_DATA \
Joel Beckerb61817e2008-02-01 15:08:23 -080098 | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \
Tiger Yang8154da32008-08-18 17:11:46 +080099 | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK \
Joel Becker9d28cfb2008-10-16 17:53:29 -0700100 | OCFS2_FEATURE_INCOMPAT_XATTR \
Mark Fasheh3a8df2b2008-11-24 17:14:09 -0800101 | OCFS2_FEATURE_INCOMPAT_META_ECC \
Tao Ma64871b82009-08-18 11:48:02 +0800102 | OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS \
103 | OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE)
Jan Kara19ece542008-08-21 20:13:17 +0200104#define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \
105 | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \
106 | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)
Mark Fashehccd979b2005-12-15 14:31:24 -0800107
108/*
109 * Heartbeat-only devices are missing journals and other files. The
110 * filesystem driver can't load them, but the library can. Never put
111 * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*.
112 */
113#define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002
114
Mark Fasheh89039012006-12-07 18:05:37 -0800115/*
116 * tunefs sets this incompat flag before starting the resize and clears it
117 * at the end. This flag protects users from inadvertently mounting the fs
118 * after an aborted run without fsck-ing.
119 */
120#define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG 0x0004
Mark Fashehccd979b2005-12-15 14:31:24 -0800121
Sunil Mushranc271c5c2006-12-05 17:56:35 -0800122/* Used to denote a non-clustered volume */
123#define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 0x0008
124
Mark Fasheh89039012006-12-07 18:05:37 -0800125/* Support for sparse allocation in b-trees */
126#define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010
127
Mark Fashehccd979b2005-12-15 14:31:24 -0800128/*
Mark Fasheh92e91ce2007-09-20 11:19:20 -0700129 * Tunefs sets this incompat flag before starting an operation which
130 * would require cleanup on abort. This is done to protect users from
131 * inadvertently mounting the fs after an aborted run without
132 * fsck-ing.
133 *
134 * s_tunefs_flags on the super block describes precisely which
135 * operations were in progress.
136 */
137#define OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG 0x0020
138
Mark Fasheh15b1e362007-09-07 13:58:15 -0700139/* Support for data packed into inode blocks */
140#define OCFS2_FEATURE_INCOMPAT_INLINE_DATA 0x0040
141
Mark Fasheh92e91ce2007-09-20 11:19:20 -0700142/*
Joel Beckerb61817e2008-02-01 15:08:23 -0800143 * Support for alternate, userspace cluster stacks. If set, the superblock
144 * field s_cluster_info contains a tag for the alternate stack in use as
145 * well as the name of the cluster being joined.
146 * mount.ocfs2 must pass in a matching stack name.
147 *
148 * If not set, the classic stack will be used. This is compatbile with
149 * all older versions.
150 */
151#define OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK 0x0080
152
Tiger Yang8154da32008-08-18 17:11:46 +0800153/* Support for the extended slot map */
154#define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100
155
156/* Support for extended attributes */
157#define OCFS2_FEATURE_INCOMPAT_XATTR 0x0200
158
Mark Fasheh9b7895e2008-11-12 16:27:44 -0800159/* Support for indexed directores */
160#define OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS 0x0400
161
Joel Beckerab552d52008-10-16 17:50:30 -0700162/* Metadata checksum and error correction */
163#define OCFS2_FEATURE_INCOMPAT_META_ECC 0x0800
164
Tao Ma721f69c2009-08-18 11:17:49 +0800165/* Refcount tree support */
166#define OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE 0x1000
167
Joel Beckerb61817e2008-02-01 15:08:23 -0800168/*
Mark Fasheh50af94b2007-01-21 14:44:59 -0800169 * backup superblock flag is used to indicate that this volume
170 * has backup superblocks.
171 */
172#define OCFS2_FEATURE_COMPAT_BACKUP_SB 0x0001
173
Mark Fasheh328d5752007-06-18 10:48:04 -0700174/*
Joel Beckera9772182008-12-16 18:10:18 -0800175 * The filesystem will correctly handle journal feature bits.
176 */
177#define OCFS2_FEATURE_COMPAT_JBD2_SB 0x0002
178
179/*
Mark Fasheh328d5752007-06-18 10:48:04 -0700180 * Unwritten extents support.
181 */
182#define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 0x0001
183
Jan Kara1a224ad2008-08-20 15:43:36 +0200184/*
185 * Maintain quota information for this filesystem
186 */
187#define OCFS2_FEATURE_RO_COMPAT_USRQUOTA 0x0002
188#define OCFS2_FEATURE_RO_COMPAT_GRPQUOTA 0x0004
189
Mark Fasheh50af94b2007-01-21 14:44:59 -0800190/* The byte offset of the first backup block will be 1G.
191 * The following will be 4G, 16G, 64G, 256G and 1T.
192 */
193#define OCFS2_BACKUP_SB_START 1 << 30
194
195/* the max backup superblock nums */
196#define OCFS2_MAX_BACKUP_SUPERBLOCKS 6
197
198/*
Mark Fasheh92e91ce2007-09-20 11:19:20 -0700199 * Flags on ocfs2_super_block.s_tunefs_flags
200 */
201#define OCFS2_TUNEFS_INPROG_REMOVE_SLOT 0x0001 /* Removing slots */
202
203/*
Mark Fashehccd979b2005-12-15 14:31:24 -0800204 * Flags on ocfs2_dinode.i_flags
205 */
206#define OCFS2_VALID_FL (0x00000001) /* Inode is valid */
207#define OCFS2_UNUSED2_FL (0x00000002)
208#define OCFS2_ORPHANED_FL (0x00000004) /* On the orphan list */
209#define OCFS2_UNUSED3_FL (0x00000008)
210/* System inode flags */
211#define OCFS2_SYSTEM_FL (0x00000010) /* System inode */
212#define OCFS2_SUPER_BLOCK_FL (0x00000020) /* Super block */
213#define OCFS2_LOCAL_ALLOC_FL (0x00000040) /* Slot local alloc bitmap */
214#define OCFS2_BITMAP_FL (0x00000080) /* Allocation bitmap */
215#define OCFS2_JOURNAL_FL (0x00000100) /* Slot local journal */
216#define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */
217#define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */
218#define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */
Jan Kara1a224ad2008-08-20 15:43:36 +0200219#define OCFS2_QUOTA_FL (0x00001000) /* Quota file */
Mark Fashehccd979b2005-12-15 14:31:24 -0800220
Mark Fasheh15b1e362007-09-07 13:58:15 -0700221/*
222 * Flags on ocfs2_dinode.i_dyn_features
223 *
224 * These can change much more often than i_flags. When adding flags,
225 * keep in mind that i_dyn_features is only 16 bits wide.
226 */
227#define OCFS2_INLINE_DATA_FL (0x0001) /* Data stored in inode block */
228#define OCFS2_HAS_XATTR_FL (0x0002)
229#define OCFS2_INLINE_XATTR_FL (0x0004)
230#define OCFS2_INDEXED_DIR_FL (0x0008)
Tao Ma721f69c2009-08-18 11:17:49 +0800231#define OCFS2_HAS_REFCOUNT_FL (0x0010)
Mark Fasheh15b1e362007-09-07 13:58:15 -0700232
Herbert Poetzlca4d1472006-07-03 17:27:12 -0700233/* Inode attributes, keep in sync with EXT2 */
234#define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
235#define OCFS2_UNRM_FL (0x00000002) /* Undelete */
236#define OCFS2_COMPR_FL (0x00000004) /* Compress file */
237#define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
238#define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
239#define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
240#define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
241#define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
242#define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
243
244#define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
245#define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
246
247/*
Mark Fashehe48edee2007-03-07 16:46:57 -0800248 * Extent record flags (e_node.leaf.flags)
249 */
Tao Ma721f69c2009-08-18 11:17:49 +0800250#define OCFS2_EXT_UNWRITTEN (0x01) /* Extent is allocated but
251 * unwritten */
252#define OCFS2_EXT_REFCOUNTED (0x02) /* Extent is reference
253 * counted in an associated
254 * refcount tree */
Mark Fashehe48edee2007-03-07 16:46:57 -0800255
256/*
Mark Fashehccd979b2005-12-15 14:31:24 -0800257 * Journal Flags (ocfs2_dinode.id1.journal1.i_flags)
258 */
259#define OCFS2_JOURNAL_DIRTY_FL (0x00000001) /* Journal needs recovery */
260
261/*
262 * superblock s_state flags
263 */
264#define OCFS2_ERROR_FS (0x00000001) /* FS saw errors */
265
266/* Limit of space in ocfs2_dir_entry */
267#define OCFS2_MAX_FILENAME_LEN 255
268
269/* Maximum slots on an ocfs2 file system */
270#define OCFS2_MAX_SLOTS 255
271
272/* Slot map indicator for an empty slot */
273#define OCFS2_INVALID_SLOT -1
274
275#define OCFS2_VOL_UUID_LEN 16
276#define OCFS2_MAX_VOL_LABEL_LEN 64
277
Joel Beckerb61817e2008-02-01 15:08:23 -0800278/* The alternate, userspace stack fields */
279#define OCFS2_STACK_LABEL_LEN 4
280#define OCFS2_CLUSTER_NAME_LEN 16
281
Mark Fashehccd979b2005-12-15 14:31:24 -0800282/* Journal limits (in bytes) */
283#define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024)
Mark Fashehccd979b2005-12-15 14:31:24 -0800284
Sunil Mushran2fbe8d12007-12-20 14:58:11 -0800285/*
286 * Default local alloc size (in megabytes)
287 *
288 * The value chosen should be such that most allocations, including new
289 * block groups, use local alloc.
290 */
291#define OCFS2_DEFAULT_LOCAL_ALLOC_SIZE 8
292
Tiger Yangfdd77702008-08-18 17:08:55 +0800293/*
294 * Inline extended attribute size (in bytes)
295 * The value chosen should be aligned to 16 byte boundaries.
296 */
297#define OCFS2_MIN_XATTR_INLINE_SIZE 256
298
Mark Fashehccd979b2005-12-15 14:31:24 -0800299struct ocfs2_system_inode_info {
300 char *si_name;
301 int si_iflags;
302 int si_mode;
303};
304
305/* System file index */
306enum {
307 BAD_BLOCK_SYSTEM_INODE = 0,
308 GLOBAL_INODE_ALLOC_SYSTEM_INODE,
309 SLOT_MAP_SYSTEM_INODE,
310#define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
311 HEARTBEAT_SYSTEM_INODE,
312 GLOBAL_BITMAP_SYSTEM_INODE,
Jan Kara1a224ad2008-08-20 15:43:36 +0200313 USER_QUOTA_SYSTEM_INODE,
314 GROUP_QUOTA_SYSTEM_INODE,
315#define OCFS2_LAST_GLOBAL_SYSTEM_INODE GROUP_QUOTA_SYSTEM_INODE
Mark Fashehccd979b2005-12-15 14:31:24 -0800316 ORPHAN_DIR_SYSTEM_INODE,
317 EXTENT_ALLOC_SYSTEM_INODE,
318 INODE_ALLOC_SYSTEM_INODE,
319 JOURNAL_SYSTEM_INODE,
320 LOCAL_ALLOC_SYSTEM_INODE,
321 TRUNCATE_LOG_SYSTEM_INODE,
Jan Kara1a224ad2008-08-20 15:43:36 +0200322 LOCAL_USER_QUOTA_SYSTEM_INODE,
323 LOCAL_GROUP_QUOTA_SYSTEM_INODE,
Mark Fashehccd979b2005-12-15 14:31:24 -0800324 NUM_SYSTEM_INODES
325};
326
327static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
328 /* Global system inodes (single copy) */
329 /* The first two are only used from userspace mfks/tunefs */
330 [BAD_BLOCK_SYSTEM_INODE] = { "bad_blocks", 0, S_IFREG | 0644 },
331 [GLOBAL_INODE_ALLOC_SYSTEM_INODE] = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
332
333 /* These are used by the running filesystem */
334 [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 },
335 [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
336 [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 },
Jan Kara1a224ad2008-08-20 15:43:36 +0200337 [USER_QUOTA_SYSTEM_INODE] = { "aquota.user", OCFS2_QUOTA_FL, S_IFREG | 0644 },
338 [GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group", OCFS2_QUOTA_FL, S_IFREG | 0644 },
Mark Fashehccd979b2005-12-15 14:31:24 -0800339
340 /* Slot-specific system inodes (one copy per slot) */
341 [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
342 [EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
343 [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
344 [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
345 [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
Jan Kara1a224ad2008-08-20 15:43:36 +0200346 [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 },
347 [LOCAL_USER_QUOTA_SYSTEM_INODE] = { "aquota.user:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
348 [LOCAL_GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
Mark Fashehccd979b2005-12-15 14:31:24 -0800349};
350
351/* Parameter passed from mount.ocfs2 to module */
352#define OCFS2_HB_NONE "heartbeat=none"
353#define OCFS2_HB_LOCAL "heartbeat=local"
354
355/*
356 * OCFS2 directory file types. Only the low 3 bits are used. The
357 * other bits are reserved for now.
358 */
359#define OCFS2_FT_UNKNOWN 0
360#define OCFS2_FT_REG_FILE 1
361#define OCFS2_FT_DIR 2
362#define OCFS2_FT_CHRDEV 3
363#define OCFS2_FT_BLKDEV 4
364#define OCFS2_FT_FIFO 5
365#define OCFS2_FT_SOCK 6
366#define OCFS2_FT_SYMLINK 7
367
368#define OCFS2_FT_MAX 8
369
370/*
371 * OCFS2_DIR_PAD defines the directory entries boundaries
372 *
373 * NOTE: It must be a multiple of 4
374 */
375#define OCFS2_DIR_PAD 4
376#define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1)
377#define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name)
378#define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \
379 OCFS2_DIR_ROUND) & \
380 ~OCFS2_DIR_ROUND)
Mark Fashehe7c17e42009-01-29 18:17:46 -0800381#define OCFS2_DIR_MIN_REC_LEN OCFS2_DIR_REC_LEN(1)
Mark Fashehccd979b2005-12-15 14:31:24 -0800382
383#define OCFS2_LINK_MAX 32000
Mark Fasheh198a1ca2008-11-20 17:54:57 -0800384#define OCFS2_DX_LINK_MAX ((1U << 31) - 1U)
385#define OCFS2_LINKS_HI_SHIFT 16
Mark Fashehe3a93c22009-02-17 15:29:35 -0800386#define OCFS2_DX_ENTRIES_MAX (0xffffffffU)
Mark Fashehccd979b2005-12-15 14:31:24 -0800387
388#define S_SHIFT 12
389static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = {
390 [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE,
391 [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR,
392 [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV,
393 [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV,
394 [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO,
395 [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK,
396 [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK,
397};
398
399
400/*
401 * Convenience casts
402 */
403#define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
404
405/*
Joel Beckerab552d52008-10-16 17:50:30 -0700406 * Block checking structure. This is used in metadata to validate the
407 * contents. If OCFS2_FEATURE_INCOMPAT_META_ECC is not set, it is all
408 * zeros.
409 */
410struct ocfs2_block_check {
411/*00*/ __le32 bc_crc32e; /* 802.3 Ethernet II CRC32 */
412 __le16 bc_ecc; /* Single-error-correction parity vector.
413 This is a simple Hamming code dependant
414 on the blocksize. OCFS2's maximum
415 blocksize, 4K, requires 16 parity bits,
416 so we fit in __le16. */
417 __le16 bc_reserved1;
418/*08*/
419};
420
421/*
Mark Fashehccd979b2005-12-15 14:31:24 -0800422 * On disk extent record for OCFS2
423 * It describes a range of clusters on disk.
Mark Fashehe48edee2007-03-07 16:46:57 -0800424 *
425 * Length fields are divided into interior and leaf node versions.
426 * This leaves room for a flags field (OCFS2_EXT_*) in the leaf nodes.
Mark Fashehccd979b2005-12-15 14:31:24 -0800427 */
428struct ocfs2_extent_rec {
429/*00*/ __le32 e_cpos; /* Offset into the file, in clusters */
Mark Fashehe48edee2007-03-07 16:46:57 -0800430 union {
431 __le32 e_int_clusters; /* Clusters covered by all children */
432 struct {
433 __le16 e_leaf_clusters; /* Clusters covered by this
434 extent */
435 __u8 e_reserved1;
436 __u8 e_flags; /* Extent flags */
437 };
438 };
Mark Fashehccd979b2005-12-15 14:31:24 -0800439 __le64 e_blkno; /* Physical disk offset, in blocks */
440/*10*/
441};
442
443struct ocfs2_chain_rec {
444 __le32 c_free; /* Number of free bits in this chain. */
445 __le32 c_total; /* Number of total bits in this chain */
446 __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */
447};
448
449struct ocfs2_truncate_rec {
450 __le32 t_start; /* 1st cluster in this log */
451 __le32 t_clusters; /* Number of total clusters covered */
452};
453
454/*
455 * On disk extent list for OCFS2 (node in the tree). Note that this
456 * is contained inside ocfs2_dinode or ocfs2_extent_block, so the
457 * offsets are relative to ocfs2_dinode.id2.i_list or
458 * ocfs2_extent_block.h_list, respectively.
459 */
460struct ocfs2_extent_list {
461/*00*/ __le16 l_tree_depth; /* Extent tree depth from this
462 point. 0 means data extents
463 hang directly off this
Mark Fashehdcd05382007-01-16 11:32:23 -0800464 header (a leaf)
465 NOTE: The high 8 bits cannot be
466 used - tree_depth is never that big.
467 */
Mark Fashehccd979b2005-12-15 14:31:24 -0800468 __le16 l_count; /* Number of extent records */
469 __le16 l_next_free_rec; /* Next unused extent slot */
470 __le16 l_reserved1;
471 __le64 l_reserved2; /* Pad to
472 sizeof(ocfs2_extent_rec) */
473/*10*/ struct ocfs2_extent_rec l_recs[0]; /* Extent records */
474};
475
476/*
477 * On disk allocation chain list for OCFS2. Note that this is
478 * contained inside ocfs2_dinode, so the offsets are relative to
479 * ocfs2_dinode.id2.i_chain.
480 */
481struct ocfs2_chain_list {
482/*00*/ __le16 cl_cpg; /* Clusters per Block Group */
483 __le16 cl_bpc; /* Bits per cluster */
484 __le16 cl_count; /* Total chains in this list */
485 __le16 cl_next_free_rec; /* Next unused chain slot */
486 __le64 cl_reserved1;
487/*10*/ struct ocfs2_chain_rec cl_recs[0]; /* Chain records */
488};
489
490/*
491 * On disk deallocation log for OCFS2. Note that this is
492 * contained inside ocfs2_dinode, so the offsets are relative to
493 * ocfs2_dinode.id2.i_dealloc.
494 */
495struct ocfs2_truncate_log {
496/*00*/ __le16 tl_count; /* Total records in this log */
497 __le16 tl_used; /* Number of records in use */
498 __le32 tl_reserved1;
499/*08*/ struct ocfs2_truncate_rec tl_recs[0]; /* Truncate records */
500};
501
502/*
503 * On disk extent block (indirect block) for OCFS2
504 */
505struct ocfs2_extent_block
506{
507/*00*/ __u8 h_signature[8]; /* Signature for verification */
Joel Beckerab552d52008-10-16 17:50:30 -0700508 struct ocfs2_block_check h_check; /* Error checking */
Mark Fashehccd979b2005-12-15 14:31:24 -0800509/*10*/ __le16 h_suballoc_slot; /* Slot suballocator this
510 extent_header belongs to */
511 __le16 h_suballoc_bit; /* Bit offset in suballocator
512 block group */
513 __le32 h_fs_generation; /* Must match super block */
514 __le64 h_blkno; /* Offset on disk, in blocks */
515/*20*/ __le64 h_reserved3;
516 __le64 h_next_leaf_blk; /* Offset on disk, in blocks,
517 of next leaf header pointing
518 to data */
519/*30*/ struct ocfs2_extent_list h_list; /* Extent record list */
520/* Actual on-disk size is one block */
521};
522
523/*
Joel Beckerfb86b1f2008-02-01 11:59:05 -0800524 * On disk slot map for OCFS2. This defines the contents of the "slot_map"
Joel Becker386a2ef2008-02-01 12:06:54 -0800525 * system file. A slot is valid if it contains a node number >= 0. The
526 * value -1 (0xFFFF) is OCFS2_INVALID_SLOT. This marks a slot empty.
Joel Beckerfb86b1f2008-02-01 11:59:05 -0800527 */
528struct ocfs2_slot_map {
529/*00*/ __le16 sm_slots[0];
530/*
531 * Actual on-disk size is one block. OCFS2_MAX_SLOTS is 255,
532 * 255 * sizeof(__le16) == 512B, within the 512B block minimum blocksize.
533 */
534};
535
Joel Becker386a2ef2008-02-01 12:06:54 -0800536struct ocfs2_extended_slot {
537/*00*/ __u8 es_valid;
538 __u8 es_reserved1[3];
539 __le32 es_node_num;
540/*10*/
541};
542
543/*
544 * The extended slot map, used when OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP
545 * is set. It separates out the valid marker from the node number, and
546 * has room to grow. Unlike the old slot map, this format is defined by
547 * i_size.
548 */
549struct ocfs2_slot_map_extended {
550/*00*/ struct ocfs2_extended_slot se_slots[0];
551/*
552 * Actual size is i_size of the slot_map system file. It should
553 * match s_max_slots * sizeof(struct ocfs2_extended_slot)
554 */
555};
556
Joel Beckerb61817e2008-02-01 15:08:23 -0800557struct ocfs2_cluster_info {
558/*00*/ __u8 ci_stack[OCFS2_STACK_LABEL_LEN];
559 __le32 ci_reserved;
560/*08*/ __u8 ci_cluster[OCFS2_CLUSTER_NAME_LEN];
561/*18*/
562};
563
Joel Beckerfb86b1f2008-02-01 11:59:05 -0800564/*
Mark Fashehccd979b2005-12-15 14:31:24 -0800565 * On disk superblock for OCFS2
566 * Note that it is contained inside an ocfs2_dinode, so all offsets
567 * are relative to the start of ocfs2_dinode.id2.
568 */
569struct ocfs2_super_block {
570/*00*/ __le16 s_major_rev_level;
571 __le16 s_minor_rev_level;
572 __le16 s_mnt_count;
573 __le16 s_max_mnt_count;
574 __le16 s_state; /* File system state */
575 __le16 s_errors; /* Behaviour when detecting errors */
576 __le32 s_checkinterval; /* Max time between checks */
577/*10*/ __le64 s_lastcheck; /* Time of last check */
578 __le32 s_creator_os; /* OS */
579 __le32 s_feature_compat; /* Compatible feature set */
580/*20*/ __le32 s_feature_incompat; /* Incompatible feature set */
581 __le32 s_feature_ro_compat; /* Readonly-compatible feature set */
582 __le64 s_root_blkno; /* Offset, in blocks, of root directory
583 dinode */
584/*30*/ __le64 s_system_dir_blkno; /* Offset, in blocks, of system
585 directory dinode */
586 __le32 s_blocksize_bits; /* Blocksize for this fs */
587 __le32 s_clustersize_bits; /* Clustersize for this fs */
588/*40*/ __le16 s_max_slots; /* Max number of simultaneous mounts
589 before tunefs required */
Mark Fasheh92e91ce2007-09-20 11:19:20 -0700590 __le16 s_tunefs_flag;
Tiger Yangcf1d6c72008-08-18 17:11:00 +0800591 __le32 s_uuid_hash; /* hash value of uuid */
Mark Fashehccd979b2005-12-15 14:31:24 -0800592 __le64 s_first_cluster_group; /* Block offset of 1st cluster
593 * group header */
594/*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */
595/*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */
Joel Beckerb61817e2008-02-01 15:08:23 -0800596/*A0*/ struct ocfs2_cluster_info s_cluster_info; /* Selected userspace
597 stack. Only valid
598 with INCOMPAT flag. */
Tiger Yang8154da32008-08-18 17:11:46 +0800599/*B8*/ __le16 s_xattr_inline_size; /* extended attribute inline size
600 for this fs*/
601 __le16 s_reserved0;
Mark Fasheh9b7895e2008-11-12 16:27:44 -0800602 __le32 s_dx_seed[3]; /* seed[0-2] for dx dir hash.
603 * s_uuid_hash serves as seed[3]. */
604/*C0*/ __le64 s_reserved2[15]; /* Fill out superblock */
Joel Beckerb61817e2008-02-01 15:08:23 -0800605/*140*/
606
607 /*
608 * NOTE: As stated above, all offsets are relative to
609 * ocfs2_dinode.id2, which is at 0xC0 in the inode.
610 * 0xC0 + 0x140 = 0x200 or 512 bytes. A superblock must fit within
611 * our smallest blocksize, which is 512 bytes. To ensure this,
612 * we reserve the space in s_reserved2. Anything past s_reserved2
613 * will not be available on the smallest blocksize.
614 */
Mark Fashehccd979b2005-12-15 14:31:24 -0800615};
616
617/*
618 * Local allocation bitmap for OCFS2 slots
619 * Note that it exists inside an ocfs2_dinode, so all offsets are
620 * relative to the start of ocfs2_dinode.id2.
621 */
622struct ocfs2_local_alloc
623{
624/*00*/ __le32 la_bm_off; /* Starting bit offset in main bitmap */
625 __le16 la_size; /* Size of included bitmap, in bytes */
626 __le16 la_reserved1;
627 __le64 la_reserved2;
628/*10*/ __u8 la_bitmap[0];
629};
630
631/*
Mark Fasheh15b1e362007-09-07 13:58:15 -0700632 * Data-in-inode header. This is only used if i_dyn_features has
633 * OCFS2_INLINE_DATA_FL set.
634 */
635struct ocfs2_inline_data
636{
637/*00*/ __le16 id_count; /* Number of bytes that can be used
638 * for data, starting at id_data */
639 __le16 id_reserved0;
640 __le32 id_reserved1;
641 __u8 id_data[0]; /* Start of user data */
642};
643
644/*
Mark Fashehccd979b2005-12-15 14:31:24 -0800645 * On disk inode for OCFS2
646 */
647struct ocfs2_dinode {
648/*00*/ __u8 i_signature[8]; /* Signature for validation */
649 __le32 i_generation; /* Generation number */
650 __le16 i_suballoc_slot; /* Slot suballocator this inode
651 belongs to */
652 __le16 i_suballoc_bit; /* Bit offset in suballocator
653 block group */
Mark Fasheh198a1ca2008-11-20 17:54:57 -0800654/*10*/ __le16 i_links_count_hi; /* High 16 bits of links count */
Tiger Yangfdd77702008-08-18 17:08:55 +0800655 __le16 i_xattr_inline_size;
Mark Fashehccd979b2005-12-15 14:31:24 -0800656 __le32 i_clusters; /* Cluster count */
657 __le32 i_uid; /* Owner UID */
658 __le32 i_gid; /* Owning GID */
659/*20*/ __le64 i_size; /* Size in bytes */
660 __le16 i_mode; /* File mode */
661 __le16 i_links_count; /* Links count */
662 __le32 i_flags; /* File flags */
663/*30*/ __le64 i_atime; /* Access time */
664 __le64 i_ctime; /* Creation time */
665/*40*/ __le64 i_mtime; /* Modification time */
666 __le64 i_dtime; /* Deletion time */
667/*50*/ __le64 i_blkno; /* Offset on disk, in blocks */
668 __le64 i_last_eb_blk; /* Pointer to last extent
669 block */
670/*60*/ __le32 i_fs_generation; /* Generation per fs-instance */
671 __le32 i_atime_nsec;
672 __le32 i_ctime_nsec;
673 __le32 i_mtime_nsec;
Tiger Yangfdd77702008-08-18 17:08:55 +0800674/*70*/ __le32 i_attr;
Tiger Yang50008632007-03-20 16:01:38 -0700675 __le16 i_orphaned_slot; /* Only valid when OCFS2_ORPHANED_FL
676 was set in i_flags */
Mark Fasheh15b1e362007-09-07 13:58:15 -0700677 __le16 i_dyn_features;
Tiger Yangfdd77702008-08-18 17:08:55 +0800678 __le64 i_xattr_loc;
Joel Beckerab552d52008-10-16 17:50:30 -0700679/*80*/ struct ocfs2_block_check i_check; /* Error checking */
Mark Fasheh9b7895e2008-11-12 16:27:44 -0800680/*88*/ __le64 i_dx_root; /* Pointer to dir index root block */
Tao Ma721f69c2009-08-18 11:17:49 +0800681/*90*/ __le64 i_refcount_loc;
682 __le64 i_reserved2[4];
Mark Fashehccd979b2005-12-15 14:31:24 -0800683/*B8*/ union {
684 __le64 i_pad1; /* Generic way to refer to this
685 64bit union */
686 struct {
687 __le64 i_rdev; /* Device number */
688 } dev1;
689 struct { /* Info for bitmap system
690 inodes */
691 __le32 i_used; /* Bits (ie, clusters) used */
692 __le32 i_total; /* Total bits (clusters)
693 available */
694 } bitmap1;
695 struct { /* Info for journal system
696 inodes */
697 __le32 ij_flags; /* Mounted, version, etc. */
Sunil Mushranc69991a2008-07-14 17:31:09 -0700698 __le32 ij_recovery_generation; /* Incremented when the
699 journal is recovered
700 after an unclean
701 shutdown */
Mark Fashehccd979b2005-12-15 14:31:24 -0800702 } journal1;
703 } id1; /* Inode type dependant 1 */
704/*C0*/ union {
705 struct ocfs2_super_block i_super;
706 struct ocfs2_local_alloc i_lab;
707 struct ocfs2_chain_list i_chain;
708 struct ocfs2_extent_list i_list;
709 struct ocfs2_truncate_log i_dealloc;
Mark Fasheh15b1e362007-09-07 13:58:15 -0700710 struct ocfs2_inline_data i_data;
Mark Fashehccd979b2005-12-15 14:31:24 -0800711 __u8 i_symlink[0];
712 } id2;
713/* Actual on-disk size is one block */
714};
715
716/*
717 * On-disk directory entry structure for OCFS2
718 *
719 * Packed as this structure could be accessed unaligned on 64-bit platforms
720 */
721struct ocfs2_dir_entry {
722/*00*/ __le64 inode; /* Inode number */
723 __le16 rec_len; /* Directory entry length */
724 __u8 name_len; /* Name length */
725 __u8 file_type;
726/*0C*/ char name[OCFS2_MAX_FILENAME_LEN]; /* File name */
727/* Actual on-disk length specified by rec_len */
728} __attribute__ ((packed));
729
730/*
Mark Fasheh87d35a72008-12-10 17:36:25 -0800731 * Per-block record for the unindexed directory btree. This is carefully
732 * crafted so that the rec_len and name_len records of an ocfs2_dir_entry are
733 * mirrored. That way, the directory manipulation code needs a minimal amount
734 * of update.
735 *
736 * NOTE: Keep this structure aligned to a multiple of 4 bytes.
737 */
738struct ocfs2_dir_block_trailer {
739/*00*/ __le64 db_compat_inode; /* Always zero. Was inode */
740
741 __le16 db_compat_rec_len; /* Backwards compatible with
742 * ocfs2_dir_entry. */
743 __u8 db_compat_name_len; /* Always zero. Was name_len */
744 __u8 db_reserved0;
745 __le16 db_reserved1;
746 __le16 db_free_rec_len; /* Size of largest empty hole
747 * in this block. (unused) */
748/*10*/ __u8 db_signature[8]; /* Signature for verification */
749 __le64 db_reserved2;
750 __le64 db_free_next; /* Next block in list (unused) */
751/*20*/ __le64 db_blkno; /* Offset on disk, in blocks */
752 __le64 db_parent_dinode; /* dinode which owns me, in
753 blocks */
Joel Beckerc175a512008-12-10 17:58:22 -0800754/*30*/ struct ocfs2_block_check db_check; /* Error checking */
Mark Fasheh87d35a72008-12-10 17:36:25 -0800755/*40*/
756};
757
Mark Fasheh9b7895e2008-11-12 16:27:44 -0800758 /*
759 * A directory entry in the indexed tree. We don't store the full name here,
760 * but instead provide a pointer to the full dirent in the unindexed tree.
761 *
762 * We also store name_len here so as to reduce the number of leaf blocks we
763 * need to search in case of collisions.
764 */
765struct ocfs2_dx_entry {
766 __le32 dx_major_hash; /* Used to find logical
767 * cluster in index */
768 __le32 dx_minor_hash; /* Lower bits used to find
769 * block in cluster */
770 __le64 dx_dirent_blk; /* Physical block in unindexed
771 * tree holding this dirent. */
772};
773
774struct ocfs2_dx_entry_list {
775 __le32 de_reserved;
776 __le16 de_count; /* Maximum number of entries
777 * possible in de_entries */
778 __le16 de_num_used; /* Current number of
779 * de_entries entries */
780 struct ocfs2_dx_entry de_entries[0]; /* Indexed dir entries
781 * in a packed array of
782 * length de_num_used */
783};
784
Mark Fasheh4ed8a6b2008-11-24 17:02:08 -0800785#define OCFS2_DX_FLAG_INLINE 0x01
786
Mark Fasheh9b7895e2008-11-12 16:27:44 -0800787/*
788 * A directory indexing block. Each indexed directory has one of these,
789 * pointed to by ocfs2_dinode.
790 *
791 * This block stores an indexed btree root, and a set of free space
792 * start-of-list pointers.
793 */
794struct ocfs2_dx_root_block {
795 __u8 dr_signature[8]; /* Signature for verification */
796 struct ocfs2_block_check dr_check; /* Error checking */
797 __le16 dr_suballoc_slot; /* Slot suballocator this
798 * block belongs to. */
799 __le16 dr_suballoc_bit; /* Bit offset in suballocator
800 * block group */
801 __le32 dr_fs_generation; /* Must match super block */
802 __le64 dr_blkno; /* Offset on disk, in blocks */
803 __le64 dr_last_eb_blk; /* Pointer to last
804 * extent block */
805 __le32 dr_clusters; /* Clusters allocated
806 * to the indexed tree. */
Mark Fasheh4ed8a6b2008-11-24 17:02:08 -0800807 __u8 dr_flags; /* OCFS2_DX_FLAG_* flags */
808 __u8 dr_reserved0;
809 __le16 dr_reserved1;
Mark Fasheh9b7895e2008-11-12 16:27:44 -0800810 __le64 dr_dir_blkno; /* Pointer to parent inode */
Mark Fashehe3a93c22009-02-17 15:29:35 -0800811 __le32 dr_num_entries; /* Total number of
812 * names stored in
813 * this directory.*/
814 __le32 dr_reserved2;
Mark Fashehe7c17e42009-01-29 18:17:46 -0800815 __le64 dr_free_blk; /* Pointer to head of free
816 * unindexed block list. */
817 __le64 dr_reserved3[15];
Mark Fasheh4ed8a6b2008-11-24 17:02:08 -0800818 union {
819 struct ocfs2_extent_list dr_list; /* Keep this aligned to 128
820 * bits for maximum space
821 * efficiency. */
822 struct ocfs2_dx_entry_list dr_entries; /* In-root-block list of
823 * entries. We grow out
824 * to extents if this
825 * gets too big. */
826 };
Mark Fasheh9b7895e2008-11-12 16:27:44 -0800827};
828
829/*
830 * The header of a leaf block in the indexed tree.
831 */
832struct ocfs2_dx_leaf {
833 __u8 dl_signature[8];/* Signature for verification */
834 struct ocfs2_block_check dl_check; /* Error checking */
835 __le64 dl_blkno; /* Offset on disk, in blocks */
836 __le32 dl_fs_generation;/* Must match super block */
837 __le32 dl_reserved0;
838 __le64 dl_reserved1;
839 struct ocfs2_dx_entry_list dl_list;
840};
841
Mark Fasheh87d35a72008-12-10 17:36:25 -0800842/*
Mark Fashehccd979b2005-12-15 14:31:24 -0800843 * On disk allocator group structure for OCFS2
844 */
845struct ocfs2_group_desc
846{
847/*00*/ __u8 bg_signature[8]; /* Signature for validation */
848 __le16 bg_size; /* Size of included bitmap in
849 bytes. */
850 __le16 bg_bits; /* Bits represented by this
851 group. */
852 __le16 bg_free_bits_count; /* Free bits count */
853 __le16 bg_chain; /* What chain I am in. */
854/*10*/ __le32 bg_generation;
855 __le32 bg_reserved1;
856 __le64 bg_next_group; /* Next group in my list, in
857 blocks */
858/*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in
859 blocks */
860 __le64 bg_blkno; /* Offset on disk, in blocks */
Joel Beckerab552d52008-10-16 17:50:30 -0700861/*30*/ struct ocfs2_block_check bg_check; /* Error checking */
862 __le64 bg_reserved2;
Mark Fashehccd979b2005-12-15 14:31:24 -0800863/*40*/ __u8 bg_bitmap[0];
864};
865
Tao Ma721f69c2009-08-18 11:17:49 +0800866struct ocfs2_refcount_rec {
867/*00*/ __le64 r_cpos; /* Physical offset, in clusters */
868 __le32 r_clusters; /* Clusters covered by this extent */
869 __le32 r_refcount; /* Reference count of this extent */
870/*10*/
871};
Tao Mae73a8192009-08-11 14:33:14 +0800872#define OCFS2_32BIT_POS_MASK (0xffffffffULL)
Tao Ma721f69c2009-08-18 11:17:49 +0800873
874#define OCFS2_REFCOUNT_LEAF_FL (0x00000001)
875#define OCFS2_REFCOUNT_TREE_FL (0x00000002)
876
877struct ocfs2_refcount_list {
878/*00*/ __le16 rl_count; /* Maximum number of entries possible
879 in rl_records */
880 __le16 rl_used; /* Current number of used records */
881 __le32 rl_reserved2;
882 __le64 rl_reserved1; /* Pad to sizeof(ocfs2_refcount_record) */
883/*10*/ struct ocfs2_refcount_rec rl_recs[0]; /* Refcount records */
884};
885
886
887struct ocfs2_refcount_block {
888/*00*/ __u8 rf_signature[8]; /* Signature for verification */
889 __le16 rf_suballoc_slot; /* Slot suballocator this block
890 belongs to */
891 __le16 rf_suballoc_bit; /* Bit offset in suballocator
892 block group */
893 __le32 rf_fs_generation; /* Must match superblock */
894/*10*/ __le64 rf_blkno; /* Offset on disk, in blocks */
895 __le64 rf_parent; /* Parent block, only valid if
896 OCFS2_REFCOUNT_LEAF_FL is set in
897 rf_flags */
898/*20*/ struct ocfs2_block_check rf_check; /* Error checking */
899 __le64 rf_last_eb_blk; /* Pointer to last extent block */
900/*30*/ __le32 rf_count; /* Number of inodes sharing this
901 refcount tree */
902 __le32 rf_flags; /* See the flags above */
903 __le32 rf_clusters; /* clusters covered by refcount tree. */
904 __le32 rf_cpos; /* cluster offset in refcount tree.*/
905/*40*/ __le32 rf_generation; /* generation number. all be the same
906 * for the same refcount tree. */
907 __le32 rf_reserved0;
908 __le64 rf_reserved1[7];
909/*80*/ union {
910 struct ocfs2_refcount_list rf_records; /* List of refcount
911 records */
912 struct ocfs2_extent_list rf_list; /* Extent record list,
913 only valid if
914 OCFS2_REFCOUNT_TREE_FL
915 is set in rf_flags */
916 };
917/* Actual on-disk size is one block */
918};
919
Tao Ma5a7bc8e2008-08-18 17:38:46 +0800920/*
921 * On disk extended attribute structure for OCFS2.
922 */
923
924/*
925 * ocfs2_xattr_entry indicates one extend attribute.
926 *
927 * Note that it can be stored in inode, one block or one xattr bucket.
928 */
929struct ocfs2_xattr_entry {
930 __le32 xe_name_hash; /* hash value of xattr prefix+suffix. */
Tao Ma8573f792008-10-24 22:24:17 +0800931 __le16 xe_name_offset; /* byte offset from the 1st entry in the
Tao Ma5a7bc8e2008-08-18 17:38:46 +0800932 local xattr storage(inode, xattr block or
933 xattr bucket). */
934 __u8 xe_name_len; /* xattr name len, does't include prefix. */
Tao Ma8573f792008-10-24 22:24:17 +0800935 __u8 xe_type; /* the low 7 bits indicate the name prefix
936 * type and the highest bit indicates whether
Tao Ma5a7bc8e2008-08-18 17:38:46 +0800937 * the EA is stored in the local storage. */
938 __le64 xe_value_size; /* real xattr value length. */
939};
940
941/*
942 * On disk structure for xattr header.
943 *
944 * One ocfs2_xattr_header describes how many ocfs2_xattr_entry records in
945 * the local xattr storage.
946 */
947struct ocfs2_xattr_header {
948 __le16 xh_count; /* contains the count of how
949 many records are in the
950 local xattr storage. */
Tao Ma0c044f02008-08-18 17:38:50 +0800951 __le16 xh_free_start; /* current offset for storing
952 xattr. */
953 __le16 xh_name_value_len; /* total length of name/value
954 length in this bucket. */
Tao Ma8573f792008-10-24 22:24:17 +0800955 __le16 xh_num_buckets; /* Number of xattr buckets
956 in this extent record,
957 only valid in the first
958 bucket. */
Joel Beckerab552d52008-10-16 17:50:30 -0700959 struct ocfs2_block_check xh_check; /* Error checking
960 (Note, this is only
961 used for xattr
962 buckets. A block uses
963 xb_check and sets
964 this field to zero.) */
Tao Ma5a7bc8e2008-08-18 17:38:46 +0800965 struct ocfs2_xattr_entry xh_entries[0]; /* xattr entry list. */
966};
967
968/*
969 * On disk structure for xattr value root.
970 *
Tao Ma8573f792008-10-24 22:24:17 +0800971 * When an xattr's value is large enough, it is stored in an external
972 * b-tree like file data. The xattr value root points to this structure.
Tao Ma5a7bc8e2008-08-18 17:38:46 +0800973 */
974struct ocfs2_xattr_value_root {
975/*00*/ __le32 xr_clusters; /* clusters covered by xattr value. */
976 __le32 xr_reserved0;
977 __le64 xr_last_eb_blk; /* Pointer to last extent block */
978/*10*/ struct ocfs2_extent_list xr_list; /* Extent record list */
979};
980
981/*
982 * On disk structure for xattr tree root.
983 *
984 * It is used when there are too many extended attributes for one file. These
985 * attributes will be organized and stored in an indexed-btree.
986 */
987struct ocfs2_xattr_tree_root {
988/*00*/ __le32 xt_clusters; /* clusters covered by xattr. */
989 __le32 xt_reserved0;
990 __le64 xt_last_eb_blk; /* Pointer to last extent block */
991/*10*/ struct ocfs2_extent_list xt_list; /* Extent record list */
992};
993
Tiger Yangcf1d6c72008-08-18 17:11:00 +0800994#define OCFS2_XATTR_INDEXED 0x1
995#define OCFS2_HASH_SHIFT 5
996#define OCFS2_XATTR_ROUND 3
997#define OCFS2_XATTR_SIZE(size) (((size) + OCFS2_XATTR_ROUND) & \
998 ~(OCFS2_XATTR_ROUND))
Tao Ma5a7bc8e2008-08-18 17:38:46 +0800999
Tao Ma0c044f02008-08-18 17:38:50 +08001000#define OCFS2_XATTR_BUCKET_SIZE 4096
1001#define OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET (OCFS2_XATTR_BUCKET_SIZE \
1002 / OCFS2_MIN_BLOCKSIZE)
1003
Tao Ma5a7bc8e2008-08-18 17:38:46 +08001004/*
1005 * On disk structure for xattr block.
1006 */
1007struct ocfs2_xattr_block {
1008/*00*/ __u8 xb_signature[8]; /* Signature for verification */
1009 __le16 xb_suballoc_slot; /* Slot suballocator this
1010 block belongs to. */
1011 __le16 xb_suballoc_bit; /* Bit offset in suballocator
1012 block group */
1013 __le32 xb_fs_generation; /* Must match super block */
1014/*10*/ __le64 xb_blkno; /* Offset on disk, in blocks */
Joel Beckerab552d52008-10-16 17:50:30 -07001015 struct ocfs2_block_check xb_check; /* Error checking */
Tao Ma5a7bc8e2008-08-18 17:38:46 +08001016/*20*/ __le16 xb_flags; /* Indicates whether this block contains
1017 real xattr or a xattr tree. */
1018 __le16 xb_reserved0;
1019 __le32 xb_reserved1;
1020 __le64 xb_reserved2;
1021/*30*/ union {
1022 struct ocfs2_xattr_header xb_header; /* xattr header if this
1023 block contains xattr */
1024 struct ocfs2_xattr_tree_root xb_root;/* xattr tree root if this
1025 block cotains xattr
1026 tree. */
1027 } xb_attrs;
1028};
1029
1030#define OCFS2_XATTR_ENTRY_LOCAL 0x80
1031#define OCFS2_XATTR_TYPE_MASK 0x7F
1032static inline void ocfs2_xattr_set_local(struct ocfs2_xattr_entry *xe,
1033 int local)
1034{
1035 if (local)
1036 xe->xe_type |= OCFS2_XATTR_ENTRY_LOCAL;
1037 else
1038 xe->xe_type &= ~OCFS2_XATTR_ENTRY_LOCAL;
1039}
1040
1041static inline int ocfs2_xattr_is_local(struct ocfs2_xattr_entry *xe)
1042{
1043 return xe->xe_type & OCFS2_XATTR_ENTRY_LOCAL;
1044}
1045
1046static inline void ocfs2_xattr_set_type(struct ocfs2_xattr_entry *xe, int type)
1047{
1048 xe->xe_type |= type & OCFS2_XATTR_TYPE_MASK;
1049}
1050
1051static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry *xe)
1052{
1053 return xe->xe_type & OCFS2_XATTR_TYPE_MASK;
1054}
1055
Jan Kara9e33d692008-08-25 19:56:50 +02001056/*
1057 * On disk structures for global quota file
1058 */
1059
1060/* Magic numbers and known versions for global quota files */
1061#define OCFS2_GLOBAL_QMAGICS {\
1062 0x0cf52470, /* USRQUOTA */ \
1063 0x0cf52471 /* GRPQUOTA */ \
1064}
1065
1066#define OCFS2_GLOBAL_QVERSIONS {\
1067 0, \
1068 0, \
1069}
1070
1071
1072/* Each block of each quota file has a certain fixed number of bytes reserved
1073 * for OCFS2 internal use at its end. OCFS2 can use it for things like
1074 * checksums, etc. */
1075#define OCFS2_QBLK_RESERVED_SPACE 8
1076
1077/* Generic header of all quota files */
1078struct ocfs2_disk_dqheader {
1079 __le32 dqh_magic; /* Magic number identifying file */
1080 __le32 dqh_version; /* Quota format version */
1081};
1082
1083#define OCFS2_GLOBAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1084
1085/* Information header of global quota file (immediately follows the generic
1086 * header) */
1087struct ocfs2_global_disk_dqinfo {
1088/*00*/ __le32 dqi_bgrace; /* Grace time for space softlimit excess */
1089 __le32 dqi_igrace; /* Grace time for inode softlimit excess */
1090 __le32 dqi_syncms; /* Time after which we sync local changes to
1091 * global quota file */
1092 __le32 dqi_blocks; /* Number of blocks in quota file */
1093/*10*/ __le32 dqi_free_blk; /* First free block in quota file */
1094 __le32 dqi_free_entry; /* First block with free dquot entry in quota
1095 * file */
1096};
1097
1098/* Structure with global user / group information. We reserve some space
1099 * for future use. */
1100struct ocfs2_global_disk_dqblk {
1101/*00*/ __le32 dqb_id; /* ID the structure belongs to */
1102 __le32 dqb_use_count; /* Number of nodes having reference to this structure */
1103 __le64 dqb_ihardlimit; /* absolute limit on allocated inodes */
1104/*10*/ __le64 dqb_isoftlimit; /* preferred inode limit */
1105 __le64 dqb_curinodes; /* current # allocated inodes */
1106/*20*/ __le64 dqb_bhardlimit; /* absolute limit on disk space */
1107 __le64 dqb_bsoftlimit; /* preferred limit on disk space */
1108/*30*/ __le64 dqb_curspace; /* current space occupied */
1109 __le64 dqb_btime; /* time limit for excessive disk use */
1110/*40*/ __le64 dqb_itime; /* time limit for excessive inode use */
1111 __le64 dqb_pad1;
1112/*50*/ __le64 dqb_pad2;
1113};
1114
1115/*
1116 * On-disk structures for local quota file
1117 */
1118
1119/* Magic numbers and known versions for local quota files */
1120#define OCFS2_LOCAL_QMAGICS {\
1121 0x0cf524c0, /* USRQUOTA */ \
1122 0x0cf524c1 /* GRPQUOTA */ \
1123}
1124
1125#define OCFS2_LOCAL_QVERSIONS {\
1126 0, \
1127 0, \
1128}
1129
1130/* Quota flags in dqinfo header */
1131#define OLQF_CLEAN 0x0001 /* Quota file is empty (this should be after\
1132 * quota has been cleanly turned off) */
1133
1134#define OCFS2_LOCAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1135
1136/* Information header of local quota file (immediately follows the generic
1137 * header) */
1138struct ocfs2_local_disk_dqinfo {
1139 __le32 dqi_flags; /* Flags for quota file */
1140 __le32 dqi_chunks; /* Number of chunks of quota structures
1141 * with a bitmap */
1142 __le32 dqi_blocks; /* Number of blocks allocated for quota file */
1143};
1144
1145/* Header of one chunk of a quota file */
1146struct ocfs2_local_disk_chunk {
1147 __le32 dqc_free; /* Number of free entries in the bitmap */
Coly Li93654542009-12-06 22:38:53 +08001148 __u8 dqc_bitmap[0]; /* Bitmap of entries in the corresponding
Jan Kara9e33d692008-08-25 19:56:50 +02001149 * chunk of quota file */
1150};
1151
1152/* One entry in local quota file */
1153struct ocfs2_local_disk_dqblk {
1154/*00*/ __le64 dqb_id; /* id this quota applies to */
1155 __le64 dqb_spacemod; /* Change in the amount of used space */
1156/*10*/ __le64 dqb_inodemod; /* Change in the amount of used inodes */
1157};
1158
Joel Beckerab552d52008-10-16 17:50:30 -07001159
1160/*
1161 * The quota trailer lives at the end of each quota block.
1162 */
1163
1164struct ocfs2_disk_dqtrailer {
1165/*00*/ struct ocfs2_block_check dq_check; /* Error checking */
1166/*08*/ /* Cannot be larger than OCFS2_QBLK_RESERVED_SPACE */
1167};
1168
1169static inline struct ocfs2_disk_dqtrailer *ocfs2_block_dqtrailer(int blocksize,
1170 void *buf)
1171{
1172 char *ptr = buf;
1173 ptr += blocksize - OCFS2_QBLK_RESERVED_SPACE;
1174
1175 return (struct ocfs2_disk_dqtrailer *)ptr;
1176}
1177
Mark Fashehccd979b2005-12-15 14:31:24 -08001178#ifdef __KERNEL__
1179static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
1180{
1181 return sb->s_blocksize -
1182 offsetof(struct ocfs2_dinode, id2.i_symlink);
1183}
1184
Tiger Yangfdd77702008-08-18 17:08:55 +08001185static inline int ocfs2_max_inline_data_with_xattr(struct super_block *sb,
1186 struct ocfs2_dinode *di)
1187{
1188 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1189
1190 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1191 return sb->s_blocksize -
1192 offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1193 xattrsize;
1194 else
1195 return sb->s_blocksize -
1196 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1197}
1198
Mark Fashehccd979b2005-12-15 14:31:24 -08001199static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
1200{
1201 int size;
1202
1203 size = sb->s_blocksize -
1204 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1205
1206 return size / sizeof(struct ocfs2_extent_rec);
1207}
1208
Tiger Yangfdd77702008-08-18 17:08:55 +08001209static inline int ocfs2_extent_recs_per_inode_with_xattr(
1210 struct super_block *sb,
1211 struct ocfs2_dinode *di)
1212{
1213 int size;
1214 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1215
1216 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1217 size = sb->s_blocksize -
1218 offsetof(struct ocfs2_dinode, id2.i_list.l_recs) -
1219 xattrsize;
1220 else
1221 size = sb->s_blocksize -
1222 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1223
1224 return size / sizeof(struct ocfs2_extent_rec);
1225}
1226
Mark Fasheh9b7895e2008-11-12 16:27:44 -08001227static inline int ocfs2_extent_recs_per_dx_root(struct super_block *sb)
1228{
1229 int size;
1230
1231 size = sb->s_blocksize -
1232 offsetof(struct ocfs2_dx_root_block, dr_list.l_recs);
1233
1234 return size / sizeof(struct ocfs2_extent_rec);
1235}
1236
Mark Fashehccd979b2005-12-15 14:31:24 -08001237static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
1238{
1239 int size;
1240
1241 size = sb->s_blocksize -
1242 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1243
1244 return size / sizeof(struct ocfs2_chain_rec);
1245}
1246
1247static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
1248{
1249 int size;
1250
1251 size = sb->s_blocksize -
1252 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1253
1254 return size / sizeof(struct ocfs2_extent_rec);
1255}
1256
Mark Fasheh9b7895e2008-11-12 16:27:44 -08001257static inline int ocfs2_dx_entries_per_leaf(struct super_block *sb)
1258{
1259 int size;
1260
1261 size = sb->s_blocksize -
1262 offsetof(struct ocfs2_dx_leaf, dl_list.de_entries);
1263
1264 return size / sizeof(struct ocfs2_dx_entry);
1265}
1266
Mark Fasheh4ed8a6b2008-11-24 17:02:08 -08001267static inline int ocfs2_dx_entries_per_root(struct super_block *sb)
1268{
1269 int size;
1270
1271 size = sb->s_blocksize -
1272 offsetof(struct ocfs2_dx_root_block, dr_entries.de_entries);
1273
1274 return size / sizeof(struct ocfs2_dx_entry);
1275}
1276
Mark Fashehccd979b2005-12-15 14:31:24 -08001277static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
1278{
1279 u16 size;
1280
1281 size = sb->s_blocksize -
1282 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1283
1284 return size;
1285}
1286
1287static inline int ocfs2_group_bitmap_size(struct super_block *sb)
1288{
1289 int size;
1290
1291 size = sb->s_blocksize -
1292 offsetof(struct ocfs2_group_desc, bg_bitmap);
1293
1294 return size;
1295}
1296
1297static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
1298{
1299 int size;
1300
1301 size = sb->s_blocksize -
1302 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1303
1304 return size / sizeof(struct ocfs2_truncate_rec);
1305}
Mark Fasheh50af94b2007-01-21 14:44:59 -08001306
1307static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
1308{
1309 u64 offset = OCFS2_BACKUP_SB_START;
1310
1311 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1312 offset <<= (2 * index);
Mark Fasheha8a75a22007-01-26 10:46:59 -08001313 offset >>= sb->s_blocksize_bits;
Mark Fasheh50af94b2007-01-21 14:44:59 -08001314 return offset;
1315 }
1316
1317 return 0;
1318
1319}
Tao Ma0c044f02008-08-18 17:38:50 +08001320
1321static inline u16 ocfs2_xattr_recs_per_xb(struct super_block *sb)
1322{
1323 int size;
1324
1325 size = sb->s_blocksize -
1326 offsetof(struct ocfs2_xattr_block,
1327 xb_attrs.xb_root.xt_list.l_recs);
1328
1329 return size / sizeof(struct ocfs2_extent_rec);
1330}
Tao Ma721f69c2009-08-18 11:17:49 +08001331
1332static inline u16 ocfs2_extent_recs_per_rb(struct super_block *sb)
1333{
1334 int size;
1335
1336 size = sb->s_blocksize -
1337 offsetof(struct ocfs2_refcount_block, rf_list.l_recs);
1338
1339 return size / sizeof(struct ocfs2_extent_rec);
1340}
1341
1342static inline u16 ocfs2_refcount_recs_per_rb(struct super_block *sb)
1343{
1344 int size;
1345
1346 size = sb->s_blocksize -
1347 offsetof(struct ocfs2_refcount_block, rf_records.rl_recs);
1348
1349 return size / sizeof(struct ocfs2_refcount_rec);
1350}
Tao Mae73a8192009-08-11 14:33:14 +08001351
1352static inline u32
1353ocfs2_get_ref_rec_low_cpos(const struct ocfs2_refcount_rec *rec)
1354{
1355 return le64_to_cpu(rec->r_cpos) & OCFS2_32BIT_POS_MASK;
1356}
Mark Fashehccd979b2005-12-15 14:31:24 -08001357#else
1358static inline int ocfs2_fast_symlink_chars(int blocksize)
1359{
1360 return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
1361}
1362
Tao Ma1097df32010-01-20 11:31:11 +08001363static inline int ocfs2_max_inline_data_with_xattr(int blocksize,
1364 struct ocfs2_dinode *di)
Mark Fasheh15b1e362007-09-07 13:58:15 -07001365{
Tao Ma1097df32010-01-20 11:31:11 +08001366 if (di && (di->i_dyn_features & OCFS2_INLINE_XATTR_FL))
1367 return blocksize -
1368 offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1369 di->i_xattr_inline_size;
1370 else
1371 return blocksize -
1372 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
Mark Fasheh15b1e362007-09-07 13:58:15 -07001373}
1374
Mark Fashehccd979b2005-12-15 14:31:24 -08001375static inline int ocfs2_extent_recs_per_inode(int blocksize)
1376{
1377 int size;
1378
1379 size = blocksize -
1380 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1381
1382 return size / sizeof(struct ocfs2_extent_rec);
1383}
1384
1385static inline int ocfs2_chain_recs_per_inode(int blocksize)
1386{
1387 int size;
1388
1389 size = blocksize -
1390 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1391
1392 return size / sizeof(struct ocfs2_chain_rec);
1393}
1394
1395static inline int ocfs2_extent_recs_per_eb(int blocksize)
1396{
1397 int size;
1398
1399 size = blocksize -
1400 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1401
1402 return size / sizeof(struct ocfs2_extent_rec);
1403}
1404
1405static inline int ocfs2_local_alloc_size(int blocksize)
1406{
1407 int size;
1408
1409 size = blocksize -
1410 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1411
1412 return size;
1413}
1414
1415static inline int ocfs2_group_bitmap_size(int blocksize)
1416{
1417 int size;
1418
1419 size = blocksize -
1420 offsetof(struct ocfs2_group_desc, bg_bitmap);
1421
1422 return size;
1423}
1424
1425static inline int ocfs2_truncate_recs_per_inode(int blocksize)
1426{
1427 int size;
1428
1429 size = blocksize -
1430 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1431
1432 return size / sizeof(struct ocfs2_truncate_rec);
1433}
Mark Fasheh50af94b2007-01-21 14:44:59 -08001434
1435static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
1436{
1437 uint64_t offset = OCFS2_BACKUP_SB_START;
1438
1439 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1440 offset <<= (2 * index);
1441 offset /= blocksize;
1442 return offset;
1443 }
1444
1445 return 0;
1446}
Tao Ma0c044f02008-08-18 17:38:50 +08001447
1448static inline int ocfs2_xattr_recs_per_xb(int blocksize)
1449{
1450 int size;
1451
1452 size = blocksize -
1453 offsetof(struct ocfs2_xattr_block,
1454 xb_attrs.xb_root.xt_list.l_recs);
1455
1456 return size / sizeof(struct ocfs2_extent_rec);
1457}
Mark Fashehccd979b2005-12-15 14:31:24 -08001458#endif /* __KERNEL__ */
1459
1460
1461static inline int ocfs2_system_inode_is_global(int type)
1462{
1463 return ((type >= 0) &&
1464 (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
1465}
1466
1467static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
1468 int type, int slot)
1469{
1470 int chars;
1471
1472 /*
1473 * Global system inodes can only have one copy. Everything
1474 * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
1475 * list has a copy per slot.
1476 */
1477 if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
Joel Beckerfe9f3872008-06-12 22:39:18 -07001478 chars = snprintf(buf, len, "%s",
Mark Fashehccd979b2005-12-15 14:31:24 -08001479 ocfs2_system_inodes[type].si_name);
1480 else
1481 chars = snprintf(buf, len,
1482 ocfs2_system_inodes[type].si_name,
1483 slot);
1484
1485 return chars;
1486}
1487
1488static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
1489 umode_t mode)
1490{
1491 de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
1492}
1493
1494#endif /* _OCFS2_FS_H */
1495