Skip to content

Commit a444c3d

Browse files
Darrick J. Wonggregkh
authored andcommitted
xfs: move ->iop_recover to xfs_defer_op_type
commit db7ccc0 upstream. 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 <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5e327f7 commit a444c3d

10 files changed

Lines changed: 109 additions & 88 deletions

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
@@ -551,12 +551,17 @@ xfs_attri_recover_work(
551551
struct xfs_mount *mp,
552552
struct xfs_defer_pending *dfp,
553553
struct xfs_attri_log_format *attrp,
554-
struct xfs_inode *ip,
554+
struct xfs_inode **ipp,
555555
struct xfs_attri_log_nameval *nv)
556556
{
557557
struct xfs_attr_intent *attr;
558558
struct xfs_da_args *args;
559559
int local;
560+
int error;
561+
562+
error = xlog_recover_iget(mp, attrp->alfi_ino, ipp);
563+
if (error)
564+
return ERR_PTR(error);
560565

561566
attr = kmem_zalloc(sizeof(struct xfs_attr_intent) +
562567
sizeof(struct xfs_da_args), KM_NOFS);
@@ -574,7 +579,7 @@ xfs_attri_recover_work(
574579
attr->xattri_nameval = xfs_attri_log_nameval_get(nv);
575580
ASSERT(attr->xattri_nameval);
576581

577-
args->dp = ip;
582+
args->dp = *ipp;
578583
args->geo = mp->m_attr_geo;
579584
args->whichfork = XFS_ATTR_FORK;
580585
args->name = nv->name.i_addr;
@@ -609,7 +614,7 @@ xfs_attri_recover_work(
609614
* delete the attr that it describes.
610615
*/
611616
STATIC int
612-
xfs_attri_item_recover(
617+
xfs_attr_recover_work(
613618
struct xfs_defer_pending *dfp,
614619
struct list_head *capture_list)
615620
{
@@ -636,11 +641,9 @@ xfs_attri_item_recover(
636641
nv->name.i_len))
637642
return -EFSCORRUPTED;
638643

639-
error = xlog_recover_iget(mp, attrp->alfi_ino, &ip);
640-
if (error)
641-
return error;
642-
643-
attr = xfs_attri_recover_work(mp, dfp, attrp, ip, nv);
644+
attr = xfs_attri_recover_work(mp, dfp, attrp, &ip, nv);
645+
if (IS_ERR(attr))
646+
return PTR_ERR(attr);
644647
args = attr->xattri_da_args;
645648

646649
xfs_init_attr_trans(args, &resv, &total);
@@ -890,6 +893,7 @@ const struct xfs_defer_op_type xfs_attr_defer_type = {
890893
.create_done = xfs_attr_create_done,
891894
.finish_item = xfs_attr_finish_item,
892895
.cancel_item = xfs_attr_cancel_item,
896+
.recover_work = xfs_attr_recover_work,
893897
};
894898

895899
/*
@@ -926,7 +930,6 @@ static const struct xfs_item_ops xfs_attri_item_ops = {
926930
.iop_format = xfs_attri_item_format,
927931
.iop_unpin = xfs_attri_item_unpin,
928932
.iop_release = xfs_attri_item_release,
929-
.iop_recover = xfs_attri_item_recover,
930933
.iop_match = xfs_attri_item_match,
931934
.iop_relog = xfs_attri_item_relog,
932935
};

fs/xfs/xfs_bmap_item.c

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

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

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

503501
xfs_defer_add_item(dfp, &bi->bi_list);
@@ -509,7 +507,7 @@ xfs_bui_recover_work(
509507
* We need to update some inode's bmbt.
510508
*/
511509
STATIC int
512-
xfs_bui_item_recover(
510+
xfs_bmap_recover_work(
513511
struct xfs_defer_pending *dfp,
514512
struct list_head *capture_list)
515513
{
@@ -531,11 +529,9 @@ xfs_bui_item_recover(
531529
}
532530

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

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

561-
work->bi_owner = ip;
562-
563557
error = xlog_recover_finish_intent(tp, dfp);
564558
if (error == -EFSCORRUPTED)
565559
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
@@ -588,6 +582,16 @@ xfs_bui_item_recover(
588582
return error;
589583
}
590584

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

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
@@ -2565,17 +2565,14 @@ xlog_recover_process_intents(
25652565
#endif
25662566

25672567
list_for_each_entry_safe(dfp, n, &log->r_dfops, dfp_list) {
2568-
struct xfs_log_item *lip = dfp->dfp_intent;
2569-
const struct xfs_item_ops *ops = lip->li_ops;
2570-
2571-
ASSERT(xlog_item_is_intent(lip));
2568+
ASSERT(xlog_item_is_intent(dfp->dfp_intent));
25722569

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

25802577
/*
25812578
* NOTE: If your intent processing routine can create more
@@ -2584,15 +2581,13 @@ xlog_recover_process_intents(
25842581
* replayed in the wrong order!
25852582
*
25862583
* The recovery function can free the log item, so we must not
2587-
* access lip after it returns. It must dispose of @dfp if it
2588-
* returns 0.
2584+
* access dfp->dfp_intent after it returns. It must dispose of
2585+
* @dfp if it returns 0.
25892586
*/
2590-
error = ops->iop_recover(dfp, &capture_list);
2591-
if (error) {
2592-
trace_xlog_intent_recovery_failed(log->l_mp, error,
2593-
ops->iop_recover);
2587+
error = xfs_defer_finish_recovery(log->l_mp, dfp,
2588+
&capture_list);
2589+
if (error)
25942590
break;
2595-
}
25962591
}
25972592
if (error)
25982593
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)