]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: fold dfops into the transaction
authorBrian Foster <bfoster@redhat.com>
Fri, 5 Oct 2018 02:36:12 +0000 (21:36 -0500)
committerEric Sandeen <sandeen@redhat.com>
Fri, 5 Oct 2018 02:36:12 +0000 (21:36 -0500)
Source kernel commit: 9d9e6233859706875c392707efd6d516cfb764fb

struct xfs_defer_ops has now been reduced to a single list_head. The
external dfops mechanism is unused and thus everywhere a (permanent)
transaction is accessible the associated dfops structure is as well.

Remove the xfs_defer_ops structure and fold the list_head into the
transaction. Also remove the last remnant of external dfops in
xfs_trans_dup().

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
12 files changed:
include/xfs_inode.h
include/xfs_trace.h
include/xfs_trans.h
libxfs/libxfs_api_defs.h
libxfs/trans.c
libxfs/xfs_bmap.c
libxfs/xfs_btree.h
libxfs/xfs_da_btree.h
libxfs/xfs_defer.c
libxfs/xfs_defer.h
libxfs/xfs_dir2.c
libxfs/xfs_dir2.h

index 46c17d8b92a9c5920190183f4437a0be5f5e75fe..f573f23bf4f4b25a3d935f9d7229d855a4889757 100644 (file)
@@ -15,7 +15,6 @@ struct xfs_trans;
 struct xfs_mount;
 struct xfs_inode_log_item;
 struct xfs_dir_ops;
-struct xfs_defer_ops;
 
 /*
  * Inode interface. This fakes up a "VFS inode" to make the xfs_inode appear
index 6829622bedbe5f95f675789467af509322f3945a..793ac56e391ba4bf38428d01fe99b8645ecd3a96 100644 (file)
 #define trace_xfs_perag_get_tag(a,b,c,d) ((c) = (c))
 #define trace_xfs_perag_put(a,b,c,d)   ((c) = (c))
 
-#define trace_xfs_defer_init(a,b,c)            ((void) 0)
-#define trace_xfs_defer_cancel(a,b,c)          ((void) 0)
+#define trace_xfs_defer_cancel(a,b)            ((void) 0)
 #define trace_xfs_defer_pending_commit(a,b)    ((void) 0)
 #define trace_xfs_defer_pending_abort(a,b)     ((void) 0)
 #define trace_xfs_defer_pending_finish(a,b)    ((void) 0)
-#define trace_xfs_defer_trans_abort(a,b,c)     ((void) 0)
-#define trace_xfs_defer_trans_roll(a,b,c)      ((void) 0)
-#define trace_xfs_defer_trans_roll_error(a,b,c)        ((void) 0)
-#define trace_xfs_defer_finish(a,b,c)          ((void) 0)
-#define trace_xfs_defer_finish_error(a,b,c)    ((void) 0)
-#define trace_xfs_defer_finish_done(a,b,c)     ((void) 0)
+#define trace_xfs_defer_trans_abort(a,b)       ((void) 0)
+#define trace_xfs_defer_trans_roll(a,b)                ((void) 0)
+#define trace_xfs_defer_trans_roll_error(a,b)  ((void) 0)
+#define trace_xfs_defer_finish(a,b)            ((void) 0)
+#define trace_xfs_defer_finish_error(a,b)      ((void) 0)
+#define trace_xfs_defer_finish_done(a,b)       ((void) 0)
 #define trace_xfs_defer_cancel_list(a,b)       ((void) 0)
 #define trace_xfs_defer_create_intent(a,b)     ((void) 0)
 
index a561e9f022a172a0865a78e55d5916d83935f3e4..31df11725d180e41232e7f08d996a1521da83ae6 100644 (file)
@@ -64,10 +64,6 @@ typedef struct xfs_qoff_logitem {
 #define XFS_DEFER_OPS_NR_INODES        2       /* join up to two inodes */
 #define XFS_DEFER_OPS_NR_BUFS  2       /* join up to two buffers */
 
