ext4: fallback to complex scan if aligned scan doesn't work

Upstream commit 1f6bc02f18489b9c9ea39b068d0695fb0e4567e9

Currently in case the goal length is a multiple of stripe size we use
ext4_mb_scan_aligned() to find the stripe size aligned physical blocks.
In case we are not able to find any, we again go back to calling
ext4_mb_choose_next_group() to search for a different suitable block
group. However, since the linear search always begins from the start,
most of the times we end up with the same BG and the cycle continues.

With large fliesystems, the CPU can be stuck in this loop for hours
which can slow down the whole system. Hence, until we figure out a
better way to continue the search (rather than starting from beginning)
in ext4_mb_choose_next_group(), lets just fallback to
ext4_mb_complex_scan_group() in case aligned scan fails, as it is much
more likely to find the needed blocks.

BUG=b/460112343
TEST=presubmit
RELEASE_NOTE=Backported an upstream commit to fix high CPU usage when
trying to find suitable blocks in ext4 fs.

cos-patch: bug
Change-Id: Ia75bd4fb2e49182542d83a2eabc142d8cc984cb1
Signed-off-by: Ojaswin Mujoo <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Signed-off-by: Theodore Ts'o <[email protected]>
Reviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/118205
Main-Branch-Verified: Cusky Presubmit Bot <[email protected]>
Tested-by: Cusky Presubmit Bot <[email protected]>
Reviewed-by: Robert Kolchmeyer <[email protected]>
Reviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/118321
1 file changed