diff options
author | Christoph Hellwig <hch@lst.de> | 2013-04-21 15:53:46 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-04-21 15:53:46 -0400 |
commit | ee1a47ab0e77600fcbdf1c87d461bd8f3f63150d (patch) | |
tree | 6340d9f4b8b53c0d18045da1372599645375efce /fs/xfs/xfs_btree.h | |
parent | a2050646f655a90400cbb66c3866d2e0137eee0c (diff) |
xfs: add support for large btree blocks
Add support for larger btree blocks that contains a CRC32C checksum,
a filesystem uuid and block number for detecting filesystem
consistency and out of place writes.
[dchinner@redhat.com] Also include an owner field to allow reverse
mappings to be implemented for improved repairability and a LSN
field to so that log recovery can easily determine the last
modification that made it to disk for each buffer.
[dchinner@redhat.com] Add buffer log format flags to indicate the
type of buffer to recovery so that we don't have to do blind magic
number tests to determine what the buffer is.
[dchinner@redhat.com] Modified to fit into the verifier structure.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_btree.h')
-rw-r--r-- | fs/xfs/xfs_btree.h | 64 |
1 files changed, 55 insertions, 9 deletions
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h index f932897194eb..6e6c915673fe 100644 --- a/fs/xfs/xfs_btree.h +++ b/fs/xfs/xfs_btree.h | |||
@@ -42,11 +42,15 @@ extern kmem_zone_t *xfs_btree_cur_zone; | |||
42 | * Generic btree header. | 42 | * Generic btree header. |
43 | * | 43 | * |
44 | * This is a combination of the actual format used on disk for short and long | 44 | * This is a combination of the actual format used on disk for short and long |
45 | * format btrees. The first three fields are shared by both format, but | 45 | * format btrees. The first three fields are shared by both format, but the |
46 | * the pointers are different and should be used with care. | 46 | * pointers are different and should be used with care. |
47 | * | 47 | * |
48 | * To get the size of the actual short or long form headers please use | 48 | * To get the size of the actual short or long form headers please use the size |
49 | * the size macros below. Never use sizeof(xfs_btree_block). | 49 | * macros below. Never use sizeof(xfs_btree_block). |
50 | * | ||
51 | * The blkno, crc, lsn, owner and uuid fields are only available in filesystems | ||
52 | * with the crc feature bit, and all accesses to them must be conditional on | ||
53 | * that flag. | ||
50 | */ | 54 | */ |
51 | struct xfs_btree_block { | 55 | struct xfs_btree_block { |
52 | __be32 bb_magic; /* magic number for block type */ | 56 | __be32 bb_magic; /* magic number for block type */ |
@@ -56,10 +60,23 @@ struct xfs_btree_block { | |||
56 | struct { | 60 | struct { |
57 | __be32 bb_leftsib; | 61 | __be32 bb_leftsib; |
58 | __be32 bb_rightsib; | 62 | __be32 bb_rightsib; |
63 | |||
64 | __be64 bb_blkno; | ||
65 | __be64 bb_lsn; | ||
66 | uuid_t bb_uuid; | ||
67 | __be32 bb_owner; | ||
68 | __le32 bb_crc; | ||
59 | } s; /* short form pointers */ | 69 | } s; /* short form pointers */ |
60 | struct { | 70 | struct { |
61 | __be64 bb_leftsib; | 71 | __be64 bb_leftsib; |
62 | __be64 bb_rightsib; | 72 | __be64 bb_rightsib; |
73 | |||
74 | __be64 bb_blkno; | ||
75 | __be64 bb_lsn; | ||
76 | uuid_t bb_uuid; | ||
77 | __be64 bb_owner; | ||
78 | __le32 bb_crc; | ||
79 | __be32 bb_pad; /* padding for alignment */ | ||
63 | } l; /* long form pointers */ | 80 | } l; /* long form pointers */ |
64 | } bb_u; /* rest */ | 81 | } bb_u; /* rest */ |
65 | }; | 82 | }; |
@@ -67,6 +84,16 @@ struct xfs_btree_block { | |||
67 | #define XFS_BTREE_SBLOCK_LEN 16 /* size of a short form block */ | 84 | #define XFS_BTREE_SBLOCK_LEN 16 /* size of a short form block */ |
68 | #define XFS_BTREE_LBLOCK_LEN 24 /* size of a long form block */ | 85 | #define XFS_BTREE_LBLOCK_LEN 24 /* size of a long form block */ |
69 | 86 | ||
87 | /* sizes of CRC enabled btree blocks */ | ||
88 | #define XFS_BTREE_SBLOCK_CRC_LEN (XFS_BTREE_SBLOCK_LEN + 40) | ||
89 | #define XFS_BTREE_LBLOCK_CRC_LEN (XFS_BTREE_LBLOCK_LEN + 48) | ||
90 | |||
91 | |||
92 | #define XFS_BTREE_SBLOCK_CRC_OFF \ | ||
93 | offsetof(struct xfs_btree_block, bb_u.s.bb_crc) | ||
94 | #define XFS_BTREE_LBLOCK_CRC_OFF \ | ||
95 | offsetof(struct xfs_btree_block, bb_u.l.bb_crc) | ||
96 | |||
70 | 97 | ||
71 | /* | 98 | /* |
72 | * Generic key, ptr and record wrapper structures. | 99 | * Generic key, ptr and record wrapper structures. |
@@ -101,13 +128,11 @@ union xfs_btree_rec { | |||
101 | #define XFS_BB_NUMRECS 0x04 | 128 | #define XFS_BB_NUMRECS 0x04 |
102 | #define XFS_BB_LEFTSIB 0x08 | 129 | #define XFS_BB_LEFTSIB 0x08 |
103 | #define XFS_BB_RIGHTSIB 0x10 | 130 | #define XFS_BB_RIGHTSIB 0x10 |
131 | #define XFS_BB_BLKNO 0x20 | ||
104 | #define XFS_BB_NUM_BITS 5 | 132 | #define XFS_BB_NUM_BITS 5 |
105 | #define XFS_BB_ALL_BITS ((1 << XFS_BB_NUM_BITS) - 1) | 133 | #define XFS_BB_ALL_BITS ((1 << XFS_BB_NUM_BITS) - 1) |
106 | 134 | #define XFS_BB_NUM_BITS_CRC 8 | |
107 | /* | 135 | #define XFS_BB_ALL_BITS_CRC ((1 << XFS_BB_NUM_BITS_CRC) - 1) |
108 | * Magic numbers for btree blocks. | ||
109 | */ | ||
110 | extern const __uint32_t xfs_magics[]; | ||
111 | 136 | ||
112 | /* | 137 | /* |
113 | * Generic stats interface | 138 | * Generic stats interface |
@@ -256,6 +281,7 @@ typedef struct xfs_btree_cur | |||
256 | #define XFS_BTREE_LONG_PTRS (1<<0) /* pointers are 64bits long */ | 281 | #define XFS_BTREE_LONG_PTRS (1<<0) /* pointers are 64bits long */ |
257 | #define XFS_BTREE_ROOT_IN_INODE (1<<1) /* root may be variable size */ | 282 | #define XFS_BTREE_ROOT_IN_INODE (1<<1) /* root may be variable size */ |
258 | #define XFS_BTREE_LASTREC_UPDATE (1<<2) /* track last rec externally */ | 283 | #define XFS_BTREE_LASTREC_UPDATE (1<<2) /* track last rec externally */ |
284 | #define XFS_BTREE_CRC_BLOCKS (1<<3) /* uses extended btree blocks */ | ||
259 | 285 | ||
260 | 286 | ||
261 | #define XFS_BTREE_NOERROR 0 | 287 | #define XFS_BTREE_NOERROR 0 |
@@ -393,8 +419,20 @@ xfs_btree_init_block( | |||
393 | __u32 magic, | 419 | __u32 magic, |
394 | __u16 level, | 420 | __u16 level, |
395 | __u16 numrecs, | 421 | __u16 numrecs, |
422 | __u64 owner, | ||
396 | unsigned int flags); | 423 | unsigned int flags); |
397 | 424 | ||
425 | void | ||
426 | xfs_btree_init_block_int( | ||
427 | struct xfs_mount *mp, | ||
428 | struct xfs_btree_block *buf, | ||
429 | xfs_daddr_t blkno, | ||
430 | __u32 magic, | ||
431 | __u16 level, | ||
432 | __u16 numrecs, | ||
433 | __u64 owner, | ||
434 | unsigned int flags); | ||
435 | |||
398 | /* | 436 | /* |
399 | * Common btree core entry points. | 437 | * Common btree core entry points. |
400 | */ | 438 | */ |
@@ -408,6 +446,14 @@ int xfs_btree_delete(struct xfs_btree_cur *, int *); | |||
408 | int xfs_btree_get_rec(struct xfs_btree_cur *, union xfs_btree_rec **, int *); | 446 | int xfs_btree_get_rec(struct xfs_btree_cur *, union xfs_btree_rec **, int *); |
409 | 447 | ||
410 | /* | 448 | /* |
449 | * btree block CRC helpers | ||
450 | */ | ||
451 | void xfs_btree_lblock_calc_crc(struct xfs_buf *); | ||
452 | bool xfs_btree_lblock_verify_crc(struct xfs_buf *); | ||
453 | void xfs_btree_sblock_calc_crc(struct xfs_buf *); | ||
454 | bool xfs_btree_sblock_verify_crc(struct xfs_buf *); | ||
455 | |||
456 | /* | ||
411 | * Internal btree helpers also used by xfs_bmap.c. | 457 | * Internal btree helpers also used by xfs_bmap.c. |
412 | */ | 458 | */ |
413 | void xfs_btree_log_block(struct xfs_btree_cur *, struct xfs_buf *, int); | 459 | void xfs_btree_log_block(struct xfs_btree_cur *, struct xfs_buf *, int); |