ext4: mballoc: refactor ext4_mb_good_group()
authorRitesh Harjani <riteshh@linux.ibm.com>
Wed, 20 May 2020 06:40:35 +0000 (12:10 +0530)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 4 Jun 2020 03:16:53 +0000 (23:16 -0400)
commit8ef123fe02ca0923b01b57bdf639800a23a2faa8
treeaecee027b64ccdff52a782397ff6e8cea495f808
parent07b5b8e1ac4004b7db1065a301df65cd434c31c9
ext4: mballoc: refactor ext4_mb_good_group()

ext4_mb_good_group() definition was changed some time back
and now it even initializes the buddy cache (via ext4_mb_init_group()),
if in case the EXT4_MB_GRP_NEED_INIT() is true for a group.
Note that ext4_mb_init_group() could sleep and so should not be called
under a spinlock held.
This is fine as of now because ext4_mb_good_group() is called before
loading the buddy bitmap without ext4_lock_group() held
and again called after loading the bitmap, only this time with
ext4_lock_group() held.
But still this whole thing is confusing.

So this patch refactors out ext4_mb_good_group_nolock() which should be
called when without holding ext4_lock_group().
Also in further patches we hold the spinlock (ext4_lock_group()) while
doing any calculations which involves grp->bb_free or grp->bb_fragments.

Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
Link: https://lore.kernel.org/r/d9f7d031a5fbe1c943fae6bf1ff5cdf0604ae722.1589955723.git.riteshh@linux.ibm.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/mballoc.c