From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 0233B33BBC0 for ; Thu, 6 Aug 2026 03:13:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785986006; cv=none; b=YB+/Ze1+tkOzrNBiWcqtr8hQ2eEoAHM8b1y6ej/X3Q5z7iH8vTuSHg9/Z3xUCyH3uS71p24doaCYVgks1QrdCiI/WCbSgfSGm9pc+7cPlbUi2oZRAVW8tPqR5KHKk9inK3qPQUt8G0C5Lvv+KBv9T7NX4V71TCBa3Sj64S4oMDM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785986006; c=relaxed/simple; bh=aotK62semVApnbmthQrhgJtYaiPbu5P/dLOx++8Gr0g=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=jYpjRhkvDrtzgIPo18Xa/M5tZuXVu71IvJnoS+1tsvJrjfMzU6kFNK8hUctNE42kmYnCHy/fygQG7JrM2Cn2TtJX9X+JWv7bm7WUELQnVPxVfv9iE7SbkCDsUX0uZkpQMXhSN/NUhdDOzlDXbUMuazAELkff3lwvvasHFA4oudk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H9tA7ipy; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H9tA7ipy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F6231F000E9; Thu, 6 Aug 2026 03:13:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785986004; bh=+zqIg0ykgNJoSYGUWmXYW0MV9QikD4fJ1B7EqnSEbTs=; h=Date:Cc:Subject:To:References:From:In-Reply-To; b=H9tA7ipyy72XOxVxFwLjRH0nURBoa4z8AIOjDu9ozdqkaZAPRWhko495lLEoTRKmg UIJRD4fp4dSMamW2IEVe8/QOxfYzl1QyxS7mnopeuJQta/BI65PJ453gIwcsKYoduA RiVQsOSjT0jbQCpvv+J1A5HkV1Tk4h32ykmHcdqcZrh1CguF/Ua5Te41cGBiXHU76c ZfOQZdwMg3SZBsjNxfUaDHTZ98sn2ob5XZQaKy7ChECnR4jdEYgCCsy8+ZlzAyYM04 t1Xtm0N14P+x3VuX5l/O9BeeXbESVYs/hM16kFr1fODWRGTcJTGVKjXOkC5XLFDLaW r8qz7tJWYVjpA== Message-ID: <5e605eb3-f3d5-4903-b054-108f4d802005@kernel.org> Date: Thu, 6 Aug 2026 11:13:21 +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, Dongjin Kim , Daejun Park Subject: Re: [PATCH v2] f2fs: issue multi-device flushes in parallel To: yonggil.song@samsung.com, "jaegeuk@kernel.org" , "linux-f2fs-devel@lists.sourceforge.net" , "linux-kernel@vger.kernel.org" References: <20260806030841epcms2p72fcdb3db8c3b6de434ceaff5635c8f41@epcms2p7> Content-Language: en-US From: Chao Yu In-Reply-To: <20260806030841epcms2p72fcdb3db8c3b6de434ceaff5635c8f41@epcms2p7> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 8/6/26 11:08, Yonggil Song wrote: > > On a multi-device setup, submit_flush_wait() walked the dirty devices > in order and aborted the whole loop on the first device whose flush > failed, leaving the remaining dirty devices un-flushed. Each device > still needs its own data made durable, so a failure on one device must > not skip the others. It also waited for one device's flush to complete > before issuing the next, even though the devices have independent > flush queues and could be flushed concurrently. > > Flush every dirty device best-effort and in parallel instead: build > one PREFLUSH bio per dirty device, submit them all, then wait for > every completion, returning the first error seen (0 if all succeed). > This bounds the flush window by the slowest device rather than the sum > of all of them. No caller depends on the previous early-abort > behaviour -- fsync only checks whether the return value is zero > (fs/f2fs/file.c). The checkpoint path (f2fs_flush_device_cache) is > unaffected; this only touches the fsync flush path. > > The per-device bio/completion array is small and bounded (at most > MAX_DEVICES entries), so allocate it with __GFP_NOFAIL rather than > keeping a separate serial fallback path for allocation failure. > > Signed-off-by: Yonggil Song > --- > fs/f2fs/segment.c | 48 ++++++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 45 insertions(+), 3 deletions(-) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index d71ddb3ee918..f3d3343e012f 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -566,21 +566,63 @@ static int __submit_flush_wait(struct f2fs_sb_info *sbi, > return ret; > } > > +static void f2fs_flush_end_io(struct bio *bio) > +{ > + complete(bio->bi_private); > +} > + > +struct f2fs_flush_bio { > + struct bio bio; > + struct completion wait; > +}; > + > static int submit_flush_wait(struct f2fs_sb_info *sbi, nid_t ino) > { > + struct f2fs_flush_bio *flush_bio; > + unsigned long devices = 0; > int ret = 0; > int i; > > if (!f2fs_is_multi_device(sbi)) > return __submit_flush_wait(sbi, sbi->sb->s_bdev); > > + flush_bio = kmalloc(array_size(sbi->s_ndevs, sizeof(*flush_bio)), > + GFP_NOFS | __GFP_NOFAIL); > + > for (i = 0; i < sbi->s_ndevs; i++) { > if (!f2fs_is_dirty_device(sbi, ino, i, FLUSH_INO)) > continue; > - ret = __submit_flush_wait(sbi, FDEV(i).bdev); > - if (ret) > - break; > + > + bio_init(&flush_bio[i].bio, FDEV(i).bdev, NULL, 0, > + REQ_OP_WRITE | REQ_SYNC | REQ_PREFLUSH); > + init_completion(&flush_bio[i].wait); > + flush_bio[i].bio.bi_private = &flush_bio[i].wait; > + flush_bio[i].bio.bi_end_io = f2fs_flush_end_io; > + devices |= BIT(i); Can we submit bio here? Thanks, > + } > + > + for (i = 0; i < sbi->s_ndevs; i++) { > + if (devices & BIT(i)) > + submit_bio(&flush_bio[i].bio); > + } > + > + for (i = 0; i < sbi->s_ndevs; i++) { > + int err; > + > + if (!(devices & BIT(i))) > + continue; > + > + wait_for_completion(&flush_bio[i].wait); > + err = blk_status_to_errno(flush_bio[i].bio.bi_status); > + trace_f2fs_issue_flush(FDEV(i).bdev, test_opt(sbi, NOBARRIER), > + test_opt(sbi, FLUSH_MERGE), err); > + if (!err) > + f2fs_update_iostat(sbi, NULL, FS_FLUSH_IO, 0); > + else if (!ret) > + ret = err; > + bio_uninit(&flush_bio[i].bio); > } > + kfree(flush_bio); > return ret; > } >