fs/ext4: Limit the number of retries if ext4_mb_regular_allocator fails.

When the filesystem is almost full and some new content is written by
processes and ext4_mb_regular_allocator() fails, the
function will try to discard preallocations, and if any blocks are
released as a result discarding preallocations, then
ext4_mb_new_blocks() will "goto repeat", and this will retry the
ext4_mb_regular_allocator().    However, if some other process has
grabbed the blocks, ext4_mb_regular_allocator() will fail (again), and
then ext4_mb_new_blocks() will try to discard the preallocations, and
the process will can end up looping forever, since there is no limit on
the number of times we will try to repeat after discarding
preallocations. This will result in a high contention state of the
system.

BUG=b/241927398
TEST=presubmit
RELEASE_NOTE=Fixed a scenario of high contention state of the system in
case filesystem is almost full and processes is trying to write content.
SOURCE=LAKITU

Change-Id: I20a67a0c45d75a18b75de464276e27083cd8d5f8
Reviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/36707
Tested-by: Cusky Presubmit Bot <presubmit@cos-infra-prod.iam.gserviceaccount.com>
Reviewed-by: Leah Rumancik <lrumancik@google.com>
Reviewed-by: Robert Kolchmeyer <rkolchmeyer@google.com>
1 file changed