Skip to content

Commit db7ccc0

Browse files
author
Darrick J. Wong
committed
xfs: move ->iop_recover to xfs_defer_op_type
Finish off the series by moving the intent item recovery function pointer to the xfs_defer_op_type struct, since this is really a deferred work function now. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent e5f1a51 commit db7ccc0

File tree

10 files changed

+109
-88
lines changed

10 files changed

+109
-88
lines changed

fs/xfs/libxfs/xfs_defer.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,23 @@ xfs_defer_cancel_recovery(
713713
xfs_defer_pending_cancel_work(mp, dfp);
714714
}
715715

716+
/* Replay the deferred work item created from a recovered log intent item. */
717+
int
718+
xfs_defer_finish_recovery(
719+
struct xfs_mount *mp,
720+
struct xfs_defer_pending *dfp,
721+
struct list_head *capture_list)
722+
{
723+
const struct xfs_defer_op_type *ops = defer_op_types[dfp->dfp_type];
724+
int error;
725+
726+
error = ops->recover_work(dfp, capture_list);
727+
if (error)
728+
trace_xlog_intent_recovery_failed(mp, error,
729+
ops->recover_work);
730+
return error;
731+
}
732+
716733
/*
717734
* Move deferred ops from one transaction to another and reset the source to
718735
* initial state. This is primarily used to carry state forward across

fs/xfs/libxfs/xfs_defer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ struct xfs_defer_op_type {
5757
void (*finish_cleanup)(struct xfs_trans *tp,
5858
struct xfs_btree_cur *state, int error);
5959
void (*cancel_item)(struct list_head *item);
60+
int (*recover_work)(struct xfs_defer_pending *dfp,
61+
struct list_head *capture_list);
6062
unsigned int max_items;
6163
};
6264

@@ -130,6 +132,8 @@ void xfs_defer_start_recovery(struct xfs_log_item *lip,
130132
enum xfs_defer_ops_type dfp_type, struct list_head *r_dfops);
131133
void xfs_defer_cancel_recovery(struct xfs_mount *mp,
132134
struct xfs_defer_pending *dfp);
135+
int xfs_defer_finish_recovery(struct xfs_mount *mp,
136+
struct xfs_defer_pending *dfp, struct list_head *capture_list);
133137

134138
static inline void
135139
xfs_defer_add_item(

fs/xfs/libxfs/xfs_log_recover.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ xlog_recover_resv(const struct xfs_trans_res *r)
153153
return ret;
154154
}
155155

156+
struct xfs_defer_pending;
157+
156158
void xlog_recover_intent_item(struct xlog *log, struct xfs_log_item *lip,
157159
xfs_lsn_t lsn, unsigned int dfp_type);
158160
int xlog_recover_finish_intent(struct xfs_trans *tp,

fs/xfs/xfs_attr_item.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -544,12 +544,17 @@ xfs_attri_recover_work(
544544
struct xfs_mount *mp,
545545
struct xfs_defer_pending *dfp,
546546
struct xfs_attri_log_format *attrp,
547-
struct xfs_inode *ip,
547+
struct xfs_inode **ipp,
548548
struct xfs_attri_log_nameval *nv)
549549
{
550550
struct xfs_attr_intent *attr;
551551
struct xfs_da_args *args;
552552
int local;
553+
int error;
554+
555+
error = xlog_recover_iget(mp, attrp->alfi_ino, ipp);
556+
if (error)
557+
return ERR_PTR(error);
553558

554559
attr = kmem_zalloc(sizeof(struct xfs_attr_intent) +
555560
sizeof(struct xfs_da_args), KM_NOFS);
@@ -567,7 +572,7 @@ xfs_attri_recover_work(
567572
attr->xattri_nameval = xfs_attri_log_nameval_get(nv);
568573
ASSERT(attr->xattri_nameval);
569574

570-
args->dp = ip;
575+
args->dp = *ipp;
571576
args->geo = mp->m_attr_geo;
572577
args->whichfork = XFS_ATTR_FORK;
573578
args->name = nv->name.i_addr;
@@ -604,7 +609,7 @@ xfs_attri_recover_work(
604609
* delete the attr that it describes.
605610
*/
606611
STATIC int
607-
xfs_attri_item_recover(
612+
xfs_attr_recover_work(
608613
struct xfs_defer_pending *dfp,
609614
struct list_head *capture_list)
610615
{
@@ -630,11 +635,9 @@ xfs_attri_item_recover(
630635
!xfs_attr_namecheck(nv->name.i_addr, nv->name.i_len))
631636
return -EFSCORRUPTED;
632637

633-
error = xlog_recover_iget(mp, attrp->alfi_ino, &ip);
634-
if (error)
635-
return error;
636-
637-
attr = xfs_attri_recover_work(mp, dfp, attrp, ip, nv);
638+
attr = xfs_attri_recover_work(mp, dfp, attrp, &ip, nv);
639+
if (IS_ERR(attr))
640+
return PTR_ERR(attr);
638641
args = attr->xattri_da_args;
639642

640643
xfs_init_attr_trans(args, &resv, &total);
@@ -820,6 +823,7 @@ const struct xfs_defer_op_type xfs_attr_defer_type = {
820823
.create_done = xfs_attr_create_done,
821824
.finish_item = xfs_attr_finish_item,
822825
.cancel_item = xfs_attr_cancel_item,
826+
.recover_work = xfs_attr_recover_work,
823827
};
824828

825829
/*
@@ -856,7 +860,6 @@ static const struct xfs_item_ops xfs_attri_item_ops = {
856860
.iop_format = xfs_attri_item_format,
857861
.iop_unpin = xfs_attri_item_unpin,
858862
.iop_release = xfs_attri_item_release,
859-
.iop_recover = xfs_attri_item_recover,
860863
.iop_match = xfs_attri_item_match,
861864
.iop_relog = xfs_attri_item_relog,
862865
};

fs/xfs/xfs_bmap_item.c

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -437,15 +437,6 @@ xfs_bmap_update_cancel_item(
437437
kmem_cache_free(xfs_bmap_intent_cache, bi);
438438
}
439439

440-
const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
441-
.max_items = XFS_BUI_MAX_FAST_EXTENTS,
442-
.create_intent = xfs_bmap_update_create_intent,
443-
.abort_intent = xfs_bmap_update_abort_intent,
444-
.create_done = xfs_bmap_update_create_done,
445-
.finish_item = xfs_bmap_update_finish_item,
446-
.cancel_item = xfs_bmap_update_cancel_item,
447-
};
448-
449440
/* Is this recovered BUI ok? */
450441
static inline bool
451442
xfs_bui_validate(
@@ -484,9 +475,15 @@ static inline struct xfs_bmap_intent *
484475
xfs_bui_recover_work(
485476
struct xfs_mount *mp,
486477
struct xfs_defer_pending *dfp,
478+
struct xfs_inode **ipp,
487479
struct xfs_map_extent *map)
488480
{
489481
struct xfs_bmap_intent *bi;
482+
int error;
483+
484+
error = xlog_recover_iget(mp, map->me_owner, ipp);
485+
if (error)
486+
return ERR_PTR(error);
490487

491488
bi = kmem_cache_zalloc(xfs_bmap_intent_cache, GFP_NOFS | __GFP_NOFAIL);
492489
bi->bi_whichfork = (map->me_flags & XFS_BMAP_EXTENT_ATTR_FORK) ?
@@ -497,6 +494,7 @@ xfs_bui_recover_work(
497494
bi->bi_bmap.br_blockcount = map->me_len;
498495
bi->bi_bmap.br_state = (map->me_flags & XFS_BMAP_EXTENT_UNWRITTEN) ?
499496
XFS_EXT_UNWRITTEN : XFS_EXT_NORM;
497+
bi->bi_owner = *ipp;
500498
xfs_bmap_update_get_group(mp, bi);
501499

502500
xfs_defer_add_item(dfp, &bi->bi_list);
@@ -508,7 +506,7 @@ xfs_bui_recover_work(
508506
* We need to update some inode's bmbt.
509507
*/
510508
STATIC int
511-
xfs_bui_item_recover(
509+
xfs_bmap_recover_work(
512510
struct xfs_defer_pending *dfp,
513511
struct list_head *capture_list)
514512
{
@@ -530,11 +528,9 @@ xfs_bui_item_recover(
530528
}
531529

532530
map = &buip->bui_format.bui_extents[0];
533-
work = xfs_bui_recover_work(mp, dfp, map);
534-
535-
error = xlog_recover_iget(mp, map->me_owner, &ip);
536-
if (error)
537-
return error;
531+
work = xfs_bui_recover_work(mp, dfp, &ip, map);
532+
if (IS_ERR(work))
533+
return PTR_ERR(work);
538534

539535
/* Allocate transaction and do the work. */
540536
resv = xlog_recover_resv(&M_RES(mp)->tr_itruncate);
@@ -557,8 +553,6 @@ xfs_bui_item_recover(
557553
if (error)
558554
goto err_cancel;
559555

560-
work->bi_owner = ip;
561-
562556
error = xlog_recover_finish_intent(tp, dfp);
563557
if (error == -EFSCORRUPTED)
564558
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
@@ -587,6 +581,16 @@ xfs_bui_item_recover(
587581
return error;
588582
}
589583

584+
const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
585+
.max_items = XFS_BUI_MAX_FAST_EXTENTS,
586+
.create_intent = xfs_bmap_update_create_intent,
587+
.abort_intent = xfs_bmap_update_abort_intent,
588+
.create_done = xfs_bmap_update_create_done,
589+
.finish_item = xfs_bmap_update_finish_item,
590+
.cancel_item = xfs_bmap_update_cancel_item,
591+
.recover_work = xfs_bmap_recover_work,
592+
};
593+
590594
STATIC bool
591595
xfs_bui_item_match(
592596
struct xfs_log_item *lip,
@@ -627,7 +631,6 @@ static const struct xfs_item_ops xfs_bui_item_ops = {
627631
.iop_format = xfs_bui_item_format,
628632
.iop_unpin = xfs_bui_item_unpin,
629633
.iop_release = xfs_bui_item_release,
630-
.iop_recover = xfs_bui_item_recover,
631634
.iop_match = xfs_bui_item_match,
632635
.iop_relog = xfs_bui_item_relog,
633636
};

fs/xfs/xfs_extfree_item.c

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -567,15 +567,6 @@ xfs_extent_free_cancel_item(
567567
kmem_cache_free(xfs_extfree_item_cache, xefi);
568568
}
569569

570-
const struct xfs_defer_op_type xfs_extent_free_defer_type = {
571-
.max_items = XFS_EFI_MAX_FAST_EXTENTS,
572-
.create_intent = xfs_extent_free_create_intent,
573-
.abort_intent = xfs_extent_free_abort_intent,
574-
.create_done = xfs_extent_free_create_done,
575-
.finish_item = xfs_extent_free_finish_item,
576-
.cancel_item = xfs_extent_free_cancel_item,
577-
};
578-
579570
/*
580571
* AGFL blocks are accounted differently in the reserve pools and are not
581572
* inserted into the busy extent list.
@@ -632,16 +623,6 @@ xfs_agfl_free_finish_item(
632623
return error;
633624
}
634625

635-
/* sub-type with special handling for AGFL deferred frees */
636-
const struct xfs_defer_op_type xfs_agfl_free_defer_type = {
637-
.max_items = XFS_EFI_MAX_FAST_EXTENTS,
638-
.create_intent = xfs_extent_free_create_intent,
639-
.abort_intent = xfs_extent_free_abort_intent,
640-
.create_done = xfs_extent_free_create_done,
641-
.finish_item = xfs_agfl_free_finish_item,
642-
.cancel_item = xfs_extent_free_cancel_item,
643-
};
644-
645626
/* Is this recovered EFI ok? */
646627
static inline bool
647628
xfs_efi_validate_ext(
@@ -675,7 +656,7 @@ xfs_efi_recover_work(
675656
* the log. We need to free the extents that it describes.
676657
*/
677658
STATIC int
678-
xfs_efi_item_recover(
659+
xfs_extent_free_recover_work(
679660
struct xfs_defer_pending *dfp,
680661
struct list_head *capture_list)
681662
{
@@ -724,6 +705,27 @@ xfs_efi_item_recover(
724705
return error;
725706
}
726707

708+
const struct xfs_defer_op_type xfs_extent_free_defer_type = {
709+
.max_items = XFS_EFI_MAX_FAST_EXTENTS,
710+
.create_intent = xfs_extent_free_create_intent,
711+
.abort_intent = xfs_extent_free_abort_intent,
712+
.create_done = xfs_extent_free_create_done,
713+
.finish_item = xfs_extent_free_finish_item,
714+
.cancel_item = xfs_extent_free_cancel_item,
715+
.recover_work = xfs_extent_free_recover_work,
716+
};
717+
718+
/* sub-type with special handling for AGFL deferred frees */
719+
const struct xfs_defer_op_type xfs_agfl_free_defer_type = {
720+
.max_items = XFS_EFI_MAX_FAST_EXTENTS,
721+
.create_intent = xfs_extent_free_create_intent,
722+
.abort_intent = xfs_extent_free_abort_intent,
723+
.create_done = xfs_extent_free_create_done,
724+
.finish_item = xfs_agfl_free_finish_item,
725+
.cancel_item = xfs_extent_free_cancel_item,
726+
.recover_work = xfs_extent_free_recover_work,
727+
};
728+
727729
STATIC bool
728730
xfs_efi_item_match(
729731
struct xfs_log_item *lip,
@@ -766,7 +768,6 @@ static const struct xfs_item_ops xfs_efi_item_ops = {
766768
.iop_format = xfs_efi_item_format,
767769
.iop_unpin = xfs_efi_item_unpin,
768770
.iop_release = xfs_efi_item_release,
769-
.iop_recover = xfs_efi_item_recover,
770771
.iop_match = xfs_efi_item_match,
771772
.iop_relog = xfs_efi_item_relog,
772773
};

fs/xfs/xfs_log_recover.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,17 +2562,14 @@ xlog_recover_process_intents(
25622562
#endif
25632563

25642564
list_for_each_entry_safe(dfp, n, &log->r_dfops, dfp_list) {
2565-
struct xfs_log_item *lip = dfp->dfp_intent;
2566-
const struct xfs_item_ops *ops = lip->li_ops;
2567-
2568-
ASSERT(xlog_item_is_intent(lip));
2565+
ASSERT(xlog_item_is_intent(dfp->dfp_intent));
25692566

25702567
/*
25712568
* We should never see a redo item with a LSN higher than
25722569
* the last transaction we found in the log at the start
25732570
* of recovery.
25742571
*/
2575-
ASSERT(XFS_LSN_CMP(last_lsn, lip->li_lsn) >= 0);
2572+
ASSERT(XFS_LSN_CMP(last_lsn, dfp->dfp_intent->li_lsn) >= 0);
25762573

25772574
/*
25782575
* NOTE: If your intent processing routine can create more
@@ -2581,15 +2578,13 @@ xlog_recover_process_intents(
25812578
* replayed in the wrong order!
25822579
*
25832580
* The recovery function can free the log item, so we must not
2584-
* access lip after it returns. It must dispose of @dfp if it
2585-
* returns 0.
2581+
* access dfp->dfp_intent after it returns. It must dispose of
2582+
* @dfp if it returns 0.
25862583
*/
2587-
error = ops->iop_recover(dfp, &capture_list);
2588-
if (error) {
2589-
trace_xlog_intent_recovery_failed(log->l_mp, error,
2590-
ops->iop_recover);
2584+
error = xfs_defer_finish_recovery(log->l_mp, dfp,
2585+
&capture_list);
2586+
if (error)
25912587
break;
2592-
}
25932588
}
25942589
if (error)
25952590
goto err;

fs/xfs/xfs_refcount_item.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -433,16 +433,6 @@ xfs_refcount_update_cancel_item(
433433
kmem_cache_free(xfs_refcount_intent_cache, ri);
434434
}
435435

436-
const struct xfs_defer_op_type xfs_refcount_update_defer_type = {
437-
.max_items = XFS_CUI_MAX_FAST_EXTENTS,
438-
.create_intent = xfs_refcount_update_create_intent,
439-
.abort_intent = xfs_refcount_update_abort_intent,
440-
.create_done = xfs_refcount_update_create_done,
441-
.finish_item = xfs_refcount_update_finish_item,
442-
.finish_cleanup = xfs_refcount_finish_one_cleanup,
443-
.cancel_item = xfs_refcount_update_cancel_item,
444-
};
445-
446436
/* Is this recovered CUI ok? */
447437
static inline bool
448438
xfs_cui_validate_phys(
@@ -491,7 +481,7 @@ xfs_cui_recover_work(
491481
* We need to update the refcountbt.
492482
*/
493483
STATIC int
494-
xfs_cui_item_recover(
484+
xfs_refcount_recover_work(
495485
struct xfs_defer_pending *dfp,
496486
struct list_head *capture_list)
497487
{
@@ -553,6 +543,17 @@ xfs_cui_item_recover(
553543
return error;
554544
}
555545

546+
const struct xfs_defer_op_type xfs_refcount_update_defer_type = {
547+
.max_items = XFS_CUI_MAX_FAST_EXTENTS,
548+
.create_intent = xfs_refcount_update_create_intent,
549+
.abort_intent = xfs_refcount_update_abort_intent,
550+
.create_done = xfs_refcount_update_create_done,
551+
.finish_item = xfs_refcount_update_finish_item,
552+
.finish_cleanup = xfs_refcount_finish_one_cleanup,
553+
.cancel_item = xfs_refcount_update_cancel_item,
554+
.recover_work = xfs_refcount_recover_work,
555+
};
556+
556557
STATIC bool
557558
xfs_cui_item_match(
558559
struct xfs_log_item *lip,
@@ -593,7 +594,6 @@ static const struct xfs_item_ops xfs_cui_item_ops = {
593594
.iop_format = xfs_cui_item_format,
594595
.iop_unpin = xfs_cui_item_unpin,
595596
.iop_release = xfs_cui_item_release,
596-
.iop_recover = xfs_cui_item_recover,
597597
.iop_match = xfs_cui_item_match,
598598
.iop_relog = xfs_cui_item_relog,
599599
};

0 commit comments

Comments
 (0)