Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xfs: remove the mappedbno argument to xfs_da_read_buf

Move the code for reading an already mapped block into
xfs_da3_node_read_mapped, which is the only caller ever passing a block
number in the mappedbno argument and replace the mappedbno argument with
the simple xfs_dabuf_get flags.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

authored by

Christoph Hellwig and committed by
Darrick J. Wong
cd2c9f1b 02c57f0a

+47 -50
+1 -1
fs/xfs/libxfs/xfs_attr_leaf.c
··· 434 434 { 435 435 int err; 436 436 437 - err = xfs_da_read_buf(tp, dp, bno, -1, bpp, XFS_ATTR_FORK, 437 + err = xfs_da_read_buf(tp, dp, bno, 0, bpp, XFS_ATTR_FORK, 438 438 &xfs_attr3_leaf_buf_ops); 439 439 if (!err && tp && *bpp) 440 440 xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_ATTR_LEAF_BUF);
+16 -18
fs/xfs/libxfs/xfs_da_btree.c
··· 369 369 { 370 370 int error; 371 371 372 - error = xfs_da_read_buf(tp, dp, bno, -1, bpp, whichfork, 372 + error = xfs_da_read_buf(tp, dp, bno, 0, bpp, whichfork, 373 373 &xfs_da3_node_buf_ops); 374 374 if (error || !*bpp || !tp) 375 375 return error; ··· 384 384 struct xfs_buf **bpp, 385 385 int whichfork) 386 386 { 387 + struct xfs_mount *mp = dp->i_mount; 387 388 int error; 388 389 389 - error = xfs_da_read_buf(tp, dp, 0, mappedbno, bpp, whichfork, 390 - &xfs_da3_node_buf_ops); 391 - if (error || !*bpp || !tp) 390 + error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, mappedbno, 391 + XFS_FSB_TO_BB(mp, xfs_dabuf_nfsb(mp, whichfork)), 0, 392 + bpp, &xfs_da3_node_buf_ops); 393 + if (error || !*bpp) 392 394 return error; 395 + 396 + if (whichfork == XFS_ATTR_FORK) 397 + xfs_buf_set_ref(*bpp, XFS_ATTR_BTREE_REF); 398 + else 399 + xfs_buf_set_ref(*bpp, XFS_DIR_BTREE_REF); 400 + 401 + if (!tp) 402 + return 0; 393 403 return xfs_da3_node_set_type(tp, *bpp); 394 404 } 395 405 ··· 2628 2618 struct xfs_trans *tp, 2629 2619 struct xfs_inode *dp, 2630 2620 xfs_dablk_t bno, 2631 - xfs_daddr_t mappedbno, 2621 + unsigned int flags, 2632 2622 struct xfs_buf **bpp, 2633 2623 int whichfork, 2634 2624 const struct xfs_buf_ops *ops) ··· 2640 2630 int error; 2641 2631 2642 2632 *bpp = NULL; 2643 - 2644 - if (mappedbno >= 0) { 2645 - error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, 2646 - mappedbno, XFS_FSB_TO_BB(mp, 2647 - xfs_dabuf_nfsb(mp, whichfork)), 2648 - 0, &bp, ops); 2649 - goto done; 2650 - } 2651 - 2652 - error = xfs_dabuf_map(dp, bno, 2653 - mappedbno == -1 ? XFS_DABUF_MAP_HOLE_OK : 0, 2654 - whichfork, &mapp, &nmap); 2633 + error = xfs_dabuf_map(dp, bno, flags, whichfork, &mapp, &nmap); 2655 2634 if (error || !nmap) 2656 2635 goto out_free; 2657 2636 2658 2637 error = xfs_trans_read_buf_map(mp, tp, mp->m_ddev_targp, mapp, nmap, 0, 2659 2638 &bp, ops); 2660 - done: 2661 2639 if (error) 2662 2640 goto out_free; 2663 2641
+2 -3
fs/xfs/libxfs/xfs_da_btree.h
··· 206 206 xfs_dablk_t bno, xfs_daddr_t mappedbno, 207 207 struct xfs_buf **bp, int whichfork); 208 208 int xfs_da_read_buf(struct xfs_trans *trans, struct xfs_inode *dp, 209 - xfs_dablk_t bno, xfs_daddr_t mappedbno, 210 - struct xfs_buf **bpp, int whichfork, 211 - const struct xfs_buf_ops *ops); 209 + xfs_dablk_t bno, unsigned int flags, struct xfs_buf **bpp, 210 + int whichfork, const struct xfs_buf_ops *ops); 212 211 int xfs_da_reada_buf(struct xfs_inode *dp, xfs_dablk_t bno, 213 212 unsigned int flags, int whichfork, 214 213 const struct xfs_buf_ops *ops);
+2 -2
fs/xfs/libxfs/xfs_dir2_block.c
··· 123 123 struct xfs_mount *mp = dp->i_mount; 124 124 int err; 125 125 126 - err = xfs_da_read_buf(tp, dp, mp->m_dir_geo->datablk, -1, bpp, 126 + err = xfs_da_read_buf(tp, dp, mp->m_dir_geo->datablk, 0, bpp, 127 127 XFS_DATA_FORK, &xfs_dir3_block_buf_ops); 128 128 if (!err && tp && *bpp) 129 129 xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_BLOCK_BUF); ··· 950 950 * Read the data block if we don't already have it, give up if it fails. 951 951 */ 952 952 if (!dbp) { 953 - error = xfs_dir3_data_read(tp, dp, args->geo->datablk, -1, &dbp); 953 + error = xfs_dir3_data_read(tp, dp, args->geo->datablk, 0, &dbp); 954 954 if (error) 955 955 return error; 956 956 }
+3 -3
fs/xfs/libxfs/xfs_dir2_data.c
··· 400 400 struct xfs_trans *tp, 401 401 struct xfs_inode *dp, 402 402 xfs_dablk_t bno, 403 - xfs_daddr_t mapped_bno, 403 + unsigned int flags, 404 404 struct xfs_buf **bpp) 405 405 { 406 406 int err; 407 407 408 - err = xfs_da_read_buf(tp, dp, bno, mapped_bno, bpp, 409 - XFS_DATA_FORK, &xfs_dir3_data_buf_ops); 408 + err = xfs_da_read_buf(tp, dp, bno, flags, bpp, XFS_DATA_FORK, 409 + &xfs_dir3_data_buf_ops); 410 410 if (!err && tp && *bpp) 411 411 xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_DATA_BUF); 412 412 return err;
+6 -7
fs/xfs/libxfs/xfs_dir2_leaf.c
··· 266 266 { 267 267 int err; 268 268 269 - err = xfs_da_read_buf(tp, dp, fbno, -1, bpp, XFS_DATA_FORK, 269 + err = xfs_da_read_buf(tp, dp, fbno, 0, bpp, XFS_DATA_FORK, 270 270 &xfs_dir3_leaf1_buf_ops); 271 271 if (!err && tp && *bpp) 272 272 xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_LEAF1_BUF); ··· 282 282 { 283 283 int err; 284 284 285 - err = xfs_da_read_buf(tp, dp, fbno, -1, bpp, XFS_DATA_FORK, 285 + err = xfs_da_read_buf(tp, dp, fbno, 0, bpp, XFS_DATA_FORK, 286 286 &xfs_dir3_leafn_buf_ops); 287 287 if (!err && tp && *bpp) 288 288 xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_LEAFN_BUF); ··· 826 826 */ 827 827 error = xfs_dir3_data_read(tp, dp, 828 828 xfs_dir2_db_to_da(args->geo, use_block), 829 - -1, &dbp); 829 + 0, &dbp); 830 830 if (error) { 831 831 xfs_trans_brelse(tp, lbp); 832 832 return error; ··· 1268 1268 xfs_trans_brelse(tp, dbp); 1269 1269 error = xfs_dir3_data_read(tp, dp, 1270 1270 xfs_dir2_db_to_da(args->geo, newdb), 1271 - -1, &dbp); 1271 + 0, &dbp); 1272 1272 if (error) { 1273 1273 xfs_trans_brelse(tp, lbp); 1274 1274 return error; ··· 1310 1310 xfs_trans_brelse(tp, dbp); 1311 1311 error = xfs_dir3_data_read(tp, dp, 1312 1312 xfs_dir2_db_to_da(args->geo, cidb), 1313 - -1, &dbp); 1313 + 0, &dbp); 1314 1314 if (error) { 1315 1315 xfs_trans_brelse(tp, lbp); 1316 1316 return error; ··· 1602 1602 /* 1603 1603 * Read the offending data block. We need its buffer. 1604 1604 */ 1605 - error = xfs_dir3_data_read(tp, dp, xfs_dir2_db_to_da(geo, db), -1, 1606 - &dbp); 1605 + error = xfs_dir3_data_read(tp, dp, xfs_dir2_db_to_da(geo, db), 0, &dbp); 1607 1606 if (error) 1608 1607 return error; 1609 1608
+7 -7
fs/xfs/libxfs/xfs_dir2_node.c
··· 212 212 struct xfs_trans *tp, 213 213 struct xfs_inode *dp, 214 214 xfs_dablk_t fbno, 215 - xfs_daddr_t mappedbno, 215 + unsigned int flags, 216 216 struct xfs_buf **bpp) 217 217 { 218 218 xfs_failaddr_t fa; 219 219 int err; 220 220 221 - err = xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp, 222 - XFS_DATA_FORK, &xfs_dir3_free_buf_ops); 221 + err = xfs_da_read_buf(tp, dp, fbno, flags, bpp, XFS_DATA_FORK, 222 + &xfs_dir3_free_buf_ops); 223 223 if (err || !*bpp) 224 224 return err; 225 225 ··· 297 297 xfs_dablk_t fbno, 298 298 struct xfs_buf **bpp) 299 299 { 300 - return __xfs_dir3_free_read(tp, dp, fbno, -1, bpp); 300 + return __xfs_dir3_free_read(tp, dp, fbno, 0, bpp); 301 301 } 302 302 303 303 static int ··· 307 307 xfs_dablk_t fbno, 308 308 struct xfs_buf **bpp) 309 309 { 310 - return __xfs_dir3_free_read(tp, dp, fbno, -2, bpp); 310 + return __xfs_dir3_free_read(tp, dp, fbno, XFS_DABUF_MAP_HOLE_OK, bpp); 311 311 } 312 312 313 313 static int ··· 857 857 error = xfs_dir3_data_read(tp, dp, 858 858 xfs_dir2_db_to_da(args->geo, 859 859 newdb), 860 - -1, &curbp); 860 + 0, &curbp); 861 861 if (error) 862 862 return error; 863 863 } ··· 1940 1940 /* Read the data block in. */ 1941 1941 error = xfs_dir3_data_read(tp, dp, 1942 1942 xfs_dir2_db_to_da(args->geo, dbno), 1943 - -1, &dbp); 1943 + 0, &dbp); 1944 1944 } 1945 1945 if (error) 1946 1946 return error;
+2 -2
fs/xfs/libxfs/xfs_dir2_priv.h
··· 77 77 78 78 extern xfs_failaddr_t __xfs_dir3_data_check(struct xfs_inode *dp, 79 79 struct xfs_buf *bp); 80 - extern int xfs_dir3_data_read(struct xfs_trans *tp, struct xfs_inode *dp, 81 - xfs_dablk_t bno, xfs_daddr_t mapped_bno, struct xfs_buf **bpp); 80 + int xfs_dir3_data_read(struct xfs_trans *tp, struct xfs_inode *dp, 81 + xfs_dablk_t bno, unsigned int flags, struct xfs_buf **bpp); 82 82 int xfs_dir3_data_readahead(struct xfs_inode *dp, xfs_dablk_t bno, 83 83 unsigned int flags); 84 84
+2 -2
fs/xfs/scrub/dabtree.c
··· 331 331 goto out_nobuf; 332 332 333 333 /* Read the buffer. */ 334 - error = xfs_da_read_buf(dargs->trans, dargs->dp, blk->blkno, -2, 335 - &blk->bp, dargs->whichfork, 334 + error = xfs_da_read_buf(dargs->trans, dargs->dp, blk->blkno, 335 + XFS_DABUF_MAP_HOLE_OK, &blk->bp, dargs->whichfork, 336 336 &xchk_da_btree_buf_ops); 337 337 if (!xchk_da_process_error(ds, level, &error)) 338 338 goto out_nobuf;
+5 -4
fs/xfs/scrub/dir.c
··· 229 229 xchk_da_set_corrupt(ds, level); 230 230 goto out; 231 231 } 232 - error = xfs_dir3_data_read(ds->dargs.trans, dp, rec_bno, -2, &bp); 232 + error = xfs_dir3_data_read(ds->dargs.trans, dp, rec_bno, 233 + XFS_DABUF_MAP_HOLE_OK, &bp); 233 234 if (!xchk_fblock_process_error(ds->sc, XFS_DATA_FORK, rec_bno, 234 235 &error)) 235 236 goto out; ··· 347 346 error = xfs_dir3_block_read(sc->tp, sc->ip, &bp); 348 347 } else { 349 348 /* dir data format */ 350 - error = xfs_dir3_data_read(sc->tp, sc->ip, lblk, -1, &bp); 349 + error = xfs_dir3_data_read(sc->tp, sc->ip, lblk, 0, &bp); 351 350 } 352 351 if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, lblk, &error)) 353 352 goto out; ··· 558 557 if (best == NULLDATAOFF) 559 558 continue; 560 559 error = xfs_dir3_data_read(sc->tp, sc->ip, 561 - i * args->geo->fsbcount, -1, &dbp); 560 + i * args->geo->fsbcount, 0, &dbp); 562 561 if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, lblk, 563 562 &error)) 564 563 break; ··· 609 608 } 610 609 error = xfs_dir3_data_read(sc->tp, sc->ip, 611 610 (freehdr.firstdb + i) * args->geo->fsbcount, 612 - -1, &dbp); 611 + 0, &dbp); 613 612 if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, lblk, 614 613 &error)) 615 614 break;
+1 -1
fs/xfs/xfs_dir2_readdir.c
··· 279 279 new_off = xfs_dir2_da_to_byte(geo, map.br_startoff); 280 280 if (new_off > *cur_off) 281 281 *cur_off = new_off; 282 - error = xfs_dir3_data_read(args->trans, dp, map.br_startoff, -1, &bp); 282 + error = xfs_dir3_data_read(args->trans, dp, map.br_startoff, 0, &bp); 283 283 if (error) 284 284 goto out; 285 285