From nobody Fri Oct 2 02:30:51 2026 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) (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 A0DD729DB64 for ; Thu, 6 Aug 2026 03:08:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785985734; cv=none; b=QirPkLsor9iudGP3HlTiPJnGFOG0ACecK3wz4U1inyMKTKPrJLbPZKgAybxnwdRffT0pZjwr4/Zt157rgraKP/QaZvkUAHBtfbsTDNI/1Rb4HR8crucp/vXN8zG/6HT4M+NNbBvdJwRBKCm+XQjkB5yf4qjHoRKwSY+TdMK5Bd4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785985734; c=relaxed/simple; bh=H4nrKF3nkriNuWWSGF+wpAhYiutxTQLVUTAc4Vf7H+w=; h=Mime-Version:Subject:From:To:CC:Message-ID:Date:Content-Type: References; b=R8mFJNSEi2nqt1D4yxydznKYei1sk1n9wfUsO5cCG0kb8zwb0ARsXL//T+z9qa42cDLkpy0J/bDmpH2imlIspxrtbyCK3kbqpxCLxVh20nAbg/t0M9uClqRH1oOVtIflfFRIioPTaFLrD2kHkpuTK44wN+NGOni/e5EeuwF+jDY= 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=jHu0TOtu; arc=none smtp.client-ip=203.254.224.33 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="jHu0TOtu" Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20260806030842epoutp031e5620e540acca5dbc34be00a8e35405~JGI1p0YNC2094620946epoutp03R for ; Thu, 6 Aug 2026 03:08:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20260806030842epoutp031e5620e540acca5dbc34be00a8e35405~JGI1p0YNC2094620946epoutp03R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1785985722; bh=z/f7KRhFbgKZ8awYHoN+cHPJaT0L+pOvVCYMxjwdQ8s=; h=Subject:Reply-To:From:To:CC:Date:References:From; b=jHu0TOtu3ClfQIKBb1WQtNPfWUAdf8KJyTT96BEoEK3bm3APXy2/NLQ7jB9hq7ZEq 0Pm+4EDly0oME5HU/KXprO6VQiPdwE/lSl8fsIJrF6CeubdXIoqlPO6lfxaR7xX+rU HXoh0boSD0c8I+bhtp8HtJ1qv9JOOmV7DqnW3kqk= Received: from epsnrtp04.localdomain (unknown [182.195.42.156]) by epcas2p3.samsung.com (KnoxPortal) with ESMTPS id 20260806030842epcas2p39013c010623443ea7c63732b3bf139c2~JGI08EeGF2319723197epcas2p3z; Thu, 6 Aug 2026 03:08:42 +0000 (GMT) Received: from epcas2p2.samsung.com (unknown [182.195.38.203]) by epsnrtp04.localdomain (Postfix) with ESMTP id 4hFsgF6PpHz6B9m8; Thu, 6 Aug 2026 03:08:41 +0000 (GMT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Subject: [PATCH v2] 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: <20260806030841epcms2p72fcdb3db8c3b6de434ceaff5635c8f41@epcms2p7> Date: Thu, 06 Aug 2026 12:08:41 +0900 X-CMS-MailID: 20260806030841epcms2p72fcdb3db8c3b6de434ceaff5635c8f41 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 --- 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 *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); + } + + for (i =3D 0; i < sbi->s_ndevs; i++) { + if (devices & 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