From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED8FC274B46 for ; Tue, 30 Dec 2025 09:27:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767086850; cv=none; b=ub4hkEaTyiTESdvR5Hp1VLIQnB/S9KV6hQV6EUG0IMZF1vx4pa6y7ojMAmlcA+1q1M0auEEmgM5OE+GDz2VyHEf4/huqKy35p/UYwMKG47jRFcgTHyNXoWw3E1jrp5bA9lmyFORsZtBmYqk74O2rZ/EpaJHtzG1SnPvm+4pvx68= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767086850; c=relaxed/simple; bh=mfqEohqL7TWMMnMvyKRo3p73IonKMFrOyhFeGU30svc=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=d+uAjCTTpy9hjMMs090kEXFajo0Yde8qH/juZoaotfjLI9IpEfKhcxeWzE4Tvgj3arkFLjJf7w8bNFDdDezf+J0Xh/l53HWqSpGjUvZvs4tqNAUkNpwFCxd35Fnl89kISdaUOcjJEwIra39c605vdcj8P6QTJS+qSxckwd6QUZc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y/Lpm9tO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Y/Lpm9tO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C733C116C6; Tue, 30 Dec 2025 09:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767086849; bh=mfqEohqL7TWMMnMvyKRo3p73IonKMFrOyhFeGU30svc=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=Y/Lpm9tO50PyKww+bs9gyyyHybFTluhcM8cM4NDxHZDA7YwLljQ1IAucG45ifoGkC e68m+m39PWixdbT26IrQw1T8CRyFvgCdQ8t/jM1NawqLYTyMk+/15u7WxwIOxh+Aqg rrgmabVOAZxlemsNDHi81AldxeyAo/nqPrCsYWd7Mz2V3t704ry94mXcNKVzyQ8CV3 H15uIIGzqstRde7UB1YlwN7/zihRlumcR1mPqhUUtBFxsBJV1ZPPRHZ9ZmQgVRH27o fHv+srfi3HGt3uyjdkzyQMpmNU6vaO5H8UtxePzxg+vDalfc3whOI8/nP9ZVse4KKa Uu0dFanA3FcRA== Message-ID: Date: Tue, 30 Dec 2025 17:27:26 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: chao@kernel.org, Jinyoung Choi , Jeuk Kim , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: Question: batching block allocation in f2fs DIO path To: Jeuk Kim , jaegeuk@kernel.org References: Content-Language: en-US From: Chao Yu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Jeuk, On 12/29/2025 2:33 PM, Jeuk Kim wrote: > Hi F2FS maintainers, > > Sorry for the duplicate — I’m resending this because the previous > message was sent in HTML format. > > I’ve been looking into the DIO allocation path in f2fs, specifically > when a DIO write needs to allocate new blocks (e.g., hole-filling). > From f2fs_map_blocks() through __allocate_data_block() → > f2fs_allocate_data_block(), it seems each block allocation is handled > one-by-one, taking curseg_lock/curseg_mutex and the SIT sentry lock > per block. > > I’m wondering whether batching allocations (a bounded batch, e.g., a > small run within the current segment) could be feasible in the DIO > path. My intuition is that with multiple threads doing DIO, reducing > per-block lock contention and improving sequentiality could help > throughput. I agree w/ you. > > Questions: > > Is there a technical or correctness reason that makes batching for DIO > infeasible (e.g., LFS/SSR/GC interactions, summary/SIT update > ordering, etc.)? > > Or is this simply an optimization that hasn’t been implemented? I've implemented a prototype of multiple block allocation for any potential use cases: pinfile fallocation, direct IO and buffered IO. I can see benefits from my previous test. I plan to upstream all implementations, but I think I need more time to clean up the draft codes and check all corner cases. You can check the MBA implementation for pinfile use case in below link, I guess this version is close to upstream. https://github.com/chaseyu/f2fs-dev/commits/feature/inbatch_write Thanks, > > If this seems acceptable, would you consider patches in this direction? > > If there are prior discussions or known issues on this, I’d appreciate pointers. > > Thanks for your time. > > Best regards, > Jeuk Kim