From patchwork Thu Aug 1 07:47:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daejun Park X-Patchwork-Id: 13749926 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EB933C3DA4A for ; Thu, 1 Aug 2024 07:48:35 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1sZQY6-0006bj-Bv; Thu, 01 Aug 2024 07:48:35 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sZQY3-0006bb-6C for linux-f2fs-devel@lists.sourceforge.net; Thu, 01 Aug 2024 07:48:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:Content-Type:Content-Transfer-Encoding: Date:Message-ID:CC:To:From:Sender:Reply-To:Subject:Mime-Version:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=V/OQizZH033qH8C4iqIA1G7wnp72fkVhXBE0pNPn1Sk=; b=brr1epfWFpq5t5i+MMlSyC/qia A6zkAQEcFS3WkwsiRStzfvTaSgybpITJZdth2bfOXOlE6I8mcmcqcR5LSHqMRYBGnlsIs5M+jyQGS 1DUqM48Ydr8Q4HNiGSW6LxTcMNAo6GqFjZC8L6EbMg8QMZSjLsAHkhxGs5FHK65+vuwo=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:Content-Type:Content-Transfer-Encoding:Date:Message-ID:CC:To: From:Sender:Reply-To:Subject:Mime-Version:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=V/OQizZH033qH8C4iqIA1G7wnp72fkVhXBE0pNPn1Sk=; b=n QITWd8waJvWxN6+PhurAK6uUd2XsgnVSezMne2zwNgxnTx0DKrhQ2O+QpiT6Z5QCOOZPsbNSBH8oj TTZJhNAyS9YbPpSRPAdz2UmwAVtBfwglQ/bmpNKa4ExI4BwVP1rDjx77SgxYyZNC+oYvJynFh+Fa1 mb71KgzNaiEqETjQ=; Received: from mailout1.samsung.com ([203.254.224.24]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1sZQY2-0002xw-Gc for linux-f2fs-devel@lists.sourceforge.net; Thu, 01 Aug 2024 07:48:31 +0000 Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240801074818epoutp0141d13d14869c4fa07006677b26a9f3ae~ni0INDFrC3154531545epoutp01u for ; Thu, 1 Aug 2024 07:48:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240801074818epoutp0141d13d14869c4fa07006677b26a9f3ae~ni0INDFrC3154531545epoutp01u DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1722498498; bh=V/OQizZH033qH8C4iqIA1G7wnp72fkVhXBE0pNPn1Sk=; h=Subject:Reply-To:From:To:CC:Date:References:From; b=ovf2qlLM8ZkhvMfn7V1S4PIasdwRTFh+0OuG1KUfKZ353LfUUkTZdP48YzueBVkT0 4AZhxYrSOnr2/ekIjzYlOkU9J0LlRJbOUcCwZnWddfyM7ipQcr6ROcx6NRQBUnCTho Q52I8CJdpOUEIs+tPZJL3cCzs18bxM6xp+UtBpT4= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20240801074817epcas2p4846c2a33c31df385de449d9b3328237c~ni0Hr4K3-1221412214epcas2p4K; Thu, 1 Aug 2024 07:48:17 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.69]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4WZLg51JRgz4x9QM; Thu, 1 Aug 2024 07:48:17 +0000 (GMT) X-AuditID: b6c32a45-ffffa700000028bf-12-66ab3dc10cc0 Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 7B.6A.10431.1CD3BA66; Thu, 1 Aug 2024 16:48:17 +0900 (KST) Mime-Version: 1.0 From: Daejun Park To: "jaegeuk@kernel.org" , "chao@kernel.org" , "linux-f2fs-devel@lists.sourceforge.net" , "linux-kernel@vger.kernel.org" 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: <20240801074715epcms2p788934486cd0e8090f67ed0d7cffbc91b@epcms2p7> Date: Thu, 01 Aug 2024 16:47:15 +0900 X-CMS-MailID: 20240801074715epcms2p788934486cd0e8090f67ed0d7cffbc91b X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBJsWRmVeSWpSXmKPExsWy7bCmue5B29VpBl9/slqcnnqWyeLlIU2L VQ/CLX6cNLHo393OYvFk/Sxmi/tbrzFaXF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f4k0b7y8XgwWPO9buW7R0J7t18PX625uX N4b+ZrVRTfG/x/r/pxJLcUaioRZzUXEiAPdMfekrBAAA DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240801074715epcms2p788934486cd0e8090f67ed0d7cffbc91b References: X-Headers-End: 1sZQY2-0002xw-Gc Subject: [f2fs-dev] [PATCH] f2fs: avoid unused block when dio write in LFS mode X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: daejun7.park@samsung.com Cc: Nayeon Kim , Siwoo Jung , Seokhwan Kim , Jeuk Kim , Dongjin Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This patch addresses the problem that when using LFS mode, unused blocks may occur in f2fs_map_blocks() during block allocation for dio writes. If a new section is allocated during block allocation, it will not be included in the map struct by map_is_mergeable() if the LBA of the allocated block is not contiguous. However, the block already allocated in this process will remain unused due to the LFS mode. This patch avoids the possibility of unused blocks by escaping f2fs_map_blocks() when allocating the last block in a section. Signed-off-by: Daejun Park --- fs/f2fs/data.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index b6dcb3bcaef7..b27a3f448f32 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1711,6 +1711,19 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag) dn.ofs_in_node = end_offset; } + if (flag == F2FS_GET_BLOCK_DIO && f2fs_lfs_mode(sbi)) { + int segno = GET_SEGNO(sbi, blkaddr); + bool last_seg, last_blk; + + last_seg = !((segno + 1) % SEGS_PER_SEC(sbi)); + last_blk = (f2fs_usable_blks_in_seg(sbi, segno) - 1) == + GET_BLKOFF_FROM_SEG0(sbi, blkaddr); + + /* LBA of the next block to be allocated may not be contiguous. */ + if (last_seg && last_blk) + goto sync_out; + } + if (pgofs >= end) goto sync_out; else if (dn.ofs_in_node < end_offset)