Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 718E7C636D4 for ; Mon, 13 Feb 2023 13:27:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230031AbjBMN1O (ORCPT ); Mon, 13 Feb 2023 08:27:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229978AbjBMN1N (ORCPT ); Mon, 13 Feb 2023 08:27:13 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 843211ABCD; Mon, 13 Feb 2023 05:27:10 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PFlVv1dYFz4f3jMK; Mon, 13 Feb 2023 21:27:03 +0800 (CST) Received: from [10.174.178.129] (unknown [10.174.178.129]) by APP2 (Coremail) with SMTP id Syh0CgBHOOanOupj5dX_DQ--.24452S2; Mon, 13 Feb 2023 21:27:05 +0800 (CST) Subject: Re: [PATCH 03/21] ext4: avoid to use preallocated blocks if EXT4_MB_HINT_GOAL_ONLY is set To: Ojaswin Mujoo Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230209194825.511043-1-shikemeng@huaweicloud.com> <20230209194825.511043-4-shikemeng@huaweicloud.com> From: Kemeng Shi Message-ID: Date: Mon, 13 Feb 2023 21:27:03 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=gbk Content-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= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org on 2/13/2023 4:38 PM, Ojaswin Mujoo wrote: > On Fri, Feb 10, 2023 at 03:48:07AM +0800, Kemeng Shi wrote: >> ext4_mb_use_preallocated will ignore the demand to alloc at goal block >> only. Return false if EXT4_MB_HINT_GOAL_ONLY is set before use >> preallocated blocks in ext4_mb_use_preallocated. >> >> Signed-off-by: Kemeng Shi >> --- >> fs/ext4/mballoc.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c >> index 375d9655b525..352ac9139fee 100644 >> --- a/fs/ext4/mballoc.c >> +++ b/fs/ext4/mballoc.c >> @@ -4368,6 +4368,9 @@ ext4_mb_use_preallocated(struct ext4_allocation_context *ac) >> if (!(ac->ac_flags & EXT4_MB_HINT_DATA)) >> return false; >> >> + if (unlikely(ac->ac_flags & EXT4_MB_HINT_GOAL_ONLY)) >> + return false; >> + >> /* first, try per-file preallocation */ >> rcu_read_lock(); >> list_for_each_entry_rcu(pa, &ei->i_prealloc_list, pa_inode_list) { >> -- >> 2.30.0 >> > So with the flag, even when we request for a logical/goal block > combination that can be satisfied by one of the inode PAs in the list, > we would still exit early and the allocation would eventually fail since > the goal block would be marked "in-use" in the buddy. This doesn't seem > to be desirable. > > Maybe instead of exiting early we should try to find a PA that satisfies > the logical block we are asking for and then incase of > EXT4_MB_HINT_GOAL_ONLY, we can add a check to see if the physical block > of the PA corresponds to the goal block. Would like to hear your > thoughts on this. Yes, this is a more thoughtful, I will improve this in next version. Besides, maybe we should also test length if EXT4_MB_HINT_MERGE is set as ext4_mb_find_by_goal do. > Regards, > ojaswin > -- Best wishes Kemeng Shi