Skip to content

Commit 1534328

Browse files
author
Darrick J. Wong
committed
xfs: pass rmap space mapping directly through the log intent code
Pass the incore rmap space mapping through the RUI logging code instead of repeatedly boxing and unboxing parameters. Signed-off-by: Darrick J. Wong <[email protected]>
1 parent 578c714 commit 1534328

File tree

3 files changed

+55
-66
lines changed

3 files changed

+55
-66
lines changed

fs/xfs/libxfs/xfs_rmap.c

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,13 +2390,7 @@ xfs_rmap_finish_one_cleanup(
23902390
int
23912391
xfs_rmap_finish_one(
23922392
struct xfs_trans *tp,
2393-
enum xfs_rmap_intent_type type,
2394-
uint64_t owner,
2395-
int whichfork,
2396-
xfs_fileoff_t startoff,
2397-
xfs_fsblock_t startblock,
2398-
xfs_filblks_t blockcount,
2399-
xfs_exntst_t state,
2393+
struct xfs_rmap_intent *ri,
24002394
struct xfs_btree_cur **pcur)
24012395
{
24022396
struct xfs_mount *mp = tp->t_mountp;
@@ -2408,11 +2402,13 @@ xfs_rmap_finish_one(
24082402
xfs_agblock_t bno;
24092403
bool unwritten;
24102404

2411-
pag = xfs_perag_get(mp, XFS_FSB_TO_AGNO(mp, startblock));
2412-
bno = XFS_FSB_TO_AGBNO(mp, startblock);
2405+
pag = xfs_perag_get(mp, XFS_FSB_TO_AGNO(mp, ri->ri_bmap.br_startblock));
2406+
bno = XFS_FSB_TO_AGBNO(mp, ri->ri_bmap.br_startblock);
24132407

2414-
trace_xfs_rmap_deferred(mp, pag->pag_agno, type, bno, owner, whichfork,
2415-
startoff, blockcount, state);
2408+
trace_xfs_rmap_deferred(mp, pag->pag_agno, ri->ri_type, bno,
2409+
ri->ri_owner, ri->ri_whichfork,
2410+
ri->ri_bmap.br_startoff, ri->ri_bmap.br_blockcount,
2411+
ri->ri_bmap.br_state);
24162412

24172413
if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_RMAP_FINISH_ONE)) {
24182414
error = -EIO;
@@ -2448,35 +2444,37 @@ xfs_rmap_finish_one(
24482444
}
24492445
*pcur = rcur;
24502446

2451-
xfs_rmap_ino_owner(&oinfo, owner, whichfork, startoff);
2452-
unwritten = state == XFS_EXT_UNWRITTEN;
2453-
bno = XFS_FSB_TO_AGBNO(rcur->bc_mp, startblock);
2447+
xfs_rmap_ino_owner(&oinfo, ri->ri_owner, ri->ri_whichfork,
2448+
ri->ri_bmap.br_startoff);
2449+
unwritten = ri->ri_bmap.br_state == XFS_EXT_UNWRITTEN;
2450+
bno = XFS_FSB_TO_AGBNO(rcur->bc_mp, ri->ri_bmap.br_startblock);
24542451

2455-
switch (type) {
2452+
switch (ri->ri_type) {
24562453
case XFS_RMAP_ALLOC:
24572454
case XFS_RMAP_MAP:
2458-
error = xfs_rmap_map(rcur, bno, blockcount, unwritten, &oinfo);
2455+
error = xfs_rmap_map(rcur, bno, ri->ri_bmap.br_blockcount,
2456+
unwritten, &oinfo);
24592457
break;
24602458
case XFS_RMAP_MAP_SHARED:
2461-
error = xfs_rmap_map_shared(rcur, bno, blockcount, unwritten,
2462-
&oinfo);
2459+
error = xfs_rmap_map_shared(rcur, bno,
2460+
ri->ri_bmap.br_blockcount, unwritten, &oinfo);
24632461
break;
24642462
case XFS_RMAP_FREE:
24652463
case XFS_RMAP_UNMAP:
2466-
error = xfs_rmap_unmap(rcur, bno, blockcount, unwritten,
2467-
&oinfo);
2464+
error = xfs_rmap_unmap(rcur, bno, ri->ri_bmap.br_blockcount,
2465+
unwritten, &oinfo);
24682466
break;
24692467
case XFS_RMAP_UNMAP_SHARED:
2470-
error = xfs_rmap_unmap_shared(rcur, bno, blockcount, unwritten,
2471-
&oinfo);
2468+
error = xfs_rmap_unmap_shared(rcur, bno,
2469+
ri->ri_bmap.br_blockcount, unwritten, &oinfo);
24722470
break;
24732471
case XFS_RMAP_CONVERT:
2474-
error = xfs_rmap_convert(rcur, bno, blockcount, !unwritten,
2475-
&oinfo);
2472+
error = xfs_rmap_convert(rcur, bno, ri->ri_bmap.br_blockcount,
2473+
!unwritten, &oinfo);
24762474
break;
24772475
case XFS_RMAP_CONVERT_SHARED:
2478-
error = xfs_rmap_convert_shared(rcur, bno, blockcount,
2479-
!unwritten, &oinfo);
2476+
error = xfs_rmap_convert_shared(rcur, bno,
2477+
ri->ri_bmap.br_blockcount, !unwritten, &oinfo);
24802478
break;
24812479
default:
24822480
ASSERT(0);

fs/xfs/libxfs/xfs_rmap.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,8 @@ void xfs_rmap_free_extent(struct xfs_trans *tp, xfs_agnumber_t agno,
179179

180180
void xfs_rmap_finish_one_cleanup(struct xfs_trans *tp,
181181
struct xfs_btree_cur *rcur, int error);
182-
int xfs_rmap_finish_one(struct xfs_trans *tp, enum xfs_rmap_intent_type type,
183-
uint64_t owner, int whichfork, xfs_fileoff_t startoff,
184-
xfs_fsblock_t startblock, xfs_filblks_t blockcount,
185-
xfs_exntst_t state, struct xfs_btree_cur **pcur);
182+
int xfs_rmap_finish_one(struct xfs_trans *tp, struct xfs_rmap_intent *ri,
183+
struct xfs_btree_cur **pcur);
186184

187185
int xfs_rmap_lookup_le_range(struct xfs_btree_cur *cur, xfs_agblock_t bno,
188186
uint64_t owner, uint64_t offset, unsigned int flags,

fs/xfs/xfs_rmap_item.c

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -293,19 +293,12 @@ static int
293293
xfs_trans_log_finish_rmap_update(
294294
struct xfs_trans *tp,
295295
struct xfs_rud_log_item *rudp,
296-
enum xfs_rmap_intent_type type,
297-
uint64_t owner,
298-
int whichfork,
299-
xfs_fileoff_t startoff,
300-
xfs_fsblock_t startblock,
301-
xfs_filblks_t blockcount,
302-
xfs_exntst_t state,
296+
struct xfs_rmap_intent *ri,
303297
struct xfs_btree_cur **pcur)
304298
{
305299
int error;
306300

307-
error = xfs_rmap_finish_one(tp, type, owner, whichfork, startoff,
308-
startblock, blockcount, state, pcur);
301+
error = xfs_rmap_finish_one(tp, ri, pcur);
309302

310303
/*
311304
* Mark the transaction dirty, even on error. This ensures the
@@ -409,10 +402,7 @@ xfs_rmap_update_finish_item(
409402
int error;
410403

411404
rmap = container_of(item, struct xfs_rmap_intent, ri_list);
412-
error = xfs_trans_log_finish_rmap_update(tp, RUD_ITEM(done),
413-
rmap->ri_type, rmap->ri_owner, rmap->ri_whichfork,
414-
rmap->ri_bmap.br_startoff, rmap->ri_bmap.br_startblock,
415-
rmap->ri_bmap.br_blockcount, rmap->ri_bmap.br_state,
405+
error = xfs_trans_log_finish_rmap_update(tp, RUD_ITEM(done), rmap,
416406
state);
417407
kmem_cache_free(xfs_rmap_intent_cache, rmap);
418408
return error;
@@ -493,15 +483,11 @@ xfs_rui_item_recover(
493483
struct list_head *capture_list)
494484
{
495485
struct xfs_rui_log_item *ruip = RUI_ITEM(lip);
496-
struct xfs_map_extent *rmap;
497486
struct xfs_rud_log_item *rudp;
498487
struct xfs_trans *tp;
499488
struct xfs_btree_cur *rcur = NULL;
500489
struct xfs_mount *mp = lip->li_log->l_mp;
501-
enum xfs_rmap_intent_type type;
502-
xfs_exntst_t state;
503490
int i;
504-
int whichfork;
505491
int error = 0;
506492

507493
/*
@@ -526,35 +512,34 @@ xfs_rui_item_recover(
526512
rudp = xfs_trans_get_rud(tp, ruip);
527513

528514
for (i = 0; i < ruip->rui_format.rui_nextents; i++) {
529-
rmap = &ruip->rui_format.rui_extents[i];
530-
state = (rmap->me_flags & XFS_RMAP_EXTENT_UNWRITTEN) ?
531-
XFS_EXT_UNWRITTEN : XFS_EXT_NORM;
532-
whichfork = (rmap->me_flags & XFS_RMAP_EXTENT_ATTR_FORK) ?
533-
XFS_ATTR_FORK : XFS_DATA_FORK;
534-
switch (rmap->me_flags & XFS_RMAP_EXTENT_TYPE_MASK) {
515+
struct xfs_rmap_intent fake = { };
516+
struct xfs_map_extent *map;
517+
518+
map = &ruip->rui_format.rui_extents[i];
519+
switch (map->me_flags & XFS_RMAP_EXTENT_TYPE_MASK) {
535520
case XFS_RMAP_EXTENT_MAP:
536-
type = XFS_RMAP_MAP;
521+
fake.ri_type = XFS_RMAP_MAP;
537522
break;
538523
case XFS_RMAP_EXTENT_MAP_SHARED:
539-
type = XFS_RMAP_MAP_SHARED;
524+
fake.ri_type = XFS_RMAP_MAP_SHARED;
540525
break;
541526
case XFS_RMAP_EXTENT_UNMAP:
542-
type = XFS_RMAP_UNMAP;
527+
fake.ri_type = XFS_RMAP_UNMAP;
543528
break;
544529
case XFS_RMAP_EXTENT_UNMAP_SHARED:
545-
type = XFS_RMAP_UNMAP_SHARED;
530+
fake.ri_type = XFS_RMAP_UNMAP_SHARED;
546531
break;
547532
case XFS_RMAP_EXTENT_CONVERT:
548-
type = XFS_RMAP_CONVERT;
533+
fake.ri_type = XFS_RMAP_CONVERT;
549534
break;
550535
case XFS_RMAP_EXTENT_CONVERT_SHARED:
551-
type = XFS_RMAP_CONVERT_SHARED;
536+
fake.ri_type = XFS_RMAP_CONVERT_SHARED;
552537
break;
553538
case XFS_RMAP_EXTENT_ALLOC:
554-
type = XFS_RMAP_ALLOC;
539+
fake.ri_type = XFS_RMAP_ALLOC;
555540
break;
556541
case XFS_RMAP_EXTENT_FREE:
557-
type = XFS_RMAP_FREE;
542+
fake.ri_type = XFS_RMAP_FREE;
558543
break;
559544
default:
560545
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
@@ -563,13 +548,21 @@ xfs_rui_item_recover(
563548
error = -EFSCORRUPTED;
564549
goto abort_error;
565550
}
566-
error = xfs_trans_log_finish_rmap_update(tp, rudp, type,
567-
rmap->me_owner, whichfork,
568-
rmap->me_startoff, rmap->me_startblock,
569-
rmap->me_len, state, &rcur);
551+
552+
fake.ri_owner = map->me_owner;
553+
fake.ri_whichfork = (map->me_flags & XFS_RMAP_EXTENT_ATTR_FORK) ?
554+
XFS_ATTR_FORK : XFS_DATA_FORK;
555+
fake.ri_bmap.br_startblock = map->me_startblock;
556+
fake.ri_bmap.br_startoff = map->me_startoff;
557+
fake.ri_bmap.br_blockcount = map->me_len;
558+
fake.ri_bmap.br_state = (map->me_flags & XFS_RMAP_EXTENT_UNWRITTEN) ?
559+
XFS_EXT_UNWRITTEN : XFS_EXT_NORM;
560+
561+
error = xfs_trans_log_finish_rmap_update(tp, rudp, &fake,
562+
&rcur);
570563
if (error == -EFSCORRUPTED)
571564
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
572-
rmap, sizeof(*rmap));
565+
map, sizeof(*map));
573566
if (error)
574567
goto abort_error;
575568

0 commit comments

Comments
 (0)