]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: remove the ip argument to xfs_defer_finish
authorChristoph Hellwig <hch@lst.de>
Wed, 18 Oct 2017 18:38:49 +0000 (13:38 -0500)
committerEric Sandeen <sandeen@redhat.com>
Wed, 18 Oct 2017 18:38:49 +0000 (13:38 -0500)
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 <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/libxfs_api_defs.h
libxfs/util.c
libxfs/xfs_attr.c
libxfs/xfs_attr_remote.c
libxfs/xfs_bmap.c
libxfs/xfs_defer.c
libxfs/xfs_defer.h
libxfs/xfs_refcount.c
mkfs/proto.c
repair/phase6.c

index 9726103998e5ec9b4681a718ab94dd5120e94a3e..9c1279b1e76700c60814ed8479d01c73f0fcef45 100644 (file)
@@ -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
 
index 5a4c1d70e03f8372c913272bc54f296a806333e0..fc96b3309c2461caf3a42c4b3476ef89f4c86d44 100644 (file)
@@ -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;
 
index 9877692a5757bc5d754ef461933df57b89bcb214..8d0abcc120e8877ab073a553a24dbecd074a8239 100644 (file)
@@ -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;
 }
 
 /*
index 4c7781a374dee34f12080b61262718f794f13e28..2f4374770ef55ef86bf20d24221e6a769343bb2e 100644 (file)
@@ -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;
 }
index e3bbde30e6bcdef0da0fa5a6d2418a7814c633e7..a4d402a00fc3289105537baf8a58838fef25322d 100644 (file)
@@ -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;
 
index 7345291d3c0bb82208e367de096e7873b1f7a681..4dc19d9cdf843dc52f361e4223d17a432f796919 100644 (file)
@@ -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. */
index 70c944b21a2a3a18f7747eb476b840bc05bc2c6e..d4f046dd44bd4ae434d8104991d0327f2d2b9fc7 100644 (file)
@@ -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);
index 3e0c815235da8980f5a062bbee333322d8e24595..2c79473ac7512196dc6c52b8a9a7507ce7d2a826 100644 (file)
@@ -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;
 
index cf8cc391b14c9bafcb7f2fa885a28d1f3d539223..bc383458638ca00e9f4ce335fcb054447cc8e76b 100644 (file)
@@ -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);
                }
index 19e29808f67fdd4d202e9373122ce76ca583c9b8..4279d2ad41fd29950e97bb89c8c140425d805912 100644 (file)
@@ -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);
                }