Patch "ext4: add EXT4_MB_HINT_GOAL_ONLY test in ext4_mb_use_preallocated" has been added to the 6.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ext4: add EXT4_MB_HINT_GOAL_ONLY test in ext4_mb_use_preallocated

to the 6.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ext4-add-ext4_mb_hint_goal_only-test-in-ext4_mb_use_.patch
and it can be found in the queue-6.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit db8ba03ed7a92f00d8af314cfde63d1439b305e2
Author: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>
Date:   Sat Jun 3 23:03:13 2023 +0800

    ext4: add EXT4_MB_HINT_GOAL_ONLY test in ext4_mb_use_preallocated
    
    [ Upstream commit 1eff590489a213a213c57d96b86f48b32cdf8c3a ]
    
    ext4_mb_use_preallocated will ignore the demand to alloc goal blocks,
    although the EXT4_MB_HINT_GOAL_ONLY is requested.
    For group pa, ext4_mb_group_or_file will not set EXT4_MB_HINT_GROUP_ALLOC
    if EXT4_MB_HINT_GOAL_ONLY is set. So we will not alloc goal blocks from
    group pa if EXT4_MB_HINT_GOAL_ONLY is set.
    For inode pa, ext4_mb_pa_goal_check is added to check if free extent in
    found inode pa meets goal blocks when EXT4_MB_HINT_GOAL_ONLY is set.
    
    Signed-off-by: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>
    Suggested-by: Ojaswin Mujoo <ojaswin@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230603150327.3596033-6-shikemeng@xxxxxxxxxxxxxxx
    Signed-off-by: Theodore Ts'o <tytso@xxxxxxx>
    Stable-dep-of: 9d3de7ee192a ("ext4: fix rbtree traversal bug in ext4_mb_use_preallocated")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index fd4d12c58c3b4..1f4d00a4308dc 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4528,6 +4528,37 @@ ext4_mb_check_group_pa(ext4_fsblk_t goal_block,
 	return pa;
 }
 
+/*
+ * check if found pa meets EXT4_MB_HINT_GOAL_ONLY
+ */
+static bool
+ext4_mb_pa_goal_check(struct ext4_allocation_context *ac,
+		      struct ext4_prealloc_space *pa)
+{
+	struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
+	ext4_fsblk_t start;
+
+	if (likely(!(ac->ac_flags & EXT4_MB_HINT_GOAL_ONLY)))
+		return true;
+
+	/*
+	 * If EXT4_MB_HINT_GOAL_ONLY is set, ac_g_ex will not be adjusted
+	 * in ext4_mb_normalize_request and will keep same with ac_o_ex
+	 * from ext4_mb_initialize_context. Choose ac_g_ex here to keep
+	 * consistent with ext4_mb_find_by_goal.
+	 */
+	start = pa->pa_pstart +
+		(ac->ac_g_ex.fe_logical - pa->pa_lstart);
+	if (ext4_grp_offs_to_block(ac->ac_sb, &ac->ac_g_ex) != start)
+		return false;
+
+	if (ac->ac_g_ex.fe_len > pa->pa_len -
+	    EXT4_B2C(sbi, ac->ac_g_ex.fe_logical - pa->pa_lstart))
+		return false;
+
+	return true;
+}
+
 /*
  * search goal blocks in preallocated space
  */
@@ -4578,7 +4609,8 @@ ext4_mb_use_preallocated(struct ext4_allocation_context *ac)
 
 		/* found preallocated blocks, use them */
 		spin_lock(&tmp_pa->pa_lock);
-		if (tmp_pa->pa_deleted == 0 && tmp_pa->pa_free) {
+		if (tmp_pa->pa_deleted == 0 && tmp_pa->pa_free &&
+		    likely(ext4_mb_pa_goal_check(ac, tmp_pa))) {
 			atomic_inc(&tmp_pa->pa_count);
 			ext4_mb_use_inode_pa(ac, tmp_pa);
 			spin_unlock(&tmp_pa->pa_lock);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux