From: Christoph Hellwig Date: Wed, 18 Oct 2017 18:38:49 +0000 (-0500) Subject: xfs: remove the ip argument to xfs_defer_finish X-Git-Tag: v4.14.0-rc1~39 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5c33baee95e5becf406589e86afb07040840cae9;p=thirdparty%2Fxfsprogs-dev.git xfs: remove the ip argument to xfs_defer_finish Source kernel commit: 8ad7c629b18695ec1ee8654fb27599864049862b And instead require callers to explicitly join the inode using xfs_defer_ijoin. Also consolidate the defer error handling in a few places using a goto label. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Eric Sandeen --- diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 972610399..9c1279b1e 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -78,6 +78,7 @@ #define xfs_zero_extent libxfs_zero_extent #define xfs_defer_init libxfs_defer_init +#define xfs_defer_ijoin libxfs_defer_ijoin #define xfs_defer_finish libxfs_defer_finish #define xfs_defer_cancel libxfs_defer_cancel diff --git a/libxfs/util.c b/libxfs/util.c index 5a4c1d70e..fc96b3309 100644 --- a/libxfs/util.c +++ b/libxfs/util.c @@ -607,8 +607,10 @@ libxfs_alloc_file_space( if (error) goto error0; - /* complete the transaction */ - error = xfs_defer_finish(&tp, &free_list, ip); + /* + * Complete the transaction + */ + error = xfs_defer_finish(&tp, &free_list); if (error) goto error0; diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 9877692a5..8d0abcc12 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -323,13 +323,12 @@ xfs_attr_set( */ xfs_defer_init(args.dfops, args.firstblock); error = xfs_attr_shortform_to_leaf(&args); - if (!error) - error = xfs_defer_finish(&args.trans, args.dfops, dp); - if (error) { - args.trans = NULL; - xfs_defer_cancel(&dfops); - goto out; - } + if (error) + goto out_defer_cancel; + xfs_defer_ijoin(args.dfops, dp); + error = xfs_defer_finish(&args.trans, args.dfops); + if (error) + goto out_defer_cancel; /* * Commit the leaf transformation. We'll need another (linked) @@ -368,6 +367,9 @@ xfs_attr_set( return error; +out_defer_cancel: + xfs_defer_cancel(&dfops); + args.trans = NULL; out: if (args.trans) xfs_trans_cancel(args.trans); @@ -588,13 +590,12 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) */ xfs_defer_init(args->dfops, args->firstblock); error = xfs_attr3_leaf_to_node(args); - if (!error) - error = xfs_defer_finish(&args->trans, args->dfops, dp); - if (error) { - args->trans = NULL; - xfs_defer_cancel(args->dfops); - return error; - } + if (error) + goto out_defer_cancel; + xfs_defer_ijoin(args->dfops, dp); + error = xfs_defer_finish(&args->trans, args->dfops); + if (error) + goto out_defer_cancel; /* * Commit the current trans (including the inode) and start @@ -679,14 +680,12 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) xfs_defer_init(args->dfops, args->firstblock); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ - if (!error) - error = xfs_defer_finish(&args->trans, - args->dfops, dp); - if (error) { - args->trans = NULL; - xfs_defer_cancel(args->dfops); - return error; - } + if (error) + goto out_defer_cancel; + xfs_defer_ijoin(args->dfops, dp); + error = xfs_defer_finish(&args->trans, args->dfops); + if (error) + goto out_defer_cancel; } /* @@ -701,6 +700,10 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) error = xfs_attr3_leaf_clearflag(args); } return error; +out_defer_cancel: + xfs_defer_cancel(args->dfops); + args->trans = NULL; + return error; } /* @@ -742,15 +745,18 @@ xfs_attr_leaf_removename(xfs_da_args_t *args) xfs_defer_init(args->dfops, args->firstblock); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ - if (!error) - error = xfs_defer_finish(&args->trans, args->dfops, dp); - if (error) { - args->trans = NULL; - xfs_defer_cancel(args->dfops); - return error; - } + if (error) + goto out_defer_cancel; + xfs_defer_ijoin(args->dfops, dp); + error = xfs_defer_finish(&args->trans, args->dfops); + if (error) + goto out_defer_cancel; } return 0; +out_defer_cancel: + xfs_defer_cancel(args->dfops); + args->trans = NULL; + return error; } /* @@ -867,14 +873,12 @@ restart: state = NULL; xfs_defer_init(args->dfops, args->firstblock); error = xfs_attr3_leaf_to_node(args); - if (!error) - error = xfs_defer_finish(&args->trans, - args->dfops, dp); - if (error) { - args->trans = NULL; - xfs_defer_cancel(args->dfops); - goto out; - } + if (error) + goto out_defer_cancel; + xfs_defer_ijoin(args->dfops, dp); + error = xfs_defer_finish(&args->trans, args->dfops); + if (error) + goto out_defer_cancel; /* * Commit the node conversion and start the next @@ -895,13 +899,12 @@ restart: */ xfs_defer_init(args->dfops, args->firstblock); error = xfs_da3_split(state); - if (!error) - error = xfs_defer_finish(&args->trans, args->dfops, dp); - if (error) { - args->trans = NULL; - xfs_defer_cancel(args->dfops); - goto out; - } + if (error) + goto out_defer_cancel; + xfs_defer_ijoin(args->dfops, dp); + error = xfs_defer_finish(&args->trans, args->dfops); + if (error) + goto out_defer_cancel; } else { /* * Addition succeeded, update Btree hashvals. @@ -994,14 +997,12 @@ restart: if (retval && (state->path.active > 1)) { xfs_defer_init(args->dfops, args->firstblock); error = xfs_da3_join(state); - if (!error) - error = xfs_defer_finish(&args->trans, - args->dfops, dp); - if (error) { - args->trans = NULL; - xfs_defer_cancel(args->dfops); - goto out; - } + if (error) + goto out_defer_cancel; + xfs_defer_ijoin(args->dfops, dp); + error = xfs_defer_finish(&args->trans, args->dfops); + if (error) + goto out_defer_cancel; } /* @@ -1027,6 +1028,10 @@ out: if (error) return error; return retval; +out_defer_cancel: + xfs_defer_cancel(args->dfops); + args->trans = NULL; + goto out; } /* @@ -1117,13 +1122,12 @@ xfs_attr_node_removename(xfs_da_args_t *args) if (retval && (state->path.active > 1)) { xfs_defer_init(args->dfops, args->firstblock); error = xfs_da3_join(state); - if (!error) - error = xfs_defer_finish(&args->trans, args->dfops, dp); - if (error) { - args->trans = NULL; - xfs_defer_cancel(args->dfops); - goto out; - } + if (error) + goto out_defer_cancel; + xfs_defer_ijoin(args->dfops, dp); + error = xfs_defer_finish(&args->trans, args->dfops); + if (error) + goto out_defer_cancel; /* * Commit the Btree join operation and start a new trans. */ @@ -1151,14 +1155,12 @@ xfs_attr_node_removename(xfs_da_args_t *args) xfs_defer_init(args->dfops, args->firstblock); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ - if (!error) - error = xfs_defer_finish(&args->trans, - args->dfops, dp); - if (error) { - args->trans = NULL; - xfs_defer_cancel(args->dfops); - goto out; - } + if (error) + goto out_defer_cancel; + xfs_defer_ijoin(args->dfops, dp); + error = xfs_defer_finish(&args->trans, args->dfops); + if (error) + goto out_defer_cancel; } else xfs_trans_brelse(args->trans, bp); } @@ -1167,6 +1169,10 @@ xfs_attr_node_removename(xfs_da_args_t *args) out: xfs_da_state_free(state); return error; +out_defer_cancel: + xfs_defer_cancel(args->dfops); + args->trans = NULL; + goto out; } /* diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index 4c7781a37..2f4374770 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -462,13 +462,12 @@ xfs_attr_rmtval_set( error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno, blkcnt, XFS_BMAPI_ATTRFORK, args->firstblock, args->total, &map, &nmap, args->dfops); - if (!error) - error = xfs_defer_finish(&args->trans, args->dfops, dp); - if (error) { - args->trans = NULL; - xfs_defer_cancel(args->dfops); - return error; - } + if (error) + goto out_defer_cancel; + xfs_defer_ijoin(args->dfops, dp); + error = xfs_defer_finish(&args->trans, args->dfops); + if (error) + goto out_defer_cancel; ASSERT(nmap == 1); ASSERT((map.br_startblock != DELAYSTARTBLOCK) && @@ -534,6 +533,10 @@ xfs_attr_rmtval_set( } ASSERT(valuelen == 0); return 0; +out_defer_cancel: + xfs_defer_cancel(args->dfops); + args->trans = NULL; + return error; } /* @@ -604,14 +607,12 @@ xfs_attr_rmtval_remove( error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt, XFS_BMAPI_ATTRFORK, 1, args->firstblock, args->dfops, &done); - if (!error) - error = xfs_defer_finish(&args->trans, args->dfops, - args->dp); - if (error) { - args->trans = NULL; - xfs_defer_cancel(args->dfops); - return error; - } + if (error) + goto out_defer_cancel; + xfs_defer_ijoin(args->dfops, args->dp); + error = xfs_defer_finish(&args->trans, args->dfops); + if (error) + goto out_defer_cancel; /* * Close out trans and start the next one in the chain. @@ -621,4 +622,8 @@ xfs_attr_rmtval_remove( return error; } return 0; +out_defer_cancel: + xfs_defer_cancel(args->dfops); + args->trans = NULL; + return error; } diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index e3bbde30e..a4d402a00 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -1187,7 +1187,7 @@ xfs_bmap_add_attrfork( xfs_log_sb(tp); } - error = xfs_defer_finish(&tp, &dfops, NULL); + error = xfs_defer_finish(&tp, &dfops); if (error) goto bmap_cancel; error = xfs_trans_commit(tp); @@ -6393,7 +6393,7 @@ xfs_bmap_split_extent( if (error) goto out; - error = xfs_defer_finish(&tp, &dfops, NULL); + error = xfs_defer_finish(&tp, &dfops); if (error) goto out; diff --git a/libxfs/xfs_defer.c b/libxfs/xfs_defer.c index 7345291d3..4dc19d9cd 100644 --- a/libxfs/xfs_defer.c +++ b/libxfs/xfs_defer.c @@ -277,8 +277,7 @@ xfs_defer_has_unfinished_work( /* * Add this inode to the deferred op. Each joined inode is relogged - * each time we roll the transaction, in addition to any inode passed - * to xfs_defer_finish(). + * each time we roll the transaction. */ int xfs_defer_ijoin( @@ -310,8 +309,7 @@ xfs_defer_ijoin( int xfs_defer_finish( struct xfs_trans **tp, - struct xfs_defer_ops *dop, - struct xfs_inode *ip) + struct xfs_defer_ops *dop) { struct xfs_defer_pending *dfp; struct list_head *li; @@ -324,8 +322,6 @@ xfs_defer_finish( trace_xfs_defer_finish((*tp)->t_mountp, dop); - xfs_defer_ijoin(dop, ip); - /* Until we run out of pending work to finish... */ while (xfs_defer_has_unfinished_work(dop)) { /* Log intents for work items sitting in the intake. */ diff --git a/libxfs/xfs_defer.h b/libxfs/xfs_defer.h index 70c944b21..d4f046dd4 100644 --- a/libxfs/xfs_defer.h +++ b/libxfs/xfs_defer.h @@ -72,8 +72,7 @@ struct xfs_defer_ops { void xfs_defer_add(struct xfs_defer_ops *dop, enum xfs_defer_ops_type type, struct list_head *h); -int xfs_defer_finish(struct xfs_trans **tp, struct xfs_defer_ops *dop, - struct xfs_inode *ip); +int xfs_defer_finish(struct xfs_trans **tp, struct xfs_defer_ops *dop); void xfs_defer_cancel(struct xfs_defer_ops *dop); void xfs_defer_init(struct xfs_defer_ops *dop, xfs_fsblock_t *fbp); bool xfs_defer_has_unfinished_work(struct xfs_defer_ops *dop); diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c index 3e0c81523..2c79473ac 100644 --- a/libxfs/xfs_refcount.c +++ b/libxfs/xfs_refcount.c @@ -1678,7 +1678,7 @@ xfs_refcount_recover_cow_leftovers( xfs_bmap_add_free(mp, &dfops, fsb, rr->rr_rrec.rc_blockcount, NULL); - error = xfs_defer_finish(&tp, &dfops, NULL); + error = xfs_defer_finish(&tp, &dfops); if (error) goto out_defer; diff --git a/mkfs/proto.c b/mkfs/proto.c index cf8cc391b..bc3834586 100644 --- a/mkfs/proto.c +++ b/mkfs/proto.c @@ -495,7 +495,8 @@ parseproto( newdirent(mp, tp, pip, &xname, ip->i_ino, &first, &dfops); libxfs_trans_log_inode(tp, ip, flags); - error = -libxfs_defer_finish(&tp, &dfops, ip); + libxfs_defer_ijoin(&dfops, ip); + error = -libxfs_defer_finish(&tp, &dfops); if (error) fail(_("Pre-allocated file creation failed"), error); libxfs_trans_commit(tp); @@ -577,7 +578,8 @@ parseproto( } newdirectory(mp, tp, ip, pip); libxfs_trans_log_inode(tp, ip, flags); - error = -libxfs_defer_finish(&tp, &dfops, ip); + libxfs_defer_ijoin(&dfops, ip); + error = -libxfs_defer_finish(&tp, &dfops); if (error) fail(_("Directory creation failed"), error); libxfs_trans_commit(tp); @@ -603,7 +605,8 @@ parseproto( fail(_("Unknown format"), EINVAL); } libxfs_trans_log_inode(tp, ip, flags); - error = -libxfs_defer_finish(&tp, &dfops, ip); + libxfs_defer_ijoin(&dfops, ip); + error = -libxfs_defer_finish(&tp, &dfops); if (error) { fail(_("Error encountered creating file from prototype file"), error); @@ -712,7 +715,8 @@ rtinit( } } - error = -libxfs_defer_finish(&tp, &dfops, rbmip); + libxfs_defer_ijoin(&dfops, rbmip); + error = -libxfs_defer_finish(&tp, &dfops); if (error) { fail(_("Completion of the realtime bitmap failed"), error); } @@ -747,7 +751,8 @@ rtinit( bno += ep->br_blockcount; } } - error = -libxfs_defer_finish(&tp, &dfops, rsumip); + libxfs_defer_ijoin(&dfops, rsumip); + error = -libxfs_defer_finish(&tp, &dfops); if (error) { fail(_("Completion of the realtime summary failed"), error); } @@ -770,7 +775,8 @@ rtinit( fail(_("Error initializing the realtime space"), error); } - error = -libxfs_defer_finish(&tp, &dfops, rbmip); + libxfs_defer_ijoin(&dfops, rbmip); + error = -libxfs_defer_finish(&tp, &dfops); if (error) { fail(_("Error completing the realtime space"), error); } diff --git a/repair/phase6.c b/repair/phase6.c index 19e29808f..4279d2ad4 100644 --- a/repair/phase6.c +++ b/repair/phase6.c @@ -565,7 +565,8 @@ mk_rbmino(xfs_mount_t *mp) bno += ep->br_blockcount; } } - error = -libxfs_defer_finish(&tp, &dfops, ip); + libxfs_defer_ijoin(&dfops, ip); + error = -libxfs_defer_finish(&tp, &dfops); if (error) { do_error( _("allocation of the realtime bitmap failed, error = %d\n"), @@ -817,7 +818,8 @@ mk_rsumino(xfs_mount_t *mp) bno += ep->br_blockcount; } } - error = -libxfs_defer_finish(&tp, &dfops, ip); + libxfs_defer_ijoin(&dfops, ip); + error = -libxfs_defer_finish(&tp, &dfops); if (error) { do_error( _("allocation of the realtime summary ino failed, error = %d\n"), @@ -1021,7 +1023,8 @@ mk_orphanage(xfs_mount_t *mp) libxfs_dir_init(tp, ip, pip); libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); - error = -libxfs_defer_finish(&tp, &dfops, ip); + libxfs_defer_ijoin(&dfops, ip); + error = -libxfs_defer_finish(&tp, &dfops); if (error) { do_error(_("%s directory creation failed -- bmapf error %d\n"), ORPHANAGE, error); @@ -1127,7 +1130,8 @@ mv_orphanage( inc_nlink(VFS_I(ino_p)); libxfs_trans_log_inode(tp, ino_p, XFS_ILOG_CORE); - err = -libxfs_defer_finish(&tp, &dfops, ino_p); + libxfs_defer_ijoin(&dfops, ino_p); + err = -libxfs_defer_finish(&tp, &dfops); if (err) do_error( _("bmap finish failed (err - %d), filesystem may be out of space\n"), @@ -1174,7 +1178,8 @@ mv_orphanage( err); } - err = -libxfs_defer_finish(&tp, &dfops, ino_p); + libxfs_defer_ijoin(&dfops, ino_p); + err = -libxfs_defer_finish(&tp, &dfops); if (err) do_error( _("bmap finish failed (%d), filesystem may be out of space\n"), @@ -1213,7 +1218,8 @@ mv_orphanage( set_nlink(VFS_I(ino_p), 1); libxfs_trans_log_inode(tp, ino_p, XFS_ILOG_CORE); - err = -libxfs_defer_finish(&tp, &dfops, ino_p); + libxfs_defer_ijoin(&dfops, ino_p); + err = -libxfs_defer_finish(&tp, &dfops); if (err) do_error( _("bmap finish failed (%d), filesystem may be out of space\n"), @@ -1313,7 +1319,8 @@ longform_dir2_rebuild( goto out_bmap_cancel; } - error = -libxfs_defer_finish(&tp, &dfops, ip); + libxfs_defer_ijoin(&dfops, ip); + error = -libxfs_defer_finish(&tp, &dfops); libxfs_trans_commit(tp); @@ -1347,7 +1354,8 @@ _("name create failed in ino %" PRIu64 " (%d), filesystem may be out of space\n" goto out_bmap_cancel; } - error = -libxfs_defer_finish(&tp, &dfops, ip); + libxfs_defer_ijoin(&dfops, ip); + error = -libxfs_defer_finish(&tp, &dfops); if (error) { do_warn( _("bmap finish failed (%d), filesystem may be out of space\n"), @@ -1407,7 +1415,8 @@ dir2_kill_block( if (error) do_error(_("shrink_inode failed inode %" PRIu64 " block %u\n"), ip->i_ino, da_bno); - libxfs_defer_finish(&tp, &dfops, ip); + libxfs_defer_ijoin(&dfops, ip); + libxfs_defer_finish(&tp, &dfops); libxfs_trans_commit(tp); } @@ -1883,7 +1892,8 @@ _("entry \"%s\" in dir inode %" PRIu64 " inconsistent with .. value (%" PRIu64 " d, &i); if (needlog) libxfs_dir2_data_log_header(&da, bp); - libxfs_defer_finish(&tp, &dfops, ip); + libxfs_defer_ijoin(&dfops, ip); + libxfs_defer_finish(&tp, &dfops); libxfs_trans_commit(tp); /* record the largest free space in the freetab for later checking */ @@ -2946,7 +2956,8 @@ process_dir_inode( libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); - error = -libxfs_defer_finish(&tp, &dfops, ip); + libxfs_defer_ijoin(&dfops, ip); + error = -libxfs_defer_finish(&tp, &dfops); ASSERT(error == 0); libxfs_trans_commit(tp); @@ -3004,7 +3015,8 @@ process_dir_inode( libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); - error = -libxfs_defer_finish(&tp, &dfops, ip); + libxfs_defer_ijoin(&dfops, ip); + error = -libxfs_defer_finish(&tp, &dfops); ASSERT(error == 0); libxfs_trans_commit(tp); }