From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (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 C7F463A4AAA for ; Thu, 22 Jan 2026 10:35:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769078122; cv=none; b=d/7IL8Wun1edZdjlNjdXy3Hw3a/j5xMTgnpf31SPd3yPWN5HmH04OkDN3JSwq2aU05V66sZ3ei44GtRQgdo2V+587/ovwVmHK3sVBMsF341Xo4bDrEraPVdhTZvexjJNNdFvd3cpTGOjuD7Gfoirw1WWwNf0luU8WqMMl5+Wu90= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769078122; c=relaxed/simple; bh=KGxm+98b774mgLXDcOMpdK89iRpMbk6NkZQbJpC3eUY=; h=From:To:Cc:In-Reply-To:Subject:Date:Message-ID:MIME-Version: Content-Type:References; b=DmSY2XPcn6P0v0/8qT4x0jvjQiOehlLFWNGKVDeRfyI2vRSOLHYmg0qeVhjArYP87pBQJH//DUPsafkkdUAXGRDbXwWTCVnaiaADqWGfgXElNsZ+Vdix2zXbYtSKkVi0D/R3paTnBgD0mDvQNfM1UuRiTAg9R5lHp0fG+EkvnWM= 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=L4qN4Sry; arc=none smtp.client-ip=203.254.224.25 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="L4qN4Sry" Received: from epcas1p2.samsung.com (unknown [182.195.41.46]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20260122103517epoutp021df0b5b65fe53f62983c49702300627f~NByzVUKa20048300483epoutp02R for ; Thu, 22 Jan 2026 10:35:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20260122103517epoutp021df0b5b65fe53f62983c49702300627f~NByzVUKa20048300483epoutp02R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1769078117; bh=FOX8ifNT4vfzjSb3CXebmqamN/hgdkioL7GJrURlahQ=; h=From:To:Cc:In-Reply-To:Subject:Date:References:From; b=L4qN4SryCHgfBWyt8YhTWVITdWCaadO5GB3ePoeloCTlUI0UIFJDkMaURjnD0YGMA N0IJFnYKavrBaB76nGmam4heFRdType/KzYNZtoDdob/8Nnn0v6AERckLL1ggV5Ag6 lkHHZOZEBMFF96TVQaiYYpixXnwI67JGOQYygBv4= Received: from epsnrtp01.localdomain (unknown [182.195.42.153]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPS id 20260122103517epcas1p1bca288d0d1d75018061a8715b6cf3c57~NByy0Ae860688406884epcas1p1j; Thu, 22 Jan 2026 10:35:17 +0000 (GMT) Received: from epcas1p2.samsung.com (unknown [182.195.38.191]) by epsnrtp01.localdomain (Postfix) with ESMTP id 4dxcs0701pz6B9m5; Thu, 22 Jan 2026 10:35:16 +0000 (GMT) Received: from epsmtip1.samsung.com (unknown [182.195.34.30]) by epcas1p2.samsung.com (KnoxPortal) with ESMTPA id 20260122103516epcas1p20b6bdbe818bf1bf3e06a94ed91893a75~NByyCIk290495704957epcas1p2l; Thu, 22 Jan 2026 10:35:16 +0000 (GMT) Received: from youngjingil03 (unknown [10.253.98.35]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20260122103516epsmtip18962457fa26a0e6f0ce1d583e7c60256~NByx-CUCS2334523345epsmtip1d; Thu, 22 Jan 2026 10:35:16 +0000 (GMT) From: "Yeongjin Gil" To: "'Chao Yu'" , , , , Cc: "'Sungjong Seo'" , "'Sunmin Jeong'" , "'Yeongjin Gil'" In-Reply-To: <8a00c027-d14d-44c8-9105-b385fabb37f2@kernel.org> Subject: RE: [PATCH RESEND] f2fs: optimize f2fs_overwrite_io() for f2fs_iomap_begin Date: Thu, 22 Jan 2026 19:35:16 +0900 Message-ID: <000101dc8b8a$cc342770$649c7650$@samsung.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQNImu6Q1q6EEabpvPETJlu1g52f/wGoyplJATaj3pOybuQsIA== Content-Language: ko X-CMS-MailID: 20260122103516epcas1p20b6bdbe818bf1bf3e06a94ed91893a75 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" CMS-TYPE: 101P cpgsPolicy: CPGSC10-711,Y X-CFilter-Loop: Reflected X-CMS-RootMailID: 20260116102347epcas1p46ed8360e1a69831f382dcf9d9ee486b0 References: <20260116102346.992546-1-youngjin.gil@samsung.com> <8a00c027-d14d-44c8-9105-b385fabb37f2@kernel.org> > On 1/16/2026 6:23 PM, Yeongjin Gil wrote: > > When overwriting already allocated blocks, f2fs_iomap_begin() calls > > f2fs_overwrite_io() to check block mappings. However, > > f2fs_overwrite_io() iterates through all mapped blocks in the range, > > which can be inefficient for fragmented files with large I/O requests. > > > > This patch optimizes f2fs_overwrite_io() by adding a 'check_first' > > parameter and introducing __f2fs_overwrite_io() helper. When called > > from f2fs_iomap_begin(), we only check the first mapping to determine > > if the range is already allocated, which is sufficient for setting > > map.m_may_create. > > > > This optimization significantly reduces the number of > > f2fs_map_blocks() calls in f2fs_overwrite_io() when called from > > f2fs_iomap_begin(), especially for fragmented files with large I/O > requests. > > > > Fixes: 351bc761338d ("f2fs: optimize f2fs DIO overwrites") > > Reviewed-by: Sungjong Seo > > Reviewed-by: Sunmin Jeong > > Signed-off-by: Yeongjin Gil > > --- > > fs/f2fs/data.c | 10 ++++++++-- > > 1 file changed, 8 insertions(+), 2 deletions(-) > > > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index > > 2e133a723b99..bfbd717e628a 100644 > > --- a/fs/f2fs/data.c > > +++ b/fs/f2fs/data.c > > @@ -1851,7 +1851,8 @@ int f2fs_map_blocks(struct inode *inode, struct > f2fs_map_blocks *map, int flag) > > return err; > > } > > > > -bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) > > +static bool __f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t > len, > > + bool check_first) > > Yeongjin, > > You may missed to add logic related to check_first parameter? > > Thanks, I made a mistake. I will resend the v2 patch. Thank you for the review. > > > { > > struct f2fs_map_blocks map; > > block_t last_lblk; > > @@ -1877,6 +1878,11 @@ bool f2fs_overwrite_io(struct inode *inode, > loff_t pos, size_t len) > > return true; > > } > > > > +bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len) { > > + return __f2fs_overwrite_io(inode, pos, len, false); } > > + > > static int f2fs_xattr_fiemap(struct inode *inode, > > struct fiemap_extent_info *fieinfo) > > { > > @@ -4443,7 +4449,7 @@ static int f2fs_iomap_begin(struct inode *inode, > loff_t offset, loff_t length, > > * f2fs_map_lock and f2fs_balance_fs are not necessary. > > */ > > if ((flags & IOMAP_WRITE) && > > - !f2fs_overwrite_io(inode, offset, length)) > > + !__f2fs_overwrite_io(inode, offset, length, true)) > > map.m_may_create = true; > > > > err = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_DIO);