ext4: don't use CR_BEST_AVAIL_LEN for non-regular files
authorRitesh Harjani <ritesh.list@gmail.com>
Sun, 16 Jul 2023 14:03:34 +0000 (19:33 +0530)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 5 Aug 2023 12:18:04 +0000 (08:18 -0400)
Using CR_BEST_AVAIL_LEN only make sense for regular files, as for
non-regular files we never normalize the allocation request length i.e.
goal len is same as original length (ac_g_ex.fe_len == ac_o_ex.fe_len).

Hence there is no scope of trimming the goal length to make it
satisfy original request len. Thus this patch avoids using
CR_BEST_AVAIL_LEN criteria for non-regular files request.

Cc: stable@kernel.org
Fixes: 33122aa930f1 ("ext4: Add allocation criteria 1.5 (CR1_5)")
Reported-by: Eric Whitney <enwlinux@gmail.com>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Tested-by: Eric Whitney <enwlinux@gmail.com>
Link: https://lore.kernel.org/r/2a694c748ff8b8c4b416995a24f06f07b55047a8.1689516047.git.ritesh.list@gmail.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/mballoc.c

index b89b5f0..3d5b0b7 100644 (file)
@@ -966,7 +966,18 @@ static void ext4_mb_choose_next_group_goal_fast(struct ext4_allocation_context *
                }
        }
 
-       *new_cr = CR_BEST_AVAIL_LEN;
+       /*
+        * CR_BEST_AVAIL_LEN works based on the concept that we have
+        * a larger normalized goal len request which can be trimmed to
+        * a smaller goal len such that it can still satisfy original
+        * request len. However, allocation request for non-regular
+        * files never gets normalized.
+        * See function ext4_mb_normalize_request() (EXT4_MB_HINT_DATA).
+        */
+       if (ac->ac_flags & EXT4_MB_HINT_DATA)
+               *new_cr = CR_BEST_AVAIL_LEN;
+       else
+               *new_cr = CR_GOAL_LEN_SLOW;
 }
 
 /*