aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_btree.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_btree.c')
-rw-r--r--fs/xfs/xfs_btree.c81
1 files changed, 40 insertions, 41 deletions
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
56int /* error (0 or EFSCORRUPTED) */ 56STATIC int /* error (0 or EFSCORRUPTED) */
57xfs_btree_check_lblock( 57xfs_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(
90STATIC int /* error (0 or EFSCORRUPTED) */ 92STATIC int /* error (0 or EFSCORRUPTED) */
91xfs_btree_check_sblock( 93xfs_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(
326static inline size_t xfs_btree_block_len(struct xfs_btree_cur *cur) 325static 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);