Skip to content

Commit cd2c9f1

Browse files
Christoph Hellwigdjwong
authored andcommitted
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 <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent 02c57f0 commit cd2c9f1

File tree

11 files changed

+47
-50
lines changed

11 files changed

+47
-50
lines changed

fs/xfs/libxfs/xfs_attr_leaf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ xfs_attr3_leaf_read(
434434
{
435435
int err;
436436

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,
438438
&xfs_attr3_leaf_buf_ops);
439439
if (!err && tp && *bpp)
440440
xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_ATTR_LEAF_BUF);

fs/xfs/libxfs/xfs_da_btree.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ xfs_da3_node_read(
369369
{
370370
int error;
371371

372-
error = xfs_da_read_buf(tp, dp, bno, -1, bpp, whichfork,
372+
error = xfs_da_read_buf(tp, dp, bno, 0, bpp, whichfork,
373373
&xfs_da3_node_buf_ops);
374374
if (error || !*bpp || !tp)
375375
return error;
@@ -384,12 +384,22 @@ xfs_da3_node_read_mapped(
384384
struct xfs_buf **bpp,
385385
int whichfork)
386386
{
387+
struct xfs_mount *mp = dp->i_mount;
387388
int error;
388389

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)
392394
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;
393403
return xfs_da3_node_set_type(tp, *bpp);
394404
}
395405

@@ -2618,7 +2628,7 @@ xfs_da_read_buf(
26182628
struct xfs_trans *tp,
26192629
struct xfs_inode *dp,
26202630
xfs_dablk_t bno,
2621-
xfs_daddr_t mappedbno,
2631+
unsigned int flags,
26222632
struct xfs_buf **bpp,
26232633
int whichfork,
26242634
const struct xfs_buf_ops *ops)
@@ -2630,24 +2640,12 @@ xfs_da_read_buf(
26302640
int error;
26312641

26322642
*bpp = NULL;
2633-
2634-
if (mappedbno >= 0) {
2635-
error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
2636-
mappedbno, XFS_FSB_TO_BB(mp,
2637-
xfs_dabuf_nfsb(mp, whichfork)),
2638-
0, &bp, ops);
2639-
goto done;
2640-
}
2641-
2642-
error = xfs_dabuf_map(dp, bno,
2643-
mappedbno == -1 ? XFS_DABUF_MAP_HOLE_OK : 0,
2644-
whichfork, &mapp, &nmap);
2643+
error = xfs_dabuf_map(dp, bno, flags, whichfork, &mapp, &nmap);
26452644
if (error || !nmap)
26462645
goto out_free;
26472646

26482647
error = xfs_trans_read_buf_map(mp, tp, mp->m_ddev_targp, mapp, nmap, 0,
26492648
&bp, ops);
2650-
done:
26512649
if (error)
26522650
goto out_free;
26532651

fs/xfs/libxfs/xfs_da_btree.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,8 @@ int xfs_da_get_buf(struct xfs_trans *trans, struct xfs_inode *dp,
206206
xfs_dablk_t bno, xfs_daddr_t mappedbno,
207207
struct xfs_buf **bp, int whichfork);
208208
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);
212211
int xfs_da_reada_buf(struct xfs_inode *dp, xfs_dablk_t bno,
213212
unsigned int flags, int whichfork,
214213
const struct xfs_buf_ops *ops);

fs/xfs/libxfs/xfs_dir2_block.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ xfs_dir3_block_read(
123123
struct xfs_mount *mp = dp->i_mount;
124124
int err;
125125

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,
127127
XFS_DATA_FORK, &xfs_dir3_block_buf_ops);
128128
if (!err && tp && *bpp)
129129
xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_BLOCK_BUF);
@@ -950,7 +950,7 @@ xfs_dir2_leaf_to_block(
950950
* Read the data block if we don't already have it, give up if it fails.
951951
*/
952952
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);
954954
if (error)
955955
return error;
956956
}

fs/xfs/libxfs/xfs_dir2_data.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,13 +400,13 @@ xfs_dir3_data_read(
400400
struct xfs_trans *tp,
401401
struct xfs_inode *dp,
402402
xfs_dablk_t bno,
403-
xfs_daddr_t mapped_bno,
403+
unsigned int flags,
404404
struct xfs_buf **bpp)
405405
{
406406
int err;
407407

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);
410410
if (!err && tp && *bpp)
411411
xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_DATA_BUF);
412412
return err;

