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>
This commit is contained in:

committed by
Ben Myers

parent
a2050646f6
commit
ee1a47ab0e
@@ -42,11 +42,15 @@ extern kmem_zone_t *xfs_btree_cur_zone;
|
||||
* Generic btree header.
|
||||
*
|
||||
* This is a combination of the actual format used on disk for short and long
|
||||
* format btrees. The first three fields are shared by both format, but
|
||||
* the pointers are different and should be used with care.
|
||||
* format btrees. The first three fields are shared by both format, but the
|
||||
* pointers are different and should be used with care.
|
||||
*
|
||||
* To get the size of the actual short or long form headers please use
|
||||
* the size macros below. Never use sizeof(xfs_btree_block).
|
||||
* To get the size of the actual short or long form headers please use the size
|
||||
* macros below. Never use sizeof(xfs_btree_block).
|
||||
*
|
||||
* The blkno, crc, lsn, owner and uuid fields are only available in filesystems
|
||||
* with the crc feature bit, and all accesses to them must be conditional on
|
||||
* that flag.
|
||||
*/
|
||||
struct xfs_btree_block {
|
||||
__be32 bb_magic; /* magic number for block type */
|
||||
@@ -56,10 +60,23 @@ struct xfs_btree_block {
|
||||
struct {
|
||||
__be32 bb_leftsib;
|
||||
__be32 bb_rightsib;
|
||||
|
||||
__be64 bb_blkno;
|
||||
__be64 bb_lsn;
|
||||
uuid_t bb_uuid;
|
||||
__be32 bb_owner;
|
||||
__le32 bb_crc;
|
||||
} s; /* short form pointers */
|
||||
struct {
|
||||
__be64 bb_leftsib;
|
||||
__be64 bb_rightsib;
|
||||
|
||||
__be64 bb_blkno;
|
||||
__be64 bb_lsn;
|
||||
uuid_t bb_uuid;
|
||||
__be64 bb_owner;
|
||||
__le32 bb_crc;
|
||||
__be32 bb_pad; /* padding for alignment */
|
||||
} l; /* long form pointers */
|
||||
} bb_u; /* rest */
|
||||
};
|
||||
@@ -67,6 +84,16 @@ struct xfs_btree_block {
|
||||
#define XFS_BTREE_SBLOCK_LEN 16 /* size of a short form block */
|
||||
#define XFS_BTREE_LBLOCK_LEN 24 /* size of a long form block */
|
||||
|
||||
/* sizes of CRC enabled btree blocks */
|
||||
#define XFS_BTREE_SBLOCK_CRC_LEN (XFS_BTREE_SBLOCK_LEN + 40)
|
||||
#define XFS_BTREE_LBLOCK_CRC_LEN (XFS_BTREE_LBLOCK_LEN + 48)
|
||||
|
||||
|
||||
#define XFS_BTREE_SBLOCK_CRC_OFF \
|
||||
offsetof(struct xfs_btree_block, bb_u.s.bb_crc)
|
||||
#define XFS_BTREE_LBLOCK_CRC_OFF \
|
||||
offsetof(struct xfs_btree_block, bb_u.l.bb_crc)
|
||||
|
||||
|
||||
/*
|
||||
* Generic key, ptr and record wrapper structures.
|
||||
@@ -101,13 +128,11 @@ union xfs_btree_rec {
|
||||
#define XFS_BB_NUMRECS 0x04
|
||||
#define XFS_BB_LEFTSIB 0x08
|
||||
#define XFS_BB_RIGHTSIB 0x10
|
||||
#define XFS_BB_BLKNO 0x20
|
||||
#define XFS_BB_NUM_BITS 5
|
||||
#define XFS_BB_ALL_BITS ((1 << XFS_BB_NUM_BITS) - 1)
|
||||
|
||||
/*
|
||||
* Magic numbers for btree blocks.
|
||||
*/
|
||||
extern const __uint32_t xfs_magics[];
|
||||
#define XFS_BB_NUM_BITS_CRC 8
|
||||
#define XFS_BB_ALL_BITS_CRC ((1 << XFS_BB_NUM_BITS_CRC) - 1)
|
||||
|
||||
/*
|
||||
* Generic stats interface
|
||||
@@ -256,6 +281,7 @@ typedef struct xfs_btree_cur
|
||||
#define XFS_BTREE_LONG_PTRS (1<<0) /* pointers are 64bits long */
|
||||
#define XFS_BTREE_ROOT_IN_INODE (1<<1) /* root may be variable size */
|
||||
#define XFS_BTREE_LASTREC_UPDATE (1<<2) /* track last rec externally */
|
||||
#define XFS_BTREE_CRC_BLOCKS (1<<3) /* uses extended btree blocks */
|
||||
|
||||
|
||||
#define XFS_BTREE_NOERROR 0
|
||||
@@ -393,8 +419,20 @@ xfs_btree_init_block(
|
||||
__u32 magic,
|
||||
__u16 level,
|
||||
__u16 numrecs,
|
||||
__u64 owner,
|
||||
unsigned int flags);
|
||||
|
||||
void
|
||||
xfs_btree_init_block_int(
|
||||
struct xfs_mount *mp,
|
||||
struct xfs_btree_block *buf,
|
||||
xfs_daddr_t blkno,
|
||||
__u32 magic,
|
||||
__u16 level,
|
||||
__u16 numrecs,
|
||||
__u64 owner,
|
||||
unsigned int flags);
|
||||
|
||||
/*
|
||||
* Common btree core entry points.
|
||||
*/
|
||||
@@ -407,6 +445,14 @@ int xfs_btree_insert(struct xfs_btree_cur *, int *);
|
||||
int xfs_btree_delete(struct xfs_btree_cur *, int *);
|
||||
int xfs_btree_get_rec(struct xfs_btree_cur *, union xfs_btree_rec **, int *);
|
||||
|
||||
/*
|
||||
* btree block CRC helpers
|
||||
*/
|
||||
void xfs_btree_lblock_calc_crc(struct xfs_buf *);
|
||||
bool xfs_btree_lblock_verify_crc(struct xfs_buf *);
|
||||
void xfs_btree_sblock_calc_crc(struct xfs_buf *);
|
||||
bool xfs_btree_sblock_verify_crc(struct xfs_buf *);
|
||||
|
||||
/*
|
||||
* Internal btree helpers also used by xfs_bmap.c.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user