aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2018-07-24 16:43:15 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2018-07-26 13:15:16 -0400
commit9e28a242be65b8274742425ca5d146f366205a90 (patch)
treea1367cc42195321646f26fb47d433258a6f706ea /fs
parentd5cca7eb244d276177a57e42494d479742bbba37 (diff)
xfs: drop unnecessary xfs_defer_finish() dfops parameter
Every caller of xfs_defer_finish() now passes the transaction and its associated ->t_dfops. The xfs_defer_ops parameter is therefore no longer necessary and can be removed. Since most xfs_defer_finish() callers also have to consider xfs_defer_cancel() on error, update the latter to also receive the transaction for consistency. The log recovery code contains an outlier case that cancels a dfops directly without an available transaction. Retain an internal wrapper to support this outlier case for the time being. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Bill O'Donnell <billodo@redhat.com> Reviewed-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>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/libxfs/xfs_attr.c27
-rw-r--r--fs/xfs/libxfs/xfs_attr_remote.c8
-rw-r--r--fs/xfs/libxfs/xfs_defer.c7
-rw-r--r--fs/xfs/libxfs/xfs_defer.h4
-rw-r--r--fs/xfs/xfs_bmap_util.c4
-rw-r--r--fs/xfs/xfs_dquot.c4
-rw-r--r--fs/xfs/xfs_inode.c4
-rw-r--r--fs/xfs/xfs_log_recover.c2
-rw-r--r--fs/xfs/xfs_reflink.c8
-rw-r--r--fs/xfs/xfs_trans.c13
-rw-r--r--fs/xfs/xfs_trans.h3
11 files changed, 46 insertions, 38 deletions
diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index 3e98f0af389c..3deb5cdadf08 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -322,7 +322,7 @@ xfs_attr_set(
322 xfs_trans_bhold(args.trans, leaf_bp); 322 xfs_trans_bhold(args.trans, leaf_bp);
323 xfs_defer_bjoin(args.trans->t_dfops, leaf_bp); 323 xfs_defer_bjoin(args.trans->t_dfops, leaf_bp);
324 xfs_defer_ijoin(args.trans->t_dfops, dp); 324 xfs_defer_ijoin(args.trans->t_dfops, dp);
325 error = xfs_defer_finish(&args.trans, args.trans->t_dfops); 325 error = xfs_defer_finish(&args.trans);
326 if (error) 326 if (error)
327 goto out; 327 goto out;
328 328
@@ -591,7 +591,7 @@ xfs_attr_leaf_addname(
591 if (error) 591 if (error)
592 goto out_defer_cancel; 592 goto out_defer_cancel;
593 xfs_defer_ijoin(args->trans->t_dfops, dp); 593 xfs_defer_ijoin(args->trans->t_dfops, dp);
594 error = xfs_defer_finish(&args->trans, args->trans->t_dfops); 594 error = xfs_defer_finish(&args->trans);
595 if (error) 595 if (error)
596 goto out_defer_cancel; 596 goto out_defer_cancel;
597 597
@@ -680,7 +680,7 @@ xfs_attr_leaf_addname(
680 if (error) 680 if (error)
681 goto out_defer_cancel; 681 goto out_defer_cancel;
682 xfs_defer_ijoin(args->trans->t_dfops, dp); 682 xfs_defer_ijoin(args->trans->t_dfops, dp);
683 error = xfs_defer_finish(&args->trans, args->trans->t_dfops); 683 error = xfs_defer_finish(&args->trans);
684 if (error) 684 if (error)
685 goto out_defer_cancel; 685 goto out_defer_cancel;
686 } 686 }
@@ -698,7 +698,7 @@ xfs_attr_leaf_addname(
698 } 698 }
699 return error; 699 return error;
700out_defer_cancel: 700out_defer_cancel:
701 xfs_defer_cancel(args->trans->t_dfops); 701 xfs_defer_cancel(args->trans);
702 return error; 702 return error;
703} 703}
704 704
@@ -744,13 +744,13 @@ xfs_attr_leaf_removename(
744 if (error) 744 if (error)
745 goto out_defer_cancel; 745 goto out_defer_cancel;
746 xfs_defer_ijoin(args->trans->t_dfops, dp); 746 xfs_defer_ijoin(args->trans->t_dfops, dp);
747 error = xfs_defer_finish(&args->trans, args->trans->t_dfops); 747 error = xfs_defer_finish(&args->trans);
748 if (error) 748 if (error)
749 goto out_defer_cancel; 749 goto out_defer_cancel;
750 } 750 }
751 return 0; 751 return 0;
752out_defer_cancel: 752out_defer_cancel:
753 xfs_defer_cancel(args->trans->t_dfops); 753 xfs_defer_cancel(args->trans);
754 return error; 754 return error;
755} 755}
756 756
@@ -871,8 +871,7 @@ restart:
871 if (error) 871 if (error)
872 goto out_defer_cancel; 872 goto out_defer_cancel;
873 xfs_defer_ijoin(args->trans->t_dfops, dp); 873 xfs_defer_ijoin(args->trans->t_dfops, dp);
874 error = xfs_defer_finish(&args->trans, 874 error = xfs_defer_finish(&args->trans);
875 args->trans->t_dfops);
876 if (error) 875 if (error)
877 goto out_defer_cancel; 876 goto out_defer_cancel;
878 877
@@ -897,7 +896,7 @@ restart:
897 if (error) 896 if (error)
898 goto out_defer_cancel; 897 goto out_defer_cancel;
899 xfs_defer_ijoin(args->trans->t_dfops, dp); 898 xfs_defer_ijoin(args->trans->t_dfops, dp);
900 error = xfs_defer_finish(&args->trans, args->trans->t_dfops); 899 error = xfs_defer_finish(&args->trans);
901 if (error) 900 if (error)
902 goto out_defer_cancel; 901 goto out_defer_cancel;
903 } else { 902 } else {
@@ -994,7 +993,7 @@ restart:
994 if (error) 993 if (error)
995 goto out_defer_cancel; 994 goto out_defer_cancel;
996 xfs_defer_ijoin(args->trans->t_dfops, dp); 995 xfs_defer_ijoin(args->trans->t_dfops, dp);
997 error = xfs_defer_finish(&args->trans, args->trans->t_dfops); 996 error = xfs_defer_finish(&args->trans);
998 if (error) 997 if (error)
999 goto out_defer_cancel; 998 goto out_defer_cancel;
1000 } 999 }
@@ -1023,7 +1022,7 @@ out:
1023 return error; 1022 return error;
1024 return retval; 1023 return retval;
1025out_defer_cancel: 1024out_defer_cancel:
1026 xfs_defer_cancel(args->trans->t_dfops); 1025 xfs_defer_cancel(args->trans);
1027 goto out; 1026 goto out;
1028} 1027}
1029 1028
@@ -1118,7 +1117,7 @@ xfs_attr_node_removename(
1118 if (error) 1117 if (error)
1119 goto out_defer_cancel; 1118 goto out_defer_cancel;
1120 xfs_defer_ijoin(args->trans->t_dfops, dp); 1119 xfs_defer_ijoin(args->trans->t_dfops, dp);
1121 error = xfs_defer_finish(&args->trans, args->trans->t_dfops); 1120 error = xfs_defer_finish(&args->trans);
1122 if (error) 1121 if (error)
1123 goto out_defer_cancel; 1122 goto out_defer_cancel;
1124 /* 1123 /*
@@ -1150,7 +1149,7 @@ xfs_attr_node_removename(
1150 if (error) 1149 if (error)
1151 goto out_defer_cancel; 1150 goto out_defer_cancel;
1152 xfs_defer_ijoin(args->trans->t_dfops, dp); 1151 xfs_defer_ijoin(args->trans->t_dfops, dp);
1153 error = xfs_defer_finish(&args->trans, args->trans->t_dfops); 1152 error = xfs_defer_finish(&args->trans);
1154 if (error) 1153 if (error)
1155 goto out_defer_cancel; 1154 goto out_defer_cancel;
1156 } else 1155 } else
@@ -1162,7 +1161,7 @@ out:
1162 xfs_da_state_free(state); 1161 xfs_da_state_free(state);
1163 return error; 1162 return error;
1164out_defer_cancel: 1163out_defer_cancel:
1165 xfs_defer_cancel(args->trans->t_dfops); 1164 xfs_defer_cancel(args->trans);
1166 goto out; 1165 goto out;
1167} 1166}
1168 1167
diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
index 0fbfb740949e..77ca38586913 100644
--- a/fs/xfs/libxfs/xfs_attr_remote.c
+++ b/fs/xfs/libxfs/xfs_attr_remote.c
@@ -487,7 +487,7 @@ xfs_attr_rmtval_set(
487 if (error) 487 if (error)
488 goto out_defer_cancel; 488 goto out_defer_cancel;
489 xfs_defer_ijoin(args->trans->t_dfops, dp); 489 xfs_defer_ijoin(args->trans->t_dfops, dp);
490 error = xfs_defer_finish(&args->trans, args->trans->t_dfops); 490 error = xfs_defer_finish(&args->trans);
491 if (error) 491 if (error)
492 goto out_defer_cancel; 492 goto out_defer_cancel;
493 493
@@ -555,7 +555,7 @@ xfs_attr_rmtval_set(
555 ASSERT(valuelen == 0); 555 ASSERT(valuelen == 0);
556 return 0; 556 return 0;
557out_defer_cancel: 557out_defer_cancel:
558 xfs_defer_cancel(args->trans->t_dfops); 558 xfs_defer_cancel(args->trans);
559 return error; 559 return error;
560} 560}
561 561
@@ -628,7 +628,7 @@ xfs_attr_rmtval_remove(
628 if (error) 628 if (error)
629 goto out_defer_cancel; 629 goto out_defer_cancel;
630 xfs_defer_ijoin(args->trans->t_dfops, args->dp); 630 xfs_defer_ijoin(args->trans->t_dfops, args->dp);
631 error = xfs_defer_finish(&args->trans, args->trans->t_dfops); 631 error = xfs_defer_finish(&args->trans);
632 if (error) 632 if (error)
633 goto out_defer_cancel; 633 goto out_defer_cancel;
634 634
@@ -641,6 +641,6 @@ xfs_attr_rmtval_remove(
641 } 641 }
642 return 0; 642 return 0;
643out_defer_cancel: 643out_defer_cancel:
644 xfs_defer_cancel(args->trans->t_dfops); 644 xfs_defer_cancel(args->trans);
645 return error; 645 return error;
646} 646}
diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
index b63cc9e730da..cbee0a86c978 100644
--- a/fs/xfs/libxfs/xfs_defer.c
+++ b/fs/xfs/libxfs/xfs_defer.c
@@ -342,9 +342,9 @@ xfs_defer_reset(
342 */ 342 */
343int 343int
344xfs_defer_finish( 344xfs_defer_finish(
345 struct xfs_trans **tp, 345 struct xfs_trans **tp)
346 struct xfs_defer_ops *dop)
347{ 346{
347 struct xfs_defer_ops *dop = (*tp)->t_dfops;
348 struct xfs_defer_pending *dfp; 348 struct xfs_defer_pending *dfp;
349 struct list_head *li; 349 struct list_head *li;
350 struct list_head *n; 350 struct list_head *n;
@@ -353,7 +353,6 @@ xfs_defer_finish(
353 void (*cleanup_fn)(struct xfs_trans *, void *, int); 353 void (*cleanup_fn)(struct xfs_trans *, void *, int);
354 354
355 ASSERT((*tp)->t_flags & XFS_TRANS_PERM_LOG_RES); 355 ASSERT((*tp)->t_flags & XFS_TRANS_PERM_LOG_RES);
356 ASSERT((*tp)->t_dfops == dop);
357 356
358 trace_xfs_defer_finish((*tp)->t_mountp, dop, _RET_IP_); 357 trace_xfs_defer_finish((*tp)->t_mountp, dop, _RET_IP_);
359 358
@@ -454,7 +453,7 @@ out:
454 * Free up any items left in the list. 453 * Free up any items left in the list.
455 */ 454 */
456void 455void
457xfs_defer_cancel( 456__xfs_defer_cancel(
458 struct xfs_defer_ops *dop) 457 struct xfs_defer_ops *dop)
459{ 458{
460 struct xfs_defer_pending *dfp; 459 struct xfs_defer_pending *dfp;
diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h
index 35507ca9a148..56f927803940 100644
--- a/fs/xfs/libxfs/xfs_defer.h
+++ b/fs/xfs/libxfs/xfs_defer.h
@@ -48,8 +48,8 @@ enum xfs_defer_ops_type {
48 48
49void xfs_defer_add(struct xfs_defer_ops *dop, enum xfs_defer_ops_type type, 49void xfs_defer_add(struct xfs_defer_ops *dop, enum xfs_defer_ops_type type,
50 struct list_head *h); 50 struct list_head *h);
51int xfs_defer_finish(struct xfs_trans **tp, struct xfs_defer_ops *dop); 51int xfs_defer_finish(struct xfs_trans **tp);
52void xfs_defer_cancel(struct xfs_defer_ops *dop); 52void __xfs_defer_cancel(struct xfs_defer_ops *dop);
53void xfs_defer_init(struct xfs_trans *tp, struct xfs_defer_ops *dop); 53void xfs_defer_init(struct xfs_trans *tp, struct xfs_defer_ops *dop);
54bool xfs_defer_has_unfinished_work(struct xfs_defer_ops *dop); 54bool xfs_defer_has_unfinished_work(struct xfs_defer_ops *dop);
55int xfs_defer_ijoin(struct xfs_defer_ops *dop, struct xfs_inode *ip); 55int xfs_defer_ijoin(struct xfs_defer_ops *dop, struct xfs_inode *ip);
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index ddb5f1200d3d..c32ec17048f5 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1624,7 +1624,7 @@ xfs_swap_extent_rmap(
1624 goto out_defer; 1624 goto out_defer;
1625 1625
1626 xfs_defer_ijoin(tp->t_dfops, ip); 1626 xfs_defer_ijoin(tp->t_dfops, ip);
1627 error = xfs_defer_finish(tpp, tp->t_dfops); 1627 error = xfs_defer_finish(tpp);
1628 tp = *tpp; 1628 tp = *tpp;
1629 if (error) 1629 if (error)
1630 goto out_defer; 1630 goto out_defer;
@@ -1645,7 +1645,7 @@ xfs_swap_extent_rmap(
1645 return 0; 1645 return 0;
1646 1646
1647out_defer: 1647out_defer:
1648 xfs_defer_cancel(tp->t_dfops); 1648 xfs_defer_cancel(tp);
1649out: 1649out:
1650 trace_xfs_swap_extent_rmap_error(ip, error, _RET_IP_); 1650 trace_xfs_swap_extent_rmap_error(ip, error, _RET_IP_);
1651 tip->i_d.di_flags2 = tip_flags2; 1651 tip->i_d.di_flags2 = tip_flags2;
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index a57d5e8c3118..da5c55cec966 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -368,7 +368,7 @@ xfs_dquot_disk_alloc(
368 xfs_trans_brelse(tp, bp); 368 xfs_trans_brelse(tp, bp);
369 goto error1; 369 goto error1;
370 } 370 }
371 error = xfs_defer_finish(tpp, tp->t_dfops); 371 error = xfs_defer_finish(tpp);
372 tp = *tpp; 372 tp = *tpp;
373 if (error) { 373 if (error) {
374 xfs_buf_relse(bp); 374 xfs_buf_relse(bp);
@@ -378,7 +378,7 @@ xfs_dquot_disk_alloc(
378 return 0; 378 return 0;
379 379
380error1: 380error1:
381 xfs_defer_cancel(tp->t_dfops); 381 xfs_defer_cancel(tp);
382error0: 382error0:
383 return error; 383 return error;
384} 384}
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index c47183a2f167..0e4bd559a6a7 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1570,7 +1570,7 @@ xfs_itruncate_extents_flags(
1570 * reservation and commit the old transaction. 1570 * reservation and commit the old transaction.
1571 */ 1571 */
1572 xfs_defer_ijoin(tp->t_dfops, ip); 1572 xfs_defer_ijoin(tp->t_dfops, ip);
1573 error = xfs_defer_finish(&tp, tp->t_dfops); 1573 error = xfs_defer_finish(&tp);
1574 if (error) 1574 if (error)
1575 goto out_bmap_cancel; 1575 goto out_bmap_cancel;
1576 1576
@@ -1606,7 +1606,7 @@ out_bmap_cancel:
1606 * the transaction can be properly aborted. We just need to make sure 1606 * the transaction can be properly aborted. We just need to make sure
1607 * we're not holding any resources that we were not when we came in. 1607 * we're not holding any resources that we were not when we came in.
1608 */ 1608 */
1609 xfs_defer_cancel(tp->t_dfops); 1609 xfs_defer_cancel(tp);
1610 goto out; 1610 goto out;
1611} 1611}
1612 1612
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 265e1f561157..94908a4019e1 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -4946,7 +4946,7 @@ out:
4946 xfs_trans_ail_cursor_done(&cur); 4946 xfs_trans_ail_cursor_done(&cur);
4947 spin_unlock(&ailp->ail_lock); 4947 spin_unlock(&ailp->ail_lock);
4948 if (error) 4948 if (error)
4949 xfs_defer_cancel(&dfops); 4949 __xfs_defer_cancel(&dfops);
4950 else 4950 else
4951 error = xlog_finish_defer_ops(log->l_mp, &dfops); 4951 error = xlog_finish_defer_ops(log->l_mp, &dfops);
4952 4952
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index a653739c9fb2..68b6921dc3f6 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -518,9 +518,9 @@ xfs_reflink_cancel_cow_blocks(
518 518
519 /* Roll the transaction */ 519 /* Roll the transaction */
520 xfs_defer_ijoin((*tpp)->t_dfops, ip); 520 xfs_defer_ijoin((*tpp)->t_dfops, ip);
521 error = xfs_defer_finish(tpp, (*tpp)->t_dfops); 521 error = xfs_defer_finish(tpp);
522 if (error) { 522 if (error) {
523 xfs_defer_cancel((*tpp)->t_dfops); 523 xfs_defer_cancel(*tpp);
524 break; 524 break;
525 } 525 }
526 526
@@ -716,7 +716,7 @@ xfs_reflink_end_cow(
716 xfs_bmap_del_extent_cow(ip, &icur, &got, &del); 716 xfs_bmap_del_extent_cow(ip, &icur, &got, &del);
717 717
718 xfs_defer_ijoin(tp->t_dfops, ip); 718 xfs_defer_ijoin(tp->t_dfops, ip);
719 error = xfs_defer_finish(&tp, tp->t_dfops); 719 error = xfs_defer_finish(&tp);
720 if (error) 720 if (error)
721 goto out_cancel; 721 goto out_cancel;
722 if (!xfs_iext_get_extent(ifp, &icur, &got)) 722 if (!xfs_iext_get_extent(ifp, &icur, &got))
@@ -1077,7 +1077,7 @@ xfs_reflink_remap_extent(
1077next_extent: 1077next_extent:
1078 /* Process all the deferred stuff. */ 1078 /* Process all the deferred stuff. */
1079 xfs_defer_ijoin(tp->t_dfops, ip); 1079 xfs_defer_ijoin(tp->t_dfops, ip);
1080 error = xfs_defer_finish(&tp, tp->t_dfops); 1080 error = xfs_defer_finish(&tp);
1081 if (error) 1081 if (error)
1082 goto out_cancel; 1082 goto out_cancel;
1083 } 1083 }
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 412c8d236c71..cd553aa9ecb0 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -933,9 +933,9 @@ __xfs_trans_commit(
933 933
934 /* finish deferred items on final commit */ 934 /* finish deferred items on final commit */
935 if (!regrant && tp->t_dfops) { 935 if (!regrant && tp->t_dfops) {
936 error = xfs_defer_finish(&tp, tp->t_dfops); 936 error = xfs_defer_finish(&tp);
937 if (error) { 937 if (error) {
938 xfs_defer_cancel(tp->t_dfops); 938 xfs_defer_cancel(tp);
939 goto out_unreserve; 939 goto out_unreserve;
940 } 940 }
941 } 941 }
@@ -1030,7 +1030,7 @@ xfs_trans_cancel(
1030 trace_xfs_trans_cancel(tp, _RET_IP_); 1030 trace_xfs_trans_cancel(tp, _RET_IP_);
1031 1031
1032 if (tp->t_dfops) 1032 if (tp->t_dfops)
1033 xfs_defer_cancel(tp->t_dfops); 1033 xfs_defer_cancel(tp);
1034 1034
1035 /* 1035 /*
1036 * See if the caller is relying on us to shut down the 1036 * See if the caller is relying on us to shut down the
@@ -1111,3 +1111,10 @@ xfs_trans_roll(
1111 tres.tr_logflags = XFS_TRANS_PERM_LOG_RES; 1111 tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
1112 return xfs_trans_reserve(*tpp, &tres, 0, 0); 1112 return xfs_trans_reserve(*tpp, &tres, 0, 0);
1113} 1113}
1114
1115void
1116xfs_defer_cancel(
1117 struct xfs_trans *tp)
1118{
1119 __xfs_defer_cancel(tp->t_dfops);
1120}
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index dc79e3c1d3e8..5170e89bec02 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -214,6 +214,9 @@ xfs_trans_read_buf(
214 flags, bpp, ops); 214 flags, bpp, ops);
215} 215}
216 216
217/* cancel dfops associated with a transaction */
218void xfs_defer_cancel(struct xfs_trans *);
219
217struct xfs_buf *xfs_trans_getsb(xfs_trans_t *, struct xfs_mount *, int); 220struct xfs_buf *xfs_trans_getsb(xfs_trans_t *, struct xfs_mount *, int);
218 221
219void xfs_trans_brelse(xfs_trans_t *, struct xfs_buf *); 222void xfs_trans_brelse(xfs_trans_t *, struct xfs_buf *);