fs/xfs/libxfs/xfs_dir2_leaf.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ xfs_dir3_leaf_read(
266266
{
267267
int err;
268268

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,
270270
&xfs_dir3_leaf1_buf_ops);
271271
if (!err && tp && *bpp)
272272
xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_LEAF1_BUF);
@@ -282,7 +282,7 @@ xfs_dir3_leafn_read(
282282
{
283283
int err;
284284

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,
286286
&xfs_dir3_leafn_buf_ops);
287287
if (!err && tp && *bpp)
288288
xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_LEAFN_BUF);
@@ -826,7 +826,7 @@ xfs_dir2_leaf_addname(
826826
*/
827827
error = xfs_dir3_data_read(tp, dp,
828828
xfs_dir2_db_to_da(args->geo, use_block),
829-
-1, &dbp);
829+
0, &dbp);
830830
if (error) {
831831
xfs_trans_brelse(tp, lbp);
832832
return error;
@@ -1268,7 +1268,7 @@ xfs_dir2_leaf_lookup_int(
12681268
xfs_trans_brelse(tp, dbp);
12691269
error = xfs_dir3_data_read(tp, dp,
12701270
xfs_dir2_db_to_da(args->geo, newdb),
1271-
-1, &dbp);
1271+
0, &dbp);
12721272
if (error) {
12731273
xfs_trans_brelse(tp, lbp);
12741274
return error;
@@ -1310,7 +1310,7 @@ xfs_dir2_leaf_lookup_int(
13101310
xfs_trans_brelse(tp, dbp);
13111311
error = xfs_dir3_data_read(tp, dp,
13121312
xfs_dir2_db_to_da(args->geo, cidb),
1313-
-1, &dbp);
1313+
0, &dbp);
13141314
if (error) {
13151315
xfs_trans_brelse(tp, lbp);
13161316
return error;
@@ -1602,8 +1602,7 @@ xfs_dir2_leaf_trim_data(
16021602
/*
16031603
* Read the offending data block. We need its buffer.
16041604
*/
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);
16071606
if (error)
16081607
return error;
16091608

fs/xfs/libxfs/xfs_dir2_node.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,14 @@ __xfs_dir3_free_read(
212212
struct xfs_trans *tp,
213213
struct xfs_inode *dp,
214214
xfs_dablk_t fbno,
215-
xfs_daddr_t mappedbno,
215+
unsigned int flags,
216216
struct xfs_buf **bpp)
217217
{
218218
xfs_failaddr_t fa;
219219
int err;
220220

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);
223223
if (err || !*bpp)
224224
return err;
225225

@@ -297,7 +297,7 @@ xfs_dir2_free_read(
297297
xfs_dablk_t fbno,
298298
struct xfs_buf **bpp)
299299
{
300-
return __xfs_dir3_free_read(tp, dp, fbno, -1, bpp);
300+
return __xfs_dir3_free_read(tp, dp, fbno, 0, bpp);
301301
}
302302

303303
static int
@@ -307,7 +307,7 @@ xfs_dir2_free_try_read(
307307
xfs_dablk_t fbno,
308308
struct xfs_buf **bpp)
309309
{
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);
311311
}
312312

313313
static int
@@ -857,7 +857,7 @@ xfs_dir2_leafn_lookup_for_entry(
857857
error = xfs_dir3_data_read(tp, dp,
858858
xfs_dir2_db_to_da(args->geo,
859859
newdb),
860-
-1, &curbp);
860+
0, &curbp);
861861
if (error)
862862
return error;
863863
}
@@ -1940,7 +1940,7 @@ xfs_dir2_node_addname_int(
19401940
/* Read the data block in. */
19411941
error = xfs_dir3_data_read(tp, dp,
19421942
xfs_dir2_db_to_da(args->geo, dbno),
1943-
-1, &dbp);
1943+
0, &dbp);
19441944
}
19451945
if (error)
19461946
return error;

fs/xfs/libxfs/xfs_dir2_priv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ extern void xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp);
7777

7878
extern xfs_failaddr_t __xfs_dir3_data_check(struct xfs_inode *dp,
7979
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);
8282
int xfs_dir3_data_readahead(struct xfs_inode *dp, xfs_dablk_t bno,
8383
unsigned int flags);
8484

fs/xfs/scrub/dabtree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,8 @@ xchk_da_btree_block(
331331
goto out_nobuf;
332332

333333
/* 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,
336336
&xchk_da_btree_buf_ops);
337337
if (!xchk_da_process_error(ds, level, &error))
338338
goto out_nobuf;

fs/xfs/scrub/dir.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ xchk_dir_rec(
229229
xchk_da_set_corrupt(ds, level);
230230
goto out;
231231
}
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);
233234
if (!xchk_fblock_process_error(ds->sc, XFS_DATA_FORK, rec_bno,
234235
&error))
235236
goto out;
@@ -346,7 +347,7 @@ xchk_directory_data_bestfree(
346347
error = xfs_dir3_block_read(sc->tp, sc->ip, &bp);
347348
} else {
348349
/* dir data format */
349-
error = xfs_dir3_data_read(sc->tp, sc->ip, lblk, -1, &bp);
350+
error = xfs_dir3_data_read(sc->tp, sc->ip, lblk, 0, &bp);
350351
}
351352
if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, lblk, &error))
352353
goto out;
@@ -557,7 +558,7 @@ xchk_directory_leaf1_bestfree(
557558
if (best == NULLDATAOFF)
558559
continue;
559560
error = xfs_dir3_data_read(sc->tp, sc->ip,
560-
i * args->geo->fsbcount, -1, &dbp);
561+
i * args->geo->fsbcount, 0, &dbp);
561562
if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, lblk,
562563
&error))
563564
break;
@@ -608,7 +609,7 @@ xchk_directory_free_bestfree(
608609
}
609610
error = xfs_dir3_data_read(sc->tp, sc->ip,
610611
(freehdr.firstdb + i) * args->geo->fsbcount,
611-
-1, &dbp);
612+
0, &dbp);
612613
if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, lblk,
613614
&error))
614615
break;

0 commit comments

Comments
 (0)