ocfs2: Use own splice write actor
[deliverable/linux.git] / fs / ocfs2 / ocfs2_fs.h
CommitLineData
ccd979bd
MF
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
50af94b1 88#define OCFS2_FEATURE_COMPAT_SUPP OCFS2_FEATURE_COMPAT_BACKUP_SB
dcd0538f
MF
89#define OCFS2_FEATURE_INCOMPAT_SUPP (OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT \
90 | OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC)
ccd979bd
MF
91#define OCFS2_FEATURE_RO_COMPAT_SUPP 0
92
93/*
94 * Heartbeat-only devices are missing journals and other files. The
95 * filesystem driver can't load them, but the library can. Never put
96 * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*.
97 */
98#define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002
99
8903901d
MF
100/*
101 * tunefs sets this incompat flag before starting the resize and clears it
102 * at the end. This flag protects users from inadvertently mounting the fs
103 * after an aborted run without fsck-ing.
104 */
105#define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG 0x0004
ccd979bd 106
c271c5c2
SM
107/* Used to denote a non-clustered volume */
108#define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 0x0008
109
8903901d
MF
110/* Support for sparse allocation in b-trees */
111#define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010
112
50af94b1
MF
113/*
114 * backup superblock flag is used to indicate that this volume
115 * has backup superblocks.
116 */
117#define OCFS2_FEATURE_COMPAT_BACKUP_SB 0x0001
118
119/* The byte offset of the first backup block will be 1G.
120 * The following will be 4G, 16G, 64G, 256G and 1T.
121 */
122#define OCFS2_BACKUP_SB_START 1 << 30
123
124/* the max backup superblock nums */
125#define OCFS2_MAX_BACKUP_SUPERBLOCKS 6
126
ccd979bd
MF
127/*
128 * Flags on ocfs2_dinode.i_flags
129 */
130#define OCFS2_VALID_FL (0x00000001) /* Inode is valid */
131#define OCFS2_UNUSED2_FL (0x00000002)
132#define OCFS2_ORPHANED_FL (0x00000004) /* On the orphan list */
133#define OCFS2_UNUSED3_FL (0x00000008)
134/* System inode flags */
135#define OCFS2_SYSTEM_FL (0x00000010) /* System inode */
136#define OCFS2_SUPER_BLOCK_FL (0x00000020) /* Super block */
137#define OCFS2_LOCAL_ALLOC_FL (0x00000040) /* Slot local alloc bitmap */
138#define OCFS2_BITMAP_FL (0x00000080) /* Allocation bitmap */
139#define OCFS2_JOURNAL_FL (0x00000100) /* Slot local journal */
140#define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */
141#define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */
142#define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */
143
ca4d147e
HP
144/* Inode attributes, keep in sync with EXT2 */
145#define OCFS2_SECRM_FL (0x00000001) /* Secure deletion */
146#define OCFS2_UNRM_FL (0x00000002) /* Undelete */
147#define OCFS2_COMPR_FL (0x00000004) /* Compress file */
148#define OCFS2_SYNC_FL (0x00000008) /* Synchronous updates */
149#define OCFS2_IMMUTABLE_FL (0x00000010) /* Immutable file */
150#define OCFS2_APPEND_FL (0x00000020) /* writes to file may only append */
151#define OCFS2_NODUMP_FL (0x00000040) /* do not dump file */
152#define OCFS2_NOATIME_FL (0x00000080) /* do not update atime */
153#define OCFS2_DIRSYNC_FL (0x00010000) /* dirsync behaviour (directories only) */
154
155#define OCFS2_FL_VISIBLE (0x000100FF) /* User visible flags */
156#define OCFS2_FL_MODIFIABLE (0x000100FF) /* User modifiable flags */
157
158/*
159 * ioctl commands
160 */
161#define OCFS2_IOC_GETFLAGS _IOR('f', 1, long)
162#define OCFS2_IOC_SETFLAGS _IOW('f', 2, long)
163
ccd979bd
MF
164/*
165 * Journal Flags (ocfs2_dinode.id1.journal1.i_flags)
166 */
167#define OCFS2_JOURNAL_DIRTY_FL (0x00000001) /* Journal needs recovery */
168
169/*
170 * superblock s_state flags
171 */
172#define OCFS2_ERROR_FS (0x00000001) /* FS saw errors */
173
174/* Limit of space in ocfs2_dir_entry */
175#define OCFS2_MAX_FILENAME_LEN 255
176
177/* Maximum slots on an ocfs2 file system */
178#define OCFS2_MAX_SLOTS 255
179
180/* Slot map indicator for an empty slot */
181#define OCFS2_INVALID_SLOT -1
182
183#define OCFS2_VOL_UUID_LEN 16
184#define OCFS2_MAX_VOL_LABEL_LEN 64
185
186/* Journal limits (in bytes) */
187#define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024)
ccd979bd
MF
188
189struct ocfs2_system_inode_info {
190 char *si_name;
191 int si_iflags;
192 int si_mode;
193};
194
195/* System file index */
196enum {
197 BAD_BLOCK_SYSTEM_INODE = 0,
198 GLOBAL_INODE_ALLOC_SYSTEM_INODE,
199 SLOT_MAP_SYSTEM_INODE,
200#define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
201 HEARTBEAT_SYSTEM_INODE,
202 GLOBAL_BITMAP_SYSTEM_INODE,
203#define OCFS2_LAST_GLOBAL_SYSTEM_INODE GLOBAL_BITMAP_SYSTEM_INODE
204 ORPHAN_DIR_SYSTEM_INODE,
205 EXTENT_ALLOC_SYSTEM_INODE,
206 INODE_ALLOC_SYSTEM_INODE,
207 JOURNAL_SYSTEM_INODE,
208 LOCAL_ALLOC_SYSTEM_INODE,
209 TRUNCATE_LOG_SYSTEM_INODE,
210 NUM_SYSTEM_INODES
211};
212
213static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
214 /* Global system inodes (single copy) */
215 /* The first two are only used from userspace mfks/tunefs */
216 [BAD_BLOCK_SYSTEM_INODE] = { "bad_blocks", 0, S_IFREG | 0644 },
217 [GLOBAL_INODE_ALLOC_SYSTEM_INODE] = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
218
219 /* These are used by the running filesystem */
220 [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 },
221 [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
222 [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 },
223
224 /* Slot-specific system inodes (one copy per slot) */
225 [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
226 [EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
227 [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
228 [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
229 [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
230 [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 }
231};
232
233/* Parameter passed from mount.ocfs2 to module */
234#define OCFS2_HB_NONE "heartbeat=none"
235#define OCFS2_HB_LOCAL "heartbeat=local"
236
237/*
238 * OCFS2 directory file types. Only the low 3 bits are used. The
239 * other bits are reserved for now.
240 */
241#define OCFS2_FT_UNKNOWN 0
242#define OCFS2_FT_REG_FILE 1
243#define OCFS2_FT_DIR 2
244#define OCFS2_FT_CHRDEV 3
245#define OCFS2_FT_BLKDEV 4
246#define OCFS2_FT_FIFO 5
247#define OCFS2_FT_SOCK 6
248#define OCFS2_FT_SYMLINK 7
249
250#define OCFS2_FT_MAX 8
251
252/*
253 * OCFS2_DIR_PAD defines the directory entries boundaries
254 *
255 * NOTE: It must be a multiple of 4
256 */
257#define OCFS2_DIR_PAD 4
258#define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1)
259#define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name)
260#define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \
261 OCFS2_DIR_ROUND) & \
262 ~OCFS2_DIR_ROUND)
263
264#define OCFS2_LINK_MAX 32000
265
266#define S_SHIFT 12
267static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = {
268 [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE,
269 [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR,
270 [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV,
271 [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV,
272 [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO,
273 [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK,
274 [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK,
275};
276
277
278/*
279 * Convenience casts
280 */
281#define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
282
283/*
284 * On disk extent record for OCFS2
285 * It describes a range of clusters on disk.
286 */
287struct ocfs2_extent_rec {
288/*00*/ __le32 e_cpos; /* Offset into the file, in clusters */
289 __le32 e_clusters; /* Clusters covered by this extent */
290 __le64 e_blkno; /* Physical disk offset, in blocks */
291/*10*/
292};
293
294struct ocfs2_chain_rec {
295 __le32 c_free; /* Number of free bits in this chain. */
296 __le32 c_total; /* Number of total bits in this chain */
297 __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */
298};
299
300struct ocfs2_truncate_rec {
301 __le32 t_start; /* 1st cluster in this log */
302 __le32 t_clusters; /* Number of total clusters covered */
303};
304
305/*
306 * On disk extent list for OCFS2 (node in the tree). Note that this
307 * is contained inside ocfs2_dinode or ocfs2_extent_block, so the
308 * offsets are relative to ocfs2_dinode.id2.i_list or
309 * ocfs2_extent_block.h_list, respectively.
310 */
311struct ocfs2_extent_list {
312/*00*/ __le16 l_tree_depth; /* Extent tree depth from this
313 point. 0 means data extents
314 hang directly off this
dcd0538f
MF
315 header (a leaf)
316 NOTE: The high 8 bits cannot be
317 used - tree_depth is never that big.
318 */
ccd979bd
MF
319 __le16 l_count; /* Number of extent records */
320 __le16 l_next_free_rec; /* Next unused extent slot */
321 __le16 l_reserved1;
322 __le64 l_reserved2; /* Pad to
323 sizeof(ocfs2_extent_rec) */
324/*10*/ struct ocfs2_extent_rec l_recs[0]; /* Extent records */
325};
326
327/*
328 * On disk allocation chain list for OCFS2. Note that this is
329 * contained inside ocfs2_dinode, so the offsets are relative to
330 * ocfs2_dinode.id2.i_chain.
331 */
332struct ocfs2_chain_list {
333/*00*/ __le16 cl_cpg; /* Clusters per Block Group */
334 __le16 cl_bpc; /* Bits per cluster */
335 __le16 cl_count; /* Total chains in this list */
336 __le16 cl_next_free_rec; /* Next unused chain slot */
337 __le64 cl_reserved1;
338/*10*/ struct ocfs2_chain_rec cl_recs[0]; /* Chain records */
339};
340
341/*
342 * On disk deallocation log for OCFS2. Note that this is
343 * contained inside ocfs2_dinode, so the offsets are relative to
344 * ocfs2_dinode.id2.i_dealloc.
345 */
346struct ocfs2_truncate_log {
347/*00*/ __le16 tl_count; /* Total records in this log */
348 __le16 tl_used; /* Number of records in use */
349 __le32 tl_reserved1;
350/*08*/ struct ocfs2_truncate_rec tl_recs[0]; /* Truncate records */
351};
352
353/*
354 * On disk extent block (indirect block) for OCFS2
355 */
356struct ocfs2_extent_block
357{
358/*00*/ __u8 h_signature[8]; /* Signature for verification */
359 __le64 h_reserved1;
360/*10*/ __le16 h_suballoc_slot; /* Slot suballocator this
361 extent_header belongs to */
362 __le16 h_suballoc_bit; /* Bit offset in suballocator
363 block group */
364 __le32 h_fs_generation; /* Must match super block */
365 __le64 h_blkno; /* Offset on disk, in blocks */
366/*20*/ __le64 h_reserved3;
367 __le64 h_next_leaf_blk; /* Offset on disk, in blocks,
368 of next leaf header pointing
369 to data */
370/*30*/ struct ocfs2_extent_list h_list; /* Extent record list */
371/* Actual on-disk size is one block */
372};
373
374/*
375 * On disk superblock for OCFS2
376 * Note that it is contained inside an ocfs2_dinode, so all offsets
377 * are relative to the start of ocfs2_dinode.id2.
378 */
379struct ocfs2_super_block {
380/*00*/ __le16 s_major_rev_level;
381 __le16 s_minor_rev_level;
382 __le16 s_mnt_count;
383 __le16 s_max_mnt_count;
384 __le16 s_state; /* File system state */
385 __le16 s_errors; /* Behaviour when detecting errors */
386 __le32 s_checkinterval; /* Max time between checks */
387/*10*/ __le64 s_lastcheck; /* Time of last check */
388 __le32 s_creator_os; /* OS */
389 __le32 s_feature_compat; /* Compatible feature set */
390/*20*/ __le32 s_feature_incompat; /* Incompatible feature set */
391 __le32 s_feature_ro_compat; /* Readonly-compatible feature set */
392 __le64 s_root_blkno; /* Offset, in blocks, of root directory
393 dinode */
394/*30*/ __le64 s_system_dir_blkno; /* Offset, in blocks, of system
395 directory dinode */
396 __le32 s_blocksize_bits; /* Blocksize for this fs */
397 __le32 s_clustersize_bits; /* Clustersize for this fs */
398/*40*/ __le16 s_max_slots; /* Max number of simultaneous mounts
399 before tunefs required */
400 __le16 s_reserved1;
401 __le32 s_reserved2;
402 __le64 s_first_cluster_group; /* Block offset of 1st cluster
403 * group header */
404/*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */
405/*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */
406/*A0*/
407};
408
409/*
410 * Local allocation bitmap for OCFS2 slots
411 * Note that it exists inside an ocfs2_dinode, so all offsets are
412 * relative to the start of ocfs2_dinode.id2.
413 */
414struct ocfs2_local_alloc
415{
416/*00*/ __le32 la_bm_off; /* Starting bit offset in main bitmap */
417 __le16 la_size; /* Size of included bitmap, in bytes */
418 __le16 la_reserved1;
419 __le64 la_reserved2;
420/*10*/ __u8 la_bitmap[0];
421};
422
423/*
424 * On disk inode for OCFS2
425 */
426struct ocfs2_dinode {
427/*00*/ __u8 i_signature[8]; /* Signature for validation */
428 __le32 i_generation; /* Generation number */
429 __le16 i_suballoc_slot; /* Slot suballocator this inode
430 belongs to */
431 __le16 i_suballoc_bit; /* Bit offset in suballocator
432 block group */
433/*10*/ __le32 i_reserved0;
434 __le32 i_clusters; /* Cluster count */
435 __le32 i_uid; /* Owner UID */
436 __le32 i_gid; /* Owning GID */
437/*20*/ __le64 i_size; /* Size in bytes */
438 __le16 i_mode; /* File mode */
439 __le16 i_links_count; /* Links count */
440 __le32 i_flags; /* File flags */
441/*30*/ __le64 i_atime; /* Access time */
442 __le64 i_ctime; /* Creation time */
443/*40*/ __le64 i_mtime; /* Modification time */
444 __le64 i_dtime; /* Deletion time */
445/*50*/ __le64 i_blkno; /* Offset on disk, in blocks */
446 __le64 i_last_eb_blk; /* Pointer to last extent
447 block */
448/*60*/ __le32 i_fs_generation; /* Generation per fs-instance */
449 __le32 i_atime_nsec;
450 __le32 i_ctime_nsec;
451 __le32 i_mtime_nsec;
ca4d147e 452 __le32 i_attr;
50008630
TY
453 __le16 i_orphaned_slot; /* Only valid when OCFS2_ORPHANED_FL
454 was set in i_flags */
455 __le16 i_reserved1;
ca4d147e 456/*70*/ __le64 i_reserved2[8];
ccd979bd
MF
457/*B8*/ union {
458 __le64 i_pad1; /* Generic way to refer to this
459 64bit union */
460 struct {
461 __le64 i_rdev; /* Device number */
462 } dev1;
463 struct { /* Info for bitmap system
464 inodes */
465 __le32 i_used; /* Bits (ie, clusters) used */
466 __le32 i_total; /* Total bits (clusters)
467 available */
468 } bitmap1;
469 struct { /* Info for journal system
470 inodes */
471 __le32 ij_flags; /* Mounted, version, etc. */
472 __le32 ij_pad;
473 } journal1;
474 } id1; /* Inode type dependant 1 */
475/*C0*/ union {
476 struct ocfs2_super_block i_super;
477 struct ocfs2_local_alloc i_lab;
478 struct ocfs2_chain_list i_chain;
479 struct ocfs2_extent_list i_list;
480 struct ocfs2_truncate_log i_dealloc;
481 __u8 i_symlink[0];
482 } id2;
483/* Actual on-disk size is one block */
484};
485
486/*
487 * On-disk directory entry structure for OCFS2
488 *
489 * Packed as this structure could be accessed unaligned on 64-bit platforms
490 */
491struct ocfs2_dir_entry {
492/*00*/ __le64 inode; /* Inode number */
493 __le16 rec_len; /* Directory entry length */
494 __u8 name_len; /* Name length */
495 __u8 file_type;
496/*0C*/ char name[OCFS2_MAX_FILENAME_LEN]; /* File name */
497/* Actual on-disk length specified by rec_len */
498} __attribute__ ((packed));
499
500/*
501 * On disk allocator group structure for OCFS2
502 */
503struct ocfs2_group_desc
504{
505/*00*/ __u8 bg_signature[8]; /* Signature for validation */
506 __le16 bg_size; /* Size of included bitmap in
507 bytes. */
508 __le16 bg_bits; /* Bits represented by this
509 group. */
510 __le16 bg_free_bits_count; /* Free bits count */
511 __le16 bg_chain; /* What chain I am in. */
512/*10*/ __le32 bg_generation;
513 __le32 bg_reserved1;
514 __le64 bg_next_group; /* Next group in my list, in
515 blocks */
516/*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in
517 blocks */
518 __le64 bg_blkno; /* Offset on disk, in blocks */
519/*30*/ __le64 bg_reserved2[2];
520/*40*/ __u8 bg_bitmap[0];
521};
522
523#ifdef __KERNEL__
524static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
525{
526 return sb->s_blocksize -
527 offsetof(struct ocfs2_dinode, id2.i_symlink);
528}
529
530static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
531{
532 int size;
533
534 size = sb->s_blocksize -
535 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
536
537 return size / sizeof(struct ocfs2_extent_rec);
538}
539
540static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
541{
542 int size;
543
544 size = sb->s_blocksize -
545 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
546
547 return size / sizeof(struct ocfs2_chain_rec);
548}
549
550static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
551{
552 int size;
553
554 size = sb->s_blocksize -
555 offsetof(struct ocfs2_extent_block, h_list.l_recs);
556
557 return size / sizeof(struct ocfs2_extent_rec);
558}
559
560static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
561{
562 u16 size;
563
564 size = sb->s_blocksize -
565 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
566
567 return size;
568}
569
570static inline int ocfs2_group_bitmap_size(struct super_block *sb)
571{
572 int size;
573
574 size = sb->s_blocksize -
575 offsetof(struct ocfs2_group_desc, bg_bitmap);
576
577 return size;
578}
579
580static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
581{
582 int size;
583
584 size = sb->s_blocksize -
585 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
586
587 return size / sizeof(struct ocfs2_truncate_rec);
588}
50af94b1
MF
589
590static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
591{
592 u64 offset = OCFS2_BACKUP_SB_START;
593
594 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
595 offset <<= (2 * index);
a8a75a20 596 offset >>= sb->s_blocksize_bits;
50af94b1
MF
597 return offset;
598 }
599
600 return 0;
601
602}
ccd979bd
MF
603#else
604static inline int ocfs2_fast_symlink_chars(int blocksize)
605{
606 return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
607}
608
609static inline int ocfs2_extent_recs_per_inode(int blocksize)
610{
611 int size;
612
613 size = blocksize -
614 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
615
616 return size / sizeof(struct ocfs2_extent_rec);
617}
618
619static inline int ocfs2_chain_recs_per_inode(int blocksize)
620{
621 int size;
622
623 size = blocksize -
624 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
625
626 return size / sizeof(struct ocfs2_chain_rec);
627}
628
629static inline int ocfs2_extent_recs_per_eb(int blocksize)
630{
631 int size;
632
633 size = blocksize -
634 offsetof(struct ocfs2_extent_block, h_list.l_recs);
635
636 return size / sizeof(struct ocfs2_extent_rec);
637}
638
639static inline int ocfs2_local_alloc_size(int blocksize)
640{
641 int size;
642
643 size = blocksize -
644 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
645
646 return size;
647}
648
649static inline int ocfs2_group_bitmap_size(int blocksize)
650{
651 int size;
652
653 size = blocksize -
654 offsetof(struct ocfs2_group_desc, bg_bitmap);
655
656 return size;
657}
658
659static inline int ocfs2_truncate_recs_per_inode(int blocksize)
660{
661 int size;
662
663 size = blocksize -
664 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
665
666 return size / sizeof(struct ocfs2_truncate_rec);
667}
50af94b1
MF
668
669static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
670{
671 uint64_t offset = OCFS2_BACKUP_SB_START;
672
673 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
674 offset <<= (2 * index);
675 offset /= blocksize;
676 return offset;
677 }
678
679 return 0;
680}
ccd979bd
MF
681#endif /* __KERNEL__ */
682
683
684static inline int ocfs2_system_inode_is_global(int type)
685{
686 return ((type >= 0) &&
687 (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
688}
689
690static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
691 int type, int slot)
692{
693 int chars;
694
695 /*
696 * Global system inodes can only have one copy. Everything
697 * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
698 * list has a copy per slot.
699 */
700 if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
701 chars = snprintf(buf, len,
702 ocfs2_system_inodes[type].si_name);
703 else
704 chars = snprintf(buf, len,
705 ocfs2_system_inodes[type].si_name,
706 slot);
707
708 return chars;
709}
710
711static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
712 umode_t mode)
713{
714 de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
715}
716
717#endif /* _OCFS2_FS_H */
718
This page took 0.294779 seconds and 5 git commands to generate.