-struct xfs_defer_ops {
-       struct list_head                dop_intake;     /* unlogged pending work */
-};
-
 typedef struct xfs_trans {
        unsigned int    t_type;                 /* transaction type */
        unsigned int    t_log_res;              /* amt of log space resvd */
@@ -82,9 +78,7 @@ typedef struct xfs_trans {
        long            t_fdblocks_delta;       /* superblock fdblocks chg */
        long            t_frextents_delta;      /* superblock freextents chg */
        struct list_head        t_items;        /* first log item desc chunk */
-       struct xfs_defer_ops    *t_dfops;       /* deferred operations */
-       struct xfs_defer_ops    t_dfops_internal;
-
+       struct list_head        t_dfops;        /* deferred operations */
 } xfs_trans_t;
 
 void   xfs_trans_init(struct xfs_mount *);
index a2251968582e69e25c2be397d4d49292441930ed..ad5d65dea4dcba468422325d7f49379bdd1317b6 100644 (file)
@@ -68,7 +68,6 @@
 #define xfs_verify_ino                 libxfs_verify_ino
 #define xfs_zero_extent                        libxfs_zero_extent
 
-#define xfs_defer_init                 libxfs_defer_init
 #define xfs_defer_finish               libxfs_defer_finish
 #define xfs_defer_cancel               libxfs_defer_cancel
 
index 9e6883bc432836b6c59d277b856da2a210d9ded0..46ff8b4ae798ec373295ff62eeb85688c9093220 100644 (file)
@@ -147,6 +147,7 @@ xfs_trans_dup(
         */
        ntp->t_mountp = tp->t_mountp;
        INIT_LIST_HEAD(&ntp->t_items);
+       INIT_LIST_HEAD(&ntp->t_dfops);
        ntp->t_firstblock = NULLFSBLOCK;
 
        ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
@@ -160,12 +161,8 @@ xfs_trans_dup(
        ntp->t_blk_res = tp->t_blk_res - tp->t_blk_res_used;
        tp->t_blk_res = tp->t_blk_res_used;
 
-       /* copy the dfops pointer if it's external, otherwise move it */
-       xfs_defer_init(ntp, &ntp->t_dfops_internal);
-       if (tp->t_dfops != &tp->t_dfops_internal)
-               ntp->t_dfops = tp->t_dfops;
-       else
-               xfs_defer_move(ntp, tp);
+       /* move deferred ops over to the new tp */
+       xfs_defer_move(ntp, tp);
 
        return ntp;
 }
@@ -264,10 +261,9 @@ libxfs_trans_alloc(
                (flags & XFS_TRANS_NOFS) ? KM_NOFS : KM_SLEEP);
        tp->t_mountp = mp;
        INIT_LIST_HEAD(&tp->t_items);
+       INIT_LIST_HEAD(&tp->t_dfops);
        tp->t_firstblock = NULLFSBLOCK;
 
-       xfs_defer_init(tp, &tp->t_dfops_internal);
-
        error = xfs_trans_reserve(tp, resp, blocks, rtextents);
        if (error) {
                xfs_trans_cancel(tp);
@@ -995,7 +991,7 @@ __xfs_trans_commit(
         * Finish deferred items on final commit. Only permanent transactions
         * should ever have deferred ops.
         */
-       WARN_ON_ONCE(!list_empty(&tp->t_dfops->dop_intake) &&
+       WARN_ON_ONCE(!list_empty(&tp->t_dfops) &&
                     !(tp->t_flags & XFS_TRANS_PERM_LOG_RES));
        if (!regrant && (tp->t_flags & XFS_TRANS_PERM_LOG_RES)) {
                error = xfs_defer_finish_noroll(&tp);
index 2c3bc099cdbbae47d6acf3b1846c45b0f60b3029..0d24ce6359a5604b5ab8de2fa31355810b1cb0b4 100644 (file)
@@ -4277,7 +4277,6 @@ xfs_bmapi_write(
        bma.ip = ip;
        bma.total = total;
        bma.datatype = 0;
-       ASSERT(!tp || tp->t_dfops);
 
        while (bno < end && n < *nmap) {
                bool                    need_alloc = false, wasdelay = false;
index 1b84de44d2cd0bba92e2cbe102fbb33bbf398935..aab9a29d7613463450b69d8126dc6fcf724e1b79 100644 (file)
@@ -7,7 +7,6 @@
 #define        __XFS_BTREE_H__
 
 struct xfs_buf;
-struct xfs_defer_ops;
 struct xfs_inode;
 struct xfs_mount;
 struct xfs_trans;
index 59e290ef334f72bd57312796aaa179ebcdd408f9..84dd865b6c3d8cb30d25c38aaecebad9d5a82e9a 100644 (file)
@@ -7,7 +7,6 @@
 #ifndef __XFS_DA_BTREE_H__
 #define        __XFS_DA_BTREE_H__
 
-struct xfs_defer_ops;
 struct xfs_inode;
 struct xfs_trans;
 struct zone;
index c8e34ceac8cde7c7df47b1071f535a59c319c764..5a6da0f3679e07287b865850516efca0f0ba872c 100644 (file)
@@ -181,11 +181,10 @@ STATIC void
 xfs_defer_create_intents(
        struct xfs_trans                *tp)
 {
-       struct xfs_defer_ops            *dop = tp->t_dfops;
        struct list_head                *li;
        struct xfs_defer_pending        *dfp;
 
-       list_for_each_entry(dfp, &dop->dop_intake, dfp_list) {
+       list_for_each_entry(dfp, &tp->t_dfops, dfp_list) {
                dfp->dfp_intent = dfp->dfp_type->create_intent(tp,
                                dfp->dfp_count);
                trace_xfs_defer_create_intent(tp->t_mountp, dfp);
@@ -204,7 +203,7 @@ xfs_defer_trans_abort(
 {
        struct xfs_defer_pending        *dfp;
 
-       trace_xfs_defer_trans_abort(tp->t_mountp, dop, _RET_IP_);
+       trace_xfs_defer_trans_abort(tp, _RET_IP_);
 
        /* Abort intent items that don't have a done item. */
        list_for_each_entry(dfp, dop_pending, dfp_list) {
@@ -263,14 +262,13 @@ xfs_defer_trans_roll(
                }
        }
 
-       trace_xfs_defer_trans_roll(tp->t_mountp, tp->t_dfops, _RET_IP_);
+       trace_xfs_defer_trans_roll(tp, _RET_IP_);
 
        /* Roll the transaction. */
        error = xfs_trans_roll(tpp);
        tp = *tpp;
        if (error) {
-               trace_xfs_defer_trans_roll_error(tp->t_mountp,
-                                                tp->t_dfops, error);
+               trace_xfs_defer_trans_roll_error(tp, error);
                return error;
        }
 
@@ -294,7 +292,7 @@ static void
 xfs_defer_reset(
        struct xfs_trans        *tp)
 {
-       ASSERT(list_empty(&tp->t_dfops->dop_intake));
+       ASSERT(list_empty(&tp->t_dfops));
 
        /*
         * Low mode state transfers across transaction rolls to mirror dfops
@@ -355,15 +353,13 @@ xfs_defer_finish_noroll(
 
        ASSERT((*tp)->t_flags & XFS_TRANS_PERM_LOG_RES);
 
-       trace_xfs_defer_finish((*tp)->t_mountp, (*tp)->t_dfops, _RET_IP_);
+       trace_xfs_defer_finish(*tp, _RET_IP_);
 
        /* Until we run out of pending work to finish... */
-       while (!list_empty(&dop_pending) ||
-              !list_empty(&(*tp)->t_dfops->dop_intake)) {
+       while (!list_empty(&dop_pending) || !list_empty(&(*tp)->t_dfops)) {
                /* log intents and pull in intake items */
                xfs_defer_create_intents(*tp);
-               list_splice_tail_init(&(*tp)->t_dfops->dop_intake,
-                                     &dop_pending);
+               list_splice_tail_init(&(*tp)->t_dfops, &dop_pending);
 
                /*
                 * Roll the transaction.
@@ -435,14 +431,13 @@ out:
        if (error) {
                xfs_defer_trans_abort(*tp, &dop_pending);
                xfs_force_shutdown((*tp)->t_mountp, SHUTDOWN_CORRUPT_INCORE);
-               trace_xfs_defer_finish_error((*tp)->t_mountp, (*tp)->t_dfops,
-                                            error);
+               trace_xfs_defer_finish_error(*tp, error);
                xfs_defer_cancel_list((*tp)->t_mountp, &dop_pending);
                xfs_defer_cancel(*tp);
                return error;
        }
 
-       trace_xfs_defer_finish_done((*tp)->t_mountp, (*tp)->t_dfops, _RET_IP_);
+       trace_xfs_defer_finish_done(*tp, _RET_IP_);
        return 0;
 }
 
@@ -477,8 +472,8 @@ xfs_defer_cancel(
 {
        struct xfs_mount        *mp = tp->t_mountp;
 
-       trace_xfs_defer_cancel(mp, tp->t_dfops, _RET_IP_);
-       xfs_defer_cancel_list(mp, &tp->t_dfops->dop_intake);
+       trace_xfs_defer_cancel(tp, _RET_IP_);
+       xfs_defer_cancel_list(mp, &tp->t_dfops);
 }
 
 /* Add an item for later deferred processing. */
@@ -488,7 +483,6 @@ xfs_defer_add(
        enum xfs_defer_ops_type         type,
        struct list_head                *li)
 {
-       struct xfs_defer_ops            *dop = tp->t_dfops;
        struct xfs_defer_pending        *dfp = NULL;
 
        ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
@@ -498,8 +492,8 @@ xfs_defer_add(
         * If the last pending item has the same type, reuse it.  Else,
         * create a new pending item at the end of the intake list.
         */
-       if (!list_empty(&dop->dop_intake)) {
-               dfp = list_last_entry(&dop->dop_intake,
+       if (!list_empty(&tp->t_dfops)) {
+               dfp = list_last_entry(&tp->t_dfops,
                                struct xfs_defer_pending, dfp_list);
                if (dfp->dfp_type->type != type ||
                    (dfp->dfp_type->max_items &&
@@ -514,7 +508,7 @@ xfs_defer_add(
                dfp->dfp_done = NULL;
                dfp->dfp_count = 0;
                INIT_LIST_HEAD(&dfp->dfp_work);
-               list_add_tail(&dfp->dfp_list, &dop->dop_intake);
+               list_add_tail(&dfp->dfp_list, &tp->t_dfops);
        }
 
        list_add_tail(li, &dfp->dfp_work);
@@ -529,39 +523,17 @@ xfs_defer_init_op_type(
        defer_op_types[type->type] = type;
 }
 
-/* Initialize a deferred operation. */
-void
-xfs_defer_init(
-       struct xfs_trans                *tp,
-       struct xfs_defer_ops            *dop)
-{
-       struct xfs_mount                *mp = NULL;
-
-       memset(dop, 0, sizeof(struct xfs_defer_ops));
-       INIT_LIST_HEAD(&dop->dop_intake);
-       if (tp) {
-               ASSERT(tp->t_firstblock == NULLFSBLOCK);
-               tp->t_dfops = dop;
-               mp = tp->t_mountp;
-       }
-       trace_xfs_defer_init(mp, dop, _RET_IP_);
-}
-
 /*
- * Move state from one xfs_defer_ops to another and reset the source to initial
- * state. This is primarily used to carry state forward across transaction rolls
- * with internal dfops.
+ * Move deferred ops from one transaction to another and reset the source to
+ * initial state. This is primarily used to carry state forward across
+ * transaction rolls with pending dfops.
  */
 void
 xfs_defer_move(
        struct xfs_trans        *dtp,
        struct xfs_trans        *stp)
 {
-       struct xfs_defer_ops    *dst = dtp->t_dfops;
-       struct xfs_defer_ops    *src = stp->t_dfops;
-       ASSERT(dst != src);
-
-       list_splice_init(&src->dop_intake, &dst->dop_intake);
+       list_splice_init(&stp->t_dfops, &dtp->t_dfops);
 
        /*
         * Low free space mode was historically controlled by a dfops field.
index b2675f1ca9094b89013bfddfc9fdd67e7ffaa289..2584a5b95b0d1aa31fa3facc59cf05bbb0c18cca 100644 (file)
@@ -7,7 +7,6 @@
 #define        __XFS_DEFER_H__
 
 struct xfs_defer_op_type;
-struct xfs_defer_ops;
 
 /*
  * Save a log intent item and a list of extents, so that we can replay
@@ -40,7 +39,6 @@ void xfs_defer_add(struct xfs_trans *tp, enum xfs_defer_ops_type type,
 int xfs_defer_finish_noroll(struct xfs_trans **tp);
 int xfs_defer_finish(struct xfs_trans **tp);
 void xfs_defer_cancel(struct xfs_trans *);
-void xfs_defer_init(struct xfs_trans *tp, struct xfs_defer_ops *dop);
 void xfs_defer_move(struct xfs_trans *dtp, struct xfs_trans *stp);
 
 /* Description of a deferred type. */
index 8fade690183e02248082e2f8b8bba1883270f7ca..b0ad4a8b797f7c8df648ae2555e753407858aeeb 100644 (file)
@@ -422,7 +422,6 @@ xfs_dir_removename(
        int                     v;              /* type-checking value */
 
        ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
-       ASSERT(tp->t_dfops);
        XFS_STATS_INC(dp->i_mount, xs_dir_remove);
 
        args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
@@ -481,7 +480,6 @@ xfs_dir_replace(
        int                     v;              /* type-checking value */
 
        ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
-       ASSERT(tp->t_dfops);
 
        rval = xfs_dir_ino_validate(tp->t_mountp, inum);
        if (rval)
index ba5acd03de942a0fe1a9944553579c5112ec61df..c3e3f6b813d869cb2f7a78bebc3b2a5765ab58ed 100644 (file)
@@ -9,7 +9,6 @@
 #include "xfs_da_format.h"
 #include "xfs_da_btree.h"
 
-struct xfs_defer_ops;
 struct xfs_da_args;
 struct xfs_inode;
 struct xfs_mount;