ocfs2: fix clusters leak in ocfs2_defrag_extent()
authorLarry Chen <[email protected]>
Fri, 2 Nov 2018 22:48:27 +0000 (15:48 -0700)
committerLinus Torvalds <[email protected]>
Sat, 3 Nov 2018 17:09:37 +0000 (10:09 -0700)
commit6194ae4242dec0c9d604bc05df83aa9260a899e4
tree12cadc6b8451443150465c1c26a3792697a4257e
parent3a3d1e51042895c58d4797831921c940b28d8c4b
ocfs2: fix clusters leak in ocfs2_defrag_extent()

ocfs2_defrag_extent() might leak allocated clusters.  When the file
system has insufficient space, the number of claimed clusters might be
less than the caller wants.  If that happens, the original code might
directly commit the transaction without returning clusters.

This patch is based on code in ocfs2_add_clusters_in_btree().

[[email protected]: include localalloc.h, reduce scope of data_ac]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Larry Chen <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Cc: Mark Fasheh <[email protected]>
Cc: Joel Becker <[email protected]>
Cc: Junxiao Bi <[email protected]>
Cc: Joseph Qi <[email protected]>
Cc: Changwei Ge <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
fs/ocfs2/move_extents.c