+ ocfs2-free-unused-clusters-on-defrag-move-errors.patch added to mm-nonmm-unstable branch
Andrew Morton <[email protected]>
| Newsgroups | org.kernel.vger.mm-commits |
|---|---|
| Message-ID | <[email protected]> |
The patch titled
Subject: ocfs2: free unused clusters on defrag move errors
has been added to the -mm mm-nonmm-unstable branch. Its filename is
ocfs2-free-unused-clusters-on-defrag-move-errors.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/ocfs2-free-unused-clusters-on-defrag-move-errors.patch
This patch will later appear in the mm-nonmm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
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
ocfs2-free-unused-clusters-on-defrag-move-errors.patch