From nobody Fri Oct 2 02:30:48 2026 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (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 B13931B87C0 for ; Thu, 6 Aug 2026 03:39:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785987564; cv=none; b=FYwIr/f+U+xltUAAl2ie9HLtmhrXCR9Y6fGallFHfiZW1ZHoZRDyDag2yqRzh3Z0/wHrN8ULoBdWdki0OzREI4wu19cmttdM+DPDKZGM5uB5726wRiYgMyxctEZczIsn4hJznNu4v+Tr5NlD7n6CpsK1f36A0U4qSl/Tf2p05cA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785987564; c=relaxed/simple; bh=gjoOUGMfT5tan2ChSfrUiSSCvsED1o/4LorTjwjtvWQ=; h=Mime-Version:Subject:From:To:CC:Message-ID:Date:Content-Type: References; b=oYAPcLTv0CDlutSVJNnTW1XCBd4lKWChQGVYn2m8ebFq63Zltl5VvUi54WdRa3qg2JTFXaKIRRZBuNNfxsQ4qhYBDK2JGPgrsz2q/d4hpPNfKKN4QbR2ZRpY01AoxVEqRXfQiqVrl6Mp9LEuiNsCkaTuHAvPg6uiT6BAx1oE5Jk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=iuJtkqoC; arc=none smtp.client-ip=203.254.224.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="iuJtkqoC" Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20260806033919epoutp01385067aa2a9741deb7fe00156e78fb84~JGjjxATTZ1071710717epoutp019 for ; Thu, 6 Aug 2026 03:39:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20260806033919epoutp01385067aa2a9741deb7fe00156e78fb84~JGjjxATTZ1071710717epoutp019 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1785987559; bh=u3kAxdfTARjDcGyDYbA+mipV9WUWcyhLy7pkNxvjRO8=; h=Subject:Reply-To:From:To:CC:Date:References:From; b=iuJtkqoCFHCdU+t7WdnRJXqTjx0FpTxNq5XYgbv+J5m5VfPf1juIwbdumMGTAmzNi Up6gNNJ2wdB30Z06kcjqjNkr9YbM558kgRcwtCjs6hhObsGm+uwWS2mx21U30bWgUT B8Y3l9ZOi0odWhaYGj6T6xrX045wmjEApUsu9Zls= Received: from epsnrtp03.localdomain (unknown [182.195.42.155]) by epcas2p4.samsung.com (KnoxPortal) with ESMTPS id 20260806033918epcas2p4e9390d48cc7dd4097dbf898b8a1e4d50~JGjjhcgEA2844728447epcas2p46; Thu, 6 Aug 2026 03:39:18 +0000 (GMT) Received: from epcas2p4.samsung.com (unknown [182.195.38.204]) by epsnrtp03.localdomain (Postfix) with ESMTP id 4hFtLZ4R60z3hhTD; Thu, 6 Aug 2026 03:39:18 +0000 (GMT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Subject: [PATCH v3] f2fs: issue multi-device flushes in parallel Reply-To: yonggil.song@samsung.com Sender: Yonggil Song From: Yonggil Song To: "jaegeuk@kernel.org" , "chao@kernel.org" , "linux-f2fs-devel@lists.sourceforge.net" , "linux-kernel@vger.kernel.org" CC: Dongjin Kim , Daejun Park X-Priority: 3 X-Content-Kind-Code: NORMAL X-CPGS-Detection: blocking_info_exchange X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20260806033918epcms2p7fa34d6df7c1045b19ac026d44b877f2f@epcms2p7> Date: Thu, 06 Aug 2026 12:39:18 +0900 X-CMS-MailID: 20260806033918epcms2p7fa34d6df7c1045b19ac026d44b877f2f Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P cpgsPolicy: CPGSC10-223,Y X-CFilter-Loop: Reflected X-CMS-RootMailID: 20260806030841epcms2p72fcdb3db8c3b6de434ceaff5635c8f41 References: 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 Reviewed-by: Chao Yu --- fs/f2fs/segment.c | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index d71ddb3ee918..5c7a3992cf60 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -566,21 +566,59 @@ static int __submit_flush_wait(struct f2fs_sb_info *s= bi, return ret; } =20 +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 =3D 0; int ret =3D 0; int i; =20 if (!f2fs_is_multi_device(sbi)) return __submit_flush_wait(sbi, sbi->sb->s_bdev); =20 + flush_bio =3D kmalloc(array_size(sbi->s_ndevs, sizeof(*flush_bio)), + GFP_NOFS | __GFP_NOFAIL); + for (i =3D 0; i < sbi->s_ndevs; i++) { if (!f2fs_is_dirty_device(sbi, ino, i, FLUSH_INO)) continue; - ret =3D __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 =3D &flush_bio[i].wait; + flush_bio[i].bio.bi_end_io =3D f2fs_flush_end_io; + devices |=3D BIT(i); + submit_bio(&flush_bio[i].bio); + } + + for (i =3D 0; i < sbi->s_ndevs; i++) { + int err; + + if (!(devices & BIT(i))) + continue; + + wait_for_completion(&flush_bio[i].wait); + err =3D 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 =3D err; + bio_uninit(&flush_bio[i].bio); } + kfree(flush_bio); return ret; } =20 --=20 2.43.0