blob: d61a1521b10e03aef38f9a66985ac815b2e60b38 [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/*
Tiger Yangfdd77702008-08-18 17:08:55 +0800286 * Inline extended attribute size (in bytes)
287 * The value chosen should be aligned to 16 byte boundaries.
288 */
289#define OCFS2_MIN_XATTR_INLINE_SIZE 256
290
Mark Fashehccd979b2005-12-15 14:31:24 -0800291struct ocfs2_system_inode_info {
292 char *si_name;
293 int si_iflags;
294 int si_mode;
295};
296
297/* System file index */
298enum {
299 BAD_BLOCK_SYSTEM_INODE = 0,
300 GLOBAL_INODE_ALLOC_SYSTEM_INODE,
301 SLOT_MAP_SYSTEM_INODE,
302#define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
303 HEARTBEAT_SYSTEM_INODE,
304 GLOBAL_BITMAP_SYSTEM_INODE,
Jan Kara1a224ad2008-08-20 15:43:36 +0200305 USER_QUOTA_SYSTEM_INODE,
306 GROUP_QUOTA_SYSTEM_INODE,
307#define OCFS2_LAST_GLOBAL_SYSTEM_INODE GROUP_QUOTA_SYSTEM_INODE
Mark Fashehccd979b2005-12-15 14:31:24 -0800308 ORPHAN_DIR_SYSTEM_INODE,
309 EXTENT_ALLOC_SYSTEM_INODE,
310 INODE_ALLOC_SYSTEM_INODE,
311 JOURNAL_SYSTEM_INODE,
312 LOCAL_ALLOC_SYSTEM_INODE,
313 TRUNCATE_LOG_SYSTEM_INODE,
Jan Kara1a224ad2008-08-20 15:43:36 +0200314 LOCAL_USER_QUOTA_SYSTEM_INODE,
315 LOCAL_GROUP_QUOTA_SYSTEM_INODE,
Mark Fashehccd979b2005-12-15 14:31:24 -0800316 NUM_SYSTEM_INODES
317};
318
319static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
320 /* Global system inodes (single copy) */
321 /* The first two are only used from userspace mfks/tunefs */
322 [BAD_BLOCK_SYSTEM_INODE] = { "bad_blocks", 0, S_IFREG | 0644 },
323 [GLOBAL_INODE_ALLOC_SYSTEM_INODE] = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
324
325 /* These are used by the running filesystem */
326 [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 },
327 [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
328 [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 },
Jan Kara1a224ad2008-08-20 15:43:36 +0200329 [USER_QUOTA_SYSTEM_INODE] = { "aquota.user", OCFS2_QUOTA_FL, S_IFREG | 0644 },
330 [GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group", OCFS2_QUOTA_FL, S_IFREG | 0644 },
Mark Fashehccd979b2005-12-15 14:31:24 -0800331
332 /* Slot-specific system inodes (one copy per slot) */
333 [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
334 [EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
335 [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
336 [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
337 [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
Jan Kara1a224ad2008-08-20 15:43:36 +0200338 [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 },
339 [LOCAL_USER_QUOTA_SYSTEM_INODE] = { "aquota.user:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
340 [LOCAL_GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
Mark Fashehccd979b2005-12-15 14:31:24 -0800341};
342
343/* Parameter passed from mount.ocfs2 to module */
344#define OCFS2_HB_NONE "heartbeat=none"
345#define OCFS2_HB_LOCAL "heartbeat=local"
346
347/*
348 * OCFS2 directory file types. Only the low 3 bits are used. The
349 * other bits are reserved for now.
350 */
351#define OCFS2_FT_UNKNOWN 0
352#define OCFS2_FT_REG_FILE 1
353#define OCFS2_FT_DIR 2
354#define OCFS2_FT_CHRDEV 3
355#define OCFS2_FT_BLKDEV 4
356#define OCFS2_FT_FIFO 5
357#define OCFS2_FT_SOCK 6
358#define OCFS2_FT_SYMLINK 7
359
360#define OCFS2_FT_MAX 8
361
362/*
363 * OCFS2_DIR_PAD defines the directory entries boundaries
364 *
365 * NOTE: It must be a multiple of 4
366 */
367#define OCFS2_DIR_PAD 4
368#define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1)
369#define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name)
370#define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \
371 OCFS2_DIR_ROUND) & \
372 ~OCFS2_DIR_ROUND)
Mark Fashehe7c17e42009-01-29 18:17:46 -0800373#define OCFS2_DIR_MIN_REC_LEN OCFS2_DIR_REC_LEN(1)
Mark Fashehccd979b2005-12-15 14:31:24 -0800374
375#define OCFS2_LINK_MAX 32000
Mark Fasheh198a1ca2008-11-20 17:54:57 -0800376#define OCFS2_DX_LINK_MAX ((1U << 31) - 1U)
377#define OCFS2_LINKS_HI_SHIFT 16
Mark Fashehe3a93c22009-02-17 15:29:35 -0800378#define OCFS2_DX_ENTRIES_MAX (0xffffffffU)
Mark Fashehccd979b2005-12-15 14:31:24 -0800379
380#define S_SHIFT 12
381static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = {
382 [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE,
383 [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR,
384 [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV,
385 [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV,
386 [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO,
387 [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK,
388 [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK,
389};
390
391
392/*
393 * Convenience casts
394 */
395#define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
396
397/*
Joel Beckerab552d52008-10-16 17:50:30 -0700398 * Block checking structure. This is used in metadata to validate the
399 * contents. If OCFS2_FEATURE_INCOMPAT_META_ECC is not set, it is all
400 * zeros.
401 */
402struct ocfs2_block_check {
403/*00*/ __le32 bc_crc32e; /* 802.3 Ethernet II CRC32 */
404 __le16 bc_ecc; /* Single-error-correction parity vector.
405 This is a simple Hamming code dependant
406 on the blocksize. OCFS2's maximum
407 blocksize, 4K, requires 16 parity bits,
408 so we fit in __le16. */
409 __le16 bc_reserved1;
410/*08*/
411};
412
413/*
Mark Fashehccd979b2005-12-15 14:31:24 -0800414 * On disk extent record for OCFS2
415 * It describes a range of clusters on disk.
Mark Fashehe48edee2007-03-07 16:46:57 -0800416 *
417 * Length fields are divided into interior and leaf node versions.
418 * This leaves room for a flags field (OCFS2_EXT_*) in the leaf nodes.
Mark Fashehccd979b2005-12-15 14:31:24 -0800419 */
420struct ocfs2_extent_rec {
421/*00*/ __le32 e_cpos; /* Offset into the file, in clusters */
Mark Fashehe48edee2007-03-07 16:46:57 -0800422 union {
423 __le32 e_int_clusters; /* Clusters covered by all children */
424 struct {
425 __le16 e_leaf_clusters; /* Clusters covered by this
426 extent */
427 __u8 e_reserved1;
428 __u8 e_flags; /* Extent flags */
429 };
430 };
Mark Fashehccd979b2005-12-15 14:31:24 -0800431 __le64 e_blkno; /* Physical disk offset, in blocks */
432/*10*/
433};
434
435struct ocfs2_chain_rec {
436 __le32 c_free; /* Number of free bits in this chain. */
437 __le32 c_total; /* Number of total bits in this chain */
438 __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */
439};
440
441struct ocfs2_truncate_rec {
442 __le32 t_start; /* 1st cluster in this log */
443 __le32 t_clusters; /* Number of total clusters covered */
444};
445
446/*
447 * On disk extent list for OCFS2 (node in the tree). Note that this
448 * is contained inside ocfs2_dinode or ocfs2_extent_block, so the
449 * offsets are relative to ocfs2_dinode.id2.i_list or
450 * ocfs2_extent_block.h_list, respectively.
451 */
452struct ocfs2_extent_list {
453/*00*/ __le16 l_tree_depth; /* Extent tree depth from this
454 point. 0 means data extents
455 hang directly off this
Mark Fashehdcd05382007-01-16 11:32:23 -0800456 header (a leaf)
457 NOTE: The high 8 bits cannot be
458 used - tree_depth is never that big.
459 */
Mark Fashehccd979b2005-12-15 14:31:24 -0800460 __le16 l_count; /* Number of extent records */
461 __le16 l_next_free_rec; /* Next unused extent slot */
462 __le16 l_reserved1;
463 __le64 l_reserved2; /* Pad to
464 sizeof(ocfs2_extent_rec) */
465/*10*/ struct ocfs2_extent_rec l_recs[0]; /* Extent records */
466};
467
468/*
469 * On disk allocation chain list for OCFS2. Note that this is
470 * contained inside ocfs2_dinode, so the offsets are relative to
471 * ocfs2_dinode.id2.i_chain.
472 */
473struct ocfs2_chain_list {
474/*00*/ __le16 cl_cpg; /* Clusters per Block Group */
475 __le16 cl_bpc; /* Bits per cluster */
476 __le16 cl_count; /* Total chains in this list */
477 __le16 cl_next_free_rec; /* Next unused chain slot */
478 __le64 cl_reserved1;
479/*10*/ struct ocfs2_chain_rec cl_recs[0]; /* Chain records */
480};
481
482/*
483 * On disk deallocation log for OCFS2. Note that this is
484 * contained inside ocfs2_dinode, so the offsets are relative to
485 * ocfs2_dinode.id2.i_dealloc.
486 */
487struct ocfs2_truncate_log {
488/*00*/ __le16 tl_count; /* Total records in this log */
489 __le16 tl_used; /* Number of records in use */
490 __le32 tl_reserved1;
491/*08*/ struct ocfs2_truncate_rec tl_recs[0]; /* Truncate records */
492};
493
494/*
495 * On disk extent block (indirect block) for OCFS2
496 */
497struct ocfs2_extent_block
498{
499/*00*/ __u8 h_signature[8]; /* Signature for verification */
Joel Beckerab552d52008-10-16 17:50:30 -0700500 struct ocfs2_block_check h_check; /* Error checking */
Mark Fashehccd979b2005-12-15 14:31:24 -0800501/*10*/ __le16 h_suballoc_slot; /* Slot suballocator this
502 extent_header belongs to */
503 __le16 h_suballoc_bit; /* Bit offset in suballocator
504 block group */
505 __le32 h_fs_generation; /* Must match super block */
506 __le64 h_blkno; /* Offset on disk, in blocks */
507/*20*/ __le64 h_reserved3;
508 __le64 h_next_leaf_blk; /* Offset on disk, in blocks,
509 of next leaf header pointing
510 to data */
511/*30*/ struct ocfs2_extent_list h_list; /* Extent record list */
512/* Actual on-disk size is one block */
513};
514
515/*
Joel Beckerfb86b1f2008-02-01 11:59:05 -0800516 * On disk slot map for OCFS2. This defines the contents of the "slot_map"
Joel Becker386a2ef2008-02-01 12:06:54 -0800517 * system file. A slot is valid if it contains a node number >= 0. The
518 * value -1 (0xFFFF) is OCFS2_INVALID_SLOT. This marks a slot empty.
Joel Beckerfb86b1f2008-02-01 11:59:05 -0800519 */
520struct ocfs2_slot_map {
521/*00*/ __le16 sm_slots[0];
522/*
523 * Actual on-disk size is one block. OCFS2_MAX_SLOTS is 255,
524 * 255 * sizeof(__le16) == 512B, within the 512B block minimum blocksize.
525 */
526};
527
Joel Becker386a2ef2008-02-01 12:06:54 -0800528struct ocfs2_extended_slot {
529/*00*/ __u8 es_valid;
530 __u8 es_reserved1[3];
531 __le32 es_node_num;
532/*10*/
533};
534
535/*
536 * The extended slot map, used when OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP
537 * is set. It separates out the valid marker from the node number, and
538 * has room to grow. Unlike the old slot map, this format is defined by
539 * i_size.
540 */
541struct ocfs2_slot_map_extended {
542/*00*/ struct ocfs2_extended_slot se_slots[0];
543/*
544 * Actual size is i_size of the slot_map system file. It should
545 * match s_max_slots * sizeof(struct ocfs2_extended_slot)
546 */
547};
548
Joel Beckerb61817e2008-02-01 15:08:23 -0800549struct ocfs2_cluster_info {
550/*00*/ __u8 ci_stack[OCFS2_STACK_LABEL_LEN];
551 __le32 ci_reserved;
552/*08*/ __u8 ci_cluster[OCFS2_CLUSTER_NAME_LEN];
553/*18*/
554};
555
Joel Beckerfb86b1f2008-02-01 11:59:05 -0800556/*
Mark Fashehccd979b2005-12-15 14:31:24 -0800557 * On disk superblock for OCFS2
558 * Note that it is contained inside an ocfs2_dinode, so all offsets
559 * are relative to the start of ocfs2_dinode.id2.
560 */
561struct ocfs2_super_block {
562/*00*/ __le16 s_major_rev_level;
563 __le16 s_minor_rev_level;
564 __le16 s_mnt_count;
565 __le16 s_max_mnt_count;
566 __le16 s_state; /* File system state */
567 __le16 s_errors; /* Behaviour when detecting errors */
568 __le32 s_checkinterval; /* Max time between checks */
569/*10*/ __le64 s_lastcheck; /* Time of last check */
570 __le32 s_creator_os; /* OS */
571 __le32 s_feature_compat; /* Compatible feature set */
572/*20*/ __le32 s_feature_incompat; /* Incompatible feature set */
573 __le32 s_feature_ro_compat; /* Readonly-compatible feature set */
574 __le64 s_root_blkno; /* Offset, in blocks, of root directory
575 dinode */
576/*30*/ __le64 s_system_dir_blkno; /* Offset, in blocks, of system
577 directory dinode */
578 __le32 s_blocksize_bits; /* Blocksize for this fs */
579 __le32 s_clustersize_bits; /* Clustersize for this fs */
580/*40*/ __le16 s_max_slots; /* Max number of simultaneous mounts
581 before tunefs required */
Mark Fasheh92e91ce2007-09-20 11:19:20 -0700582 __le16 s_tunefs_flag;
Tiger Yangcf1d6c72008-08-18 17:11:00 +0800583 __le32 s_uuid_hash; /* hash value of uuid */
Mark Fashehccd979b2005-12-15 14:31:24 -0800584 __le64 s_first_cluster_group; /* Block offset of 1st cluster
585 * group header */
586/*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */
587/*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */
Joel Beckerb61817e2008-02-01 15:08:23 -0800588/*A0*/ struct ocfs2_cluster_info s_cluster_info; /* Selected userspace
589 stack. Only valid
590 with INCOMPAT flag. */
Tiger Yang8154da32008-08-18 17:11:46 +0800591/*B8*/ __le16 s_xattr_inline_size; /* extended attribute inline size
592 for this fs*/
593 __le16 s_reserved0;
Mark Fasheh9b7895e2008-11-12 16:27:44 -0800594 __le32 s_dx_seed[3]; /* seed[0-2] for dx dir hash.
595 * s_uuid_hash serves as seed[3]. */
596/*C0*/ __le64 s_reserved2[15]; /* Fill out superblock */
Joel Beckerb61817e2008-02-01 15:08:23 -0800597/*140*/
598
599 /*
600 * NOTE: As stated above, all offsets are relative to
601 * ocfs2_dinode.id2, which is at 0xC0 in the inode.
602 * 0xC0 + 0x140 = 0x200 or 512 bytes. A superblock must fit within
603 * our smallest blocksize, which is 512 bytes. To ensure this,
604 * we reserve the space in s_reserved2. Anything past s_reserved2
605 * will not be available on the smallest blocksize.
606 */
Mark Fashehccd979b2005-12-15 14:31:24 -0800607};
608
609/*
610 * Local allocation bitmap for OCFS2 slots
611 * Note that it exists inside an ocfs2_dinode, so all offsets are
612 * relative to the start of ocfs2_dinode.id2.
613 */
614struct ocfs2_local_alloc
615{
616/*00*/ __le32 la_bm_off; /* Starting bit offset in main bitmap */
617 __le16 la_size; /* Size of included bitmap, in bytes */
618 __le16 la_reserved1;
619 __le64 la_reserved2;
620/*10*/ __u8 la_bitmap[0];
621};
622
623/*
Mark Fasheh15b1e362007-09-07 13:58:15 -0700624 * Data-in-inode header. This is only used if i_dyn_features has
625 * OCFS2_INLINE_DATA_FL set.
626 */
627struct ocfs2_inline_data
628{
629/*00*/ __le16 id_count; /* Number of bytes that can be used
630 * for data, starting at id_data */
631 __le16 id_reserved0;
632 __le32 id_reserved1;
633 __u8 id_data[0]; /* Start of user data */
634};
635
636/*
Mark Fashehccd979b2005-12-15 14:31:24 -0800637 * On disk inode for OCFS2
638 */
639struct ocfs2_dinode {
640/*00*/ __u8 i_signature[8]; /* Signature for validation */
641 __le32 i_generation; /* Generation number */
642 __le16 i_suballoc_slot; /* Slot suballocator this inode
643 belongs to */
644 __le16 i_suballoc_bit; /* Bit offset in suballocator
645 block group */
Mark Fasheh198a1ca2008-11-20 17:54:57 -0800646/*10*/ __le16 i_links_count_hi; /* High 16 bits of links count */
Tiger Yangfdd77702008-08-18 17:08:55 +0800647 __le16 i_xattr_inline_size;
Mark Fashehccd979b2005-12-15 14:31:24 -0800648 __le32 i_clusters; /* Cluster count */
649 __le32 i_uid; /* Owner UID */
650 __le32 i_gid; /* Owning GID */
651/*20*/ __le64 i_size; /* Size in bytes */
652 __le16 i_mode; /* File mode */
653 __le16 i_links_count; /* Links count */
654 __le32 i_flags; /* File flags */
655/*30*/ __le64 i_atime; /* Access time */
656 __le64 i_ctime; /* Creation time */
657/*40*/ __le64 i_mtime; /* Modification time */
658 __le64 i_dtime; /* Deletion time */
659/*50*/ __le64 i_blkno; /* Offset on disk, in blocks */
660 __le64 i_last_eb_blk; /* Pointer to last extent
661 block */
662/*60*/ __le32 i_fs_generation; /* Generation per fs-instance */
663 __le32 i_atime_nsec;
664 __le32 i_ctime_nsec;
665 __le32 i_mtime_nsec;
Tiger Yangfdd77702008-08-18 17:08:55 +0800666/*70*/ __le32 i_attr;
Tiger Yang50008632007-03-20 16:01:38 -0700667 __le16 i_orphaned_slot; /* Only valid when OCFS2_ORPHANED_FL
668 was set in i_flags */
Mark Fasheh15b1e362007-09-07 13:58:15 -0700669 __le16 i_dyn_features;
Tiger Yangfdd77702008-08-18 17:08:55 +0800670 __le64 i_xattr_loc;
Joel Beckerab552d52008-10-16 17:50:30 -0700671/*80*/ struct ocfs2_block_check i_check; /* Error checking */
Mark Fasheh9b7895e2008-11-12 16:27:44 -0800672/*88*/ __le64 i_dx_root; /* Pointer to dir index root block */
Tao Ma721f69c2009-08-18 11:17:49 +0800673/*90*/ __le64 i_refcount_loc;
674 __le64 i_reserved2[4];
Mark Fashehccd979b2005-12-15 14:31:24 -0800675/*B8*/ union {
676 __le64 i_pad1; /* Generic way to refer to this
677 64bit union */
678 struct {
679 __le64 i_rdev; /* Device number */
680 } dev1;
681 struct { /* Info for bitmap system
682 inodes */
683 __le32 i_used; /* Bits (ie, clusters) used */
684 __le32 i_total; /* Total bits (clusters)
685 available */
686 } bitmap1;
687 struct { /* Info for journal system
688 inodes */
689 __le32 ij_flags; /* Mounted, version, etc. */
Sunil Mushranc69991a2008-07-14 17:31:09 -0700690 __le32 ij_recovery_generation; /* Incremented when the
691 journal is recovered
692 after an unclean
693 shutdown */
Mark Fashehccd979b2005-12-15 14:31:24 -0800694 } journal1;
695 } id1; /* Inode type dependant 1 */
696/*C0*/ union {
697 struct ocfs2_super_block i_super;
698 struct ocfs2_local_alloc i_lab;
699 struct ocfs2_chain_list i_chain;
700 struct ocfs2_extent_list i_list;
701 struct ocfs2_truncate_log i_dealloc;
Mark Fasheh15b1e362007-09-07 13:58:15 -0700702 struct ocfs2_inline_data i_data;
Mark Fashehccd979b2005-12-15 14:31:24 -0800703 __u8 i_symlink[0];
704 } id2;
705/* Actual on-disk size is one block */
706};
707
708/*
709 * On-disk directory entry structure for OCFS2
710 *
711 * Packed as this structure could be accessed unaligned on 64-bit platforms
712 */
713struct ocfs2_dir_entry {
714/*00*/ __le64 inode; /* Inode number */
715 __le16 rec_len; /* Directory entry length */
716 __u8 name_len; /* Name length */
717 __u8 file_type;
718/*0C*/ char name[OCFS2_MAX_FILENAME_LEN]; /* File name */
719/* Actual on-disk length specified by rec_len */
720} __attribute__ ((packed));
721
722/*
Mark Fasheh87d35a72008-12-10 17:36:25 -0800723 * Per-block record for the unindexed directory btree. This is carefully
724 * crafted so that the rec_len and name_len records of an ocfs2_dir_entry are
725 * mirrored. That way, the directory manipulation code needs a minimal amount
726 * of update.
727 *
728 * NOTE: Keep this structure aligned to a multiple of 4 bytes.
729 */
730struct ocfs2_dir_block_trailer {
731/*00*/ __le64 db_compat_inode; /* Always zero. Was inode */
732
733 __le16 db_compat_rec_len; /* Backwards compatible with
734 * ocfs2_dir_entry. */
735 __u8 db_compat_name_len; /* Always zero. Was name_len */
736 __u8 db_reserved0;
737 __le16 db_reserved1;
738 __le16 db_free_rec_len; /* Size of largest empty hole
739 * in this block. (unused) */
740/*10*/ __u8 db_signature[8]; /* Signature for verification */
741 __le64 db_reserved2;
742 __le64 db_free_next; /* Next block in list (unused) */
743/*20*/ __le64 db_blkno; /* Offset on disk, in blocks */
744 __le64 db_parent_dinode; /* dinode which owns me, in
745 blocks */
Joel Beckerc175a512008-12-10 17:58:22 -0800746/*30*/ struct ocfs2_block_check db_check; /* Error checking */
Mark Fasheh87d35a72008-12-10 17:36:25 -0800747/*40*/
748};
749
Mark Fasheh9b7895e2008-11-12 16:27:44 -0800750 /*
751 * A directory entry in the indexed tree. We don't store the full name here,
752 * but instead provide a pointer to the full dirent in the unindexed tree.
753 *
754 * We also store name_len here so as to reduce the number of leaf blocks we
755 * need to search in case of collisions.
756 */
757struct ocfs2_dx_entry {
758 __le32 dx_major_hash; /* Used to find logical
759 * cluster in index */
760 __le32 dx_minor_hash; /* Lower bits used to find
761 * block in cluster */
762 __le64 dx_dirent_blk; /* Physical block in unindexed
763 * tree holding this dirent. */
764};
765
766struct ocfs2_dx_entry_list {
767 __le32 de_reserved;
768 __le16 de_count; /* Maximum number of entries
769 * possible in de_entries */
770 __le16 de_num_used; /* Current number of
771 * de_entries entries */
772 struct ocfs2_dx_entry de_entries[0]; /* Indexed dir entries
773 * in a packed array of
774 * length de_num_used */
775};
776
Mark Fasheh4ed8a6b2008-11-24 17:02:08 -0800777#define OCFS2_DX_FLAG_INLINE 0x01
778
Mark Fasheh9b7895e2008-11-12 16:27:44 -0800779/*
780 * A directory indexing block. Each indexed directory has one of these,
781 * pointed to by ocfs2_dinode.
782 *
783 * This block stores an indexed btree root, and a set of free space
784 * start-of-list pointers.
785 */
786struct ocfs2_dx_root_block {
787 __u8 dr_signature[8]; /* Signature for verification */
788 struct ocfs2_block_check dr_check; /* Error checking */
789 __le16 dr_suballoc_slot; /* Slot suballocator this
790 * block belongs to. */
791 __le16 dr_suballoc_bit; /* Bit offset in suballocator
792 * block group */
793 __le32 dr_fs_generation; /* Must match super block */
794 __le64 dr_blkno; /* Offset on disk, in blocks */
795 __le64 dr_last_eb_blk; /* Pointer to last
796 * extent block */
797 __le32 dr_clusters; /* Clusters allocated
798 * to the indexed tree. */
Mark Fasheh4ed8a6b2008-11-24 17:02:08 -0800799 __u8 dr_flags; /* OCFS2_DX_FLAG_* flags */
800 __u8 dr_reserved0;
801 __le16 dr_reserved1;
Mark Fasheh9b7895e2008-11-12 16:27:44 -0800802 __le64 dr_dir_blkno; /* Pointer to parent inode */
Mark Fashehe3a93c22009-02-17 15:29:35 -0800803 __le32 dr_num_entries; /* Total number of
804 * names stored in
805 * this directory.*/
806 __le32 dr_reserved2;
Mark Fashehe7c17e42009-01-29 18:17:46 -0800807 __le64 dr_free_blk; /* Pointer to head of free
808 * unindexed block list. */
809 __le64 dr_reserved3[15];
Mark Fasheh4ed8a6b2008-11-24 17:02:08 -0800810 union {
811 struct ocfs2_extent_list dr_list; /* Keep this aligned to 128
812 * bits for maximum space
813 * efficiency. */
814 struct ocfs2_dx_entry_list dr_entries; /* In-root-block list of
815 * entries. We grow out
816 * to extents if this
817 * gets too big. */
818 };
Mark Fasheh9b7895e2008-11-12 16:27:44 -0800819};
820
821/*
822 * The header of a leaf block in the indexed tree.
823 */
824struct ocfs2_dx_leaf {
825 __u8 dl_signature[8];/* Signature for verification */
826 struct ocfs2_block_check dl_check; /* Error checking */
827 __le64 dl_blkno; /* Offset on disk, in blocks */
828 __le32 dl_fs_generation;/* Must match super block */
829 __le32 dl_reserved0;
830 __le64 dl_reserved1;
831 struct ocfs2_dx_entry_list dl_list;
832};
833
Mark Fasheh87d35a72008-12-10 17:36:25 -0800834/*
Mark Fashehccd979b2005-12-15 14:31:24 -0800835 * On disk allocator group structure for OCFS2
836 */
837struct ocfs2_group_desc
838{
839/*00*/ __u8 bg_signature[8]; /* Signature for validation */
840 __le16 bg_size; /* Size of included bitmap in
841 bytes. */
842 __le16 bg_bits; /* Bits represented by this
843 group. */
844 __le16 bg_free_bits_count; /* Free bits count */
845 __le16 bg_chain; /* What chain I am in. */
846/*10*/ __le32 bg_generation;
847 __le32 bg_reserved1;
848 __le64 bg_next_group; /* Next group in my list, in
849 blocks */
850/*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in
851 blocks */
852 __le64 bg_blkno; /* Offset on disk, in blocks */
Joel Beckerab552d52008-10-16 17:50:30 -0700853/*30*/ struct ocfs2_block_check bg_check; /* Error checking */
854 __le64 bg_reserved2;
Mark Fashehccd979b2005-12-15 14:31:24 -0800855/*40*/ __u8 bg_bitmap[0];
856};
857
Tao Ma721f69c2009-08-18 11:17:49 +0800858struct ocfs2_refcount_rec {
859/*00*/ __le64 r_cpos; /* Physical offset, in clusters */
860 __le32 r_clusters; /* Clusters covered by this extent */
861 __le32 r_refcount; /* Reference count of this extent */
862/*10*/
863};
Tao Mae73a8192009-08-11 14:33:14 +0800864#define OCFS2_32BIT_POS_MASK (0xffffffffULL)
Tao Ma721f69c2009-08-18 11:17:49 +0800865
866#define OCFS2_REFCOUNT_LEAF_FL (0x00000001)
867#define OCFS2_REFCOUNT_TREE_FL (0x00000002)
868
869struct ocfs2_refcount_list {
870/*00*/ __le16 rl_count; /* Maximum number of entries possible
871 in rl_records */
872 __le16 rl_used; /* Current number of used records */
873 __le32 rl_reserved2;
874 __le64 rl_reserved1; /* Pad to sizeof(ocfs2_refcount_record) */
875/*10*/ struct ocfs2_refcount_rec rl_recs[0]; /* Refcount records */
876};
877
878
879struct ocfs2_refcount_block {
880/*00*/ __u8 rf_signature[8]; /* Signature for verification */
881 __le16 rf_suballoc_slot; /* Slot suballocator this block
882 belongs to */
883 __le16 rf_suballoc_bit; /* Bit offset in suballocator
884 block group */
885 __le32 rf_fs_generation; /* Must match superblock */
886/*10*/ __le64 rf_blkno; /* Offset on disk, in blocks */
887 __le64 rf_parent; /* Parent block, only valid if
888 OCFS2_REFCOUNT_LEAF_FL is set in
889 rf_flags */
890/*20*/ struct ocfs2_block_check rf_check; /* Error checking */
891 __le64 rf_last_eb_blk; /* Pointer to last extent block */
892/*30*/ __le32 rf_count; /* Number of inodes sharing this
893 refcount tree */
894 __le32 rf_flags; /* See the flags above */
895 __le32 rf_clusters; /* clusters covered by refcount tree. */
896 __le32 rf_cpos; /* cluster offset in refcount tree.*/
897/*40*/ __le32 rf_generation; /* generation number. all be the same
898 * for the same refcount tree. */
899 __le32 rf_reserved0;
900 __le64 rf_reserved1[7];
901/*80*/ union {
902 struct ocfs2_refcount_list rf_records; /* List of refcount
903 records */
904 struct ocfs2_extent_list rf_list; /* Extent record list,
905 only valid if
906 OCFS2_REFCOUNT_TREE_FL
907 is set in rf_flags */
908 };
909/* Actual on-disk size is one block */
910};
911
Tao Ma5a7bc8e2008-08-18 17:38:46 +0800912/*
913 * On disk extended attribute structure for OCFS2.
914 */
915
916/*
917 * ocfs2_xattr_entry indicates one extend attribute.
918 *
919 * Note that it can be stored in inode, one block or one xattr bucket.
920 */
921struct ocfs2_xattr_entry {
922 __le32 xe_name_hash; /* hash value of xattr prefix+suffix. */
Tao Ma8573f792008-10-24 22:24:17 +0800923 __le16 xe_name_offset; /* byte offset from the 1st entry in the
Tao Ma5a7bc8e2008-08-18 17:38:46 +0800924 local xattr storage(inode, xattr block or
925 xattr bucket). */
926 __u8 xe_name_len; /* xattr name len, does't include prefix. */
Tao Ma8573f792008-10-24 22:24:17 +0800927 __u8 xe_type; /* the low 7 bits indicate the name prefix
928 * type and the highest bit indicates whether
Tao Ma5a7bc8e2008-08-18 17:38:46 +0800929 * the EA is stored in the local storage. */
930 __le64 xe_value_size; /* real xattr value length. */
931};
932
933/*
934 * On disk structure for xattr header.
935 *
936 * One ocfs2_xattr_header describes how many ocfs2_xattr_entry records in
937 * the local xattr storage.
938 */
939struct ocfs2_xattr_header {
940 __le16 xh_count; /* contains the count of how
941 many records are in the
942 local xattr storage. */
Tao Ma0c044f02008-08-18 17:38:50 +0800943 __le16 xh_free_start; /* current offset for storing
944 xattr. */
945 __le16 xh_name_value_len; /* total length of name/value
946 length in this bucket. */
Tao Ma8573f792008-10-24 22:24:17 +0800947 __le16 xh_num_buckets; /* Number of xattr buckets
948 in this extent record,
949 only valid in the first
950 bucket. */
Joel Beckerab552d52008-10-16 17:50:30 -0700951 struct ocfs2_block_check xh_check; /* Error checking
952 (Note, this is only
953 used for xattr
954 buckets. A block uses
955 xb_check and sets
956 this field to zero.) */
Tao Ma5a7bc8e2008-08-18 17:38:46 +0800957 struct ocfs2_xattr_entry xh_entries[0]; /* xattr entry list. */
958};
959
960/*
961 * On disk structure for xattr value root.
962 *
Tao Ma8573f792008-10-24 22:24:17 +0800963 * When an xattr's value is large enough, it is stored in an external
964 * b-tree like file data. The xattr value root points to this structure.
Tao Ma5a7bc8e2008-08-18 17:38:46 +0800965 */
966struct ocfs2_xattr_value_root {
967/*00*/ __le32 xr_clusters; /* clusters covered by xattr value. */
968 __le32 xr_reserved0;
969 __le64 xr_last_eb_blk; /* Pointer to last extent block */
970/*10*/ struct ocfs2_extent_list xr_list; /* Extent record list */
971};
972
973/*
974 * On disk structure for xattr tree root.
975 *
976 * It is used when there are too many extended attributes for one file. These
977 * attributes will be organized and stored in an indexed-btree.
978 */
979struct ocfs2_xattr_tree_root {
980/*00*/ __le32 xt_clusters; /* clusters covered by xattr. */
981 __le32 xt_reserved0;
982 __le64 xt_last_eb_blk; /* Pointer to last extent block */
983/*10*/ struct ocfs2_extent_list xt_list; /* Extent record list */
984};
985
Tiger Yangcf1d6c72008-08-18 17:11:00 +0800986#define OCFS2_XATTR_INDEXED 0x1
987#define OCFS2_HASH_SHIFT 5
988#define OCFS2_XATTR_ROUND 3
989#define OCFS2_XATTR_SIZE(size) (((size) + OCFS2_XATTR_ROUND) & \
990 ~(OCFS2_XATTR_ROUND))
Tao Ma5a7bc8e2008-08-18 17:38:46 +0800991
Tao Ma0c044f02008-08-18 17:38:50 +0800992#define OCFS2_XATTR_BUCKET_SIZE 4096
993#define OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET (OCFS2_XATTR_BUCKET_SIZE \
994 / OCFS2_MIN_BLOCKSIZE)
995
Tao Ma5a7bc8e2008-08-18 17:38:46 +0800996/*
997 * On disk structure for xattr block.
998 */
999struct ocfs2_xattr_block {
1000/*00*/ __u8 xb_signature[8]; /* Signature for verification */
1001 __le16 xb_suballoc_slot; /* Slot suballocator this
1002 block belongs to. */
1003 __le16 xb_suballoc_bit; /* Bit offset in suballocator
1004 block group */
1005 __le32 xb_fs_generation; /* Must match super block */
1006/*10*/ __le64 xb_blkno; /* Offset on disk, in blocks */
Joel Beckerab552d52008-10-16 17:50:30 -07001007 struct ocfs2_block_check xb_check; /* Error checking */
Tao Ma5a7bc8e2008-08-18 17:38:46 +08001008/*20*/ __le16 xb_flags; /* Indicates whether this block contains
1009 real xattr or a xattr tree. */
1010 __le16 xb_reserved0;
1011 __le32 xb_reserved1;
1012 __le64 xb_reserved2;
1013/*30*/ union {
1014 struct ocfs2_xattr_header xb_header; /* xattr header if this
1015 block contains xattr */
1016 struct ocfs2_xattr_tree_root xb_root;/* xattr tree root if this
1017 block cotains xattr
1018 tree. */
1019 } xb_attrs;
1020};
1021
1022#define OCFS2_XATTR_ENTRY_LOCAL 0x80
1023#define OCFS2_XATTR_TYPE_MASK 0x7F
1024static inline void ocfs2_xattr_set_local(struct ocfs2_xattr_entry *xe,
1025 int local)
1026{
1027 if (local)
1028 xe->xe_type |= OCFS2_XATTR_ENTRY_LOCAL;
1029 else
1030 xe->xe_type &= ~OCFS2_XATTR_ENTRY_LOCAL;
1031}
1032
1033static inline int ocfs2_xattr_is_local(struct ocfs2_xattr_entry *xe)
1034{
1035 return xe->xe_type & OCFS2_XATTR_ENTRY_LOCAL;
1036}
1037
1038static inline void ocfs2_xattr_set_type(struct ocfs2_xattr_entry *xe, int type)
1039{
1040 xe->xe_type |= type & OCFS2_XATTR_TYPE_MASK;
1041}
1042
1043static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry *xe)
1044{
1045 return xe->xe_type & OCFS2_XATTR_TYPE_MASK;
1046}
1047
Jan Kara9e33d692008-08-25 19:56:50 +02001048/*
1049 * On disk structures for global quota file
1050 */
1051
1052/* Magic numbers and known versions for global quota files */
1053#define OCFS2_GLOBAL_QMAGICS {\
1054 0x0cf52470, /* USRQUOTA */ \
1055 0x0cf52471 /* GRPQUOTA */ \
1056}
1057
1058#define OCFS2_GLOBAL_QVERSIONS {\
1059 0, \
1060 0, \
1061}
1062
1063
1064/* Each block of each quota file has a certain fixed number of bytes reserved
1065 * for OCFS2 internal use at its end. OCFS2 can use it for things like
1066 * checksums, etc. */
1067#define OCFS2_QBLK_RESERVED_SPACE 8
1068
1069/* Generic header of all quota files */
1070struct ocfs2_disk_dqheader {
1071 __le32 dqh_magic; /* Magic number identifying file */
1072 __le32 dqh_version; /* Quota format version */
1073};
1074
1075#define OCFS2_GLOBAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1076
1077/* Information header of global quota file (immediately follows the generic
1078 * header) */
1079struct ocfs2_global_disk_dqinfo {
1080/*00*/ __le32 dqi_bgrace; /* Grace time for space softlimit excess */
1081 __le32 dqi_igrace; /* Grace time for inode softlimit excess */
1082 __le32 dqi_syncms; /* Time after which we sync local changes to
1083 * global quota file */
1084 __le32 dqi_blocks; /* Number of blocks in quota file */
1085/*10*/ __le32 dqi_free_blk; /* First free block in quota file */
1086 __le32 dqi_free_entry; /* First block with free dquot entry in quota
1087 * file */
1088};
1089
1090/* Structure with global user / group information. We reserve some space
1091 * for future use. */
1092struct ocfs2_global_disk_dqblk {
1093/*00*/ __le32 dqb_id; /* ID the structure belongs to */
1094 __le32 dqb_use_count; /* Number of nodes having reference to this structure */
1095 __le64 dqb_ihardlimit; /* absolute limit on allocated inodes */
1096/*10*/ __le64 dqb_isoftlimit; /* preferred inode limit */
1097 __le64 dqb_curinodes; /* current # allocated inodes */
1098/*20*/ __le64 dqb_bhardlimit; /* absolute limit on disk space */
1099 __le64 dqb_bsoftlimit; /* preferred limit on disk space */
1100/*30*/ __le64 dqb_curspace; /* current space occupied */
1101 __le64 dqb_btime; /* time limit for excessive disk use */
1102/*40*/ __le64 dqb_itime; /* time limit for excessive inode use */
1103 __le64 dqb_pad1;
1104/*50*/ __le64 dqb_pad2;
1105};
1106
1107/*
1108 * On-disk structures for local quota file
1109 */
1110
1111/* Magic numbers and known versions for local quota files */
1112#define OCFS2_LOCAL_QMAGICS {\
1113 0x0cf524c0, /* USRQUOTA */ \
1114 0x0cf524c1 /* GRPQUOTA */ \
1115}
1116
1117#define OCFS2_LOCAL_QVERSIONS {\
1118 0, \
1119 0, \
1120}
1121
1122/* Quota flags in dqinfo header */
1123#define OLQF_CLEAN 0x0001 /* Quota file is empty (this should be after\
1124 * quota has been cleanly turned off) */
1125
1126#define OCFS2_LOCAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1127
1128/* Information header of local quota file (immediately follows the generic
1129 * header) */
1130struct ocfs2_local_disk_dqinfo {
1131 __le32 dqi_flags; /* Flags for quota file */
1132 __le32 dqi_chunks; /* Number of chunks of quota structures
1133 * with a bitmap */
1134 __le32 dqi_blocks; /* Number of blocks allocated for quota file */
1135};
1136
1137/* Header of one chunk of a quota file */
1138struct ocfs2_local_disk_chunk {
1139 __le32 dqc_free; /* Number of free entries in the bitmap */
Coly Li93654542009-12-06 22:38:53 +08001140 __u8 dqc_bitmap[0]; /* Bitmap of entries in the corresponding
Jan Kara9e33d692008-08-25 19:56:50 +02001141 * chunk of quota file */
1142};
1143
1144/* One entry in local quota file */
1145struct ocfs2_local_disk_dqblk {
1146/*00*/ __le64 dqb_id; /* id this quota applies to */
1147 __le64 dqb_spacemod; /* Change in the amount of used space */
1148/*10*/ __le64 dqb_inodemod; /* Change in the amount of used inodes */
1149};
1150
Joel Beckerab552d52008-10-16 17:50:30 -07001151
1152/*
1153 * The quota trailer lives at the end of each quota block.
1154 */
1155
1156struct ocfs2_disk_dqtrailer {
1157/*00*/ struct ocfs2_block_check dq_check; /* Error checking */
1158/*08*/ /* Cannot be larger than OCFS2_QBLK_RESERVED_SPACE */
1159};
1160
1161static inline struct ocfs2_disk_dqtrailer *ocfs2_block_dqtrailer(int blocksize,
1162 void *buf)
1163{
1164 char *ptr = buf;
1165 ptr += blocksize - OCFS2_QBLK_RESERVED_SPACE;
1166
1167 return (struct ocfs2_disk_dqtrailer *)ptr;
1168}
1169
Mark Fashehccd979b2005-12-15 14:31:24 -08001170#ifdef __KERNEL__
1171static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
1172{
1173 return sb->s_blocksize -
1174 offsetof(struct ocfs2_dinode, id2.i_symlink);
1175}
1176
Tiger Yangfdd77702008-08-18 17:08:55 +08001177static inline int ocfs2_max_inline_data_with_xattr(struct super_block *sb,
1178 struct ocfs2_dinode *di)
1179{
1180 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1181
1182 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1183 return sb->s_blocksize -
1184 offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1185 xattrsize;
1186 else
1187 return sb->s_blocksize -
1188 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1189}
1190
Mark Fashehccd979b2005-12-15 14:31:24 -08001191static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
1192{
1193 int size;
1194
1195 size = sb->s_blocksize -
1196 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1197
1198 return size / sizeof(struct ocfs2_extent_rec);
1199}
1200
Tiger Yangfdd77702008-08-18 17:08:55 +08001201static inline int ocfs2_extent_recs_per_inode_with_xattr(
1202 struct super_block *sb,
1203 struct ocfs2_dinode *di)
1204{
1205 int size;
1206 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1207
1208 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1209 size = sb->s_blocksize -
1210 offsetof(struct ocfs2_dinode, id2.i_list.l_recs) -
1211 xattrsize;
1212 else
1213 size = sb->s_blocksize -
1214 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1215
1216 return size / sizeof(struct ocfs2_extent_rec);
1217}
1218
Mark Fasheh9b7895e2008-11-12 16:27:44 -08001219static inline int ocfs2_extent_recs_per_dx_root(struct super_block *sb)
1220{
1221 int size;
1222
1223 size = sb->s_blocksize -
1224 offsetof(struct ocfs2_dx_root_block, dr_list.l_recs);
1225
1226 return size / sizeof(struct ocfs2_extent_rec);
1227}
1228
Mark Fashehccd979b2005-12-15 14:31:24 -08001229static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
1230{
1231 int size;
1232
1233 size = sb->s_blocksize -
1234 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1235
1236 return size / sizeof(struct ocfs2_chain_rec);
1237}
1238
1239static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
1240{
1241 int size;
1242
1243 size = sb->s_blocksize -
1244 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1245
1246 return size / sizeof(struct ocfs2_extent_rec);
1247}
1248
Mark Fasheh9b7895e2008-11-12 16:27:44 -08001249static inline int ocfs2_dx_entries_per_leaf(struct super_block *sb)
1250{
1251 int size;
1252
1253 size = sb->s_blocksize -
1254 offsetof(struct ocfs2_dx_leaf, dl_list.de_entries);
1255
1256 return size / sizeof(struct ocfs2_dx_entry);
1257}
1258
Mark Fasheh4ed8a6b2008-11-24 17:02:08 -08001259static inline int ocfs2_dx_entries_per_root(struct super_block *sb)
1260{
1261 int size;
1262
1263 size = sb->s_blocksize -
1264 offsetof(struct ocfs2_dx_root_block, dr_entries.de_entries);
1265
1266 return size / sizeof(struct ocfs2_dx_entry);
1267}
1268
Mark Fashehccd979b2005-12-15 14:31:24 -08001269static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
1270{
1271 u16 size;
1272
1273 size = sb->s_blocksize -
1274 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1275
1276 return size;
1277}
1278
1279static inline int ocfs2_group_bitmap_size(struct super_block *sb)
1280{
1281 int size;
1282
1283 size = sb->s_blocksize -
1284 offsetof(struct ocfs2_group_desc, bg_bitmap);
1285
1286 return size;
1287}
1288
1289static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
1290{
1291 int size;
1292
1293 size = sb->s_blocksize -
1294 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1295
1296 return size / sizeof(struct ocfs2_truncate_rec);
1297}
Mark Fasheh50af94b2007-01-21 14:44:59 -08001298
1299static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
1300{
1301 u64 offset = OCFS2_BACKUP_SB_START;
1302
1303 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1304 offset <<= (2 * index);
Mark Fasheha8a75a22007-01-26 10:46:59 -08001305 offset >>= sb->s_blocksize_bits;
Mark Fasheh50af94b2007-01-21 14:44:59 -08001306 return offset;
1307 }
1308
1309 return 0;
1310
1311}
Tao Ma0c044f02008-08-18 17:38:50 +08001312
1313static inline u16 ocfs2_xattr_recs_per_xb(struct super_block *sb)
1314{
1315 int size;
1316
1317 size = sb->s_blocksize -
1318 offsetof(struct ocfs2_xattr_block,
1319 xb_attrs.xb_root.xt_list.l_recs);
1320
1321 return size / sizeof(struct ocfs2_extent_rec);
1322}
Tao Ma721f69c2009-08-18 11:17:49 +08001323
1324static inline u16 ocfs2_extent_recs_per_rb(struct super_block *sb)
1325{
1326 int size;
1327
1328 size = sb->s_blocksize -
1329 offsetof(struct ocfs2_refcount_block, rf_list.l_recs);
1330
1331 return size / sizeof(struct ocfs2_extent_rec);
1332}
1333
1334static inline u16 ocfs2_refcount_recs_per_rb(struct super_block *sb)
1335{
1336 int size;
1337
1338 size = sb->s_blocksize -
1339 offsetof(struct ocfs2_refcount_block, rf_records.rl_recs);
1340
1341 return size / sizeof(struct ocfs2_refcount_rec);
1342}
Tao Mae73a8192009-08-11 14:33:14 +08001343
1344static inline u32
1345ocfs2_get_ref_rec_low_cpos(const struct ocfs2_refcount_rec *rec)
1346{
1347 return le64_to_cpu(rec->r_cpos) & OCFS2_32BIT_POS_MASK;
1348}
Mark Fashehccd979b2005-12-15 14:31:24 -08001349#else
1350static inline int ocfs2_fast_symlink_chars(int blocksize)
1351{
1352 return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
1353}
1354
Tao Ma1097df32010-01-20 11:31:11 +08001355static inline int ocfs2_max_inline_data_with_xattr(int blocksize,
1356 struct ocfs2_dinode *di)
Mark Fasheh15b1e362007-09-07 13:58:15 -07001357{
Tao Ma1097df32010-01-20 11:31:11 +08001358 if (di && (di->i_dyn_features & OCFS2_INLINE_XATTR_FL))
1359 return blocksize -
1360 offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1361 di->i_xattr_inline_size;
1362 else
1363 return blocksize -
1364 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
Mark Fasheh15b1e362007-09-07 13:58:15 -07001365}
1366
Mark Fashehccd979b2005-12-15 14:31:24 -08001367static inline int ocfs2_extent_recs_per_inode(int blocksize)
1368{
1369 int size;
1370
1371 size = blocksize -
1372 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1373
1374 return size / sizeof(struct ocfs2_extent_rec);
1375}
1376
1377static inline int ocfs2_chain_recs_per_inode(int blocksize)
1378{
1379 int size;
1380
1381 size = blocksize -
1382 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1383
1384 return size / sizeof(struct ocfs2_chain_rec);
1385}
1386
1387static inline int ocfs2_extent_recs_per_eb(int blocksize)
1388{
1389 int size;
1390
1391 size = blocksize -
1392 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1393
1394 return size / sizeof(struct ocfs2_extent_rec);
1395}
1396
1397static inline int ocfs2_local_alloc_size(int blocksize)
1398{
1399 int size;
1400
1401 size = blocksize -
1402 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1403
1404 return size;
1405}
1406
1407static inline int ocfs2_group_bitmap_size(int blocksize)
1408{
1409 int size;
1410
1411 size = blocksize -
1412 offsetof(struct ocfs2_group_desc, bg_bitmap);
1413
1414 return size;
1415}
1416
1417static inline int ocfs2_truncate_recs_per_inode(int blocksize)
1418{
1419 int size;
1420
1421 size = blocksize -
1422 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1423
1424 return size / sizeof(struct ocfs2_truncate_rec);
1425}
Mark Fasheh50af94b2007-01-21 14:44:59 -08001426
1427static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
1428{
1429 uint64_t offset = OCFS2_BACKUP_SB_START;
1430
1431 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1432 offset <<= (2 * index);
1433 offset /= blocksize;
1434 return offset;
1435 }
1436
1437 return 0;
1438}
Tao Ma0c044f02008-08-18 17:38:50 +08001439
1440static inline int ocfs2_xattr_recs_per_xb(int blocksize)
1441{
1442 int size;
1443
1444 size = blocksize -
1445 offsetof(struct ocfs2_xattr_block,
1446 xb_attrs.xb_root.xt_list.l_recs);
1447
1448 return size / sizeof(struct ocfs2_extent_rec);
1449}
Mark Fashehccd979b2005-12-15 14:31:24 -08001450#endif /* __KERNEL__ */
1451
1452
1453static inline int ocfs2_system_inode_is_global(int type)
1454{
1455 return ((type >= 0) &&
1456 (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
1457}
1458
1459static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
1460 int type, int slot)
1461{
1462 int chars;
1463
1464 /*
1465 * Global system inodes can only have one copy. Everything
1466 * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
1467 * list has a copy per slot.
1468 */
1469 if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
Joel Beckerfe9f3872008-06-12 22:39:18 -07001470 chars = snprintf(buf, len, "%s",
Mark Fashehccd979b2005-12-15 14:31:24 -08001471 ocfs2_system_inodes[type].si_name);
1472 else
1473 chars = snprintf(buf, len,
1474 ocfs2_system_inodes[type].si_name,
1475 slot);
1476
1477 return chars;
1478}
1479
1480static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
1481 umode_t mode)
1482{
1483 de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
1484}
1485
1486#endif /* _OCFS2_FS_H */
1487