aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/ocfs2_fs.h
diff options
context:
space:
mode:
authorMark Fasheh <mark.fasheh@oracle.com>2005-12-15 17:31:24 -0500
committerJoel Becker <joel.becker@oracle.com>2006-01-03 14:45:47 -0500
commitccd979bdbce9fba8412beb3f1de68a9d0171b12c (patch)
treec50ed941849ce06ccadd4ce27599b3ef9fdbe2ae /fs/ocfs2/ocfs2_fs.h
parent8df08c89c668e1bd922a053fdb5ba1fadbecbb38 (diff)
[PATCH] OCFS2: The Second Oracle Cluster Filesystem
The OCFS2 file system module. Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com> Signed-off-by: Kurt Hackel <kurt.hackel@oracle.com>
Diffstat (limited to 'fs/ocfs2/ocfs2_fs.h')
-rw-r--r--fs/ocfs2/ocfs2_fs.h638
1 files changed, 638 insertions, 0 deletions
diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h
new file mode 100644
index 000000000000..dfb8a5bedfc8
--- /dev/null
+++ b/fs/ocfs2/ocfs2_fs.h
@@ -0,0 +1,638 @@
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
68/* Compatibility flags */
69#define OCFS2_HAS_COMPAT_FEATURE(sb,mask) \
70 ( OCFS2_SB(sb)->s_feature_compat & (mask) )
71#define OCFS2_HAS_RO_COMPAT_FEATURE(sb,mask) \
72 ( OCFS2_SB(sb)->s_feature_ro_compat & (mask) )
73#define OCFS2_HAS_INCOMPAT_FEATURE(sb,mask) \
74 ( OCFS2_SB(sb)->s_feature_incompat & (mask) )
75#define OCFS2_SET_COMPAT_FEATURE(sb,mask) \
76 OCFS2_SB(sb)->s_feature_compat |= (mask)
77#define OCFS2_SET_RO_COMPAT_FEATURE(sb,mask) \
78 OCFS2_SB(sb)->s_feature_ro_compat |= (mask)
79#define OCFS2_SET_INCOMPAT_FEATURE(sb,mask) \
80 OCFS2_SB(sb)->s_feature_incompat |= (mask)
81#define OCFS2_CLEAR_COMPAT_FEATURE(sb,mask) \
82 OCFS2_SB(sb)->s_feature_compat &= ~(mask)
83#define OCFS2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
84 OCFS2_SB(sb)->s_feature_ro_compat &= ~(mask)
85#define OCFS2_CLEAR_INCOMPAT_FEATURE(sb,mask) \
86 OCFS2_SB(sb)->s_feature_incompat &= ~(mask)
87
88#define OCFS2_FEATURE_COMPAT_SUPP 0
89#define OCFS2_FEATURE_INCOMPAT_SUPP 0
90#define OCFS2_FEATURE_RO_COMPAT_SUPP 0
91
92/*
93 * Heartbeat-only devices are missing journals and other files. The
94 * filesystem driver can't load them, but the library can. Never put
95 * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*.
96 */
97#define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002
98
99
100/*
101 * Flags on ocfs2_dinode.i_flags
102 */
103#define OCFS2_VALID_FL (0x00000001) /* Inode is valid */
104#define OCFS2_UNUSED2_FL (0x00000002)
105#define OCFS2_ORPHANED_FL (0x00000004) /* On the orphan list */
106#define OCFS2_UNUSED3_FL (0x00000008)
107/* System inode flags */
108#define OCFS2_SYSTEM_FL (0x00000010) /* System inode */
109#define OCFS2_SUPER_BLOCK_FL (0x00000020) /* Super block */
110#define OCFS2_LOCAL_ALLOC_FL (0x00000040) /* Slot local alloc bitmap */
111#define OCFS2_BITMAP_FL (0x00000080) /* Allocation bitmap */
112#define OCFS2_JOURNAL_FL (0x00000100) /* Slot local journal */
113#define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */
114#define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */
115#define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */
116
117/*
118 * Journal Flags (ocfs2_dinode.id1.journal1.i_flags)
119 */
120#define OCFS2_JOURNAL_DIRTY_FL (0x00000001) /* Journal needs recovery */
121
122/*
123 * superblock s_state flags
124 */
125#define OCFS2_ERROR_FS (0x00000001) /* FS saw errors */
126
127/* Limit of space in ocfs2_dir_entry */
128#define OCFS2_MAX_FILENAME_LEN 255
129
130/* Maximum slots on an ocfs2 file system */
131#define OCFS2_MAX_SLOTS 255
132
133/* Slot map indicator for an empty slot */
134#define OCFS2_INVALID_SLOT -1
135
136#define OCFS2_VOL_UUID_LEN 16
137#define OCFS2_MAX_VOL_LABEL_LEN 64
138
139/* Journal limits (in bytes) */
140#define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024)
141#define OCFS2_MAX_JOURNAL_SIZE (500 * 1024 * 1024)
142
143struct ocfs2_system_inode_info {
144 char *si_name;
145 int si_iflags;
146 int si_mode;
147};
148
149/* System file index */
150enum {
151 BAD_BLOCK_SYSTEM_INODE = 0,
152 GLOBAL_INODE_ALLOC_SYSTEM_INODE,
153 SLOT_MAP_SYSTEM_INODE,
154#define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
155 HEARTBEAT_SYSTEM_INODE,
156 GLOBAL_BITMAP_SYSTEM_INODE,
157#define OCFS2_LAST_GLOBAL_SYSTEM_INODE GLOBAL_BITMAP_SYSTEM_INODE
158 ORPHAN_DIR_SYSTEM_INODE,
159 EXTENT_ALLOC_SYSTEM_INODE,
160 INODE_ALLOC_SYSTEM_INODE,
161 JOURNAL_SYSTEM_INODE,
162 LOCAL_ALLOC_SYSTEM_INODE,
163 TRUNCATE_LOG_SYSTEM_INODE,
164 NUM_SYSTEM_INODES
165};
166
167static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
168 /* Global system inodes (single copy) */
169 /* The first two are only used from userspace mfks/tunefs */
170 [BAD_BLOCK_SYSTEM_INODE] = { "bad_blocks", 0, S_IFREG | 0644 },
171 [GLOBAL_INODE_ALLOC_SYSTEM_INODE] = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
172
173 /* These are used by the running filesystem */
174 [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 },
175 [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
176 [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 },
177
178 /* Slot-specific system inodes (one copy per slot) */
179 [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
180 [EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
181 [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
182 [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
183 [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
184 [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 }
185};
186
187/* Parameter passed from mount.ocfs2 to module */
188#define OCFS2_HB_NONE "heartbeat=none"
189#define OCFS2_HB_LOCAL "heartbeat=local"
190
191/*
192 * OCFS2 directory file types. Only the low 3 bits are used. The
193 * other bits are reserved for now.
194 */
195#define OCFS2_FT_UNKNOWN 0
196#define OCFS2_FT_REG_FILE 1
197#define OCFS2_FT_DIR 2
198#define OCFS2_FT_CHRDEV 3
199#define OCFS2_FT_BLKDEV 4
200#define OCFS2_FT_FIFO 5
201#define OCFS2_FT_SOCK 6
202#define OCFS2_FT_SYMLINK 7
203
204#define OCFS2_FT_MAX 8
205
206/*
207 * OCFS2_DIR_PAD defines the directory entries boundaries
208 *
209 * NOTE: It must be a multiple of 4
210 */
211#define OCFS2_DIR_PAD 4
212#define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1)
213#define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name)
214#define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \
215 OCFS2_DIR_ROUND) & \
216 ~OCFS2_DIR_ROUND)
217
218#define OCFS2_LINK_MAX 32000
219
220#define S_SHIFT 12
221static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = {
222 [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE,
223 [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR,
224 [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV,
225 [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV,
226 [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO,
227 [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK,
228 [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK,
229};
230
231
232/*
233 * Convenience casts
234 */
235#define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
236
237/*
238 * On disk extent record for OCFS2
239 * It describes a range of clusters on disk.
240 */
241struct ocfs2_extent_rec {
242/*00*/ __le32 e_cpos; /* Offset into the file, in clusters */
243 __le32 e_clusters; /* Clusters covered by this extent */
244 __le64 e_blkno; /* Physical disk offset, in blocks */
245/*10*/
246};
247
248struct ocfs2_chain_rec {
249 __le32 c_free; /* Number of free bits in this chain. */
250 __le32 c_total; /* Number of total bits in this chain */
251 __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */
252};
253
254struct ocfs2_truncate_rec {
255 __le32 t_start; /* 1st cluster in this log */
256 __le32 t_clusters; /* Number of total clusters covered */
257};
258
259/*
260 * On disk extent list for OCFS2 (node in the tree). Note that this
261 * is contained inside ocfs2_dinode or ocfs2_extent_block, so the
262 * offsets are relative to ocfs2_dinode.id2.i_list or
263 * ocfs2_extent_block.h_list, respectively.
264 */
265struct ocfs2_extent_list {
266/*00*/ __le16 l_tree_depth; /* Extent tree depth from this
267 point. 0 means data extents
268 hang directly off this
269 header (a leaf) */
270 __le16 l_count; /* Number of extent records */
271 __le16 l_next_free_rec; /* Next unused extent slot */
272 __le16 l_reserved1;
273 __le64 l_reserved2; /* Pad to
274 sizeof(ocfs2_extent_rec) */
275/*10*/ struct ocfs2_extent_rec l_recs[0]; /* Extent records */
276};
277
278/*
279 * On disk allocation chain list for OCFS2. Note that this is
280 * contained inside ocfs2_dinode, so the offsets are relative to
281 * ocfs2_dinode.id2.i_chain.
282 */
283struct ocfs2_chain_list {
284/*00*/ __le16 cl_cpg; /* Clusters per Block Group */
285 __le16 cl_bpc; /* Bits per cluster */
286 __le16 cl_count; /* Total chains in this list */
287 __le16 cl_next_free_rec; /* Next unused chain slot */
288 __le64 cl_reserved1;
289/*10*/ struct ocfs2_chain_rec cl_recs[0]; /* Chain records */
290};
291
292/*
293 * On disk deallocation log for OCFS2. Note that this is
294 * contained inside ocfs2_dinode, so the offsets are relative to
295 * ocfs2_dinode.id2.i_dealloc.
296 */
297struct ocfs2_truncate_log {
298/*00*/ __le16 tl_count; /* Total records in this log */
299 __le16 tl_used; /* Number of records in use */
300 __le32 tl_reserved1;
301/*08*/ struct ocfs2_truncate_rec tl_recs[0]; /* Truncate records */
302};
303
304/*
305 * On disk extent block (indirect block) for OCFS2
306 */
307struct ocfs2_extent_block
308{
309/*00*/ __u8 h_signature[8]; /* Signature for verification */
310 __le64 h_reserved1;
311/*10*/ __le16 h_suballoc_slot; /* Slot suballocator this
312 extent_header belongs to */
313 __le16 h_suballoc_bit; /* Bit offset in suballocator
314 block group */
315 __le32 h_fs_generation; /* Must match super block */
316 __le64 h_blkno; /* Offset on disk, in blocks */
317/*20*/ __le64 h_reserved3;
318 __le64 h_next_leaf_blk; /* Offset on disk, in blocks,
319 of next leaf header pointing
320 to data */
321/*30*/ struct ocfs2_extent_list h_list; /* Extent record list */
322/* Actual on-disk size is one block */
323};
324
325/*
326 * On disk superblock for OCFS2
327 * Note that it is contained inside an ocfs2_dinode, so all offsets
328 * are relative to the start of ocfs2_dinode.id2.
329 */
330struct ocfs2_super_block {
331/*00*/ __le16 s_major_rev_level;
332 __le16 s_minor_rev_level;
333 __le16 s_mnt_count;
334 __le16 s_max_mnt_count;
335 __le16 s_state; /* File system state */
336 __le16 s_errors; /* Behaviour when detecting errors */
337 __le32 s_checkinterval; /* Max time between checks */
338/*10*/ __le64 s_lastcheck; /* Time of last check */
339 __le32 s_creator_os; /* OS */
340 __le32 s_feature_compat; /* Compatible feature set */
341/*20*/ __le32 s_feature_incompat; /* Incompatible feature set */
342 __le32 s_feature_ro_compat; /* Readonly-compatible feature set */
343 __le64 s_root_blkno; /* Offset, in blocks, of root directory
344 dinode */
345/*30*/ __le64 s_system_dir_blkno; /* Offset, in blocks, of system
346 directory dinode */
347 __le32 s_blocksize_bits; /* Blocksize for this fs */
348 __le32 s_clustersize_bits; /* Clustersize for this fs */
349/*40*/ __le16 s_max_slots; /* Max number of simultaneous mounts
350 before tunefs required */
351 __le16 s_reserved1;
352 __le32 s_reserved2;
353 __le64 s_first_cluster_group; /* Block offset of 1st cluster
354 * group header */
355/*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */
356/*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */
357/*A0*/
358};
359
360/*
361 * Local allocation bitmap for OCFS2 slots
362 * Note that it exists inside an ocfs2_dinode, so all offsets are
363 * relative to the start of ocfs2_dinode.id2.
364 */
365struct ocfs2_local_alloc
366{
367/*00*/ __le32 la_bm_off; /* Starting bit offset in main bitmap */
368 __le16 la_size; /* Size of included bitmap, in bytes */
369 __le16 la_reserved1;
370 __le64 la_reserved2;
371/*10*/ __u8 la_bitmap[0];
372};
373
374/*
375 * On disk inode for OCFS2
376 */
377struct ocfs2_dinode {
378/*00*/ __u8 i_signature[8]; /* Signature for validation */
379 __le32 i_generation; /* Generation number */
380 __le16 i_suballoc_slot; /* Slot suballocator this inode
381 belongs to */
382 __le16 i_suballoc_bit; /* Bit offset in suballocator
383 block group */
384/*10*/ __le32 i_reserved0;
385 __le32 i_clusters; /* Cluster count */
386 __le32 i_uid; /* Owner UID */
387 __le32 i_gid; /* Owning GID */
388/*20*/ __le64 i_size; /* Size in bytes */
389 __le16 i_mode; /* File mode */
390 __le16 i_links_count; /* Links count */
391 __le32 i_flags; /* File flags */
392/*30*/ __le64 i_atime; /* Access time */
393 __le64 i_ctime; /* Creation time */
394/*40*/ __le64 i_mtime; /* Modification time */
395 __le64 i_dtime; /* Deletion time */
396/*50*/ __le64 i_blkno; /* Offset on disk, in blocks */
397 __le64 i_last_eb_blk; /* Pointer to last extent
398 block */
399/*60*/ __le32 i_fs_generation; /* Generation per fs-instance */
400 __le32 i_atime_nsec;
401 __le32 i_ctime_nsec;
402 __le32 i_mtime_nsec;
403/*70*/ __le64 i_reserved1[9];
404/*B8*/ union {
405 __le64 i_pad1; /* Generic way to refer to this
406 64bit union */
407 struct {
408 __le64 i_rdev; /* Device number */
409 } dev1;
410 struct { /* Info for bitmap system
411 inodes */
412 __le32 i_used; /* Bits (ie, clusters) used */
413 __le32 i_total; /* Total bits (clusters)
414 available */
415 } bitmap1;
416 struct { /* Info for journal system
417 inodes */
418 __le32 ij_flags; /* Mounted, version, etc. */
419 __le32 ij_pad;
420 } journal1;
421 } id1; /* Inode type dependant 1 */
422/*C0*/ union {
423 struct ocfs2_super_block i_super;
424 struct ocfs2_local_alloc i_lab;
425 struct ocfs2_chain_list i_chain;
426 struct ocfs2_extent_list i_list;
427 struct ocfs2_truncate_log i_dealloc;
428 __u8 i_symlink[0];
429 } id2;
430/* Actual on-disk size is one block */
431};
432
433/*
434 * On-disk directory entry structure for OCFS2
435 *
436 * Packed as this structure could be accessed unaligned on 64-bit platforms
437 */
438struct ocfs2_dir_entry {
439/*00*/ __le64 inode; /* Inode number */
440 __le16 rec_len; /* Directory entry length */
441 __u8 name_len; /* Name length */
442 __u8 file_type;
443/*0C*/ char name[OCFS2_MAX_FILENAME_LEN]; /* File name */
444/* Actual on-disk length specified by rec_len */
445} __attribute__ ((packed));
446
447/*
448 * On disk allocator group structure for OCFS2
449 */
450struct ocfs2_group_desc
451{
452/*00*/ __u8 bg_signature[8]; /* Signature for validation */
453 __le16 bg_size; /* Size of included bitmap in
454 bytes. */
455 __le16 bg_bits; /* Bits represented by this
456 group. */
457 __le16 bg_free_bits_count; /* Free bits count */
458 __le16 bg_chain; /* What chain I am in. */
459/*10*/ __le32 bg_generation;
460 __le32 bg_reserved1;
461 __le64 bg_next_group; /* Next group in my list, in
462 blocks */
463/*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in
464 blocks */
465 __le64 bg_blkno; /* Offset on disk, in blocks */
466/*30*/ __le64 bg_reserved2[2];
467/*40*/ __u8 bg_bitmap[0];
468};
469
470#ifdef __KERNEL__
471static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
472{
473 return sb->s_blocksize -
474 offsetof(struct ocfs2_dinode, id2.i_symlink);
475}
476
477static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
478{
479 int size;
480
481 size = sb->s_blocksize -
482 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
483
484 return size / sizeof(struct ocfs2_extent_rec);
485}
486
487static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
488{
489 int size;
490
491 size = sb->s_blocksize -
492 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
493
494 return size / sizeof(struct ocfs2_chain_rec);
495}
496
497static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
498{
499 int size;
500
501 size = sb->s_blocksize -
502 offsetof(struct ocfs2_extent_block, h_list.l_recs);
503
504 return size / sizeof(struct ocfs2_extent_rec);
505}
506
507static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
508{
509 u16 size;
510
511 size = sb->s_blocksize -
512 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
513
514 return size;
515}
516
517static inline int ocfs2_group_bitmap_size(struct super_block *sb)
518{
519 int size;
520
521 size = sb->s_blocksize -
522 offsetof(struct ocfs2_group_desc, bg_bitmap);
523
524 return size;
525}
526
527static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
528{
529 int size;
530
531 size = sb->s_blocksize -
532 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
533
534 return size / sizeof(struct ocfs2_truncate_rec);
535}
536#else
537static inline int ocfs2_fast_symlink_chars(int blocksize)
538{
539 return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
540}
541
542static inline int ocfs2_extent_recs_per_inode(int blocksize)
543{
544 int size;
545
546 size = blocksize -
547 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
548
549 return size / sizeof(struct ocfs2_extent_rec);
550}
551
552static inline int ocfs2_chain_recs_per_inode(int blocksize)
553{
554 int size;
555
556 size = blocksize -
557 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
558
559 return size / sizeof(struct ocfs2_chain_rec);
560}
561
562static inline int ocfs2_extent_recs_per_eb(int blocksize)
563{
564 int size;
565
566 size = blocksize -
567 offsetof(struct ocfs2_extent_block, h_list.l_recs);
568
569 return size / sizeof(struct ocfs2_extent_rec);
570}
571
572static inline int ocfs2_local_alloc_size(int blocksize)
573{
574 int size;
575
576 size = blocksize -
577 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
578
579 return size;
580}
581
582static inline int ocfs2_group_bitmap_size(int blocksize)
583{
584 int size;
585
586 size = blocksize -
587 offsetof(struct ocfs2_group_desc, bg_bitmap);
588
589 return size;
590}
591
592static inline int ocfs2_truncate_recs_per_inode(int blocksize)
593{
594 int size;
595
596 size = blocksize -
597 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
598
599 return size / sizeof(struct ocfs2_truncate_rec);
600}
601#endif /* __KERNEL__ */
602
603
604static inline int ocfs2_system_inode_is_global(int type)
605{
606 return ((type >= 0) &&
607 (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
608}
609
610static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
611 int type, int slot)
612{
613 int chars;
614
615 /*
616 * Global system inodes can only have one copy. Everything
617 * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
618 * list has a copy per slot.
619 */
620 if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
621 chars = snprintf(buf, len,
622 ocfs2_system_inodes[type].si_name);
623 else
624 chars = snprintf(buf, len,
625 ocfs2_system_inodes[type].si_name,
626 slot);
627
628 return chars;
629}
630
631static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
632 umode_t mode)
633{
634 de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
635}
636
637#endif /* _OCFS2_FS_H */
638