]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - fs/ocfs2/ocfs2_fs.h
ocfs2: Add JBD2 compat feature bit.
[linux-2.6-omap-h63xx.git] / fs / ocfs2 / ocfs2_fs.h
1 /* -*- 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"
67 #define OCFS2_XATTR_BLOCK_SIGNATURE     "XATTR01"
68
69 /* Compatibility flags */
70 #define OCFS2_HAS_COMPAT_FEATURE(sb,mask)                       \
71         ( OCFS2_SB(sb)->s_feature_compat & (mask) )
72 #define OCFS2_HAS_RO_COMPAT_FEATURE(sb,mask)                    \
73         ( OCFS2_SB(sb)->s_feature_ro_compat & (mask) )
74 #define OCFS2_HAS_INCOMPAT_FEATURE(sb,mask)                     \
75         ( OCFS2_SB(sb)->s_feature_incompat & (mask) )
76 #define OCFS2_SET_COMPAT_FEATURE(sb,mask)                       \
77         OCFS2_SB(sb)->s_feature_compat |= (mask)
78 #define OCFS2_SET_RO_COMPAT_FEATURE(sb,mask)                    \
79         OCFS2_SB(sb)->s_feature_ro_compat |= (mask)
80 #define OCFS2_SET_INCOMPAT_FEATURE(sb,mask)                     \
81         OCFS2_SB(sb)->s_feature_incompat |= (mask)
82 #define OCFS2_CLEAR_COMPAT_FEATURE(sb,mask)                     \
83         OCFS2_SB(sb)->s_feature_compat &= ~(mask)
84 #define OCFS2_CLEAR_RO_COMPAT_FEATURE(sb,mask)                  \
85         OCFS2_SB(sb)->s_feature_ro_compat &= ~(mask)
86 #define OCFS2_CLEAR_INCOMPAT_FEATURE(sb,mask)                   \
87         OCFS2_SB(sb)->s_feature_incompat &= ~(mask)
88
89 #define OCFS2_FEATURE_COMPAT_SUPP       (OCFS2_FEATURE_COMPAT_BACKUP_SB \
90                                          | OCFS2_FEATURE_COMPAT_JBD2_SB)
91 #define OCFS2_FEATURE_INCOMPAT_SUPP     (OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT \
92                                          | OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC \
93                                          | OCFS2_FEATURE_INCOMPAT_INLINE_DATA \
94                                          | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \
95                                          | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK \
96                                          | OCFS2_FEATURE_INCOMPAT_XATTR)
97 #define OCFS2_FEATURE_RO_COMPAT_SUPP    OCFS2_FEATURE_RO_COMPAT_UNWRITTEN
98
99 /*
100  * Heartbeat-only devices are missing journals and other files.  The
101  * filesystem driver can't load them, but the library can.  Never put
102  * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*.
103  */
104 #define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV    0x0002
105
106 /*
107  * tunefs sets this incompat flag before starting the resize and clears it
108  * at the end. This flag protects users from inadvertently mounting the fs
109  * after an aborted run without fsck-ing.
110  */
111 #define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG    0x0004
112
113 /* Used to denote a non-clustered volume */
114 #define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT      0x0008
115
116 /* Support for sparse allocation in b-trees */
117 #define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC     0x0010
118
119 /*
120  * Tunefs sets this incompat flag before starting an operation which
121  * would require cleanup on abort. This is done to protect users from
122  * inadvertently mounting the fs after an aborted run without
123  * fsck-ing.
124  *
125  * s_tunefs_flags on the super block describes precisely which
126  * operations were in progress.
127  */
128 #define OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG    0x0020
129
130 /* Support for data packed into inode blocks */
131 #define OCFS2_FEATURE_INCOMPAT_INLINE_DATA      0x0040
132
133 /*
134  * Support for alternate, userspace cluster stacks.  If set, the superblock
135  * field s_cluster_info contains a tag for the alternate stack in use as
136  * well as the name of the cluster being joined.
137  * mount.ocfs2 must pass in a matching stack name.
138  *
139  * If not set, the classic stack will be used.  This is compatbile with
140  * all older versions.
141  */
142 #define OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK  0x0080
143
144 /* Support for the extended slot map */
145 #define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100
146
147 /* Support for extended attributes */
148 #define OCFS2_FEATURE_INCOMPAT_XATTR            0x0200
149
150 /*
151  * backup superblock flag is used to indicate that this volume
152  * has backup superblocks.
153  */
154 #define OCFS2_FEATURE_COMPAT_BACKUP_SB          0x0001
155
156 /*
157  * The filesystem will correctly handle journal feature bits.
158  */
159 #define OCFS2_FEATURE_COMPAT_JBD2_SB            0x0002
160
161 /*
162  * Unwritten extents support.
163  */
164 #define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN       0x0001
165
166 /* The byte offset of the first backup block will be 1G.
167  * The following will be 4G, 16G, 64G, 256G and 1T.
168  */
169 #define OCFS2_BACKUP_SB_START                   1 << 30
170
171 /* the max backup superblock nums */
172 #define OCFS2_MAX_BACKUP_SUPERBLOCKS    6
173
174 /*
175  * Flags on ocfs2_super_block.s_tunefs_flags
176  */
177 #define OCFS2_TUNEFS_INPROG_REMOVE_SLOT         0x0001  /* Removing slots */
178
179 /*
180  * Flags on ocfs2_dinode.i_flags
181  */
182 #define OCFS2_VALID_FL          (0x00000001)    /* Inode is valid */
183 #define OCFS2_UNUSED2_FL        (0x00000002)
184 #define OCFS2_ORPHANED_FL       (0x00000004)    /* On the orphan list */
185 #define OCFS2_UNUSED3_FL        (0x00000008)
186 /* System inode flags */
187 #define OCFS2_SYSTEM_FL         (0x00000010)    /* System inode */
188 #define OCFS2_SUPER_BLOCK_FL    (0x00000020)    /* Super block */
189 #define OCFS2_LOCAL_ALLOC_FL    (0x00000040)    /* Slot local alloc bitmap */
190 #define OCFS2_BITMAP_FL         (0x00000080)    /* Allocation bitmap */
191 #define OCFS2_JOURNAL_FL        (0x00000100)    /* Slot local journal */
192 #define OCFS2_HEARTBEAT_FL      (0x00000200)    /* Heartbeat area */
193 #define OCFS2_CHAIN_FL          (0x00000400)    /* Chain allocator */
194 #define OCFS2_DEALLOC_FL        (0x00000800)    /* Truncate log */
195
196 /*
197  * Flags on ocfs2_dinode.i_dyn_features
198  *
199  * These can change much more often than i_flags. When adding flags,
200  * keep in mind that i_dyn_features is only 16 bits wide.
201  */
202 #define OCFS2_INLINE_DATA_FL    (0x0001)        /* Data stored in inode block */
203 #define OCFS2_HAS_XATTR_FL      (0x0002)
204 #define OCFS2_INLINE_XATTR_FL   (0x0004)
205 #define OCFS2_INDEXED_DIR_FL    (0x0008)
206
207 /* Inode attributes, keep in sync with EXT2 */
208 #define OCFS2_SECRM_FL          (0x00000001)    /* Secure deletion */
209 #define OCFS2_UNRM_FL           (0x00000002)    /* Undelete */
210 #define OCFS2_COMPR_FL          (0x00000004)    /* Compress file */
211 #define OCFS2_SYNC_FL           (0x00000008)    /* Synchronous updates */
212 #define OCFS2_IMMUTABLE_FL      (0x00000010)    /* Immutable file */
213 #define OCFS2_APPEND_FL         (0x00000020)    /* writes to file may only append */
214 #define OCFS2_NODUMP_FL         (0x00000040)    /* do not dump file */
215 #define OCFS2_NOATIME_FL        (0x00000080)    /* do not update atime */
216 #define OCFS2_DIRSYNC_FL        (0x00010000)    /* dirsync behaviour (directories only) */
217
218 #define OCFS2_FL_VISIBLE        (0x000100FF)    /* User visible flags */
219 #define OCFS2_FL_MODIFIABLE     (0x000100FF)    /* User modifiable flags */
220
221 /*
222  * Extent record flags (e_node.leaf.flags)
223  */
224 #define OCFS2_EXT_UNWRITTEN     (0x01)  /* Extent is allocated but
225                                          * unwritten */
226
227 /*
228  * ioctl commands
229  */
230 #define OCFS2_IOC_GETFLAGS      _IOR('f', 1, long)
231 #define OCFS2_IOC_SETFLAGS      _IOW('f', 2, long)
232 #define OCFS2_IOC32_GETFLAGS    _IOR('f', 1, int)
233 #define OCFS2_IOC32_SETFLAGS    _IOW('f', 2, int)
234
235 /*
236  * Space reservation / allocation / free ioctls and argument structure
237  * are designed to be compatible with XFS.
238  *
239  * ALLOCSP* and FREESP* are not and will never be supported, but are
240  * included here for completeness.
241  */
242 struct ocfs2_space_resv {
243         __s16           l_type;
244         __s16           l_whence;
245         __s64           l_start;
246         __s64           l_len;          /* len == 0 means until end of file */
247         __s32           l_sysid;
248         __u32           l_pid;
249         __s32           l_pad[4];       /* reserve area                     */
250 };
251
252 #define OCFS2_IOC_ALLOCSP               _IOW ('X', 10, struct ocfs2_space_resv)
253 #define OCFS2_IOC_FREESP                _IOW ('X', 11, struct ocfs2_space_resv)
254 #define OCFS2_IOC_RESVSP                _IOW ('X', 40, struct ocfs2_space_resv)
255 #define OCFS2_IOC_UNRESVSP      _IOW ('X', 41, struct ocfs2_space_resv)
256 #define OCFS2_IOC_ALLOCSP64     _IOW ('X', 36, struct ocfs2_space_resv)
257 #define OCFS2_IOC_FREESP64      _IOW ('X', 37, struct ocfs2_space_resv)
258 #define OCFS2_IOC_RESVSP64      _IOW ('X', 42, struct ocfs2_space_resv)
259 #define OCFS2_IOC_UNRESVSP64    _IOW ('X', 43, struct ocfs2_space_resv)
260
261 /* Used to pass group descriptor data when online resize is done */
262 struct ocfs2_new_group_input {
263         __u64 group;            /* Group descriptor's blkno. */
264         __u32 clusters;         /* Total number of clusters in this group */
265         __u32 frees;            /* Total free clusters in this group */
266         __u16 chain;            /* Chain for this group */
267         __u16 reserved1;
268         __u32 reserved2;
269 };
270
271 #define OCFS2_IOC_GROUP_EXTEND  _IOW('o', 1, int)
272 #define OCFS2_IOC_GROUP_ADD     _IOW('o', 2,struct ocfs2_new_group_input)
273 #define OCFS2_IOC_GROUP_ADD64   _IOW('o', 3,struct ocfs2_new_group_input)
274
275 /*
276  * Journal Flags (ocfs2_dinode.id1.journal1.i_flags)
277  */
278 #define OCFS2_JOURNAL_DIRTY_FL  (0x00000001)    /* Journal needs recovery */
279
280 /*
281  * superblock s_state flags
282  */
283 #define OCFS2_ERROR_FS          (0x00000001)    /* FS saw errors */
284
285 /* Limit of space in ocfs2_dir_entry */
286 #define OCFS2_MAX_FILENAME_LEN          255
287
288 /* Maximum slots on an ocfs2 file system */
289 #define OCFS2_MAX_SLOTS                 255
290
291 /* Slot map indicator for an empty slot */
292 #define OCFS2_INVALID_SLOT              -1
293
294 #define OCFS2_VOL_UUID_LEN              16
295 #define OCFS2_MAX_VOL_LABEL_LEN         64
296
297 /* The alternate, userspace stack fields */
298 #define OCFS2_STACK_LABEL_LEN           4
299 #define OCFS2_CLUSTER_NAME_LEN          16
300
301 /* Journal limits (in bytes) */
302 #define OCFS2_MIN_JOURNAL_SIZE          (4 * 1024 * 1024)
303
304 /*
305  * Default local alloc size (in megabytes)
306  *
307  * The value chosen should be such that most allocations, including new
308  * block groups, use local alloc.
309  */
310 #define OCFS2_DEFAULT_LOCAL_ALLOC_SIZE  8
311
312 /*
313  * Inline extended attribute size (in bytes)
314  * The value chosen should be aligned to 16 byte boundaries.
315  */
316 #define OCFS2_MIN_XATTR_INLINE_SIZE     256
317
318 struct ocfs2_system_inode_info {
319         char    *si_name;
320         int     si_iflags;
321         int     si_mode;
322 };
323
324 /* System file index */
325 enum {
326         BAD_BLOCK_SYSTEM_INODE = 0,
327         GLOBAL_INODE_ALLOC_SYSTEM_INODE,
328         SLOT_MAP_SYSTEM_INODE,
329 #define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
330         HEARTBEAT_SYSTEM_INODE,
331         GLOBAL_BITMAP_SYSTEM_INODE,
332 #define OCFS2_LAST_GLOBAL_SYSTEM_INODE GLOBAL_BITMAP_SYSTEM_INODE
333         ORPHAN_DIR_SYSTEM_INODE,
334         EXTENT_ALLOC_SYSTEM_INODE,
335         INODE_ALLOC_SYSTEM_INODE,
336         JOURNAL_SYSTEM_INODE,
337         LOCAL_ALLOC_SYSTEM_INODE,
338         TRUNCATE_LOG_SYSTEM_INODE,
339         NUM_SYSTEM_INODES
340 };
341
342 static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
343         /* Global system inodes (single copy) */
344         /* The first two are only used from userspace mfks/tunefs */
345         [BAD_BLOCK_SYSTEM_INODE]                = { "bad_blocks", 0, S_IFREG | 0644 },
346         [GLOBAL_INODE_ALLOC_SYSTEM_INODE]       = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
347
348         /* These are used by the running filesystem */
349         [SLOT_MAP_SYSTEM_INODE]                 = { "slot_map", 0, S_IFREG | 0644 },
350         [HEARTBEAT_SYSTEM_INODE]                = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
351         [GLOBAL_BITMAP_SYSTEM_INODE]            = { "global_bitmap", 0, S_IFREG | 0644 },
352
353         /* Slot-specific system inodes (one copy per slot) */
354         [ORPHAN_DIR_SYSTEM_INODE]               = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
355         [EXTENT_ALLOC_SYSTEM_INODE]             = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
356         [INODE_ALLOC_SYSTEM_INODE]              = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
357         [JOURNAL_SYSTEM_INODE]                  = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
358         [LOCAL_ALLOC_SYSTEM_INODE]              = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
359         [TRUNCATE_LOG_SYSTEM_INODE]             = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 }
360 };
361
362 /* Parameter passed from mount.ocfs2 to module */
363 #define OCFS2_HB_NONE                   "heartbeat=none"
364 #define OCFS2_HB_LOCAL                  "heartbeat=local"
365
366 /*
367  * OCFS2 directory file types.  Only the low 3 bits are used.  The
368  * other bits are reserved for now.
369  */
370 #define OCFS2_FT_UNKNOWN        0
371 #define OCFS2_FT_REG_FILE       1
372 #define OCFS2_FT_DIR            2
373 #define OCFS2_FT_CHRDEV         3
374 #define OCFS2_FT_BLKDEV         4
375 #define OCFS2_FT_FIFO           5
376 #define OCFS2_FT_SOCK           6
377 #define OCFS2_FT_SYMLINK        7
378
379 #define OCFS2_FT_MAX            8
380
381 /*
382  * OCFS2_DIR_PAD defines the directory entries boundaries
383  *
384  * NOTE: It must be a multiple of 4
385  */
386 #define OCFS2_DIR_PAD                   4
387 #define OCFS2_DIR_ROUND                 (OCFS2_DIR_PAD - 1)
388 #define OCFS2_DIR_MEMBER_LEN            offsetof(struct ocfs2_dir_entry, name)
389 #define OCFS2_DIR_REC_LEN(name_len)     (((name_len) + OCFS2_DIR_MEMBER_LEN + \
390                                           OCFS2_DIR_ROUND) & \
391                                          ~OCFS2_DIR_ROUND)
392
393 #define OCFS2_LINK_MAX          32000
394
395 #define S_SHIFT                 12
396 static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = {
397         [S_IFREG >> S_SHIFT]  = OCFS2_FT_REG_FILE,
398         [S_IFDIR >> S_SHIFT]  = OCFS2_FT_DIR,
399         [S_IFCHR >> S_SHIFT]  = OCFS2_FT_CHRDEV,
400         [S_IFBLK >> S_SHIFT]  = OCFS2_FT_BLKDEV,
401         [S_IFIFO >> S_SHIFT]  = OCFS2_FT_FIFO,
402         [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK,
403         [S_IFLNK >> S_SHIFT]  = OCFS2_FT_SYMLINK,
404 };
405
406
407 /*
408  * Convenience casts
409  */
410 #define OCFS2_RAW_SB(dinode)            (&((dinode)->id2.i_super))
411
412 /*
413  * On disk extent record for OCFS2
414  * It describes a range of clusters on disk.
415  *
416  * Length fields are divided into interior and leaf node versions.
417  * This leaves room for a flags field (OCFS2_EXT_*) in the leaf nodes.
418  */
419 struct ocfs2_extent_rec {
420 /*00*/  __le32 e_cpos;          /* Offset into the file, in clusters */
421         union {
422                 __le32 e_int_clusters; /* Clusters covered by all children */
423                 struct {
424                         __le16 e_leaf_clusters; /* Clusters covered by this
425                                                    extent */
426                         __u8 e_reserved1;
427                         __u8 e_flags; /* Extent flags */
428                 };
429         };
430         __le64 e_blkno;         /* Physical disk offset, in blocks */
431 /*10*/
432 };
433
434 struct ocfs2_chain_rec {
435         __le32 c_free;  /* Number of free bits in this chain. */
436         __le32 c_total; /* Number of total bits in this chain */
437         __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */
438 };
439
440 struct ocfs2_truncate_rec {
441         __le32 t_start;         /* 1st cluster in this log */
442         __le32 t_clusters;      /* Number of total clusters covered */
443 };
444
445 /*
446  * On disk extent list for OCFS2 (node in the tree).  Note that this
447  * is contained inside ocfs2_dinode or ocfs2_extent_block, so the
448  * offsets are relative to ocfs2_dinode.id2.i_list or
449  * ocfs2_extent_block.h_list, respectively.
450  */
451 struct ocfs2_extent_list {
452 /*00*/  __le16 l_tree_depth;            /* Extent tree depth from this
453                                            point.  0 means data extents
454                                            hang directly off this
455                                            header (a leaf)
456                                            NOTE: The high 8 bits cannot be
457                                            used - tree_depth is never that big.
458                                         */
459         __le16 l_count;                 /* Number of extent records */
460         __le16 l_next_free_rec;         /* Next unused extent slot */
461         __le16 l_reserved1;
462         __le64 l_reserved2;             /* Pad to
463                                            sizeof(ocfs2_extent_rec) */
464 /*10*/  struct ocfs2_extent_rec l_recs[0];      /* Extent records */
465 };
466
467 /*
468  * On disk allocation chain list for OCFS2.  Note that this is
469  * contained inside ocfs2_dinode, so the offsets are relative to
470  * ocfs2_dinode.id2.i_chain.
471  */
472 struct ocfs2_chain_list {
473 /*00*/  __le16 cl_cpg;                  /* Clusters per Block Group */
474         __le16 cl_bpc;                  /* Bits per cluster */
475         __le16 cl_count;                /* Total chains in this list */
476         __le16 cl_next_free_rec;        /* Next unused chain slot */
477         __le64 cl_reserved1;
478 /*10*/  struct ocfs2_chain_rec cl_recs[0];      /* Chain records */
479 };
480
481 /*
482  * On disk deallocation log for OCFS2.  Note that this is
483  * contained inside ocfs2_dinode, so the offsets are relative to
484  * ocfs2_dinode.id2.i_dealloc.
485  */
486 struct ocfs2_truncate_log {
487 /*00*/  __le16 tl_count;                /* Total records in this log */
488         __le16 tl_used;                 /* Number of records in use */
489         __le32 tl_reserved1;
490 /*08*/  struct ocfs2_truncate_rec tl_recs[0];   /* Truncate records */
491 };
492
493 /*
494  * On disk extent block (indirect block) for OCFS2
495  */
496 struct ocfs2_extent_block
497 {
498 /*00*/  __u8 h_signature[8];            /* Signature for verification */
499         __le64 h_reserved1;
500 /*10*/  __le16 h_suballoc_slot;         /* Slot suballocator this
501                                            extent_header belongs to */
502         __le16 h_suballoc_bit;          /* Bit offset in suballocator
503                                            block group */
504         __le32 h_fs_generation;         /* Must match super block */
505         __le64 h_blkno;                 /* Offset on disk, in blocks */
506 /*20*/  __le64 h_reserved3;
507         __le64 h_next_leaf_blk;         /* Offset on disk, in blocks,
508                                            of next leaf header pointing
509                                            to data */
510 /*30*/  struct ocfs2_extent_list h_list;        /* Extent record list */
511 /* Actual on-disk size is one block */
512 };
513
514 /*
515  * On disk slot map for OCFS2.  This defines the contents of the "slot_map"
516  * system file.  A slot is valid if it contains a node number >= 0.  The
517  * value -1 (0xFFFF) is OCFS2_INVALID_SLOT.  This marks a slot empty.
518  */
519 struct ocfs2_slot_map {
520 /*00*/  __le16 sm_slots[0];
521 /*
522  * Actual on-disk size is one block.  OCFS2_MAX_SLOTS is 255,
523  * 255 * sizeof(__le16) == 512B, within the 512B block minimum blocksize.
524  */
525 };
526
527 struct ocfs2_extended_slot {
528 /*00*/  __u8    es_valid;
529         __u8    es_reserved1[3];
530         __le32  es_node_num;
531 /*10*/
532 };
533
534 /*
535  * The extended slot map, used when OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP
536  * is set.  It separates out the valid marker from the node number, and
537  * has room to grow.  Unlike the old slot map, this format is defined by
538  * i_size.
539  */
540 struct ocfs2_slot_map_extended {
541 /*00*/  struct ocfs2_extended_slot se_slots[0];
542 /*
543  * Actual size is i_size of the slot_map system file.  It should
544  * match s_max_slots * sizeof(struct ocfs2_extended_slot)
545  */
546 };
547
548 struct ocfs2_cluster_info {
549 /*00*/  __u8   ci_stack[OCFS2_STACK_LABEL_LEN];
550         __le32 ci_reserved;
551 /*08*/  __u8   ci_cluster[OCFS2_CLUSTER_NAME_LEN];
552 /*18*/
553 };
554
555 /*
556  * On disk superblock for OCFS2
557  * Note that it is contained inside an ocfs2_dinode, so all offsets
558  * are relative to the start of ocfs2_dinode.id2.
559  */
560 struct ocfs2_super_block {
561 /*00*/  __le16 s_major_rev_level;
562         __le16 s_minor_rev_level;
563         __le16 s_mnt_count;
564         __le16 s_max_mnt_count;
565         __le16 s_state;                 /* File system state */
566         __le16 s_errors;                        /* Behaviour when detecting errors */
567         __le32 s_checkinterval;         /* Max time between checks */
568 /*10*/  __le64 s_lastcheck;             /* Time of last check */
569         __le32 s_creator_os;            /* OS */
570         __le32 s_feature_compat;                /* Compatible feature set */
571 /*20*/  __le32 s_feature_incompat;      /* Incompatible feature set */
572         __le32 s_feature_ro_compat;     /* Readonly-compatible feature set */
573         __le64 s_root_blkno;            /* Offset, in blocks, of root directory
574                                            dinode */
575 /*30*/  __le64 s_system_dir_blkno;      /* Offset, in blocks, of system
576                                            directory dinode */
577         __le32 s_blocksize_bits;                /* Blocksize for this fs */
578         __le32 s_clustersize_bits;      /* Clustersize for this fs */
579 /*40*/  __le16 s_max_slots;             /* Max number of simultaneous mounts
580                                            before tunefs required */
581         __le16 s_tunefs_flag;
582         __le32 s_uuid_hash;             /* hash value of uuid */
583         __le64 s_first_cluster_group;   /* Block offset of 1st cluster
584                                          * group header */
585 /*50*/  __u8  s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */
586 /*90*/  __u8  s_uuid[OCFS2_VOL_UUID_LEN];       /* 128-bit uuid */
587 /*A0*/  struct ocfs2_cluster_info s_cluster_info; /* Selected userspace
588                                                      stack.  Only valid
589                                                      with INCOMPAT flag. */
590 /*B8*/  __le16 s_xattr_inline_size;     /* extended attribute inline size
591                                            for this fs*/
592         __le16 s_reserved0;
593         __le32 s_reserved1;
594 /*C0*/  __le64 s_reserved2[16];         /* Fill out superblock */
595 /*140*/
596
597         /*
598          * NOTE: As stated above, all offsets are relative to
599          * ocfs2_dinode.id2, which is at 0xC0 in the inode.
600          * 0xC0 + 0x140 = 0x200 or 512 bytes.  A superblock must fit within
601          * our smallest blocksize, which is 512 bytes.  To ensure this,
602          * we reserve the space in s_reserved2.  Anything past s_reserved2
603          * will not be available on the smallest blocksize.
604          */
605 };
606
607 /*
608  * Local allocation bitmap for OCFS2 slots
609  * Note that it exists inside an ocfs2_dinode, so all offsets are
610  * relative to the start of ocfs2_dinode.id2.
611  */
612 struct ocfs2_local_alloc
613 {
614 /*00*/  __le32 la_bm_off;       /* Starting bit offset in main bitmap */
615         __le16 la_size;         /* Size of included bitmap, in bytes */
616         __le16 la_reserved1;
617         __le64 la_reserved2;
618 /*10*/  __u8   la_bitmap[0];
619 };
620
621 /*
622  * Data-in-inode header. This is only used if i_dyn_features has
623  * OCFS2_INLINE_DATA_FL set.
624  */
625 struct ocfs2_inline_data
626 {
627 /*00*/  __le16  id_count;       /* Number of bytes that can be used
628                                  * for data, starting at id_data */
629         __le16  id_reserved0;
630         __le32  id_reserved1;
631         __u8    id_data[0];     /* Start of user data */
632 };
633
634 /*
635  * On disk inode for OCFS2
636  */
637 struct ocfs2_dinode {
638 /*00*/  __u8 i_signature[8];            /* Signature for validation */
639         __le32 i_generation;            /* Generation number */
640         __le16 i_suballoc_slot;         /* Slot suballocator this inode
641                                            belongs to */
642         __le16 i_suballoc_bit;          /* Bit offset in suballocator
643                                            block group */
644 /*10*/  __le16 i_reserved0;
645         __le16 i_xattr_inline_size;
646         __le32 i_clusters;              /* Cluster count */
647         __le32 i_uid;                   /* Owner UID */
648         __le32 i_gid;                   /* Owning GID */
649 /*20*/  __le64 i_size;                  /* Size in bytes */
650         __le16 i_mode;                  /* File mode */
651         __le16 i_links_count;           /* Links count */
652         __le32 i_flags;                 /* File flags */
653 /*30*/  __le64 i_atime;                 /* Access time */
654         __le64 i_ctime;                 /* Creation time */
655 /*40*/  __le64 i_mtime;                 /* Modification time */
656         __le64 i_dtime;                 /* Deletion time */
657 /*50*/  __le64 i_blkno;                 /* Offset on disk, in blocks */
658         __le64 i_last_eb_blk;           /* Pointer to last extent
659                                            block */
660 /*60*/  __le32 i_fs_generation;         /* Generation per fs-instance */
661         __le32 i_atime_nsec;
662         __le32 i_ctime_nsec;
663         __le32 i_mtime_nsec;
664 /*70*/  __le32 i_attr;
665         __le16 i_orphaned_slot;         /* Only valid when OCFS2_ORPHANED_FL
666                                            was set in i_flags */
667         __le16 i_dyn_features;
668         __le64 i_xattr_loc;
669 /*80*/  __le64 i_reserved2[7];
670 /*B8*/  union {
671                 __le64 i_pad1;          /* Generic way to refer to this
672                                            64bit union */
673                 struct {
674                         __le64 i_rdev;  /* Device number */
675                 } dev1;
676                 struct {                /* Info for bitmap system
677                                            inodes */
678                         __le32 i_used;  /* Bits (ie, clusters) used  */
679                         __le32 i_total; /* Total bits (clusters)
680                                            available */
681                 } bitmap1;
682                 struct {                /* Info for journal system
683                                            inodes */
684                         __le32 ij_flags;        /* Mounted, version, etc. */
685                         __le32 ij_recovery_generation; /* Incremented when the
686                                                           journal is recovered
687                                                           after an unclean
688                                                           shutdown */
689                 } journal1;
690         } id1;                          /* Inode type dependant 1 */
691 /*C0*/  union {
692                 struct ocfs2_super_block        i_super;
693                 struct ocfs2_local_alloc        i_lab;
694                 struct ocfs2_chain_list         i_chain;
695                 struct ocfs2_extent_list        i_list;
696                 struct ocfs2_truncate_log       i_dealloc;
697                 struct ocfs2_inline_data        i_data;
698                 __u8                            i_symlink[0];
699         } id2;
700 /* Actual on-disk size is one block */
701 };
702
703 /*
704  * On-disk directory entry structure for OCFS2
705  *
706  * Packed as this structure could be accessed unaligned on 64-bit platforms
707  */
708 struct ocfs2_dir_entry {
709 /*00*/  __le64   inode;                  /* Inode number */
710         __le16   rec_len;                /* Directory entry length */
711         __u8    name_len;               /* Name length */
712         __u8    file_type;
713 /*0C*/  char    name[OCFS2_MAX_FILENAME_LEN];   /* File name */
714 /* Actual on-disk length specified by rec_len */
715 } __attribute__ ((packed));
716
717 /*
718  * On disk allocator group structure for OCFS2
719  */
720 struct ocfs2_group_desc
721 {
722 /*00*/  __u8    bg_signature[8];        /* Signature for validation */
723         __le16   bg_size;                /* Size of included bitmap in
724                                            bytes. */
725         __le16   bg_bits;                /* Bits represented by this
726                                            group. */
727         __le16  bg_free_bits_count;     /* Free bits count */
728         __le16   bg_chain;               /* What chain I am in. */
729 /*10*/  __le32   bg_generation;
730         __le32  bg_reserved1;
731         __le64   bg_next_group;          /* Next group in my list, in
732                                            blocks */
733 /*20*/  __le64   bg_parent_dinode;       /* dinode which owns me, in
734                                            blocks */
735         __le64   bg_blkno;               /* Offset on disk, in blocks */
736 /*30*/  __le64   bg_reserved2[2];
737 /*40*/  __u8    bg_bitmap[0];
738 };
739
740 /*
741  * On disk extended attribute structure for OCFS2.
742  */
743
744 /*
745  * ocfs2_xattr_entry indicates one extend attribute.
746  *
747  * Note that it can be stored in inode, one block or one xattr bucket.
748  */
749 struct ocfs2_xattr_entry {
750         __le32  xe_name_hash;    /* hash value of xattr prefix+suffix. */
751         __le16  xe_name_offset;  /* byte offset from the 1st entry in the
752                                     local xattr storage(inode, xattr block or
753                                     xattr bucket). */
754         __u8    xe_name_len;     /* xattr name len, does't include prefix. */
755         __u8    xe_type;         /* the low 7 bits indicate the name prefix
756                                   * type and the highest bit indicates whether
757                                   * the EA is stored in the local storage. */
758         __le64  xe_value_size;   /* real xattr value length. */
759 };
760
761 /*
762  * On disk structure for xattr header.
763  *
764  * One ocfs2_xattr_header describes how many ocfs2_xattr_entry records in
765  * the local xattr storage.
766  */
767 struct ocfs2_xattr_header {
768         __le16  xh_count;                       /* contains the count of how
769                                                    many records are in the
770                                                    local xattr storage. */
771         __le16  xh_free_start;                  /* current offset for storing
772                                                    xattr. */
773         __le16  xh_name_value_len;              /* total length of name/value
774                                                    length in this bucket. */
775         __le16  xh_num_buckets;                 /* Number of xattr buckets
776                                                    in this extent record,
777                                                    only valid in the first
778                                                    bucket. */
779         __le64  xh_csum;
780         struct ocfs2_xattr_entry xh_entries[0]; /* xattr entry list. */
781 };
782
783 /*
784  * On disk structure for xattr value root.
785  *
786  * When an xattr's value is large enough, it is stored in an external
787  * b-tree like file data.  The xattr value root points to this structure.
788  */
789 struct ocfs2_xattr_value_root {
790 /*00*/  __le32  xr_clusters;              /* clusters covered by xattr value. */
791         __le32  xr_reserved0;
792         __le64  xr_last_eb_blk;           /* Pointer to last extent block */
793 /*10*/  struct ocfs2_extent_list xr_list; /* Extent record list */
794 };
795
796 /*
797  * On disk structure for xattr tree root.
798  *
799  * It is used when there are too many extended attributes for one file. These
800  * attributes will be organized and stored in an indexed-btree.
801  */
802 struct ocfs2_xattr_tree_root {
803 /*00*/  __le32  xt_clusters;              /* clusters covered by xattr. */
804         __le32  xt_reserved0;
805         __le64  xt_last_eb_blk;           /* Pointer to last extent block */
806 /*10*/  struct ocfs2_extent_list xt_list; /* Extent record list */
807 };
808
809 #define OCFS2_XATTR_INDEXED     0x1
810 #define OCFS2_HASH_SHIFT        5
811 #define OCFS2_XATTR_ROUND       3
812 #define OCFS2_XATTR_SIZE(size)  (((size) + OCFS2_XATTR_ROUND) & \
813                                 ~(OCFS2_XATTR_ROUND))
814
815 #define OCFS2_XATTR_BUCKET_SIZE                 4096
816 #define OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET       (OCFS2_XATTR_BUCKET_SIZE \
817                                                  / OCFS2_MIN_BLOCKSIZE)
818
819 /*
820  * On disk structure for xattr block.
821  */
822 struct ocfs2_xattr_block {
823 /*00*/  __u8    xb_signature[8];     /* Signature for verification */
824         __le16  xb_suballoc_slot;    /* Slot suballocator this
825                                         block belongs to. */
826         __le16  xb_suballoc_bit;     /* Bit offset in suballocator
827                                         block group */
828         __le32  xb_fs_generation;    /* Must match super block */
829 /*10*/  __le64  xb_blkno;            /* Offset on disk, in blocks */
830         __le64  xb_csum;
831 /*20*/  __le16  xb_flags;            /* Indicates whether this block contains
832                                         real xattr or a xattr tree. */
833         __le16  xb_reserved0;
834         __le32  xb_reserved1;
835         __le64  xb_reserved2;
836 /*30*/  union {
837                 struct ocfs2_xattr_header xb_header; /* xattr header if this
838                                                         block contains xattr */
839                 struct ocfs2_xattr_tree_root xb_root;/* xattr tree root if this
840                                                         block cotains xattr
841                                                         tree. */
842         } xb_attrs;
843 };
844
845 #define OCFS2_XATTR_ENTRY_LOCAL         0x80
846 #define OCFS2_XATTR_TYPE_MASK           0x7F
847 static inline void ocfs2_xattr_set_local(struct ocfs2_xattr_entry *xe,
848                                          int local)
849 {
850         if (local)
851                 xe->xe_type |= OCFS2_XATTR_ENTRY_LOCAL;
852         else
853                 xe->xe_type &= ~OCFS2_XATTR_ENTRY_LOCAL;
854 }
855
856 static inline int ocfs2_xattr_is_local(struct ocfs2_xattr_entry *xe)
857 {
858         return xe->xe_type & OCFS2_XATTR_ENTRY_LOCAL;
859 }
860
861 static inline void ocfs2_xattr_set_type(struct ocfs2_xattr_entry *xe, int type)
862 {
863         xe->xe_type |= type & OCFS2_XATTR_TYPE_MASK;
864 }
865
866 static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry *xe)
867 {
868         return xe->xe_type & OCFS2_XATTR_TYPE_MASK;
869 }
870
871 #ifdef __KERNEL__
872 static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
873 {
874         return  sb->s_blocksize -
875                  offsetof(struct ocfs2_dinode, id2.i_symlink);
876 }
877
878 static inline int ocfs2_max_inline_data(struct super_block *sb)
879 {
880         return sb->s_blocksize -
881                 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
882 }
883
884 static inline int ocfs2_max_inline_data_with_xattr(struct super_block *sb,
885                                                    struct ocfs2_dinode *di)
886 {
887         unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
888
889         if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
890                 return sb->s_blocksize -
891                         offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
892                         xattrsize;
893         else
894                 return sb->s_blocksize -
895                         offsetof(struct ocfs2_dinode, id2.i_data.id_data);
896 }
897
898 static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
899 {
900         int size;
901
902         size = sb->s_blocksize -
903                 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
904
905         return size / sizeof(struct ocfs2_extent_rec);
906 }
907
908 static inline int ocfs2_extent_recs_per_inode_with_xattr(
909                                                 struct super_block *sb,
910                                                 struct ocfs2_dinode *di)
911 {
912         int size;
913         unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
914
915         if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
916                 size = sb->s_blocksize -
917                         offsetof(struct ocfs2_dinode, id2.i_list.l_recs) -
918                         xattrsize;
919         else
920                 size = sb->s_blocksize -
921                         offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
922
923         return size / sizeof(struct ocfs2_extent_rec);
924 }
925
926 static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
927 {
928         int size;
929
930         size = sb->s_blocksize -
931                 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
932
933         return size / sizeof(struct ocfs2_chain_rec);
934 }
935
936 static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
937 {
938         int size;
939
940         size = sb->s_blocksize -
941                 offsetof(struct ocfs2_extent_block, h_list.l_recs);
942
943         return size / sizeof(struct ocfs2_extent_rec);
944 }
945
946 static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
947 {
948         u16 size;
949
950         size = sb->s_blocksize -
951                 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
952
953         return size;
954 }
955
956 static inline int ocfs2_group_bitmap_size(struct super_block *sb)
957 {
958         int size;
959
960         size = sb->s_blocksize -
961                 offsetof(struct ocfs2_group_desc, bg_bitmap);
962
963         return size;
964 }
965
966 static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
967 {
968         int size;
969
970         size = sb->s_blocksize -
971                 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
972
973         return size / sizeof(struct ocfs2_truncate_rec);
974 }
975
976 static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
977 {
978         u64 offset = OCFS2_BACKUP_SB_START;
979
980         if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
981                 offset <<= (2 * index);
982                 offset >>= sb->s_blocksize_bits;
983                 return offset;
984         }
985
986         return 0;
987
988 }
989
990 static inline u16 ocfs2_xattr_recs_per_xb(struct super_block *sb)
991 {
992         int size;
993
994         size = sb->s_blocksize -
995                 offsetof(struct ocfs2_xattr_block,
996                          xb_attrs.xb_root.xt_list.l_recs);
997
998         return size / sizeof(struct ocfs2_extent_rec);
999 }
1000 #else
1001 static inline int ocfs2_fast_symlink_chars(int blocksize)
1002 {
1003         return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
1004 }
1005
1006 static inline int ocfs2_max_inline_data(int blocksize)
1007 {
1008         return blocksize - offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1009 }
1010
1011 static inline int ocfs2_extent_recs_per_inode(int blocksize)
1012 {
1013         int size;
1014
1015         size = blocksize -
1016                 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1017
1018         return size / sizeof(struct ocfs2_extent_rec);
1019 }
1020
1021 static inline int ocfs2_chain_recs_per_inode(int blocksize)
1022 {
1023         int size;
1024
1025         size = blocksize -
1026                 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1027
1028         return size / sizeof(struct ocfs2_chain_rec);
1029 }
1030
1031 static inline int ocfs2_extent_recs_per_eb(int blocksize)
1032 {
1033         int size;
1034
1035         size = blocksize -
1036                 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1037
1038         return size / sizeof(struct ocfs2_extent_rec);
1039 }
1040
1041 static inline int ocfs2_local_alloc_size(int blocksize)
1042 {
1043         int size;
1044
1045         size = blocksize -
1046                 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1047
1048         return size;
1049 }
1050
1051 static inline int ocfs2_group_bitmap_size(int blocksize)
1052 {
1053         int size;
1054
1055         size = blocksize -
1056                 offsetof(struct ocfs2_group_desc, bg_bitmap);
1057
1058         return size;
1059 }
1060
1061 static inline int ocfs2_truncate_recs_per_inode(int blocksize)
1062 {
1063         int size;
1064
1065         size = blocksize -
1066                 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1067
1068         return size / sizeof(struct ocfs2_truncate_rec);
1069 }
1070
1071 static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
1072 {
1073         uint64_t offset = OCFS2_BACKUP_SB_START;
1074
1075         if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1076                 offset <<= (2 * index);
1077                 offset /= blocksize;
1078                 return offset;
1079         }
1080
1081         return 0;
1082 }
1083
1084 static inline int ocfs2_xattr_recs_per_xb(int blocksize)
1085 {
1086         int size;
1087
1088         size = blocksize -
1089                 offsetof(struct ocfs2_xattr_block,
1090                          xb_attrs.xb_root.xt_list.l_recs);
1091
1092         return size / sizeof(struct ocfs2_extent_rec);
1093 }
1094 #endif  /* __KERNEL__ */
1095
1096
1097 static inline int ocfs2_system_inode_is_global(int type)
1098 {
1099         return ((type >= 0) &&
1100                 (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
1101 }
1102
1103 static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
1104                                                   int type, int slot)
1105 {
1106         int chars;
1107
1108         /*
1109          * Global system inodes can only have one copy.  Everything
1110          * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
1111          * list has a copy per slot.
1112          */
1113         if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
1114                 chars = snprintf(buf, len, "%s",
1115                                  ocfs2_system_inodes[type].si_name);
1116         else
1117                 chars = snprintf(buf, len,
1118                                  ocfs2_system_inodes[type].si_name,
1119                                  slot);
1120
1121         return chars;
1122 }
1123
1124 static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
1125                                     umode_t mode)
1126 {
1127         de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
1128 }
1129
1130 #endif  /* _OCFS2_FS_H */
1131