xfs_btree.c (04fcad80cd068731a779fb442f78234732683755) | xfs_btree.c (9343ee76909e3f6466d85c9ebb0e343cdf54de71) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. 4 * All Rights Reserved. 5 */ 6#include "xfs.h" 7#include "xfs_fs.h" 8#include "xfs_shared.h" --- 56 unchanged lines hidden (view full) --- 65 struct xfs_mount *mp = cur->bc_mp; 66 xfs_btnum_t btnum = cur->bc_btnum; 67 int crc = xfs_has_crc(mp); 68 69 if (crc) { 70 if (!uuid_equal(&block->bb_u.l.bb_uuid, &mp->m_sb.sb_meta_uuid)) 71 return __this_address; 72 if (block->bb_u.l.bb_blkno != | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. 4 * All Rights Reserved. 5 */ 6#include "xfs.h" 7#include "xfs_fs.h" 8#include "xfs_shared.h" --- 56 unchanged lines hidden (view full) --- 65 struct xfs_mount *mp = cur->bc_mp; 66 xfs_btnum_t btnum = cur->bc_btnum; 67 int crc = xfs_has_crc(mp); 68 69 if (crc) { 70 if (!uuid_equal(&block->bb_u.l.bb_uuid, &mp->m_sb.sb_meta_uuid)) 71 return __this_address; 72 if (block->bb_u.l.bb_blkno != |
73 cpu_to_be64(bp ? bp->b_bn : XFS_BUF_DADDR_NULL)) | 73 cpu_to_be64(bp ? xfs_buf_daddr(bp) : XFS_BUF_DADDR_NULL)) |
74 return __this_address; 75 if (block->bb_u.l.bb_pad != cpu_to_be32(0)) 76 return __this_address; 77 } 78 79 if (be32_to_cpu(block->bb_magic) != xfs_btree_magic(crc, btnum)) 80 return __this_address; 81 if (be16_to_cpu(block->bb_level) != level) --- 48 unchanged lines hidden (view full) --- 130 struct xfs_mount *mp = cur->bc_mp; 131 xfs_btnum_t btnum = cur->bc_btnum; 132 int crc = xfs_has_crc(mp); 133 134 if (crc) { 135 if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid)) 136 return __this_address; 137 if (block->bb_u.s.bb_blkno != | 74 return __this_address; 75 if (block->bb_u.l.bb_pad != cpu_to_be32(0)) 76 return __this_address; 77 } 78 79 if (be32_to_cpu(block->bb_magic) != xfs_btree_magic(crc, btnum)) 80 return __this_address; 81 if (be16_to_cpu(block->bb_level) != level) --- 48 unchanged lines hidden (view full) --- 130 struct xfs_mount *mp = cur->bc_mp; 131 xfs_btnum_t btnum = cur->bc_btnum; 132 int crc = xfs_has_crc(mp); 133 134 if (crc) { 135 if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid)) 136 return __this_address; 137 if (block->bb_u.s.bb_blkno != |
138 cpu_to_be64(bp ? bp->b_bn : XFS_BUF_DADDR_NULL)) | 138 cpu_to_be64(bp ? xfs_buf_daddr(bp) : XFS_BUF_DADDR_NULL)) |
139 return __this_address; 140 } 141 142 if (be32_to_cpu(block->bb_magic) != xfs_btree_magic(crc, btnum)) 143 return __this_address; 144 if (be16_to_cpu(block->bb_level) != level) 145 return __this_address; 146 if (be16_to_cpu(block->bb_numrecs) > --- 979 unchanged lines hidden (view full) --- 1126xfs_btree_init_block( 1127 struct xfs_mount *mp, 1128 struct xfs_buf *bp, 1129 xfs_btnum_t btnum, 1130 __u16 level, 1131 __u16 numrecs, 1132 __u64 owner) 1133{ | 139 return __this_address; 140 } 141 142 if (be32_to_cpu(block->bb_magic) != xfs_btree_magic(crc, btnum)) 143 return __this_address; 144 if (be16_to_cpu(block->bb_level) != level) 145 return __this_address; 146 if (be16_to_cpu(block->bb_numrecs) > --- 979 unchanged lines hidden (view full) --- 1126xfs_btree_init_block( 1127 struct xfs_mount *mp, 1128 struct xfs_buf *bp, 1129 xfs_btnum_t btnum, 1130 __u16 level, 1131 __u16 numrecs, 1132 __u64 owner) 1133{ |
1134 xfs_btree_init_block_int(mp, XFS_BUF_TO_BLOCK(bp), bp->b_bn, | 1134 xfs_btree_init_block_int(mp, XFS_BUF_TO_BLOCK(bp), xfs_buf_daddr(bp), |
1135 btnum, level, numrecs, owner, 0); 1136} 1137 1138void 1139xfs_btree_init_block_cur( 1140 struct xfs_btree_cur *cur, 1141 struct xfs_buf *bp, 1142 int level, --- 7 unchanged lines hidden (view full) --- 1150 * change in future, but is safe for current users of the generic btree 1151 * code. 1152 */ 1153 if (cur->bc_flags & XFS_BTREE_LONG_PTRS) 1154 owner = cur->bc_ino.ip->i_ino; 1155 else 1156 owner = cur->bc_ag.pag->pag_agno; 1157 | 1135 btnum, level, numrecs, owner, 0); 1136} 1137 1138void 1139xfs_btree_init_block_cur( 1140 struct xfs_btree_cur *cur, 1141 struct xfs_buf *bp, 1142 int level, --- 7 unchanged lines hidden (view full) --- 1150 * change in future, but is safe for current users of the generic btree 1151 * code. 1152 */ 1153 if (cur->bc_flags & XFS_BTREE_LONG_PTRS) 1154 owner = cur->bc_ino.ip->i_ino; 1155 else 1156 owner = cur->bc_ag.pag->pag_agno; 1157 |
1158 xfs_btree_init_block_int(cur->bc_mp, XFS_BUF_TO_BLOCK(bp), bp->b_bn, 1159 cur->bc_btnum, level, numrecs, 1160 owner, cur->bc_flags); | 1158 xfs_btree_init_block_int(cur->bc_mp, XFS_BUF_TO_BLOCK(bp), 1159 xfs_buf_daddr(bp), cur->bc_btnum, level, 1160 numrecs, owner, cur->bc_flags); |
1161} 1162 1163/* 1164 * Return true if ptr is the last record in the btree and 1165 * we need to track updates to this record. The decision 1166 * will be further refined in the update_lastrec method. 1167 */ 1168STATIC int --- 1749 unchanged lines hidden (view full) --- 2918 goto error0; 2919 2920 /* 2921 * we can't just memcpy() the root in for CRC enabled btree blocks. 2922 * In that case have to also ensure the blkno remains correct 2923 */ 2924 memcpy(cblock, block, xfs_btree_block_len(cur)); 2925 if (cur->bc_flags & XFS_BTREE_CRC_BLOCKS) { | 1161} 1162 1163/* 1164 * Return true if ptr is the last record in the btree and 1165 * we need to track updates to this record. The decision 1166 * will be further refined in the update_lastrec method. 1167 */ 1168STATIC int --- 1749 unchanged lines hidden (view full) --- 2918 goto error0; 2919 2920 /* 2921 * we can't just memcpy() the root in for CRC enabled btree blocks. 2922 * In that case have to also ensure the blkno remains correct 2923 */ 2924 memcpy(cblock, block, xfs_btree_block_len(cur)); 2925 if (cur->bc_flags & XFS_BTREE_CRC_BLOCKS) { |
2926 __be64 bno = cpu_to_be64(xfs_buf_daddr(cbp)); |
|
2926 if (cur->bc_flags & XFS_BTREE_LONG_PTRS) | 2927 if (cur->bc_flags & XFS_BTREE_LONG_PTRS) |
2927 cblock->bb_u.l.bb_blkno = cpu_to_be64(cbp->b_bn); | 2928 cblock->bb_u.l.bb_blkno = bno; |
2928 else | 2929 else |
2929 cblock->bb_u.s.bb_blkno = cpu_to_be64(cbp->b_bn); | 2930 cblock->bb_u.s.bb_blkno = bno; |
2930 } 2931 2932 be16_add_cpu(&block->bb_level, 1); 2933 xfs_btree_set_numrecs(block, 1); 2934 cur->bc_nlevels++; 2935 cur->bc_ptrs[level + 1] = 1; 2936 2937 kp = xfs_btree_key_addr(cur, 1, block); --- 282 unchanged lines hidden (view full) --- 3220 } 3221 3222 optr = ptr; 3223 3224 XFS_BTREE_STATS_INC(cur, insrec); 3225 3226 /* Get pointers to the btree buffer and block. */ 3227 block = xfs_btree_get_block(cur, level, &bp); | 2931 } 2932 2933 be16_add_cpu(&block->bb_level, 1); 2934 xfs_btree_set_numrecs(block, 1); 2935 cur->bc_nlevels++; 2936 cur->bc_ptrs[level + 1] = 1; 2937 2938 kp = xfs_btree_key_addr(cur, 1, block); --- 282 unchanged lines hidden (view full) --- 3221 } 3222 3223 optr = ptr; 3224 3225 XFS_BTREE_STATS_INC(cur, insrec); 3226 3227 /* Get pointers to the btree buffer and block. */ 3228 block = xfs_btree_get_block(cur, level, &bp); |
3228 old_bn = bp ? bp->b_bn : XFS_BUF_DADDR_NULL; | 3229 old_bn = bp ? xfs_buf_daddr(bp) : XFS_BUF_DADDR_NULL; |
3229 numrecs = xfs_btree_get_numrecs(block); 3230 3231#ifdef DEBUG 3232 error = xfs_btree_check_block(cur, block, level, bp); 3233 if (error) 3234 goto error0; 3235 3236 /* Check that the new entry is being inserted in the right place. */ --- 99 unchanged lines hidden (view full) --- 3336 /* 3337 * If we just inserted into a new tree block, we have to 3338 * recalculate nkey here because nkey is out of date. 3339 * 3340 * Otherwise we're just updating an existing block (having shoved 3341 * some records into the new tree block), so use the regular key 3342 * update mechanism. 3343 */ | 3230 numrecs = xfs_btree_get_numrecs(block); 3231 3232#ifdef DEBUG 3233 error = xfs_btree_check_block(cur, block, level, bp); 3234 if (error) 3235 goto error0; 3236 3237 /* Check that the new entry is being inserted in the right place. */ --- 99 unchanged lines hidden (view full) --- 3337 /* 3338 * If we just inserted into a new tree block, we have to 3339 * recalculate nkey here because nkey is out of date. 3340 * 3341 * Otherwise we're just updating an existing block (having shoved 3342 * some records into the new tree block), so use the regular key 3343 * update mechanism. 3344 */ |
3344 if (bp && bp->b_bn != old_bn) { | 3345 if (bp && xfs_buf_daddr(bp) != old_bn) { |
3345 xfs_btree_get_keys(cur, block, lkey); 3346 } else if (xfs_btree_needs_key_update(cur, optr)) { 3347 error = xfs_btree_update_keys(cur, level); 3348 if (error) 3349 goto error0; 3350 } 3351 3352 /* --- 1064 unchanged lines hidden (view full) --- 4417{ 4418 struct xfs_mount *mp = bp->b_mount; 4419 struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); 4420 4421 if (!xfs_has_crc(mp)) 4422 return __this_address; 4423 if (!uuid_equal(&block->bb_u.l.bb_uuid, &mp->m_sb.sb_meta_uuid)) 4424 return __this_address; | 3346 xfs_btree_get_keys(cur, block, lkey); 3347 } else if (xfs_btree_needs_key_update(cur, optr)) { 3348 error = xfs_btree_update_keys(cur, level); 3349 if (error) 3350 goto error0; 3351 } 3352 3353 /* --- 1064 unchanged lines hidden (view full) --- 4418{ 4419 struct xfs_mount *mp = bp->b_mount; 4420 struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); 4421 4422 if (!xfs_has_crc(mp)) 4423 return __this_address; 4424 if (!uuid_equal(&block->bb_u.l.bb_uuid, &mp->m_sb.sb_meta_uuid)) 4425 return __this_address; |
4425 if (block->bb_u.l.bb_blkno != cpu_to_be64(bp->b_bn)) | 4426 if (block->bb_u.l.bb_blkno != cpu_to_be64(xfs_buf_daddr(bp))) |
4426 return __this_address; 4427 if (owner != XFS_RMAP_OWN_UNKNOWN && 4428 be64_to_cpu(block->bb_u.l.bb_owner) != owner) 4429 return __this_address; 4430 return NULL; 4431} 4432 4433/* Verify a long-format btree block. */ --- 33 unchanged lines hidden (view full) --- 4467 struct xfs_mount *mp = bp->b_mount; 4468 struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); 4469 struct xfs_perag *pag = bp->b_pag; 4470 4471 if (!xfs_has_crc(mp)) 4472 return __this_address; 4473 if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid)) 4474 return __this_address; | 4427 return __this_address; 4428 if (owner != XFS_RMAP_OWN_UNKNOWN && 4429 be64_to_cpu(block->bb_u.l.bb_owner) != owner) 4430 return __this_address; 4431 return NULL; 4432} 4433 4434/* Verify a long-format btree block. */ --- 33 unchanged lines hidden (view full) --- 4468 struct xfs_mount *mp = bp->b_mount; 4469 struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); 4470 struct xfs_perag *pag = bp->b_pag; 4471 4472 if (!xfs_has_crc(mp)) 4473 return __this_address; 4474 if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid)) 4475 return __this_address; |
4475 if (block->bb_u.s.bb_blkno != cpu_to_be64(bp->b_bn)) | 4476 if (block->bb_u.s.bb_blkno != cpu_to_be64(xfs_buf_daddr(bp))) |
4476 return __this_address; 4477 if (pag && be32_to_cpu(block->bb_u.s.bb_owner) != pag->pag_agno) 4478 return __this_address; 4479 return NULL; 4480} 4481 4482/** 4483 * xfs_btree_sblock_verify() -- verify a short-format btree block --- 442 unchanged lines hidden --- | 4477 return __this_address; 4478 if (pag && be32_to_cpu(block->bb_u.s.bb_owner) != pag->pag_agno) 4479 return __this_address; 4480 return NULL; 4481} 4482 4483/** 4484 * xfs_btree_sblock_verify() -- verify a short-format btree block --- 442 unchanged lines hidden --- |