]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: drop unnecessary xfs_defer_finish() dfops parameter
authorBrian Foster <bfoster@redhat.com>
Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)
committerEric Sandeen <sandeen@redhat.com>
Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)
Source kernel commit: 9e28a242be65b8274742425ca5d146f366205a90

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>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
include/xfs_trans.h
libxfs/trans.c
libxfs/xfs_attr.c
libxfs/xfs_attr_remote.c
libxfs/xfs_defer.c
libxfs/xfs_defer.h

index 4c722b59e9937e03cbcfb639c306a12c60c47cb5..c11e694f8d6b1936a611f2df963a5c023fa80e6c 100644 (file)
@@ -104,6 +104,10 @@ int        libxfs_trans_alloc_rollable(struct xfs_mount *mp, uint blocks,
 int    libxfs_trans_alloc_empty(struct xfs_mount *mp, struct xfs_trans **tpp);
 int    libxfs_trans_commit(struct xfs_trans *);
 void   libxfs_trans_cancel(struct xfs_trans *);
+
+/* cancel dfops associated with a transaction */
+void xfs_defer_cancel(struct xfs_trans *);
+
 struct xfs_buf *libxfs_trans_getsb(struct xfs_trans *, struct xfs_mount *, int);
 
 int    libxfs_trans_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
index ec509667cc71f16eec0b8affea14f2fe1b50f089..d1736706da9f16dac56cb7bdb47d49490f0011e6 100644 (file)
@@ -115,6 +115,14 @@ libxfs_trans_roll(
        return xfs_trans_reserve(*tpp, &tres, 0, 0);
 }
 
+void
+xfs_defer_cancel(
+       struct xfs_trans        *tp)
+{
+       __xfs_defer_cancel(tp->t_dfops);
+}
+
+
 /*
  * Free the transaction structure.  If there is more clean up
  * to do when the structure is freed, add it here.
@@ -334,7 +342,7 @@ libxfs_trans_cancel(
                goto out;
 
        if (tp->t_dfops)
-               xfs_defer_cancel(tp->t_dfops);
+               xfs_defer_cancel(tp);
 
        xfs_trans_free_items(tp);
        xfs_trans_free(tp);
@@ -996,9 +1004,9 @@ __xfs_trans_commit(
 
        /* finish deferred items on final commit */
        if (!regrant && tp->t_dfops) {
-               error = xfs_defer_finish(&tp, tp->t_dfops);
+               error = xfs_defer_finish(&tp);
                if (error) {
-                       xfs_defer_cancel(tp->t_dfops);
+                       xfs_defer_cancel(tp);
                        goto out_unreserve;
                }
        }
index c14e8a346fcea41da713123b422b54fed027af58..63c92c76455c9eb1af34b480cdb268c7c279c8cb 100644 (file)
@@ -317,7 +317,7 @@ xfs_attr_set(
                xfs_trans_bhold(args.trans, leaf_bp);
                xfs_defer_bjoin(args.trans->t_dfops, leaf_bp);
                xfs_defer_ijoin(args.trans->t_dfops, dp);
-               error = xfs_defer_finish(&args.trans, args.trans->t_dfops);
+               error = xfs_defer_finish(&args.trans);
                if (error)
                        goto out;
 
@@ -586,7 +586,7 @@ xfs_attr_leaf_addname(
                if (error)
                        goto out_defer_cancel;
                xfs_defer_ijoin(args->trans->t_dfops, dp);
-               error = xfs_defer_finish(&args->trans, args->trans->t_dfops);
+               error = xfs_defer_finish(&args->trans);
                if (error)
                        goto out_defer_cancel;
 
@@ -675,7 +675,7 @@ xfs_attr_leaf_addname(
                        if (error)
                                goto out_defer_cancel;
                        xfs_defer_ijoin(args->trans->t_dfops, dp);
-                       error = xfs_defer_finish(&args->trans, args->trans->t_dfops);
+                       error = xfs_defer_finish(&args->trans);
                        if (error)
                                goto out_defer_cancel;
                }
@@ -693,7 +693,7 @@ xfs_attr_leaf_addname(
        }
        return error;
 out_defer_cancel:
-       xfs_defer_cancel(args->trans->t_dfops);
+       xfs_defer_cancel(args->trans);
        return error;
 }
 
@@ -739,13 +739,13 @@ xfs_attr_leaf_removename(
                if (error)
                        goto out_defer_cancel;
                xfs_defer_ijoin(args->trans->t_dfops, dp);
-               error = xfs_defer_finish(&args->trans, args->trans->t_dfops);
+               error = xfs_defer_finish(&args->trans);
                if (error)
                        goto out_defer_cancel;
        }
        return 0;
 out_defer_cancel:
-       xfs_defer_cancel(args->trans->t_dfops);
+       xfs_defer_cancel(args->trans);
        return error;
 }
 
@@ -866,8 +866,7 @@ restart:
                        if (error)
                                goto out_defer_cancel;
                        xfs_defer_ijoin(args->trans->t_dfops, dp);
-                       error = xfs_defer_finish(&args->trans,
-                                                args->trans->t_dfops);
+                       error = xfs_defer_finish(&args->trans);
                        if (error)
                                goto out_defer_cancel;
 
@@ -892,7 +891,7 @@ restart:
                if (error)
                        goto out_defer_cancel;
                xfs_defer_ijoin(args->trans->t_dfops, dp);
-               error = xfs_defer_finish(&args->trans, args->trans->t_dfops);
+               error = xfs_defer_finish(&args->trans);
                if (error)
                        goto out_defer_cancel;
        } else {
@@ -989,7 +988,7 @@ restart:
                        if (error)
                                goto out_defer_cancel;
                        xfs_defer_ijoin(args->trans->t_dfops, dp);
-                       error = xfs_defer_finish(&args->trans, args->trans->t_dfops);
+                       error = xfs_defer_finish(&args->trans);
                        if (error)
                                goto out_defer_cancel;
                }
