Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ocfs2: fix the la space leak when unmounting an ocfs2 volume

This bug has existed since the initial OCFS2 code. The code logic in
ocfs2_sync_local_to_main() is wrong, as it ignores the last contiguous
free bits, which causes an OCFS2 volume to lose the last free clusters of
LA window on each umount command.

Link: https://lkml.kernel.org/r/20240719114310.14245-1-heming.zhao@suse.com
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
Reviewed-by: Su Yue <glass.su@suse.com>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Gang He <ghe@suse.com>
Cc: Jun Piao <piaojun@huawei.com>
Cc: Heming Zhao <heming.zhao@suse.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Heming Zhao and committed by
Andrew Morton
dfe6c569 acf02be3

+19
+19
fs/ocfs2/localalloc.c
··· 1002 1002 start = bit_off + 1; 1003 1003 } 1004 1004 1005 + /* clear the contiguous bits until the end boundary */ 1006 + if (count) { 1007 + blkno = la_start_blk + 1008 + ocfs2_clusters_to_blocks(osb->sb, 1009 + start - count); 1010 + 1011 + trace_ocfs2_sync_local_to_main_free( 1012 + count, start - count, 1013 + (unsigned long long)la_start_blk, 1014 + (unsigned long long)blkno); 1015 + 1016 + status = ocfs2_release_clusters(handle, 1017 + main_bm_inode, 1018 + main_bm_bh, blkno, 1019 + count); 1020 + if (status < 0) 1021 + mlog_errno(status); 1022 + } 1023 + 1005 1024 bail: 1006 1025 if (status) 1007 1026 mlog_errno(status);