diff options
-rw-r--r-- | fs/xfs/xfs_alloc.c | 23 | ||||
-rw-r--r-- | fs/xfs/xfs_alloc_btree.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_alloc_btree.h | 18 | ||||
-rw-r--r-- | fs/xfs/xfs_bmap.c | 71 | ||||
-rw-r--r-- | fs/xfs/xfs_bmap_btree.c | 14 | ||||
-rw-r--r-- | fs/xfs/xfs_bmap_btree.h | 23 | ||||
-rw-r--r-- | fs/xfs/xfs_btree.c | 81 | ||||
-rw-r--r-- | fs/xfs/xfs_btree.h | 53 | ||||
-rw-r--r-- | fs/xfs/xfs_dinode.h | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_fsops.c | 20 | ||||
-rw-r--r-- | fs/xfs/xfs_ialloc_btree.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_ialloc_btree.h | 19 | ||||
-rw-r--r-- | fs/xfs/xfs_inode.c | 13 | ||||
-rw-r--r-- | fs/xfs/xfs_inode.h | 3 | ||||
-rw-r--r-- | fs/xfs/xfs_log_recover.c | 8 |
15 files changed, 165 insertions, 187 deletions
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c index 0a2a87208b17..c47ce9075728 100644 --- a/fs/xfs/xfs_alloc.c +++ b/fs/xfs/xfs_alloc.c | |||
@@ -380,21 +380,20 @@ xfs_alloc_fixup_trees( | |||
380 | return error; | 380 | return error; |
381 | XFS_WANT_CORRUPTED_RETURN(i == 1); | 381 | XFS_WANT_CORRUPTED_RETURN(i == 1); |
382 | } | 382 | } |
383 | |||
383 | #ifdef DEBUG | 384 | #ifdef DEBUG |
384 | { | 385 | if (bno_cur->bc_nlevels == 1 && cnt_cur->bc_nlevels == 1) { |
385 | xfs_alloc_block_t *bnoblock; | 386 | struct xfs_btree_block *bnoblock; |
386 | xfs_alloc_block_t *cntblock; | 387 | struct xfs_btree_block *cntblock; |
387 | 388 | ||
388 | if (bno_cur->bc_nlevels == 1 && | 389 | bnoblock = XFS_BUF_TO_BLOCK(bno_cur->bc_bufs[0]); |
389 | cnt_cur->bc_nlevels == 1) { | 390 | cntblock = XFS_BUF_TO_BLOCK(cnt_cur->bc_bufs[0]); |
390 | bnoblock = XFS_BUF_TO_ALLOC_BLOCK(bno_cur->bc_bufs[0]); | 391 | |
391 | cntblock = XFS_BUF_TO_ALLOC_BLOCK(cnt_cur->bc_bufs[0]); | 392 | XFS_WANT_CORRUPTED_RETURN( |
392 | XFS_WANT_CORRUPTED_RETURN( | 393 | bnoblock->bb_numrecs == cntblock->bb_numrecs); |
393 | be16_to_cpu(bnoblock->bb_numrecs) == | ||
394 | be16_to_cpu(cntblock->bb_numrecs)); | ||
395 | } | ||
396 | } | 394 | } |
397 | #endif | 395 | #endif |
396 | |||
398 | /* | 397 | /* |
399 | * Deal with all four cases: the allocated record is contained | 398 | * Deal with all four cases: the allocated record is contained |
400 | * within the freespace record, so we can have new freespace | 399 | * within the freespace record, so we can have new freespace |
diff --git a/fs/xfs/xfs_alloc_btree.c b/fs/xfs/xfs_alloc_btree.c index 72c083f62a94..733cb75a8c5d 100644 --- a/fs/xfs/xfs_alloc_btree.c +++ b/fs/xfs/xfs_alloc_btree.c | |||
@@ -490,7 +490,7 @@ xfs_allocbt_maxrecs( | |||
490 | int blocklen, | 490 | int blocklen, |
491 | int leaf) | 491 | int leaf) |
492 | { | 492 | { |
493 | blocklen -= sizeof(struct xfs_btree_sblock); | 493 | blocklen -= XFS_ALLOC_BLOCK_LEN(mp); |
494 | 494 | ||
495 | if (leaf) | 495 | if (leaf) |
496 | return blocklen / sizeof(xfs_alloc_rec_t); | 496 | return blocklen / sizeof(xfs_alloc_rec_t); |
diff --git a/fs/xfs/xfs_alloc_btree.h b/fs/xfs/xfs_alloc_btree.h index 579f9c7e0872..a6caa0022c9b 100644 --- a/fs/xfs/xfs_alloc_btree.h +++ b/fs/xfs/xfs_alloc_btree.h | |||
@@ -24,7 +24,6 @@ | |||
24 | 24 | ||
25 | struct xfs_buf; | 25 | struct xfs_buf; |
26 | struct xfs_btree_cur; | 26 | struct xfs_btree_cur; |
27 | struct xfs_btree_sblock; | ||
28 | struct xfs_mount; | 27 | struct xfs_mount; |
29 | 28 | ||
30 | /* | 29 | /* |
@@ -50,10 +49,6 @@ typedef struct xfs_alloc_rec_incore { | |||
50 | 49 | ||
51 | /* btree pointer type */ | 50 | /* btree pointer type */ |
52 | typedef __be32 xfs_alloc_ptr_t; | 51 | typedef __be32 xfs_alloc_ptr_t; |
53 | /* btree block header type */ | ||
54 | typedef struct xfs_btree_sblock xfs_alloc_block_t; | ||
55 | |||
56 | #define XFS_BUF_TO_ALLOC_BLOCK(bp) ((xfs_alloc_block_t *)XFS_BUF_PTR(bp)) | ||
57 | 52 | ||
58 | /* | 53 | /* |
59 | * Minimum and maximum blocksize and sectorsize. | 54 | * Minimum and maximum blocksize and sectorsize. |
@@ -77,6 +72,13 @@ typedef struct xfs_btree_sblock xfs_alloc_block_t; | |||
77 | #define XFS_CNT_BLOCK(mp) ((xfs_agblock_t)(XFS_BNO_BLOCK(mp) + 1)) | 72 | #define XFS_CNT_BLOCK(mp) ((xfs_agblock_t)(XFS_BNO_BLOCK(mp) + 1)) |
78 | 73 | ||
79 | /* | 74 | /* |
75 | * Btree block header size depends on a superblock flag. | ||
76 | * | ||
77 | * (not quite yet, but soon) | ||
78 | */ | ||
79 | #define XFS_ALLOC_BLOCK_LEN(mp) XFS_BTREE_SBLOCK_LEN | ||
80 | |||
81 | /* | ||
80 | * Record, key, and pointer address macros for btree blocks. | 82 | * Record, key, and pointer address macros for btree blocks. |
81 | * | 83 | * |
82 | * (note that some of these may appear unused, but they are used in userspace) | 84 | * (note that some of these may appear unused, but they are used in userspace) |
@@ -84,19 +86,19 @@ typedef struct xfs_btree_sblock xfs_alloc_block_t; | |||
84 | #define XFS_ALLOC_REC_ADDR(mp, block, index) \ | 86 | #define XFS_ALLOC_REC_ADDR(mp, block, index) \ |
85 | ((xfs_alloc_rec_t *) \ | 87 | ((xfs_alloc_rec_t *) \ |
86 | ((char *)(block) + \ | 88 | ((char *)(block) + \ |
87 | sizeof(struct xfs_btree_sblock) + \ | 89 | XFS_ALLOC_BLOCK_LEN(mp) + \ |
88 | (((index) - 1) * sizeof(xfs_alloc_rec_t)))) | 90 | (((index) - 1) * sizeof(xfs_alloc_rec_t)))) |
89 | 91 | ||
90 | #define XFS_ALLOC_KEY_ADDR(mp, block, index) \ | 92 | #define XFS_ALLOC_KEY_ADDR(mp, block, index) \ |
91 | ((xfs_alloc_key_t *) \ | 93 | ((xfs_alloc_key_t *) \ |
92 | ((char *)(block) + \ | 94 | ((char *)(block) + \ |
93 | sizeof(struct xfs_btree_sblock) + \ | 95 | XFS_ALLOC_BLOCK_LEN(mp) + \ |
94 | ((index) - 1) * sizeof(xfs_alloc_key_t))) | 96 | ((index) - 1) * sizeof(xfs_alloc_key_t))) |
95 | 97 | ||
96 | #define XFS_ALLOC_PTR_ADDR(mp, block, index, maxrecs) \ | 98 | #define XFS_ALLOC_PTR_ADDR(mp, block, index, maxrecs) \ |
97 | ((xfs_alloc_ptr_t *) \ | 99 | ((xfs_alloc_ptr_t *) \ |
98 | ((char *)(block) + \ | 100 | ((char *)(block) + \ |
99 | sizeof(struct xfs_btree_sblock) + \ | 101 | XFS_ALLOC_BLOCK_LEN(mp) + \ |
100 | (maxrecs) * sizeof(xfs_alloc_key_t) + \ | 102 | (maxrecs) * sizeof(xfs_alloc_key_t) + \ |
101 | ((index) - 1) * sizeof(xfs_alloc_ptr_t))) | 103 | ((index) - 1) * sizeof(xfs_alloc_ptr_t))) |
102 | 104 | ||
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index 3dab937d4b85..7796a0c140eb 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -394,7 +394,7 @@ xfs_bmap_count_leaves( | |||
394 | STATIC void | 394 | STATIC void |
395 | xfs_bmap_disk_count_leaves( | 395 | xfs_bmap_disk_count_leaves( |
396 | struct xfs_mount *mp, | 396 | struct xfs_mount *mp, |
397 | xfs_bmbt_block_t *block, | 397 | struct xfs_btree_block *block, |
398 | int numrecs, | 398 | int numrecs, |
399 | int *count); | 399 | int *count); |
400 | 400 | ||
@@ -3042,14 +3042,14 @@ xfs_bmap_btree_to_extents( | |||
3042 | int whichfork) /* data or attr fork */ | 3042 | int whichfork) /* data or attr fork */ |
3043 | { | 3043 | { |
3044 | /* REFERENCED */ | 3044 | /* REFERENCED */ |
3045 | xfs_bmbt_block_t *cblock;/* child btree block */ | 3045 | struct xfs_btree_block *cblock;/* child btree block */ |
3046 | xfs_fsblock_t cbno; /* child block number */ | 3046 | xfs_fsblock_t cbno; /* child block number */ |
3047 | xfs_buf_t *cbp; /* child block's buffer */ | 3047 | xfs_buf_t *cbp; /* child block's buffer */ |
3048 | int error; /* error return value */ | 3048 | int error; /* error return value */ |
3049 | xfs_ifork_t *ifp; /* inode fork data */ | 3049 | xfs_ifork_t *ifp; /* inode fork data */ |
3050 | xfs_mount_t *mp; /* mount point structure */ | 3050 | xfs_mount_t *mp; /* mount point structure */ |
3051 | __be64 *pp; /* ptr to block address */ | 3051 | __be64 *pp; /* ptr to block address */ |
3052 | xfs_bmbt_block_t *rblock;/* root btree block */ | 3052 | struct xfs_btree_block *rblock;/* root btree block */ |
3053 | 3053 | ||
3054 | mp = ip->i_mount; | 3054 | mp = ip->i_mount; |
3055 | ifp = XFS_IFORK_PTR(ip, whichfork); | 3055 | ifp = XFS_IFORK_PTR(ip, whichfork); |
@@ -3069,8 +3069,8 @@ xfs_bmap_btree_to_extents( | |||
3069 | if ((error = xfs_btree_read_bufl(mp, tp, cbno, 0, &cbp, | 3069 | if ((error = xfs_btree_read_bufl(mp, tp, cbno, 0, &cbp, |
3070 | XFS_BMAP_BTREE_REF))) | 3070 | XFS_BMAP_BTREE_REF))) |
3071 | return error; | 3071 | return error; |
3072 | cblock = XFS_BUF_TO_BMBT_BLOCK(cbp); | 3072 | cblock = XFS_BUF_TO_BLOCK(cbp); |
3073 | if ((error = xfs_btree_check_lblock(cur, cblock, 0, cbp))) | 3073 | if ((error = xfs_btree_check_block(cur, cblock, 0, cbp))) |
3074 | return error; | 3074 | return error; |
3075 | xfs_bmap_add_free(cbno, 1, cur->bc_private.b.flist, mp); | 3075 | xfs_bmap_add_free(cbno, 1, cur->bc_private.b.flist, mp); |
3076 | ip->i_d.di_nblocks--; | 3076 | ip->i_d.di_nblocks--; |
@@ -3450,11 +3450,11 @@ xfs_bmap_extents_to_btree( | |||
3450 | int *logflagsp, /* inode logging flags */ | 3450 | int *logflagsp, /* inode logging flags */ |
3451 | int whichfork) /* data or attr fork */ | 3451 | int whichfork) /* data or attr fork */ |
3452 | { | 3452 | { |
3453 | xfs_bmbt_block_t *ablock; /* allocated (child) bt block */ | 3453 | struct xfs_btree_block *ablock; /* allocated (child) bt block */ |
3454 | xfs_buf_t *abp; /* buffer for ablock */ | 3454 | xfs_buf_t *abp; /* buffer for ablock */ |
3455 | xfs_alloc_arg_t args; /* allocation arguments */ | 3455 | xfs_alloc_arg_t args; /* allocation arguments */ |
3456 | xfs_bmbt_rec_t *arp; /* child record pointer */ | 3456 | xfs_bmbt_rec_t *arp; /* child record pointer */ |
3457 | xfs_bmbt_block_t *block; /* btree root block */ | 3457 | struct xfs_btree_block *block; /* btree root block */ |
3458 | xfs_btree_cur_t *cur; /* bmap btree cursor */ | 3458 | xfs_btree_cur_t *cur; /* bmap btree cursor */ |
3459 | xfs_bmbt_rec_host_t *ep; /* extent record pointer */ | 3459 | xfs_bmbt_rec_host_t *ep; /* extent record pointer */ |
3460 | int error; /* error return value */ | 3460 | int error; /* error return value */ |
@@ -3474,6 +3474,7 @@ xfs_bmap_extents_to_btree( | |||
3474 | */ | 3474 | */ |
3475 | xfs_iroot_realloc(ip, 1, whichfork); | 3475 | xfs_iroot_realloc(ip, 1, whichfork); |
3476 | ifp->if_flags |= XFS_IFBROOT; | 3476 | ifp->if_flags |= XFS_IFBROOT; |
3477 | |||
3477 | /* | 3478 | /* |
3478 | * Fill in the root. | 3479 | * Fill in the root. |
3479 | */ | 3480 | */ |
@@ -3481,8 +3482,9 @@ xfs_bmap_extents_to_btree( | |||
3481 | block->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); | 3482 | block->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); |
3482 | block->bb_level = cpu_to_be16(1); | 3483 | block->bb_level = cpu_to_be16(1); |
3483 | block->bb_numrecs = cpu_to_be16(1); | 3484 | block->bb_numrecs = cpu_to_be16(1); |
3484 | block->bb_leftsib = cpu_to_be64(NULLDFSBNO); | 3485 | block->bb_u.l.bb_leftsib = cpu_to_be64(NULLDFSBNO); |
3485 | block->bb_rightsib = cpu_to_be64(NULLDFSBNO); | 3486 | block->bb_u.l.bb_rightsib = cpu_to_be64(NULLDFSBNO); |
3487 | |||
3486 | /* | 3488 | /* |
3487 | * Need a cursor. Can't allocate until bb_level is filled in. | 3489 | * Need a cursor. Can't allocate until bb_level is filled in. |
3488 | */ | 3490 | */ |
@@ -3534,11 +3536,11 @@ xfs_bmap_extents_to_btree( | |||
3534 | /* | 3536 | /* |
3535 | * Fill in the child block. | 3537 | * Fill in the child block. |
3536 | */ | 3538 | */ |
3537 | ablock = XFS_BUF_TO_BMBT_BLOCK(abp); | 3539 | ablock = XFS_BUF_TO_BLOCK(abp); |
3538 | ablock->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); | 3540 | ablock->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); |
3539 | ablock->bb_level = 0; | 3541 | ablock->bb_level = 0; |
3540 | ablock->bb_leftsib = cpu_to_be64(NULLDFSBNO); | 3542 | ablock->bb_u.l.bb_leftsib = cpu_to_be64(NULLDFSBNO); |
3541 | ablock->bb_rightsib = cpu_to_be64(NULLDFSBNO); | 3543 | ablock->bb_u.l.bb_rightsib = cpu_to_be64(NULLDFSBNO); |
3542 | arp = XFS_BMBT_REC_ADDR(mp, ablock, 1); | 3544 | arp = XFS_BMBT_REC_ADDR(mp, ablock, 1); |
3543 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | 3545 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); |
3544 | for (cnt = i = 0; i < nextents; i++) { | 3546 | for (cnt = i = 0; i < nextents; i++) { |
@@ -3550,7 +3552,8 @@ xfs_bmap_extents_to_btree( | |||
3550 | } | 3552 | } |
3551 | } | 3553 | } |
3552 | ASSERT(cnt == XFS_IFORK_NEXTENTS(ip, whichfork)); | 3554 | ASSERT(cnt == XFS_IFORK_NEXTENTS(ip, whichfork)); |
3553 | ablock->bb_numrecs = cpu_to_be16(cnt); | 3555 | xfs_btree_set_numrecs(ablock, cnt); |
3556 | |||
3554 | /* | 3557 | /* |
3555 | * Fill in the root key and pointer. | 3558 | * Fill in the root key and pointer. |
3556 | */ | 3559 | */ |
@@ -4533,7 +4536,7 @@ xfs_bmap_read_extents( | |||
4533 | xfs_inode_t *ip, /* incore inode */ | 4536 | xfs_inode_t *ip, /* incore inode */ |
4534 | int whichfork) /* data or attr fork */ | 4537 | int whichfork) /* data or attr fork */ |
4535 | { | 4538 | { |
4536 | xfs_bmbt_block_t *block; /* current btree block */ | 4539 | struct xfs_btree_block *block; /* current btree block */ |
4537 | xfs_fsblock_t bno; /* block # of "block" */ | 4540 | xfs_fsblock_t bno; /* block # of "block" */ |
4538 | xfs_buf_t *bp; /* buffer for "block" */ | 4541 | xfs_buf_t *bp; /* buffer for "block" */ |
4539 | int error; /* error return value */ | 4542 | int error; /* error return value */ |
@@ -4570,7 +4573,7 @@ xfs_bmap_read_extents( | |||
4570 | if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, | 4573 | if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, |
4571 | XFS_BMAP_BTREE_REF))) | 4574 | XFS_BMAP_BTREE_REF))) |
4572 | return error; | 4575 | return error; |
4573 | block = XFS_BUF_TO_BMBT_BLOCK(bp); | 4576 | block = XFS_BUF_TO_BLOCK(bp); |
4574 | XFS_WANT_CORRUPTED_GOTO( | 4577 | XFS_WANT_CORRUPTED_GOTO( |
4575 | XFS_BMAP_SANITY_CHECK(mp, block, level), | 4578 | XFS_BMAP_SANITY_CHECK(mp, block, level), |
4576 | error0); | 4579 | error0); |
@@ -4596,7 +4599,7 @@ xfs_bmap_read_extents( | |||
4596 | xfs_extnum_t start; | 4599 | xfs_extnum_t start; |
4597 | 4600 | ||
4598 | 4601 | ||
4599 | num_recs = be16_to_cpu(block->bb_numrecs); | 4602 | num_recs = xfs_btree_get_numrecs(block); |
4600 | if (unlikely(i + num_recs > room)) { | 4603 | if (unlikely(i + num_recs > room)) { |
4601 | ASSERT(i + num_recs <= room); | 4604 | ASSERT(i + num_recs <= room); |
4602 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, | 4605 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, |
@@ -4613,7 +4616,7 @@ xfs_bmap_read_extents( | |||
4613 | /* | 4616 | /* |
4614 | * Read-ahead the next leaf block, if any. | 4617 | * Read-ahead the next leaf block, if any. |
4615 | */ | 4618 | */ |
4616 | nextbno = be64_to_cpu(block->bb_rightsib); | 4619 | nextbno = be64_to_cpu(block->bb_u.l.bb_rightsib); |
4617 | if (nextbno != NULLFSBLOCK) | 4620 | if (nextbno != NULLFSBLOCK) |
4618 | xfs_btree_reada_bufl(mp, nextbno, 1); | 4621 | xfs_btree_reada_bufl(mp, nextbno, 1); |
4619 | /* | 4622 | /* |
@@ -4650,7 +4653,7 @@ xfs_bmap_read_extents( | |||
4650 | if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, | 4653 | if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, |
4651 | XFS_BMAP_BTREE_REF))) | 4654 | XFS_BMAP_BTREE_REF))) |
4652 | return error; | 4655 | return error; |
4653 | block = XFS_BUF_TO_BMBT_BLOCK(bp); | 4656 | block = XFS_BUF_TO_BLOCK(bp); |
4654 | } | 4657 | } |
4655 | ASSERT(i == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))); | 4658 | ASSERT(i == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))); |
4656 | ASSERT(i == XFS_IFORK_NEXTENTS(ip, whichfork)); | 4659 | ASSERT(i == XFS_IFORK_NEXTENTS(ip, whichfork)); |
@@ -6175,7 +6178,7 @@ xfs_bmap_get_bp( | |||
6175 | 6178 | ||
6176 | void | 6179 | void |
6177 | xfs_check_block( | 6180 | xfs_check_block( |
6178 | xfs_bmbt_block_t *block, | 6181 | struct xfs_btree_block *block, |
6179 | xfs_mount_t *mp, | 6182 | xfs_mount_t *mp, |
6180 | int root, | 6183 | int root, |
6181 | short sz) | 6184 | short sz) |
@@ -6187,7 +6190,7 @@ xfs_check_block( | |||
6187 | ASSERT(be16_to_cpu(block->bb_level) > 0); | 6190 | ASSERT(be16_to_cpu(block->bb_level) > 0); |
6188 | 6191 | ||
6189 | prevp = NULL; | 6192 | prevp = NULL; |
6190 | for( i = 1; i <= be16_to_cpu(block->bb_numrecs); i++) { | 6193 | for( i = 1; i <= xfs_btree_get_numrecs(block); i++) { |
6191 | dmxr = mp->m_bmap_dmxr[0]; | 6194 | dmxr = mp->m_bmap_dmxr[0]; |
6192 | keyp = XFS_BMBT_KEY_ADDR(mp, block, i); | 6195 | keyp = XFS_BMBT_KEY_ADDR(mp, block, i); |
6193 | 6196 | ||
@@ -6232,7 +6235,7 @@ xfs_bmap_check_leaf_extents( | |||
6232 | xfs_inode_t *ip, /* incore inode pointer */ | 6235 | xfs_inode_t *ip, /* incore inode pointer */ |
6233 | int whichfork) /* data or attr fork */ | 6236 | int whichfork) /* data or attr fork */ |
6234 | { | 6237 | { |
6235 | xfs_bmbt_block_t *block; /* current btree block */ | 6238 | struct xfs_btree_block *block; /* current btree block */ |
6236 | xfs_fsblock_t bno; /* block # of "block" */ | 6239 | xfs_fsblock_t bno; /* block # of "block" */ |
6237 | xfs_buf_t *bp; /* buffer for "block" */ | 6240 | xfs_buf_t *bp; /* buffer for "block" */ |
6238 | int error; /* error return value */ | 6241 | int error; /* error return value */ |
@@ -6282,7 +6285,7 @@ xfs_bmap_check_leaf_extents( | |||
6282 | if (!bp && (error = xfs_btree_read_bufl(mp, NULL, bno, 0, &bp, | 6285 | if (!bp && (error = xfs_btree_read_bufl(mp, NULL, bno, 0, &bp, |
6283 | XFS_BMAP_BTREE_REF))) | 6286 | XFS_BMAP_BTREE_REF))) |
6284 | goto error_norelse; | 6287 | goto error_norelse; |
6285 | block = XFS_BUF_TO_BMBT_BLOCK(bp); | 6288 | block = XFS_BUF_TO_BLOCK(bp); |
6286 | XFS_WANT_CORRUPTED_GOTO( | 6289 | XFS_WANT_CORRUPTED_GOTO( |
6287 | XFS_BMAP_SANITY_CHECK(mp, block, level), | 6290 | XFS_BMAP_SANITY_CHECK(mp, block, level), |
6288 | error0); | 6291 | error0); |
@@ -6317,13 +6320,13 @@ xfs_bmap_check_leaf_extents( | |||
6317 | xfs_extnum_t num_recs; | 6320 | xfs_extnum_t num_recs; |
6318 | 6321 | ||
6319 | 6322 | ||
6320 | num_recs = be16_to_cpu(block->bb_numrecs); | 6323 | num_recs = xfs_btree_get_numrecs(block); |
6321 | 6324 | ||
6322 | /* | 6325 | /* |
6323 | * Read-ahead the next leaf block, if any. | 6326 | * Read-ahead the next leaf block, if any. |
6324 | */ | 6327 | */ |
6325 | 6328 | ||
6326 | nextbno = be64_to_cpu(block->bb_rightsib); | 6329 | nextbno = be64_to_cpu(block->bb_u.l.bb_rightsib); |
6327 | 6330 | ||
6328 | /* | 6331 | /* |
6329 | * Check all the extents to make sure they are OK. | 6332 | * Check all the extents to make sure they are OK. |
@@ -6367,7 +6370,7 @@ xfs_bmap_check_leaf_extents( | |||
6367 | if (!bp && (error = xfs_btree_read_bufl(mp, NULL, bno, 0, &bp, | 6370 | if (!bp && (error = xfs_btree_read_bufl(mp, NULL, bno, 0, &bp, |
6368 | XFS_BMAP_BTREE_REF))) | 6371 | XFS_BMAP_BTREE_REF))) |
6369 | goto error_norelse; | 6372 | goto error_norelse; |
6370 | block = XFS_BUF_TO_BMBT_BLOCK(bp); | 6373 | block = XFS_BUF_TO_BLOCK(bp); |
6371 | } | 6374 | } |
6372 | if (bp_release) { | 6375 | if (bp_release) { |
6373 | bp_release = 0; | 6376 | bp_release = 0; |
@@ -6397,7 +6400,7 @@ xfs_bmap_count_blocks( | |||
6397 | int whichfork, /* data or attr fork */ | 6400 | int whichfork, /* data or attr fork */ |
6398 | int *count) /* out: count of blocks */ | 6401 | int *count) /* out: count of blocks */ |
6399 | { | 6402 | { |
6400 | xfs_bmbt_block_t *block; /* current btree block */ | 6403 | struct xfs_btree_block *block; /* current btree block */ |
6401 | xfs_fsblock_t bno; /* block # of "block" */ | 6404 | xfs_fsblock_t bno; /* block # of "block" */ |
6402 | xfs_ifork_t *ifp; /* fork structure */ | 6405 | xfs_ifork_t *ifp; /* fork structure */ |
6403 | int level; /* btree level, for checking */ | 6406 | int level; /* btree level, for checking */ |
@@ -6454,24 +6457,24 @@ xfs_bmap_count_tree( | |||
6454 | __be64 *pp; | 6457 | __be64 *pp; |
6455 | xfs_fsblock_t bno = blockno; | 6458 | xfs_fsblock_t bno = blockno; |
6456 | xfs_fsblock_t nextbno; | 6459 | xfs_fsblock_t nextbno; |
6457 | xfs_bmbt_block_t *block, *nextblock; | 6460 | struct xfs_btree_block *block, *nextblock; |
6458 | int numrecs; | 6461 | int numrecs; |
6459 | 6462 | ||
6460 | if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, XFS_BMAP_BTREE_REF))) | 6463 | if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, XFS_BMAP_BTREE_REF))) |
6461 | return error; | 6464 | return error; |
6462 | *count += 1; | 6465 | *count += 1; |
6463 | block = XFS_BUF_TO_BMBT_BLOCK(bp); | 6466 | block = XFS_BUF_TO_BLOCK(bp); |
6464 | 6467 | ||
6465 | if (--level) { | 6468 | if (--level) { |
6466 | /* Not at node above leafs, count this level of nodes */ | 6469 | /* Not at node above leafs, count this level of nodes */ |
6467 | nextbno = be64_to_cpu(block->bb_rightsib); | 6470 | nextbno = be64_to_cpu(block->bb_u.l.bb_rightsib); |
6468 | while (nextbno != NULLFSBLOCK) { | 6471 | while (nextbno != NULLFSBLOCK) { |
6469 | if ((error = xfs_btree_read_bufl(mp, tp, nextbno, | 6472 | if ((error = xfs_btree_read_bufl(mp, tp, nextbno, |
6470 | 0, &nbp, XFS_BMAP_BTREE_REF))) | 6473 | 0, &nbp, XFS_BMAP_BTREE_REF))) |
6471 | return error; | 6474 | return error; |
6472 | *count += 1; | 6475 | *count += 1; |
6473 | nextblock = XFS_BUF_TO_BMBT_BLOCK(nbp); | 6476 | nextblock = XFS_BUF_TO_BLOCK(nbp); |
6474 | nextbno = be64_to_cpu(nextblock->bb_rightsib); | 6477 | nextbno = be64_to_cpu(nextblock->bb_u.l.bb_rightsib); |
6475 | xfs_trans_brelse(tp, nbp); | 6478 | xfs_trans_brelse(tp, nbp); |
6476 | } | 6479 | } |
6477 | 6480 | ||
@@ -6489,7 +6492,7 @@ xfs_bmap_count_tree( | |||
6489 | } else { | 6492 | } else { |
6490 | /* count all level 1 nodes and their leaves */ | 6493 | /* count all level 1 nodes and their leaves */ |
6491 | for (;;) { | 6494 | for (;;) { |
6492 | nextbno = be64_to_cpu(block->bb_rightsib); | 6495 | nextbno = be64_to_cpu(block->bb_u.l.bb_rightsib); |
6493 | numrecs = be16_to_cpu(block->bb_numrecs); | 6496 | numrecs = be16_to_cpu(block->bb_numrecs); |
6494 | xfs_bmap_disk_count_leaves(mp, block, numrecs, count); | 6497 | xfs_bmap_disk_count_leaves(mp, block, numrecs, count); |
6495 | xfs_trans_brelse(tp, bp); | 6498 | xfs_trans_brelse(tp, bp); |
@@ -6500,7 +6503,7 @@ xfs_bmap_count_tree( | |||
6500 | XFS_BMAP_BTREE_REF))) | 6503 | XFS_BMAP_BTREE_REF))) |
6501 | return error; | 6504 | return error; |
6502 | *count += 1; | 6505 | *count += 1; |
6503 | block = XFS_BUF_TO_BMBT_BLOCK(bp); | 6506 | block = XFS_BUF_TO_BLOCK(bp); |
6504 | } | 6507 | } |
6505 | } | 6508 | } |
6506 | return 0; | 6509 | return 0; |
@@ -6531,7 +6534,7 @@ xfs_bmap_count_leaves( | |||
6531 | STATIC void | 6534 | STATIC void |
6532 | xfs_bmap_disk_count_leaves( | 6535 | xfs_bmap_disk_count_leaves( |
6533 | struct xfs_mount *mp, | 6536 | struct xfs_mount *mp, |
6534 | xfs_bmbt_block_t *block, | 6537 | struct xfs_btree_block *block, |
6535 | int numrecs, | 6538 | int numrecs, |
6536 | int *count) | 6539 | int *count) |
6537 | { | 6540 | { |
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c index 11137c042c94..e46e02b8e277 100644 --- a/fs/xfs/xfs_bmap_btree.c +++ b/fs/xfs/xfs_bmap_btree.c | |||
@@ -68,7 +68,7 @@ xfs_bmdr_to_bmbt( | |||
68 | struct xfs_mount *mp, | 68 | struct xfs_mount *mp, |
69 | xfs_bmdr_block_t *dblock, | 69 | xfs_bmdr_block_t *dblock, |
70 | int dblocklen, | 70 | int dblocklen, |
71 | xfs_bmbt_block_t *rblock, | 71 | struct xfs_btree_block *rblock, |
72 | int rblocklen) | 72 | int rblocklen) |
73 | { | 73 | { |
74 | int dmxr; | 74 | int dmxr; |
@@ -81,8 +81,8 @@ xfs_bmdr_to_bmbt( | |||
81 | rblock->bb_level = dblock->bb_level; | 81 | rblock->bb_level = dblock->bb_level; |
82 | ASSERT(be16_to_cpu(rblock->bb_level) > 0); | 82 | ASSERT(be16_to_cpu(rblock->bb_level) > 0); |
83 | rblock->bb_numrecs = dblock->bb_numrecs; | 83 | rblock->bb_numrecs = dblock->bb_numrecs; |
84 | rblock->bb_leftsib = cpu_to_be64(NULLDFSBNO); | 84 | rblock->bb_u.l.bb_leftsib = cpu_to_be64(NULLDFSBNO); |
85 | rblock->bb_rightsib = cpu_to_be64(NULLDFSBNO); | 85 | rblock->bb_u.l.bb_rightsib = cpu_to_be64(NULLDFSBNO); |
86 | dmxr = xfs_bmdr_maxrecs(mp, dblocklen, 0); | 86 | dmxr = xfs_bmdr_maxrecs(mp, dblocklen, 0); |
87 | fkp = XFS_BMDR_KEY_ADDR(dblock, 1); | 87 | fkp = XFS_BMDR_KEY_ADDR(dblock, 1); |
88 | tkp = XFS_BMBT_KEY_ADDR(mp, rblock, 1); | 88 | tkp = XFS_BMBT_KEY_ADDR(mp, rblock, 1); |
@@ -429,7 +429,7 @@ xfs_bmbt_set_state( | |||
429 | void | 429 | void |
430 | xfs_bmbt_to_bmdr( | 430 | xfs_bmbt_to_bmdr( |
431 | struct xfs_mount *mp, | 431 | struct xfs_mount *mp, |
432 | xfs_bmbt_block_t *rblock, | 432 | struct xfs_btree_block *rblock, |
433 | int rblocklen, | 433 | int rblocklen, |
434 | xfs_bmdr_block_t *dblock, | 434 | xfs_bmdr_block_t *dblock, |
435 | int dblocklen) | 435 | int dblocklen) |
@@ -441,8 +441,8 @@ xfs_bmbt_to_bmdr( | |||
441 | __be64 *tpp; | 441 | __be64 *tpp; |
442 | 442 | ||
443 | ASSERT(be32_to_cpu(rblock->bb_magic) == XFS_BMAP_MAGIC); | 443 | ASSERT(be32_to_cpu(rblock->bb_magic) == XFS_BMAP_MAGIC); |
444 | ASSERT(be64_to_cpu(rblock->bb_leftsib) == NULLDFSBNO); | 444 | ASSERT(be64_to_cpu(rblock->bb_u.l.bb_leftsib) == NULLDFSBNO); |
445 | ASSERT(be64_to_cpu(rblock->bb_rightsib) == NULLDFSBNO); | 445 | ASSERT(be64_to_cpu(rblock->bb_u.l.bb_rightsib) == NULLDFSBNO); |
446 | ASSERT(be16_to_cpu(rblock->bb_level) > 0); | 446 | ASSERT(be16_to_cpu(rblock->bb_level) > 0); |
447 | dblock->bb_level = rblock->bb_level; | 447 | dblock->bb_level = rblock->bb_level; |
448 | dblock->bb_numrecs = rblock->bb_numrecs; | 448 | dblock->bb_numrecs = rblock->bb_numrecs; |
@@ -906,7 +906,7 @@ xfs_bmbt_maxrecs( | |||
906 | int blocklen, | 906 | int blocklen, |
907 | int leaf) | 907 | int leaf) |
908 | { | 908 | { |
909 | blocklen -= sizeof(struct xfs_btree_lblock); | 909 | blocklen -= XFS_BMBT_BLOCK_LEN(mp); |
910 | 910 | ||
911 | if (leaf) | 911 | if (leaf) |
912 | return blocklen / sizeof(xfs_bmbt_rec_t); | 912 | return blocklen / sizeof(xfs_bmbt_rec_t); |
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h index 7f001072db47..735a42418c99 100644 --- a/fs/xfs/xfs_bmap_btree.h +++ b/fs/xfs/xfs_bmap_btree.h | |||
@@ -22,7 +22,6 @@ | |||
22 | 22 | ||
23 | struct xfs_btree_cur; | 23 | struct xfs_btree_cur; |
24 | struct xfs_btree_block; | 24 | struct xfs_btree_block; |
25 | struct xfs_btree_lblock; | ||
26 | struct xfs_mount; | 25 | struct xfs_mount; |
27 | struct xfs_inode; | 26 | struct xfs_inode; |
28 | struct xfs_trans; | 27 | struct xfs_trans; |
@@ -147,27 +146,29 @@ typedef struct xfs_bmbt_key { | |||
147 | /* btree pointer type */ | 146 | /* btree pointer type */ |
148 | typedef __be64 xfs_bmbt_ptr_t, xfs_bmdr_ptr_t; | 147 | typedef __be64 xfs_bmbt_ptr_t, xfs_bmdr_ptr_t; |
149 | 148 | ||
150 | /* btree block header type */ | 149 | /* |
151 | typedef struct xfs_btree_lblock xfs_bmbt_block_t; | 150 | * Btree block header size depends on a superblock flag. |
152 | 151 | * | |
153 | #define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)XFS_BUF_PTR(bp)) | 152 | * (not quite yet, but soon) |
153 | */ | ||
154 | #define XFS_BMBT_BLOCK_LEN(mp) XFS_BTREE_LBLOCK_LEN | ||
154 | 155 | ||
155 | #define XFS_BMBT_REC_ADDR(mp, block, index) \ | 156 | #define XFS_BMBT_REC_ADDR(mp, block, index) \ |
156 | ((xfs_bmbt_rec_t *) \ | 157 | ((xfs_bmbt_rec_t *) \ |
157 | ((char *)(block) + \ | 158 | ((char *)(block) + \ |
158 | sizeof(struct xfs_btree_lblock) + \ | 159 | XFS_BMBT_BLOCK_LEN(mp) + \ |
159 | ((index) - 1) * sizeof(xfs_bmbt_rec_t))) | 160 | ((index) - 1) * sizeof(xfs_bmbt_rec_t))) |
160 | 161 | ||
161 | #define XFS_BMBT_KEY_ADDR(mp, block, index) \ | 162 | #define XFS_BMBT_KEY_ADDR(mp, block, index) \ |
162 | ((xfs_bmbt_key_t *) \ | 163 | ((xfs_bmbt_key_t *) \ |
163 | ((char *)(block) + \ | 164 | ((char *)(block) + \ |
164 | sizeof(struct xfs_btree_lblock) + \ | 165 | XFS_BMBT_BLOCK_LEN(mp) + \ |
165 | ((index) - 1) * sizeof(xfs_bmbt_key_t))) | 166 | ((index) - 1) * sizeof(xfs_bmbt_key_t))) |
166 | 167 | ||
167 | #define XFS_BMBT_PTR_ADDR(mp, block, index, maxrecs) \ | 168 | #define XFS_BMBT_PTR_ADDR(mp, block, index, maxrecs) \ |
168 | ((xfs_bmbt_ptr_t *) \ | 169 | ((xfs_bmbt_ptr_t *) \ |
169 | ((char *)(block) + \ | 170 | ((char *)(block) + \ |
170 | sizeof(struct xfs_btree_lblock) + \ | 171 | XFS_BMBT_BLOCK_LEN(mp) + \ |
171 | (maxrecs) * sizeof(xfs_bmbt_key_t) + \ | 172 | (maxrecs) * sizeof(xfs_bmbt_key_t) + \ |
172 | ((index) - 1) * sizeof(xfs_bmbt_ptr_t))) | 173 | ((index) - 1) * sizeof(xfs_bmbt_ptr_t))) |
173 | 174 | ||
@@ -198,7 +199,7 @@ typedef struct xfs_btree_lblock xfs_bmbt_block_t; | |||
198 | XFS_BMBT_PTR_ADDR(mp, bb, i, xfs_bmbt_maxrecs(mp, sz, 0)) | 199 | XFS_BMBT_PTR_ADDR(mp, bb, i, xfs_bmbt_maxrecs(mp, sz, 0)) |
199 | 200 | ||
200 | #define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \ | 201 | #define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \ |
201 | (int)(sizeof(xfs_bmbt_block_t) + \ | 202 | (int)(XFS_BTREE_LBLOCK_LEN + \ |
202 | ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t)))) | 203 | ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t)))) |
203 | 204 | ||
204 | #define XFS_BMAP_BROOT_SPACE(bb) \ | 205 | #define XFS_BMAP_BROOT_SPACE(bb) \ |
@@ -223,7 +224,7 @@ typedef struct xfs_btree_lblock xfs_bmbt_block_t; | |||
223 | * Prototypes for xfs_bmap.c to call. | 224 | * Prototypes for xfs_bmap.c to call. |
224 | */ | 225 | */ |
225 | extern void xfs_bmdr_to_bmbt(struct xfs_mount *, xfs_bmdr_block_t *, int, | 226 | extern void xfs_bmdr_to_bmbt(struct xfs_mount *, xfs_bmdr_block_t *, int, |
226 | xfs_bmbt_block_t *, int); | 227 | struct xfs_btree_block *, int); |
227 | extern void xfs_bmbt_get_all(xfs_bmbt_rec_host_t *r, xfs_bmbt_irec_t *s); | 228 | extern void xfs_bmbt_get_all(xfs_bmbt_rec_host_t *r, xfs_bmbt_irec_t *s); |
228 | extern xfs_filblks_t xfs_bmbt_get_blockcount(xfs_bmbt_rec_host_t *r); | 229 | extern xfs_filblks_t xfs_bmbt_get_blockcount(xfs_bmbt_rec_host_t *r); |
229 | extern xfs_fsblock_t xfs_bmbt_get_startblock(xfs_bmbt_rec_host_t *r); | 230 | extern xfs_fsblock_t xfs_bmbt_get_startblock(xfs_bmbt_rec_host_t *r); |
@@ -246,7 +247,7 @@ extern void xfs_bmbt_disk_set_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s); | |||
246 | extern void xfs_bmbt_disk_set_allf(xfs_bmbt_rec_t *r, xfs_fileoff_t o, | 247 | extern void xfs_bmbt_disk_set_allf(xfs_bmbt_rec_t *r, xfs_fileoff_t o, |
247 | xfs_fsblock_t b, xfs_filblks_t c, xfs_exntst_t v); | 248 | xfs_fsblock_t b, xfs_filblks_t c, xfs_exntst_t v); |
248 | 249 | ||
249 | extern void xfs_bmbt_to_bmdr(struct xfs_mount *, xfs_bmbt_block_t *, int, | 250 | extern void xfs_bmbt_to_bmdr(struct xfs_mount *, struct xfs_btree_block *, int, |
250 | xfs_bmdr_block_t *, int); | 251 | xfs_bmdr_block_t *, int); |
251 | 252 | ||
252 | extern int xfs_bmbt_get_maxrecs(struct xfs_btree_cur *, int level); | 253 | extern int xfs_bmbt_get_maxrecs(struct xfs_btree_cur *, int level); |
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c index 72a26bb76430..7ed59267420d 100644 --- a/fs/xfs/xfs_btree.c +++ b/fs/xfs/xfs_btree.c | |||
@@ -53,10 +53,10 @@ const __uint32_t xfs_magics[XFS_BTNUM_MAX] = { | |||
53 | }; | 53 | }; |
54 | 54 | ||
55 | 55 | ||
56 | int /* error (0 or EFSCORRUPTED) */ | 56 | STATIC int /* error (0 or EFSCORRUPTED) */ |
57 | xfs_btree_check_lblock( | 57 | xfs_btree_check_lblock( |
58 | struct xfs_btree_cur *cur, /* btree cursor */ | 58 | struct xfs_btree_cur *cur, /* btree cursor */ |
59 | struct xfs_btree_lblock *block, /* btree long form block pointer */ | 59 | struct xfs_btree_block *block, /* btree long form block pointer */ |
60 | int level, /* level of the btree block */ | 60 | int level, /* level of the btree block */ |
61 | struct xfs_buf *bp) /* buffer for block, if any */ | 61 | struct xfs_buf *bp) /* buffer for block, if any */ |
62 | { | 62 | { |
@@ -69,12 +69,14 @@ xfs_btree_check_lblock( | |||
69 | be16_to_cpu(block->bb_level) == level && | 69 | be16_to_cpu(block->bb_level) == level && |
70 | be16_to_cpu(block->bb_numrecs) <= | 70 | be16_to_cpu(block->bb_numrecs) <= |
71 | cur->bc_ops->get_maxrecs(cur, level) && | 71 | cur->bc_ops->get_maxrecs(cur, level) && |
72 | block->bb_leftsib && | 72 | block->bb_u.l.bb_leftsib && |
73 | (be64_to_cpu(block->bb_leftsib) == NULLDFSBNO || | 73 | (be64_to_cpu(block->bb_u.l.bb_leftsib) == NULLDFSBNO || |
74 | XFS_FSB_SANITY_CHECK(mp, be64_to_cpu(block->bb_leftsib))) && | 74 | XFS_FSB_SANITY_CHECK(mp, |
75 | block->bb_rightsib && | 75 | be64_to_cpu(block->bb_u.l.bb_leftsib))) && |
76 | (be64_to_cpu(block->bb_rightsib) == NULLDFSBNO || | 76 | block->bb_u.l.bb_rightsib && |
77 | XFS_FSB_SANITY_CHECK(mp, be64_to_cpu(block->bb_rightsib))); | 77 | (be64_to_cpu(block->bb_u.l.bb_rightsib) == NULLDFSBNO || |
78 | XFS_FSB_SANITY_CHECK(mp, | ||
79 | be64_to_cpu(block->bb_u.l.bb_rightsib))); | ||
78 | if (unlikely(XFS_TEST_ERROR(!lblock_ok, mp, | 80 | if (unlikely(XFS_TEST_ERROR(!lblock_ok, mp, |
79 | XFS_ERRTAG_BTREE_CHECK_LBLOCK, | 81 | XFS_ERRTAG_BTREE_CHECK_LBLOCK, |
80 | XFS_RANDOM_BTREE_CHECK_LBLOCK))) { | 82 | XFS_RANDOM_BTREE_CHECK_LBLOCK))) { |
@@ -90,7 +92,7 @@ xfs_btree_check_lblock( | |||
90 | STATIC int /* error (0 or EFSCORRUPTED) */ | 92 | STATIC int /* error (0 or EFSCORRUPTED) */ |
91 | xfs_btree_check_sblock( | 93 | xfs_btree_check_sblock( |
92 | struct xfs_btree_cur *cur, /* btree cursor */ | 94 | struct xfs_btree_cur *cur, /* btree cursor */ |
93 | struct xfs_btree_sblock *block, /* btree short form block pointer */ | 95 | struct xfs_btree_block *block, /* btree short form block pointer */ |
94 | int level, /* level of the btree block */ | 96 | int level, /* level of the btree block */ |
95 | struct xfs_buf *bp) /* buffer containing block */ | 97 | struct xfs_buf *bp) /* buffer containing block */ |
96 | { | 98 | { |
@@ -107,12 +109,12 @@ xfs_btree_check_sblock( | |||
107 | be16_to_cpu(block->bb_level) == level && | 109 | be16_to_cpu(block->bb_level) == level && |
108 | be16_to_cpu(block->bb_numrecs) <= | 110 | be16_to_cpu(block->bb_numrecs) <= |
109 | cur->bc_ops->get_maxrecs(cur, level) && | 111 | cur->bc_ops->get_maxrecs(cur, level) && |
110 | (be32_to_cpu(block->bb_leftsib) == NULLAGBLOCK || | 112 | (be32_to_cpu(block->bb_u.s.bb_leftsib) == NULLAGBLOCK || |
111 | be32_to_cpu(block->bb_leftsib) < agflen) && | 113 | be32_to_cpu(block->bb_u.s.bb_leftsib) < agflen) && |
112 | block->bb_leftsib && | 114 | block->bb_u.s.bb_leftsib && |
113 | (be32_to_cpu(block->bb_rightsib) == NULLAGBLOCK || | 115 | (be32_to_cpu(block->bb_u.s.bb_rightsib) == NULLAGBLOCK || |
114 | be32_to_cpu(block->bb_rightsib) < agflen) && | 116 | be32_to_cpu(block->bb_u.s.bb_rightsib) < agflen) && |
115 | block->bb_rightsib; | 117 | block->bb_u.s.bb_rightsib; |
116 | if (unlikely(XFS_TEST_ERROR(!sblock_ok, cur->bc_mp, | 118 | if (unlikely(XFS_TEST_ERROR(!sblock_ok, cur->bc_mp, |
117 | XFS_ERRTAG_BTREE_CHECK_SBLOCK, | 119 | XFS_ERRTAG_BTREE_CHECK_SBLOCK, |
118 | XFS_RANDOM_BTREE_CHECK_SBLOCK))) { | 120 | XFS_RANDOM_BTREE_CHECK_SBLOCK))) { |
@@ -135,13 +137,10 @@ xfs_btree_check_block( | |||
135 | int level, /* level of the btree block */ | 137 | int level, /* level of the btree block */ |
136 | struct xfs_buf *bp) /* buffer containing block, if any */ | 138 | struct xfs_buf *bp) /* buffer containing block, if any */ |
137 | { | 139 | { |
138 | if (cur->bc_flags & XFS_BTREE_LONG_PTRS) { | 140 | if (cur->bc_flags & XFS_BTREE_LONG_PTRS) |
139 | return xfs_btree_check_lblock(cur, | 141 | return xfs_btree_check_lblock(cur, block, level, bp); |
140 | (struct xfs_btree_lblock *)block, level, bp); | 142 | else |
141 | } else { | 143 | return xfs_btree_check_sblock(cur, block, level, bp); |
142 | return xfs_btree_check_sblock(cur, | ||
143 | (struct xfs_btree_sblock *)block, level, bp); | ||
144 | } | ||
145 | } | 144 | } |
146 | 145 | ||
147 | /* | 146 | /* |
@@ -326,8 +325,8 @@ xfs_btree_dup_cursor( | |||
326 | static inline size_t xfs_btree_block_len(struct xfs_btree_cur *cur) | 325 | static inline size_t xfs_btree_block_len(struct xfs_btree_cur *cur) |
327 | { | 326 | { |
328 | return (cur->bc_flags & XFS_BTREE_LONG_PTRS) ? | 327 | return (cur->bc_flags & XFS_BTREE_LONG_PTRS) ? |
329 | sizeof(struct xfs_btree_lblock) : | 328 | XFS_BTREE_LBLOCK_LEN : |
330 | sizeof(struct xfs_btree_sblock); | 329 | XFS_BTREE_SBLOCK_LEN; |
331 | } | 330 | } |
332 | 331 | ||
333 | /* | 332 | /* |
@@ -510,7 +509,7 @@ xfs_btree_islastblock( | |||
510 | xfs_btree_cur_t *cur, /* btree cursor */ | 509 | xfs_btree_cur_t *cur, /* btree cursor */ |
511 | int level) /* level to check */ | 510 | int level) /* level to check */ |
512 | { | 511 | { |
513 | xfs_btree_block_t *block; /* generic btree block pointer */ | 512 | struct xfs_btree_block *block; /* generic btree block pointer */ |
514 | xfs_buf_t *bp; /* buffer containing block */ | 513 | xfs_buf_t *bp; /* buffer containing block */ |
515 | 514 | ||
516 | block = xfs_btree_get_block(cur, level, &bp); | 515 | block = xfs_btree_get_block(cur, level, &bp); |
@@ -530,7 +529,7 @@ xfs_btree_firstrec( | |||
530 | xfs_btree_cur_t *cur, /* btree cursor */ | 529 | xfs_btree_cur_t *cur, /* btree cursor */ |
531 | int level) /* level to change */ | 530 | int level) /* level to change */ |
532 | { | 531 | { |
533 | xfs_btree_block_t *block; /* generic btree block pointer */ | 532 | struct xfs_btree_block *block; /* generic btree block pointer */ |
534 | xfs_buf_t *bp; /* buffer containing block */ | 533 | xfs_buf_t *bp; /* buffer containing block */ |
535 | 534 | ||
536 | /* | 535 | /* |
@@ -559,7 +558,7 @@ xfs_btree_lastrec( | |||
559 | xfs_btree_cur_t *cur, /* btree cursor */ | 558 | xfs_btree_cur_t *cur, /* btree cursor */ |
560 | int level) /* level to change */ | 559 | int level) /* level to change */ |
561 | { | 560 | { |
562 | xfs_btree_block_t *block; /* generic btree block pointer */ | 561 | struct xfs_btree_block *block; /* generic btree block pointer */ |
563 | xfs_buf_t *bp; /* buffer containing block */ | 562 | xfs_buf_t *bp; /* buffer containing block */ |
564 | 563 | ||
565 | /* | 564 | /* |
@@ -814,7 +813,7 @@ xfs_btree_setbuf( | |||
814 | int lev, /* level in btree */ | 813 | int lev, /* level in btree */ |
815 | xfs_buf_t *bp) /* new buffer to set */ | 814 | xfs_buf_t *bp) /* new buffer to set */ |
816 | { | 815 | { |
817 | xfs_btree_block_t *b; /* btree block */ | 816 | struct xfs_btree_block *b; /* btree block */ |
818 | xfs_buf_t *obp; /* old buffer pointer */ | 817 | xfs_buf_t *obp; /* old buffer pointer */ |
819 | 818 | ||
820 | obp = cur->bc_bufs[lev]; | 819 | obp = cur->bc_bufs[lev]; |
@@ -1252,20 +1251,20 @@ xfs_btree_log_block( | |||
1252 | int first; /* first byte offset logged */ | 1251 | int first; /* first byte offset logged */ |
1253 | int last; /* last byte offset logged */ | 1252 | int last; /* last byte offset logged */ |
1254 | static const short soffsets[] = { /* table of offsets (short) */ | 1253 | static const short soffsets[] = { /* table of offsets (short) */ |
1255 | offsetof(struct xfs_btree_sblock, bb_magic), | 1254 | offsetof(struct xfs_btree_block, bb_magic), |
1256 | offsetof(struct xfs_btree_sblock, bb_level), | 1255 | offsetof(struct xfs_btree_block, bb_level), |
1257 | offsetof(struct xfs_btree_sblock, bb_numrecs), | 1256 | offsetof(struct xfs_btree_block, bb_numrecs), |
1258 | offsetof(struct xfs_btree_sblock, bb_leftsib), | 1257 | offsetof(struct xfs_btree_block, bb_u.s.bb_leftsib), |
1259 | offsetof(struct xfs_btree_sblock, bb_rightsib), | 1258 | offsetof(struct xfs_btree_block, bb_u.s.bb_rightsib), |
1260 | sizeof(struct xfs_btree_sblock) | 1259 | XFS_BTREE_SBLOCK_LEN |
1261 | }; | 1260 | }; |
1262 | static const short loffsets[] = { /* table of offsets (long) */ | 1261 | static const short loffsets[] = { /* table of offsets (long) */ |
1263 | offsetof(struct xfs_btree_lblock, bb_magic), | 1262 | offsetof(struct xfs_btree_block, bb_magic), |
1264 | offsetof(struct xfs_btree_lblock, bb_level), | 1263 | offsetof(struct xfs_btree_block, bb_level), |
1265 | offsetof(struct xfs_btree_lblock, bb_numrecs), | 1264 | offsetof(struct xfs_btree_block, bb_numrecs), |
1266 | offsetof(struct xfs_btree_lblock, bb_leftsib), | 1265 | offsetof(struct xfs_btree_block, bb_u.l.bb_leftsib), |
1267 | offsetof(struct xfs_btree_lblock, bb_rightsib), | 1266 | offsetof(struct xfs_btree_block, bb_u.l.bb_rightsib), |
1268 | sizeof(struct xfs_btree_lblock) | 1267 | XFS_BTREE_LBLOCK_LEN |
1269 | }; | 1268 | }; |
1270 | 1269 | ||
1271 | XFS_BTREE_TRACE_CURSOR(cur, XBT_ENTRY); | 1270 | XFS_BTREE_TRACE_CURSOR(cur, XBT_ENTRY); |
@@ -3018,7 +3017,7 @@ xfs_btree_kill_iroot( | |||
3018 | if (index) { | 3017 | if (index) { |
3019 | xfs_iroot_realloc(cur->bc_private.b.ip, index, | 3018 | xfs_iroot_realloc(cur->bc_private.b.ip, index, |
3020 | cur->bc_private.b.whichfork); | 3019 | cur->bc_private.b.whichfork); |
3021 | block = (struct xfs_btree_block *)ifp->if_broot; | 3020 | block = ifp->if_broot; |
3022 | } | 3021 | } |
3023 | 3022 | ||
3024 | be16_add_cpu(&block->bb_numrecs, index); | 3023 | be16_add_cpu(&block->bb_numrecs, index); |
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h index d6120a749060..789fffdf8b2f 100644 --- a/fs/xfs/xfs_btree.h +++ b/fs/xfs/xfs_btree.h | |||
@@ -39,31 +39,16 @@ extern kmem_zone_t *xfs_btree_cur_zone; | |||
39 | #define XFS_BTNUM_INO ((xfs_btnum_t)XFS_BTNUM_INOi) | 39 | #define XFS_BTNUM_INO ((xfs_btnum_t)XFS_BTNUM_INOi) |
40 | 40 | ||
41 | /* | 41 | /* |
42 | * Short form header: space allocation btrees. | 42 | * Generic btree header. |
43 | */ | 43 | * |
44 | typedef struct xfs_btree_sblock { | 44 | * This is a comination of the actual format used on disk for short and long |
45 | __be32 bb_magic; /* magic number for block type */ | 45 | * format btrees. The first three fields are shared by both format, but |
46 | __be16 bb_level; /* 0 is a leaf */ | 46 | * the pointers are different and should be used with care. |
47 | __be16 bb_numrecs; /* current # of data records */ | 47 | * |
48 | __be32 bb_leftsib; /* left sibling block or NULLAGBLOCK */ | 48 | * To get the size of the actual short or long form headers please use |
49 | __be32 bb_rightsib; /* right sibling block or NULLAGBLOCK */ | 49 | * the size macros below. Never use sizeof(xfs_btree_block). |
50 | } xfs_btree_sblock_t; | ||
51 | |||
52 | /* | ||
53 | * Long form header: bmap btrees. | ||
54 | */ | ||
55 | typedef struct xfs_btree_lblock { | ||
56 | __be32 bb_magic; /* magic number for block type */ | ||
57 | __be16 bb_level; /* 0 is a leaf */ | ||
58 | __be16 bb_numrecs; /* current # of data records */ | ||
59 | __be64 bb_leftsib; /* left sibling block or NULLDFSBNO */ | ||
60 | __be64 bb_rightsib; /* right sibling block or NULLDFSBNO */ | ||
61 | } xfs_btree_lblock_t; | ||
62 | |||
63 | /* | ||
64 | * Combined header and structure, used by common code. | ||
65 | */ | 50 | */ |
66 | typedef struct xfs_btree_block { | 51 | struct xfs_btree_block { |
67 | __be32 bb_magic; /* magic number for block type */ | 52 | __be32 bb_magic; /* magic number for block type */ |
68 | __be16 bb_level; /* 0 is a leaf */ | 53 | __be16 bb_level; /* 0 is a leaf */ |
69 | __be16 bb_numrecs; /* current # of data records */ | 54 | __be16 bb_numrecs; /* current # of data records */ |
@@ -77,7 +62,11 @@ typedef struct xfs_btree_block { | |||
77 | __be64 bb_rightsib; | 62 | __be64 bb_rightsib; |
78 | } l; /* long form pointers */ | 63 | } l; /* long form pointers */ |
79 | } bb_u; /* rest */ | 64 | } bb_u; /* rest */ |
80 | } xfs_btree_block_t; | 65 | }; |
66 | |||
67 | #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 */ | ||
69 | |||
81 | 70 | ||
82 | /* | 71 | /* |
83 | * Generic key, ptr and record wrapper structures. | 72 | * Generic key, ptr and record wrapper structures. |
@@ -294,20 +283,8 @@ typedef struct xfs_btree_cur | |||
294 | /* | 283 | /* |
295 | * Convert from buffer to btree block header. | 284 | * Convert from buffer to btree block header. |
296 | */ | 285 | */ |
297 | #define XFS_BUF_TO_BLOCK(bp) ((xfs_btree_block_t *)XFS_BUF_PTR(bp)) | 286 | #define XFS_BUF_TO_BLOCK(bp) ((struct xfs_btree_block *)XFS_BUF_PTR(bp)) |
298 | #define XFS_BUF_TO_LBLOCK(bp) ((xfs_btree_lblock_t *)XFS_BUF_PTR(bp)) | ||
299 | #define XFS_BUF_TO_SBLOCK(bp) ((xfs_btree_sblock_t *)XFS_BUF_PTR(bp)) | ||
300 | |||
301 | 287 | ||
302 | /* | ||
303 | * Check that long form block header is ok. | ||
304 | */ | ||
305 | int /* error (0 or EFSCORRUPTED) */ | ||
306 | xfs_btree_check_lblock( | ||
307 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
308 | struct xfs_btree_lblock *block, /* btree long form block pointer */ | ||
309 | int level, /* level of the btree block */ | ||
310 | struct xfs_buf *bp); /* buffer containing block, if any */ | ||
311 | 288 | ||
312 | /* | 289 | /* |
313 | * Check that block header is ok. | 290 | * Check that block header is ok. |
diff --git a/fs/xfs/xfs_dinode.h b/fs/xfs/xfs_dinode.h index 2a00fcc36d8e..d7cf392cc852 100644 --- a/fs/xfs/xfs_dinode.h +++ b/fs/xfs/xfs_dinode.h | |||
@@ -165,7 +165,7 @@ typedef enum xfs_dinode_fmt | |||
165 | */ | 165 | */ |
166 | #define XFS_LITINO(mp) ((mp)->m_litino) | 166 | #define XFS_LITINO(mp) ((mp)->m_litino) |
167 | #define XFS_BROOT_SIZE_ADJ \ | 167 | #define XFS_BROOT_SIZE_ADJ \ |
168 | (sizeof(xfs_bmbt_block_t) - sizeof(xfs_bmdr_block_t)) | 168 | (XFS_BTREE_LBLOCK_LEN - sizeof(xfs_bmdr_block_t)) |
169 | 169 | ||
170 | /* | 170 | /* |
171 | * Inode data & attribute fork sizes, per inode. | 171 | * Inode data & attribute fork sizes, per inode. |
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 8ce72aba027f..f1d0585041b9 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c | |||
@@ -126,7 +126,7 @@ xfs_growfs_data_private( | |||
126 | xfs_extlen_t agsize; | 126 | xfs_extlen_t agsize; |
127 | xfs_extlen_t tmpsize; | 127 | xfs_extlen_t tmpsize; |
128 | xfs_alloc_rec_t *arec; | 128 | xfs_alloc_rec_t *arec; |
129 | xfs_btree_sblock_t *block; | 129 | struct xfs_btree_block *block; |
130 | xfs_buf_t *bp; | 130 | xfs_buf_t *bp; |
131 | int bucket; | 131 | int bucket; |
132 | int dpct; | 132 | int dpct; |
@@ -251,13 +251,13 @@ xfs_growfs_data_private( | |||
251 | bp = xfs_buf_get(mp->m_ddev_targp, | 251 | bp = xfs_buf_get(mp->m_ddev_targp, |
252 | XFS_AGB_TO_DADDR(mp, agno, XFS_BNO_BLOCK(mp)), | 252 | XFS_AGB_TO_DADDR(mp, agno, XFS_BNO_BLOCK(mp)), |
253 | BTOBB(mp->m_sb.sb_blocksize), 0); | 253 | BTOBB(mp->m_sb.sb_blocksize), 0); |
254 | block = XFS_BUF_TO_SBLOCK(bp); | 254 | block = XFS_BUF_TO_BLOCK(bp); |
255 | memset(block, 0, mp->m_sb.sb_blocksize); | 255 | memset(block, 0, mp->m_sb.sb_blocksize); |
256 | block->bb_magic = cpu_to_be32(XFS_ABTB_MAGIC); | 256 | block->bb_magic = cpu_to_be32(XFS_ABTB_MAGIC); |
257 | block->bb_level = 0; | 257 | block->bb_level = 0; |
258 | block->bb_numrecs = cpu_to_be16(1); | 258 | block->bb_numrecs = cpu_to_be16(1); |
259 | block->bb_leftsib = cpu_to_be32(NULLAGBLOCK); | 259 | block->bb_u.s.bb_leftsib = cpu_to_be32(NULLAGBLOCK); |
260 | block->bb_rightsib = cpu_to_be32(NULLAGBLOCK); | 260 | block->bb_u.s.bb_rightsib = cpu_to_be32(NULLAGBLOCK); |
261 | arec = XFS_ALLOC_REC_ADDR(mp, block, 1); | 261 | arec = XFS_ALLOC_REC_ADDR(mp, block, 1); |
262 | arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp)); | 262 | arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp)); |
263 | arec->ar_blockcount = cpu_to_be32( | 263 | arec->ar_blockcount = cpu_to_be32( |
@@ -272,13 +272,13 @@ xfs_growfs_data_private( | |||
272 | bp = xfs_buf_get(mp->m_ddev_targp, | 272 | bp = xfs_buf_get(mp->m_ddev_targp, |
273 | XFS_AGB_TO_DADDR(mp, agno, XFS_CNT_BLOCK(mp)), | 273 | XFS_AGB_TO_DADDR(mp, agno, XFS_CNT_BLOCK(mp)), |
274 | BTOBB(mp->m_sb.sb_blocksize), 0); | 274 | BTOBB(mp->m_sb.sb_blocksize), 0); |
275 | block = XFS_BUF_TO_SBLOCK(bp); | 275 | block = XFS_BUF_TO_BLOCK(bp); |
276 | memset(block, 0, mp->m_sb.sb_blocksize); | 276 | memset(block, 0, mp->m_sb.sb_blocksize); |
277 | block->bb_magic = cpu_to_be32(XFS_ABTC_MAGIC); | 277 | block->bb_magic = cpu_to_be32(XFS_ABTC_MAGIC); |
278 | block->bb_level = 0; | 278 | block->bb_level = 0; |
279 | block->bb_numrecs = cpu_to_be16(1); | 279 | block->bb_numrecs = cpu_to_be16(1); |
280 | block->bb_leftsib = cpu_to_be32(NULLAGBLOCK); | 280 | block->bb_u.s.bb_leftsib = cpu_to_be32(NULLAGBLOCK); |
281 | block->bb_rightsib = cpu_to_be32(NULLAGBLOCK); | 281 | block->bb_u.s.bb_rightsib = cpu_to_be32(NULLAGBLOCK); |
282 | arec = XFS_ALLOC_REC_ADDR(mp, block, 1); | 282 | arec = XFS_ALLOC_REC_ADDR(mp, block, 1); |
283 | arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp)); | 283 | arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp)); |
284 | arec->ar_blockcount = cpu_to_be32( | 284 | arec->ar_blockcount = cpu_to_be32( |
@@ -294,13 +294,13 @@ xfs_growfs_data_private( | |||
294 | bp = xfs_buf_get(mp->m_ddev_targp, | 294 | bp = xfs_buf_get(mp->m_ddev_targp, |
295 | XFS_AGB_TO_DADDR(mp, agno, XFS_IBT_BLOCK(mp)), | 295 | XFS_AGB_TO_DADDR(mp, agno, XFS_IBT_BLOCK(mp)), |
296 | BTOBB(mp->m_sb.sb_blocksize), 0); | 296 | BTOBB(mp->m_sb.sb_blocksize), 0); |
297 | block = XFS_BUF_TO_SBLOCK(bp); | 297 | block = XFS_BUF_TO_BLOCK(bp); |
298 | memset(block, 0, mp->m_sb.sb_blocksize); | 298 | memset(block, 0, mp->m_sb.sb_blocksize); |
299 | block->bb_magic = cpu_to_be32(XFS_IBT_MAGIC); | 299 | block->bb_magic = cpu_to_be32(XFS_IBT_MAGIC); |
300 | block->bb_level = 0; | 300 | block->bb_level = 0; |
301 | block->bb_numrecs = 0; | 301 | block->bb_numrecs = 0; |
302 | block->bb_leftsib = cpu_to_be32(NULLAGBLOCK); | 302 | block->bb_u.s.bb_leftsib = cpu_to_be32(NULLAGBLOCK); |
303 | block->bb_rightsib = cpu_to_be32(NULLAGBLOCK); | 303 | block->bb_u.s.bb_rightsib = cpu_to_be32(NULLAGBLOCK); |
304 | error = xfs_bwrite(mp, bp); | 304 | error = xfs_bwrite(mp, bp); |
305 | if (error) { | 305 | if (error) { |
306 | goto error0; | 306 | goto error0; |
diff --git a/fs/xfs/xfs_ialloc_btree.c b/fs/xfs/xfs_ialloc_btree.c index 46aabb3fcbf3..99f2408e8d8e 100644 --- a/fs/xfs/xfs_ialloc_btree.c +++ b/fs/xfs/xfs_ialloc_btree.c | |||
@@ -375,7 +375,7 @@ xfs_inobt_maxrecs( | |||
375 | int blocklen, | 375 | int blocklen, |
376 | int leaf) | 376 | int leaf) |
377 | { | 377 | { |
378 | blocklen -= sizeof(struct xfs_btree_sblock); | 378 | blocklen -= XFS_INOBT_BLOCK_LEN(mp); |
379 | 379 | ||
380 | if (leaf) | 380 | if (leaf) |
381 | return blocklen / sizeof(xfs_inobt_rec_t); | 381 | return blocklen / sizeof(xfs_inobt_rec_t); |
diff --git a/fs/xfs/xfs_ialloc_btree.h b/fs/xfs/xfs_ialloc_btree.h index fa12c85db340..37e5dd01a577 100644 --- a/fs/xfs/xfs_ialloc_btree.h +++ b/fs/xfs/xfs_ialloc_btree.h | |||
@@ -24,7 +24,6 @@ | |||
24 | 24 | ||
25 | struct xfs_buf; | 25 | struct xfs_buf; |
26 | struct xfs_btree_cur; | 26 | struct xfs_btree_cur; |
27 | struct xfs_btree_sblock; | ||
28 | struct xfs_mount; | 27 | struct xfs_mount; |
29 | 28 | ||
30 | /* | 29 | /* |
@@ -70,11 +69,6 @@ typedef struct xfs_inobt_key { | |||
70 | /* btree pointer type */ | 69 | /* btree pointer type */ |
71 | typedef __be32 xfs_inobt_ptr_t; | 70 | typedef __be32 xfs_inobt_ptr_t; |
72 | 71 | ||
73 | /* btree block header type */ | ||
74 | typedef struct xfs_btree_sblock xfs_inobt_block_t; | ||
75 | |||
76 | #define XFS_BUF_TO_INOBT_BLOCK(bp) ((xfs_inobt_block_t *)XFS_BUF_PTR(bp)) | ||
77 | |||
78 | /* | 72 | /* |
79 | * Bit manipulations for ir_free. | 73 | * Bit manipulations for ir_free. |
80 | */ | 74 | */ |
@@ -96,6 +90,13 @@ typedef struct xfs_btree_sblock xfs_inobt_block_t; | |||
96 | #define XFS_PREALLOC_BLOCKS(mp) ((xfs_agblock_t)(XFS_IBT_BLOCK(mp) + 1)) | 90 | #define XFS_PREALLOC_BLOCKS(mp) ((xfs_agblock_t)(XFS_IBT_BLOCK(mp) + 1)) |
97 | 91 | ||
98 | /* | 92 | /* |
93 | * Btree block header size depends on a superblock flag. | ||
94 | * | ||
95 | * (not quite yet, but soon) | ||
96 | */ | ||
97 | #define XFS_INOBT_BLOCK_LEN(mp) XFS_BTREE_SBLOCK_LEN | ||
98 | |||
99 | /* | ||
99 | * Record, key, and pointer address macros for btree blocks. | 100 | * Record, key, and pointer address macros for btree blocks. |
100 | * | 101 | * |
101 | * (note that some of these may appear unused, but they are used in userspace) | 102 | * (note that some of these may appear unused, but they are used in userspace) |
@@ -103,19 +104,19 @@ typedef struct xfs_btree_sblock xfs_inobt_block_t; | |||
103 | #define XFS_INOBT_REC_ADDR(mp, block, index) \ | 104 | #define XFS_INOBT_REC_ADDR(mp, block, index) \ |
104 | ((xfs_inobt_rec_t *) \ | 105 | ((xfs_inobt_rec_t *) \ |
105 | ((char *)(block) + \ | 106 | ((char *)(block) + \ |
106 | sizeof(struct xfs_btree_sblock) + \ | 107 | XFS_INOBT_BLOCK_LEN(mp) + \ |
107 | (((index) - 1) * sizeof(xfs_inobt_rec_t)))) | 108 | (((index) - 1) * sizeof(xfs_inobt_rec_t)))) |
108 | 109 | ||
109 | #define XFS_INOBT_KEY_ADDR(mp, block, index) \ | 110 | #define XFS_INOBT_KEY_ADDR(mp, block, index) \ |
110 | ((xfs_inobt_key_t *) \ | 111 | ((xfs_inobt_key_t *) \ |
111 | ((char *)(block) + \ | 112 | ((char *)(block) + \ |
112 | sizeof(struct xfs_btree_sblock) + \ | 113 | XFS_INOBT_BLOCK_LEN(mp) + \ |
113 | ((index) - 1) * sizeof(xfs_inobt_key_t))) | 114 | ((index) - 1) * sizeof(xfs_inobt_key_t))) |
114 | 115 | ||
115 | #define XFS_INOBT_PTR_ADDR(mp, block, index, maxrecs) \ | 116 | #define XFS_INOBT_PTR_ADDR(mp, block, index, maxrecs) \ |
116 | ((xfs_inobt_ptr_t *) \ | 117 | ((xfs_inobt_ptr_t *) \ |
117 | ((char *)(block) + \ | 118 | ((char *)(block) + \ |
118 | sizeof(struct xfs_btree_sblock) + \ | 119 | XFS_INOBT_BLOCK_LEN(mp) + \ |
119 | (maxrecs) * sizeof(xfs_inobt_key_t) + \ | 120 | (maxrecs) * sizeof(xfs_inobt_key_t) + \ |
120 | ((index) - 1) * sizeof(xfs_inobt_ptr_t))) | 121 | ((index) - 1) * sizeof(xfs_inobt_ptr_t))) |
121 | 122 | ||
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 7b4f13c710d6..bc33762abc49 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -2352,7 +2352,7 @@ xfs_iroot_realloc( | |||
2352 | struct xfs_mount *mp = ip->i_mount; | 2352 | struct xfs_mount *mp = ip->i_mount; |
2353 | int cur_max; | 2353 | int cur_max; |
2354 | xfs_ifork_t *ifp; | 2354 | xfs_ifork_t *ifp; |
2355 | xfs_bmbt_block_t *new_broot; | 2355 | struct xfs_btree_block *new_broot; |
2356 | int new_max; | 2356 | int new_max; |
2357 | size_t new_size; | 2357 | size_t new_size; |
2358 | char *np; | 2358 | char *np; |
@@ -2373,8 +2373,7 @@ xfs_iroot_realloc( | |||
2373 | */ | 2373 | */ |
2374 | if (ifp->if_broot_bytes == 0) { | 2374 | if (ifp->if_broot_bytes == 0) { |
2375 | new_size = (size_t)XFS_BMAP_BROOT_SPACE_CALC(rec_diff); | 2375 | new_size = (size_t)XFS_BMAP_BROOT_SPACE_CALC(rec_diff); |
2376 | ifp->if_broot = (xfs_bmbt_block_t*)kmem_alloc(new_size, | 2376 | ifp->if_broot = kmem_alloc(new_size, KM_SLEEP); |
2377 | KM_SLEEP); | ||
2378 | ifp->if_broot_bytes = (int)new_size; | 2377 | ifp->if_broot_bytes = (int)new_size; |
2379 | return; | 2378 | return; |
2380 | } | 2379 | } |
@@ -2388,9 +2387,7 @@ xfs_iroot_realloc( | |||
2388 | cur_max = xfs_bmbt_maxrecs(mp, ifp->if_broot_bytes, 0); | 2387 | cur_max = xfs_bmbt_maxrecs(mp, ifp->if_broot_bytes, 0); |
2389 | new_max = cur_max + rec_diff; | 2388 | new_max = cur_max + rec_diff; |
2390 | new_size = (size_t)XFS_BMAP_BROOT_SPACE_CALC(new_max); | 2389 | new_size = (size_t)XFS_BMAP_BROOT_SPACE_CALC(new_max); |
2391 | ifp->if_broot = (xfs_bmbt_block_t *) | 2390 | ifp->if_broot = kmem_realloc(ifp->if_broot, new_size, |
2392 | kmem_realloc(ifp->if_broot, | ||
2393 | new_size, | ||
2394 | (size_t)XFS_BMAP_BROOT_SPACE_CALC(cur_max), /* old size */ | 2391 | (size_t)XFS_BMAP_BROOT_SPACE_CALC(cur_max), /* old size */ |
2395 | KM_SLEEP); | 2392 | KM_SLEEP); |
2396 | op = (char *)XFS_BMAP_BROOT_PTR_ADDR(mp, ifp->if_broot, 1, | 2393 | op = (char *)XFS_BMAP_BROOT_PTR_ADDR(mp, ifp->if_broot, 1, |
@@ -2418,11 +2415,11 @@ xfs_iroot_realloc( | |||
2418 | else | 2415 | else |
2419 | new_size = 0; | 2416 | new_size = 0; |
2420 | if (new_size > 0) { | 2417 | if (new_size > 0) { |
2421 | new_broot = (xfs_bmbt_block_t *)kmem_alloc(new_size, KM_SLEEP); | 2418 | new_broot = kmem_alloc(new_size, KM_SLEEP); |
2422 | /* | 2419 | /* |
2423 | * First copy over the btree block header. | 2420 | * First copy over the btree block header. |
2424 | */ | 2421 | */ |
2425 | memcpy(new_broot, ifp->if_broot, sizeof(xfs_bmbt_block_t)); | 2422 | memcpy(new_broot, ifp->if_broot, XFS_BTREE_LBLOCK_LEN); |
2426 | } else { | 2423 | } else { |
2427 | new_broot = NULL; | 2424 | new_broot = NULL; |
2428 | ifp->if_flags &= ~XFS_IFBROOT; | 2425 | ifp->if_flags &= ~XFS_IFBROOT; |
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 55d50b888b68..6fd20fc179a4 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h | |||
@@ -63,7 +63,7 @@ typedef struct xfs_ext_irec { | |||
63 | typedef struct xfs_ifork { | 63 | typedef struct xfs_ifork { |
64 | int if_bytes; /* bytes in if_u1 */ | 64 | int if_bytes; /* bytes in if_u1 */ |
65 | int if_real_bytes; /* bytes allocated in if_u1 */ | 65 | int if_real_bytes; /* bytes allocated in if_u1 */ |
66 | xfs_bmbt_block_t *if_broot; /* file's incore btree root */ | 66 | struct xfs_btree_block *if_broot; /* file's incore btree root */ |
67 | short if_broot_bytes; /* bytes allocated for root */ | 67 | short if_broot_bytes; /* bytes allocated for root */ |
68 | unsigned char if_flags; /* per-fork flags */ | 68 | unsigned char if_flags; /* per-fork flags */ |
69 | unsigned char if_ext_max; /* max # of extent records */ | 69 | unsigned char if_ext_max; /* max # of extent records */ |
@@ -213,7 +213,6 @@ struct ktrace; | |||
213 | struct xfs_buf; | 213 | struct xfs_buf; |
214 | struct xfs_bmap_free; | 214 | struct xfs_bmap_free; |
215 | struct xfs_bmbt_irec; | 215 | struct xfs_bmbt_irec; |
216 | struct xfs_bmbt_block; | ||
217 | struct xfs_inode_log_item; | 216 | struct xfs_inode_log_item; |
218 | struct xfs_mount; | 217 | struct xfs_mount; |
219 | struct xfs_trans; | 218 | struct xfs_trans; |
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 23c3a782a9e7..199c8ea36474 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -2452,8 +2452,8 @@ xlog_recover_do_inode_trans( | |||
2452 | break; | 2452 | break; |
2453 | 2453 | ||
2454 | case XFS_ILOG_DBROOT: | 2454 | case XFS_ILOG_DBROOT: |
2455 | xfs_bmbt_to_bmdr(mp, (xfs_bmbt_block_t *)src, len, | 2455 | xfs_bmbt_to_bmdr(mp, (struct xfs_btree_block *)src, len, |
2456 | &(dip->di_u.di_bmbt), | 2456 | &dip->di_u.di_bmbt, |
2457 | XFS_DFORK_DSIZE(dip, mp)); | 2457 | XFS_DFORK_DSIZE(dip, mp)); |
2458 | break; | 2458 | break; |
2459 | 2459 | ||
@@ -2490,8 +2490,8 @@ xlog_recover_do_inode_trans( | |||
2490 | 2490 | ||
2491 | case XFS_ILOG_ABROOT: | 2491 | case XFS_ILOG_ABROOT: |
2492 | dest = XFS_DFORK_APTR(dip); | 2492 | dest = XFS_DFORK_APTR(dip); |
2493 | xfs_bmbt_to_bmdr(mp, (xfs_bmbt_block_t *)src, len, | 2493 | xfs_bmbt_to_bmdr(mp, (struct xfs_btree_block *)src, |
2494 | (xfs_bmdr_block_t*)dest, | 2494 | len, (xfs_bmdr_block_t*)dest, |
2495 | XFS_DFORK_ASIZE(dip, mp)); | 2495 | XFS_DFORK_ASIZE(dip, mp)); |
2496 | break; | 2496 | break; |
2497 | 2497 | ||