]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: splice unsorted log items back to the transaction after the loop
authorWeiming Shi <bestswngs@gmail.com>
Thu, 2 Jul 2026 16:19:59 +0000 (09:19 -0700)
committerCarlos Maiolino <cem@kernel.org>
Tue, 7 Jul 2026 07:57:19 +0000 (09:57 +0200)
On error, xlog_recover_reorder_trans() splices the leftover sort_list
items back to trans->r_itemq inside the loop before breaking out.  The
loop tail already splices the per-fate lists back, so do sort_list there
too, guarded by the assert that used to sit after the loop.

No functional change.  It drops the duplicated splice so the next patch
can add another error case without repeating it.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Weiming Shi <bestswngs@gmail.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/xfs_log_recover.c

index a1b373c68f0e6ae389d5bcc4aeef427502413ef8..103b2a79667b761473bf2a3d8978afb6ea411166 100644 (file)
@@ -1912,12 +1912,6 @@ xlog_recover_reorder_trans(
                        xfs_warn(log->l_mp,
                                "%s: unrecognized type of log operation (%d)",
                                __func__, ITEM_TYPE(item));
-                       /*
-                        * return the remaining items back to the transaction
-                        * item list so they can be freed in caller.
-                        */
-                       if (!list_empty(&sort_list))
-                               list_splice_init(&sort_list, &trans->r_itemq);
                        error = -EFSCORRUPTED;
                        break;
                }
@@ -1945,7 +1939,15 @@ xlog_recover_reorder_trans(
                }
        }
 
-       ASSERT(list_empty(&sort_list));
+       /*
+        * Return the remaining items back to the transaction item list so they
+        * can be freed in caller.  This should only happen when we encounter
+        * an error.
+        */
+       if (!list_empty(&sort_list)) {
+               ASSERT(error);
+               list_splice_init(&sort_list, &trans->r_itemq);
+       }
        if (!list_empty(&buffer_list))
                list_splice(&buffer_list, &trans->r_itemq);
        if (!list_empty(&item_list))