mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ocfs2: free claimed clusters when defrag move fails
@ 2026-07-08  6:22 Guangshuo Li
  2026-07-09  3:59 ` Joseph Qi
  0 siblings, 1 reply; 3+ messages in thread
From: Guangshuo Li @ 2026-07-08  6:22 UTC (permalink / raw)
  To: Mark Fasheh, Joel Becker, Joseph Qi, Tristan Ye, ocfs2-devel,
	linux-kernel
  Cc: Guangshuo Li

ocfs2_defrag_extent() claims new clusters before calling
__ocfs2_move_extent(). If __ocfs2_move_extent() fails, the newly claimed
clusters have not been attached to the inode extent tree, but the error
path only logs the error and continues.

The following ocfs2_cow_sync_writeback() call can then overwrite the
original error with 0, while the claimed clusters are left allocated and
unreferenced.

Set need_free and leave through out_commit when __ocfs2_move_extent()
fails, so the claimed clusters are released and the original error is
returned to the caller.

Fixes: 202ee5facb2c ("Ocfs2/move_extents: defrag a range of extent.")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 fs/ocfs2/move_extents.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
index ad1678ee7cc4..4f1745d58a88 100644
--- a/fs/ocfs2/move_extents.c
+++ b/fs/ocfs2/move_extents.c
@@ -310,8 +310,11 @@ static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context,
 
 	ret = __ocfs2_move_extent(handle, context, cpos, new_len, phys_cpos,
 				  new_phys_cpos, ext_flags);
-	if (ret)
+	if (ret) {
 		mlog_errno(ret);
+		need_free = 1;
+		goto out_commit;
+	}
 
 	if (partial && (new_len != *len))
 		*len = new_len;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-14  7:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-08  6:22 [PATCH] ocfs2: free claimed clusters when defrag move fails Guangshuo Li
2026-07-09  3:59 ` Joseph Qi
2026-07-14  7:54   ` Guangshuo Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome