xfs_btree.c (e9c4d8bfb26c13c41b73fdf4183d3df2d392101e) | xfs_btree.c (77a530e6c49d22bd4a221d2f059db24fc30094db) |
---|---|
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" --- 211 unchanged lines hidden (view full) --- 220static xfs_failaddr_t 221__xfs_btree_check_agblock( 222 struct xfs_btree_cur *cur, 223 struct xfs_btree_block *block, 224 int level, 225 struct xfs_buf *bp) 226{ 227 struct xfs_mount *mp = cur->bc_mp; | 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" --- 211 unchanged lines hidden (view full) --- 220static xfs_failaddr_t 221__xfs_btree_check_agblock( 222 struct xfs_btree_cur *cur, 223 struct xfs_btree_block *block, 224 int level, 225 struct xfs_buf *bp) 226{ 227 struct xfs_mount *mp = cur->bc_mp; |
228 struct xfs_perag *pag = cur->bc_ag.pag; | 228 struct xfs_perag *pag = to_perag(cur->bc_group); |
229 xfs_failaddr_t fa; 230 xfs_agblock_t agbno; 231 232 if (xfs_has_crc(mp)) { 233 if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid)) 234 return __this_address; 235 if (block->bb_u.s.bb_blkno != cpu_to_be64(xfs_buf_daddr(bp))) 236 return __this_address; --- 89 unchanged lines hidden (view full) --- 326 return -EFSCORRUPTED; 327 break; 328 case XFS_BTREE_TYPE_INODE: 329 if (!xfs_verify_fsbno(cur->bc_mp, 330 be64_to_cpu((&ptr->l)[index]))) 331 return -EFSCORRUPTED; 332 break; 333 case XFS_BTREE_TYPE_AG: | 229 xfs_failaddr_t fa; 230 xfs_agblock_t agbno; 231 232 if (xfs_has_crc(mp)) { 233 if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid)) 234 return __this_address; 235 if (block->bb_u.s.bb_blkno != cpu_to_be64(xfs_buf_daddr(bp))) 236 return __this_address; --- 89 unchanged lines hidden (view full) --- 326 return -EFSCORRUPTED; 327 break; 328 case XFS_BTREE_TYPE_INODE: 329 if (!xfs_verify_fsbno(cur->bc_mp, 330 be64_to_cpu((&ptr->l)[index]))) 331 return -EFSCORRUPTED; 332 break; 333 case XFS_BTREE_TYPE_AG: |
334 if (!xfs_verify_agbno(cur->bc_ag.pag, | 334 if (!xfs_verify_agbno(to_perag(cur->bc_group), |
335 be32_to_cpu((&ptr->s)[index]))) 336 return -EFSCORRUPTED; 337 break; 338 } 339 340 return 0; 341} 342 --- 24 unchanged lines hidden (view full) --- 367"Inode %llu fork %d: Corrupt %sbt pointer at level %d index %d.", 368 cur->bc_ino.ip->i_ino, 369 cur->bc_ino.whichfork, cur->bc_ops->name, 370 level, index); 371 break; 372 case XFS_BTREE_TYPE_AG: 373 xfs_err(cur->bc_mp, 374"AG %u: Corrupt %sbt pointer at level %d index %d.", | 335 be32_to_cpu((&ptr->s)[index]))) 336 return -EFSCORRUPTED; 337 break; 338 } 339 340 return 0; 341} 342 --- 24 unchanged lines hidden (view full) --- 367"Inode %llu fork %d: Corrupt %sbt pointer at level %d index %d.", 368 cur->bc_ino.ip->i_ino, 369 cur->bc_ino.whichfork, cur->bc_ops->name, 370 level, index); 371 break; 372 case XFS_BTREE_TYPE_AG: 373 xfs_err(cur->bc_mp, 374"AG %u: Corrupt %sbt pointer at level %d index %d.", |
375 pag_agno(cur->bc_ag.pag), cur->bc_ops->name, | 375 cur->bc_group->xg_gno, cur->bc_ops->name, |
376 level, index); 377 break; 378 } 379 xfs_btree_mark_sick(cur); 380 } 381 382 return error; 383} --- 134 unchanged lines hidden (view full) --- 518 * If we are doing a BMBT update, the number of unaccounted blocks 519 * allocated during this cursor life time should be zero. If it's not 520 * zero, then we should be shut down or on our way to shutdown due to 521 * cancelling a dirty transaction on error. 522 */ 523 ASSERT(!xfs_btree_is_bmap(cur->bc_ops) || cur->bc_bmap.allocated == 0 || 524 xfs_is_shutdown(cur->bc_mp) || error != 0); 525 | 376 level, index); 377 break; 378 } 379 xfs_btree_mark_sick(cur); 380 } 381 382 return error; 383} --- 134 unchanged lines hidden (view full) --- 518 * If we are doing a BMBT update, the number of unaccounted blocks 519 * allocated during this cursor life time should be zero. If it's not 520 * zero, then we should be shut down or on our way to shutdown due to 521 * cancelling a dirty transaction on error. 522 */ 523 ASSERT(!xfs_btree_is_bmap(cur->bc_ops) || cur->bc_bmap.allocated == 0 || 524 xfs_is_shutdown(cur->bc_mp) || error != 0); 525 |
526 switch (cur->bc_ops->type) { 527 case XFS_BTREE_TYPE_AG: 528 if (cur->bc_ag.pag) 529 xfs_perag_put(cur->bc_ag.pag); 530 break; 531 case XFS_BTREE_TYPE_INODE: 532 /* nothing to do */ 533 break; 534 case XFS_BTREE_TYPE_MEM: 535 if (cur->bc_mem.pag) 536 xfs_perag_put(cur->bc_mem.pag); 537 break; 538 } 539 | 526 if (cur->bc_group) 527 xfs_group_put(cur->bc_group); |
540 kmem_cache_free(cur->bc_cache, cur); 541} 542 543/* Return the buffer target for this btree's buffer. */ 544static inline struct xfs_buftarg * 545xfs_btree_buftarg( 546 struct xfs_btree_cur *cur) 547{ --- 464 unchanged lines hidden (view full) --- 1012 1013STATIC int 1014xfs_btree_readahead_agblock( 1015 struct xfs_btree_cur *cur, 1016 int lr, 1017 struct xfs_btree_block *block) 1018{ 1019 struct xfs_mount *mp = cur->bc_mp; | 528 kmem_cache_free(cur->bc_cache, cur); 529} 530 531/* Return the buffer target for this btree's buffer. */ 532static inline struct xfs_buftarg * 533xfs_btree_buftarg( 534 struct xfs_btree_cur *cur) 535{ --- 464 unchanged lines hidden (view full) --- 1000 1001STATIC int 1002xfs_btree_readahead_agblock( 1003 struct xfs_btree_cur *cur, 1004 int lr, 1005 struct xfs_btree_block *block) 1006{ 1007 struct xfs_mount *mp = cur->bc_mp; |
1008 struct xfs_perag *pag = to_perag(cur->bc_group); |
|
1020 xfs_agblock_t left = be32_to_cpu(block->bb_u.s.bb_leftsib); 1021 xfs_agblock_t right = be32_to_cpu(block->bb_u.s.bb_rightsib); 1022 int rval = 0; 1023 1024 if ((lr & XFS_BTCUR_LEFTRA) && left != NULLAGBLOCK) { 1025 xfs_buf_readahead(mp->m_ddev_targp, | 1009 xfs_agblock_t left = be32_to_cpu(block->bb_u.s.bb_leftsib); 1010 xfs_agblock_t right = be32_to_cpu(block->bb_u.s.bb_rightsib); 1011 int rval = 0; 1012 1013 if ((lr & XFS_BTCUR_LEFTRA) && left != NULLAGBLOCK) { 1014 xfs_buf_readahead(mp->m_ddev_targp, |
1026 xfs_agbno_to_daddr(cur->bc_ag.pag, left), 1027 mp->m_bsize, cur->bc_ops->buf_ops); | 1015 xfs_agbno_to_daddr(pag, left), mp->m_bsize, 1016 cur->bc_ops->buf_ops); |
1028 rval++; 1029 } 1030 1031 if ((lr & XFS_BTCUR_RIGHTRA) && right != NULLAGBLOCK) { 1032 xfs_buf_readahead(mp->m_ddev_targp, | 1017 rval++; 1018 } 1019 1020 if ((lr & XFS_BTCUR_RIGHTRA) && right != NULLAGBLOCK) { 1021 xfs_buf_readahead(mp->m_ddev_targp, |
1033 xfs_agbno_to_daddr(cur->bc_ag.pag, right), 1034 mp->m_bsize, cur->bc_ops->buf_ops); | 1022 xfs_agbno_to_daddr(pag, right), mp->m_bsize, 1023 cur->bc_ops->buf_ops); |
1035 rval++; 1036 } 1037 1038 return rval; 1039} 1040 1041/* 1042 * Read-ahead btree blocks, at the given level. --- 42 unchanged lines hidden (view full) --- 1085 int error; 1086 1087 error = xfs_btree_check_ptr(cur, ptr, 0, 1); 1088 if (error) 1089 return error; 1090 1091 switch (cur->bc_ops->type) { 1092 case XFS_BTREE_TYPE_AG: | 1024 rval++; 1025 } 1026 1027 return rval; 1028} 1029 1030/* 1031 * Read-ahead btree blocks, at the given level. --- 42 unchanged lines hidden (view full) --- 1074 int error; 1075 1076 error = xfs_btree_check_ptr(cur, ptr, 0, 1); 1077 if (error) 1078 return error; 1079 1080 switch (cur->bc_ops->type) { 1081 case XFS_BTREE_TYPE_AG: |
1093 *daddr = xfs_agbno_to_daddr(cur->bc_ag.pag, | 1082 *daddr = xfs_agbno_to_daddr(to_perag(cur->bc_group), |
1094 be32_to_cpu(ptr->s)); 1095 break; 1096 case XFS_BTREE_TYPE_INODE: 1097 *daddr = XFS_FSB_TO_DADDR(cur->bc_mp, be64_to_cpu(ptr->l)); 1098 break; 1099 case XFS_BTREE_TYPE_MEM: 1100 *daddr = xfbno_to_daddr(be64_to_cpu(ptr->l)); 1101 break; --- 205 unchanged lines hidden (view full) --- 1307 struct xfs_btree_cur *cur) 1308{ 1309 switch (cur->bc_ops->type) { 1310 case XFS_BTREE_TYPE_MEM: 1311 return cur->bc_mem.xfbtree->owner; 1312 case XFS_BTREE_TYPE_INODE: 1313 return cur->bc_ino.ip->i_ino; 1314 case XFS_BTREE_TYPE_AG: | 1083 be32_to_cpu(ptr->s)); 1084 break; 1085 case XFS_BTREE_TYPE_INODE: 1086 *daddr = XFS_FSB_TO_DADDR(cur->bc_mp, be64_to_cpu(ptr->l)); 1087 break; 1088 case XFS_BTREE_TYPE_MEM: 1089 *daddr = xfbno_to_daddr(be64_to_cpu(ptr->l)); 1090 break; --- 205 unchanged lines hidden (view full) --- 1296 struct xfs_btree_cur *cur) 1297{ 1298 switch (cur->bc_ops->type) { 1299 case XFS_BTREE_TYPE_MEM: 1300 return cur->bc_mem.xfbtree->owner; 1301 case XFS_BTREE_TYPE_INODE: 1302 return cur->bc_ino.ip->i_ino; 1303 case XFS_BTREE_TYPE_AG: |
1315 return pag_agno(cur->bc_ag.pag); | 1304 return cur->bc_group->xg_gno; |
1316 default: 1317 ASSERT(0); 1318 return 0; 1319 } 1320} 1321 1322void 1323xfs_btree_init_block_cur( --- 4077 unchanged lines hidden --- | 1305 default: 1306 ASSERT(0); 1307 return 0; 1308 } 1309} 1310 1311void 1312xfs_btree_init_block_cur( --- 4077 unchanged lines hidden --- |