@@ -1018,7 +1017,7 @@ out:
                return error;
        return retval;
 out_defer_cancel:
-       xfs_defer_cancel(args->trans->t_dfops);
+       xfs_defer_cancel(args->trans);
        goto out;
 }
 
@@ -1113,7 +1112,7 @@ xfs_attr_node_removename(
                if (error)
                        goto out_defer_cancel;
                xfs_defer_ijoin(args->trans->t_dfops, dp);
-               error = xfs_defer_finish(&args->trans, args->trans->t_dfops);
+               error = xfs_defer_finish(&args->trans);
                if (error)
                        goto out_defer_cancel;
                /*
@@ -1145,7 +1144,7 @@ xfs_attr_node_removename(
                        if (error)
                                goto out_defer_cancel;
                        xfs_defer_ijoin(args->trans->t_dfops, dp);
-                       error = xfs_defer_finish(&args->trans, args->trans->t_dfops);
+                       error = xfs_defer_finish(&args->trans);
                        if (error)
                                goto out_defer_cancel;
                } else
@@ -1157,7 +1156,7 @@ out:
        xfs_da_state_free(state);
        return error;
 out_defer_cancel:
-       xfs_defer_cancel(args->trans->t_dfops);
+       xfs_defer_cancel(args->trans);
        goto out;
 }
 
index 73e8598a739ac3b4a534ec634bbc0b6d7760d1fb..2c03d4dbcd6157edbf8eb6b40d714e9c0de88c55 100644 (file)
@@ -482,7 +482,7 @@ xfs_attr_rmtval_set(
                if (error)
                        goto out_defer_cancel;
                xfs_defer_ijoin(args->trans->t_dfops, dp);
-               error = xfs_defer_finish(&args->trans, args->trans->t_dfops);
+               error = xfs_defer_finish(&args->trans);
                if (error)
                        goto out_defer_cancel;
 
@@ -550,7 +550,7 @@ xfs_attr_rmtval_set(
        ASSERT(valuelen == 0);
        return 0;
 out_defer_cancel:
-       xfs_defer_cancel(args->trans->t_dfops);
+       xfs_defer_cancel(args->trans);
        return error;
 }
 
@@ -623,7 +623,7 @@ xfs_attr_rmtval_remove(
                if (error)
                        goto out_defer_cancel;
                xfs_defer_ijoin(args->trans->t_dfops, args->dp);
-               error = xfs_defer_finish(&args->trans, args->trans->t_dfops);
+               error = xfs_defer_finish(&args->trans);
                if (error)
                        goto out_defer_cancel;
 
@@ -636,6 +636,6 @@ xfs_attr_rmtval_remove(
        }
        return 0;
 out_defer_cancel:
-       xfs_defer_cancel(args->trans->t_dfops);
+       xfs_defer_cancel(args->trans);
        return error;
 }
index d8b940efb69bf4e01bcf99bc8808d5521ae203aa..bfc9f7f97ce64302c782bfb2baacb5e56199b291 100644 (file)
@@ -342,9 +342,9 @@ xfs_defer_reset(
  */
 int
 xfs_defer_finish(
-       struct xfs_trans                **tp,
-       struct xfs_defer_ops            *dop)
+       struct xfs_trans                **tp)
 {
+       struct xfs_defer_ops            *dop = (*tp)->t_dfops;
        struct xfs_defer_pending        *dfp;
        struct list_head                *li;
        struct list_head                *n;
@@ -353,7 +353,6 @@ xfs_defer_finish(
        void                            (*cleanup_fn)(struct xfs_trans *, void *, int);
 
        ASSERT((*tp)->t_flags & XFS_TRANS_PERM_LOG_RES);
-       ASSERT((*tp)->t_dfops == dop);
 
        trace_xfs_defer_finish((*tp)->t_mountp, dop, _RET_IP_);
 
@@ -454,7 +453,7 @@ out:
  * Free up any items left in the list.
  */
 void
-xfs_defer_cancel(
+__xfs_defer_cancel(
        struct xfs_defer_ops            *dop)
 {
        struct xfs_defer_pending        *dfp;
index 35507ca9a148456d57fe2f814198de351a56ff38..56f9278039407d94b7bf6b8dce26b7978ca1b69b 100644 (file)
@@ -48,8 +48,8 @@ enum xfs_defer_ops_type {
 
 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);
-void xfs_defer_cancel(struct xfs_defer_ops *dop);
+int xfs_defer_finish(struct xfs_trans **tp);
+void __xfs_defer_cancel(struct xfs_defer_ops *dop);
 void xfs_defer_init(struct xfs_trans *tp, struct xfs_defer_ops *dop);
 bool xfs_defer_has_unfinished_work(struct xfs_defer_ops *dop);
 int xfs_defer_ijoin(struct xfs_defer_ops *dop, struct xfs_inode *ip);