[to-be-updated] ocfs2-free-unused-clusters-on-defrag-move-errors.patch removed from -mm tree

Andrew Morton <[email protected]>
Newsgroups org.kernel.vger.mm-commits
Message-ID <[email protected]>
The quilt patch titled
     Subject: ocfs2: free unused clusters on defrag move errors
has been removed from the -mm tree.  Its filename was
     ocfs2-free-unused-clusters-on-defrag-move-errors.patch

This patch was dropped because an updated version will be issued

------------------------------------------------------
From: Guangshuo Li <[email protected]>
Subject: ocfs2: free unused clusters on defrag move errors
Date: Mon, 20 Jul 2026 22:19:43 +0800

ocfs2_defrag_extent() claims new clusters before calling
__ocfs2_move_extent().  If the move fails before ocfs2_split_extent()
succeeds, the claimed clusters are not referenced by the inode and must be
released.

The current error path only logs the error and continues to
ocfs2_cow_sync_writeback(), which can overwrite the original error with
zero and leave the claimed clusters allocated.

Not every __ocfs2_move_extent() error can free the new clusters.  Once
ocfs2_split_extent() succeeds, the extent tree references them even if
ocfs2_decrease_refcount() or ocfs2_truncate_log_append() subsequently
fails.  Freeing the clusters in that case would leave the extent tree
pointing to clusters marked free.

context->new_phys_cpos is updated immediately after a successful extent
split.  Compare it with the newly claimed physical cluster on error.  If
they differ, the split for the current move did not complete and the
claimed clusters can be freed.  If they match, leave the clusters
allocated because the extent tree already references them.

Return move errors through the transaction cleanup path so that the
original error is preserved instead of being overwritten by writeback.

Link: https://lore.kernel.org/[email protected]
Fixes: 202ee5facb2c ("Ocfs2/move_extents: defrag a range of extent.")
Signed-off-by: Guangshuo Li <[email protected]>
Reviewed-by: Joseph Qi <[email protected]>
Cc: Mark Fasheh <[email protected]>
Cc: Joel Becker <[email protected]>
Cc: Junxiao Bi <[email protected]>
Cc: Changwei Ge <[email protected]>
Cc: Jun Piao <[email protected]>
Cc: Heming Zhao <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
---

 fs/ocfs2/move_extents.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- a/fs/ocfs2/move_extents.c~ocfs2-free-unused-clusters-on-defrag-move-errors
+++ a/fs/ocfs2/move_extents.c
@@ -310,8 +310,12 @@ static int ocfs2_defrag_extent(struct oc
 
 	ret = __ocfs2_move_extent(handle, context, cpos, new_len, phys_cpos,
 				  new_phys_cpos, ext_flags);
-	if (ret)
+	if (ret) {
 		mlog_errno(ret);
+		if (context->new_phys_cpos != new_phys_cpos)
+			need_free = 1;
+		goto out_commit;
+	}
 
 	if (partial && (new_len != *len))
 		*len = new_len;
_

Patches currently in -mm which might be from [email protected] are

rapidio-clear-mport-net-when-rio_add_net-fails.patch
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.