]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: return the allocated transaction from xfs_trans_alloc_empty
authorChristoph Hellwig <hch@lst.de>
Wed, 16 Jul 2025 12:43:15 +0000 (14:43 +0200)
committerCarlos Maiolino <cem@kernel.org>
Thu, 24 Jul 2025 15:30:13 +0000 (17:30 +0200)
xfs_trans_alloc_empty can't return errors, so return the allocated
transaction directly instead of an output double pointer argument.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
17 files changed:
fs/xfs/libxfs/xfs_refcount.c
fs/xfs/scrub/common.c
fs/xfs/scrub/repair.c
fs/xfs/scrub/scrub.c
fs/xfs/xfs_attr_item.c
fs/xfs/xfs_discard.c
fs/xfs/xfs_fsmap.c
fs/xfs/xfs_icache.c
fs/xfs/xfs_inode.c
fs/xfs/xfs_itable.c
fs/xfs/xfs_iwalk.c
fs/xfs/xfs_notify_failure.c
fs/xfs/xfs_qm.c
fs/xfs/xfs_rtalloc.c
fs/xfs/xfs_trans.c
fs/xfs/xfs_trans.h
fs/xfs/xfs_zone_gc.c

index cebe83f7842a1c692bf1469414020f48f3934d6e..8977840374836e45b1dd7767be61a636d9427df8 100644 (file)
@@ -2099,9 +2099,7 @@ xfs_refcount_recover_cow_leftovers(
         * recording the CoW debris we cancel the (empty) transaction
         * and everything goes away cleanly.
         */
-       error = xfs_trans_alloc_empty(mp, &tp);
-       if (error)
-               return error;
+       tp = xfs_trans_alloc_empty(mp);
 
        if (isrt) {
                xfs_rtgroup_lock(to_rtg(xg), XFS_RTGLOCK_REFCOUNT);
index 28ad341df8eede1739680edb2e080c1abd2e245c..d080f4e6e9d8c29dd77c03650b6e5e37e98afb45 100644 (file)
@@ -870,7 +870,8 @@ int
 xchk_trans_alloc_empty(
        struct xfs_scrub        *sc)
 {
-       return xfs_trans_alloc_empty(sc->mp, &sc->tp);
+       sc->tp = xfs_trans_alloc_empty(sc->mp);
+       return 0;
 }
 
 /*
index f8f9ed30f56b03c151f63de7985448d1505f4741..f7f80ff32afc25ed4ac7c5f04b968dffaeb19b43 100644 (file)
@@ -1279,18 +1279,10 @@ xrep_trans_alloc_hook_dummy(
        void                    **cookiep,
        struct xfs_trans        **tpp)
 {
-       int                     error;
-
        *cookiep = current->journal_info;
        current->journal_info = NULL;
-
-       error = xfs_trans_alloc_empty(mp, tpp);
-       if (!error)
-               return 0;
-
-       current->journal_info = *cookiep;
-       *cookiep = NULL;
-       return error;
+       *tpp = xfs_trans_alloc_empty(mp);
+       return 0;
 }
 
 /* Cancel a dummy transaction used by a live update hook function. */
index 76e24032e99a531e71d97b72fe63c780d93d0768..3c3b0d25006ff4a0224657bacbcf67d570da7f4a 100644 (file)
@@ -876,10 +876,7 @@ xchk_scrubv_open_by_handle(
        struct xfs_inode                *ip;
        int                             error;
 
-       error = xfs_trans_alloc_empty(mp, &tp);
-       if (error)
-               return NULL;
-
+       tp = xfs_trans_alloc_empty(mp);
        error = xfs_iget(mp, tp, head->svh_ino, XCHK_IGET_FLAGS, 0, &ip);
        xfs_trans_cancel(tp);
        if (error)
index f683b7a9323f16146b1c8cad6e54a40ca056997d..da1e11f38eb004dc0f430b1e5106d4570003a69d 100644 (file)
@@ -616,10 +616,7 @@ xfs_attri_iread_extents(
        struct xfs_trans                *tp;
        int                             error;
 
-       error = xfs_trans_alloc_empty(ip->i_mount, &tp);
-       if (error)
-               return error;
-
+       tp = xfs_trans_alloc_empty(ip->i_mount);
        xfs_ilock(ip, XFS_ILOCK_EXCL);
        error = xfs_iread_extents(tp, ip, XFS_ATTR_FORK);
        xfs_iunlock(ip, XFS_ILOCK_EXCL);
index 603d513656450889f7bc8dbb2d57642c6ad9e457..ee49f20875afa31a8958d8d0cb8cd56ca3f4f667 100644 (file)
@@ -189,9 +189,7 @@ xfs_trim_gather_extents(
         */
        xfs_log_force(mp, XFS_LOG_SYNC);
 
-       error = xfs_trans_alloc_empty(mp, &tp);
-       if (error)
-               return error;
+       tp = xfs_trans_alloc_empty(mp);
 
        error = xfs_alloc_read_agf(pag, tp, 0, &agbp);
        if (error)
@@ -583,9 +581,7 @@ xfs_trim_rtextents(
        struct xfs_trans        *tp;
        int                     error;
 
-       error = xfs_trans_alloc_empty(mp, &tp);
-       if (error)
-               return error;
+       tp = xfs_trans_alloc_empty(mp);
 
        /*
         * Walk the free ranges between low and high.  The query_range function
@@ -701,9 +697,7 @@ xfs_trim_rtgroup_extents(
        struct xfs_trans        *tp;
        int                     error;
 
-       error = xfs_trans_alloc_empty(mp, &tp);
-       if (error)
-               return error;
+       tp = xfs_trans_alloc_empty(mp);
 
        /*
         * Walk the free ranges between low and high.  The query_range function
index 414b27a86458864b048fc978f51fee05679df0cf..af68c7de8ee8ad6feb2ddeedb58f3e3bcd695da0 100644 (file)
@@ -1270,9 +1270,7 @@ xfs_getfsmap(
                 * buffer locking abilities to detect cycles in the rmapbt
                 * without deadlocking.
                 */
-               error = xfs_trans_alloc_empty(mp, &tp);
-               if (error)
-                       break;
+               tp = xfs_trans_alloc_empty(mp);
 
                info.dev = handlers[i].dev;
                info.last = false;
index bbc2f2973dcc9021b740ffb9009c17696dc1a0ea..4cf7abe5014371a5c560a49ff74e71742dd9d8a7 100644 (file)
@@ -893,10 +893,7 @@ xfs_metafile_iget(
        struct xfs_trans        *tp;
        int                     error;
 
-       error = xfs_trans_alloc_empty(mp, &tp);
-       if (error)
-               return error;
-
+       tp = xfs_trans_alloc_empty(mp);
        error = xfs_trans_metafile_iget(tp, ino, metafile_type, ipp);
        xfs_trans_cancel(tp);
        return error;
index 761a996a857caca58d2a8ad8f344fa8100f040b2..9c39251961a32ac1642586ca418b017f3efcdb4f 100644 (file)
@@ -2932,12 +2932,9 @@ xfs_inode_reload_unlinked(
        struct xfs_inode        *ip)
 {
        struct xfs_trans        *tp;
-       int                     error;
-
-       error = xfs_trans_alloc_empty(ip->i_mount, &tp);
-       if (error)
-               return error;
+       int                     error = 0;
 
+       tp = xfs_trans_alloc_empty(ip->i_mount);
        xfs_ilock(ip, XFS_ILOCK_SHARED);
        if (xfs_inode_unlinked_incomplete(ip))
                error = xfs_inode_reload_unlinked_bucket(tp, ip);
index 1fa1c0564b0c5a3168676b29ae5aa359329f0cef..c8c9b8d8309f7ac4a8d8f145b9a9ec82cc5ee93b 100644 (file)
@@ -239,14 +239,10 @@ xfs_bulkstat_one(
         * Grab an empty transaction so that we can use its recursive buffer
         * locking abilities to detect cycles in the inobt without deadlocking.
         */
-       error = xfs_trans_alloc_empty(breq->mp, &tp);
-       if (error)
-               goto out;
-
+       tp = xfs_trans_alloc_empty(breq->mp);
        error = xfs_bulkstat_one_int(breq->mp, breq->idmap, tp,
                        breq->startino, &bc);
        xfs_trans_cancel(tp);
-out:
        kfree(bc.buf);
 
        /*
@@ -331,17 +327,13 @@ xfs_bulkstat(
         * Grab an empty transaction so that we can use its recursive buffer
         * locking abilities to detect cycles in the inobt without deadlocking.
         */
-       error = xfs_trans_alloc_empty(breq->mp, &tp);
-       if (error)
-               goto out;
-
+       tp = xfs_trans_alloc_empty(breq->mp);
        if (breq->flags & XFS_IBULK_SAME_AG)
                iwalk_flags |= XFS_IWALK_SAME_AG;
 
        error = xfs_iwalk(breq->mp, tp, breq->startino, iwalk_flags,
                        xfs_bulkstat_iwalk, breq->icount, &bc);
        xfs_trans_cancel(tp);
-out:
        kfree(bc.buf);
 
        /*
@@ -464,14 +456,10 @@ xfs_inumbers(
         * Grab an empty transaction so that we can use its recursive buffer
         * locking abilities to detect cycles in the inobt without deadlocking.
         */
-       error = xfs_trans_alloc_empty(breq->mp, &tp);
-       if (error)
-               goto out;
-
+       tp = xfs_trans_alloc_empty(breq->mp);
        error = xfs_inobt_walk(breq->mp, tp, breq->startino, breq->flags,
                        xfs_inumbers_walk, breq->icount, &ic);
        xfs_trans_cancel(tp);
-out:
 
        /*
         * We found some inode groups, so clear the error status and return
index 7db3ece370b1003bc1cb1a2f75a0b645b406140d..c1c31d1a8e21b5fcdfce2ac8e8e93b2beaca31f2 100644 (file)
@@ -377,11 +377,8 @@ xfs_iwalk_run_callbacks(
        if (!has_more)
                return 0;
 
-       if (iwag->drop_trans) {
-               error = xfs_trans_alloc_empty(mp, &iwag->tp);
-               if (error)
-                       return error;
-       }
+       if (iwag->drop_trans)
+               iwag->tp = xfs_trans_alloc_empty(mp);
 
        /* ...and recreate the cursor just past where we left off. */
        error = xfs_ialloc_read_agi(iwag->pag, iwag->tp, 0, agi_bpp);
@@ -617,9 +614,7 @@ xfs_iwalk_ag_work(
         * Grab an empty transaction so that we can use its recursive buffer
         * locking abilities to detect cycles in the inobt without deadlocking.
         */
-       error = xfs_trans_alloc_empty(mp, &iwag->tp);
-       if (error)
-               goto out;
+       iwag->tp = xfs_trans_alloc_empty(mp);
        iwag->drop_trans = 1;
 
        error = xfs_iwalk_ag(iwag);
index 42e9c72b85c00f006ac3112da46ec5c62a414180..fbd521f898745a419323cc0c6f391d6c0005a866 100644 (file)
@@ -279,10 +279,7 @@ xfs_dax_notify_dev_failure(
                kernel_frozen = xfs_dax_notify_failure_freeze(mp) == 0;
        }
 
-       error = xfs_trans_alloc_empty(mp, &tp);
-       if (error)
-               goto out;
-
+       tp = xfs_trans_alloc_empty(mp);
        start_gno = xfs_fsb_to_gno(mp, start_bno, type);
        end_gno = xfs_fsb_to_gno(mp, end_bno, type);
        while ((xg = xfs_group_next_range(mp, xg, start_gno, end_gno, type))) {
index fa135ac264710afc442f8fc34cf6ce5696d2065b..23ba84ec919a4d2fcb0a995f1dff5095fad971bf 100644 (file)
@@ -660,10 +660,7 @@ xfs_qm_load_metadir_qinos(
        struct xfs_trans        *tp;
        int                     error;
 
-       error = xfs_trans_alloc_empty(mp, &tp);
-       if (error)
-               return error;
-
+       tp = xfs_trans_alloc_empty(mp);
        error = xfs_dqinode_load_parent(tp, &qi->qi_dirip);
        if (error == -ENOENT) {
                /* no quota dir directory, but we'll create one later */
@@ -1755,10 +1752,7 @@ xfs_qm_qino_load(
        struct xfs_inode        *dp = NULL;
        int                     error;
 
-       error = xfs_trans_alloc_empty(mp, &tp);
-       if (error)
-               return error;
-
+       tp = xfs_trans_alloc_empty(mp);
        if (xfs_has_metadir(mp)) {
                error = xfs_dqinode_load_parent(tp, &dp);
                if (error)
index 736eb0924573d379c4d524c09317a616764fb655..6907e871fa1511a70145d09db5bf65b5ec9b8714 100644 (file)
@@ -729,9 +729,7 @@ xfs_rtginode_ensure(
        if (rtg->rtg_inodes[type])
                return 0;
 
-       error = xfs_trans_alloc_empty(rtg_mount(rtg), &tp);
-       if (error)
-               return error;
+       tp = xfs_trans_alloc_empty(rtg_mount(rtg));
        error = xfs_rtginode_load(rtg, type, tp);
        xfs_trans_cancel(tp);
 
@@ -1305,9 +1303,7 @@ xfs_growfs_rt_prep_groups(
        if (!mp->m_rtdirip) {
                struct xfs_trans        *tp;
 
-               error = xfs_trans_alloc_empty(mp, &tp);
-               if (error)
-                       return error;
+               tp = xfs_trans_alloc_empty(mp);
                error = xfs_rtginode_load_parent(tp);
                xfs_trans_cancel(tp);
 
@@ -1674,10 +1670,7 @@ xfs_rtmount_inodes(
        struct xfs_rtgroup      *rtg = NULL;
        int                     error;
 
-       error = xfs_trans_alloc_empty(mp, &tp);
-       if (error)
-               return error;
-
+       tp = xfs_trans_alloc_empty(mp);
        if (xfs_has_rtgroups(mp) && mp->m_sb.sb_rgcount > 0) {
                error = xfs_rtginode_load_parent(tp);
                if (error)
index 8d0aee747f72ac319c4e86a9d1bcfe64f1df19c5..ece374d622b3e9925d257b5e675fd0e8ee024d7f 100644 (file)
@@ -298,13 +298,11 @@ retry:
  * where we can be grabbing buffers at the same time that freeze is trying to
  * drain the buffer LRU list.
  */
-int
+struct xfs_trans *
 xfs_trans_alloc_empty(
-       struct xfs_mount                *mp,
-       struct xfs_trans                **tpp)
+       struct xfs_mount                *mp)
 {
-       *tpp = __xfs_trans_alloc(mp, XFS_TRANS_NO_WRITECOUNT);
-       return 0;
+       return __xfs_trans_alloc(mp, XFS_TRANS_NO_WRITECOUNT);
 }
 
 /*
index 2b366851e9a4f428d12b32ff4f856a65ef37cc49..a6b10aaeb1f1e027861e4a9b8443f00e5b7181cc 100644 (file)
@@ -168,8 +168,7 @@ int         xfs_trans_alloc(struct xfs_mount *mp, struct xfs_trans_res *resp,
                        struct xfs_trans **tpp);
 int            xfs_trans_reserve_more(struct xfs_trans *tp,
                        unsigned int blocks, unsigned int rtextents);
-int            xfs_trans_alloc_empty(struct xfs_mount *mp,
-                       struct xfs_trans **tpp);
+struct xfs_trans *xfs_trans_alloc_empty(struct xfs_mount *mp);
 void           xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t);
 
 int xfs_trans_get_buf_map(struct xfs_trans *tp, struct xfs_buftarg *target,
index 9c00fc5baa3073071e609d1e984070cc06acd386..e1954b0e6021ef52ff0ac1f76ccaa5c7fb350e4a 100644 (file)
@@ -328,10 +328,7 @@ xfs_zone_gc_query(
        iter->rec_idx = 0;
        iter->rec_count = 0;
 
-       error = xfs_trans_alloc_empty(mp, &tp);
-       if (error)
-               return error;
-
+       tp = xfs_trans_alloc_empty(mp);
        xfs_rtgroup_lock(rtg, XFS_RTGLOCK_RMAP);
        cur = xfs_rtrmapbt_init_cursor(tp, rtg);
        error = xfs_rmap_query_range(cur, &ri_low, &ri_high,