• Heming Zhao via Ocfs2-devel's avatar
    ocfs2: fix non-auto defrag path not working issue · 236b9254
    Heming Zhao via Ocfs2-devel authored
    This fixes three issues on move extents ioctl without auto defrag:
    
    a) In ocfs2_find_victim_alloc_group(), we have to convert bits to block
       first in case of global bitmap.
    
    b) In ocfs2_probe_alloc_group(), when finding enough bits in block
       group bitmap, we have to back off move_len to start pos as well,
       otherwise it may corrupt filesystem.
    
    c) In ocfs2_ioctl_move_extents(), set me_threshold both for non-auto
       and auto defrag paths.  Otherwise it will set move_max_hop to 0 and
       finally cause unexpectedly ENOSPC error.
    
    Currently there are no tools triggering the above issues since
    defragfs.ocfs2 enables auto defrag by default.  Tested with manually
    changing defragfs.ocfs2 to run non auto defrag path.
    
    Link: https://lkml.kernel.org/r/20230220050526.22020-1-heming.zhao@suse.comSigned-off-by: default avatarHeming Zhao <heming.zhao@suse.com>
    Reviewed-by: default avatarJoseph 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: <stable@vger.kernel.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    236b9254
move_extents.c 24.9 KB