From patchwork Tue Nov 26 06:45:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: zangyangyang1 X-Patchwork-Id: 13885513 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 A61AFD5A6DF for ; Tue, 26 Nov 2024 06:45:37 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1tFpKK-0000wD-7e; Tue, 26 Nov 2024 06:45:36 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tFpKI-0000w5-Bm for linux-f2fs-devel@lists.sourceforge.net; Tue, 26 Nov 2024 06:45:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Date:Subject:CC:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=GhNpY+7MNd2l/d5pwlgHNlDYChihSGkx/yYj3rMp66E=; b=jc8Q4iqgNvzGyBztLXybTPpaQN aGQBPLppJVzd4SMBW9++uMOxd7cuyA1+8kBSvg23Z62s40QQavRNhIPLwxHb0TlLvAd8KkFtPbkHA FTnltyMhOkE9gPqXj5F08ZySStEpOStKanhJPzHetGDkNOouphklGqrMR0FrhT+KhPoE=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Date: Subject:CC:To:From:Sender:Reply-To:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=GhNpY+7MNd2l/d5pwlgHNlDYChihSGkx/yYj3rMp66E=; b=C AmF3YCZI3hwukd2I2Y6U+hczDMxliKiCgtbUkvBelx7X9Pluyxl6B/DS9ItWbbPbzyQK3W6umQToa yUVS4SJtHAU2TcAkpiWcQeeSKA9rKOvnoh+sKsM+NkYf0apnXJzNQy4EEBl4gkSdby//TzqIL3MUA mlfTWSceLEixi1+o=; Received: from outboundhk.mxmail.xiaomi.com ([118.143.206.90]) by sfi-mx-2.v28.lw.sourceforge.com with esmtp (Exim 4.95) id 1tFpKH-0000We-1N for linux-f2fs-devel@lists.sourceforge.net; Tue, 26 Nov 2024 06:45:34 +0000 X-CSE-ConnectionGUID: NAOGOMEdRR2KbOMDMuw3nw== X-CSE-MsgGUID: q4lfMYyeTwGT4piHzTcbDQ== X-IronPort-AV: E=Sophos;i="6.12,185,1728921600"; d="scan'208";a="101749439" To: Date: Tue, 26 Nov 2024 14:45:09 +0800 Message-ID: <20241126064509.3943768-1-zangyangyang1@xiaomi.com> X-Mailer: git-send-email 2.43.2 MIME-Version: 1.0 X-Originating-IP: [10.149.44.251] X-ClientProxiedBy: yz-mbx13.mioffice.cn (10.237.88.133) To bj-mbx11.mioffice.cn (10.237.8.131) X-Headers-End: 1tFpKH-0000We-1N Subject: [f2fs-dev] [PATCH] f2fs: fiemap support to map continuous holes address 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: , X-Patchwork-Original-From: zangyangyang1 via Linux-f2fs-devel From: zangyangyang1 Reply-To: zangyangyang1 Cc: jaegeuk@kernel.org, zangyangyang1 , linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This patch supports to map continuous holes to improve performace of lookuping mapping info during fiemap. [testcase] truncate -s 1m hole && fsync hole f2fs_io fiemap 0 256 hole [before] f2fs_map_blocks: dev = (254,54), ino = 18563, file offset = 0, start blkaddr = 0x0, len = 0x0, flags = 0, seg_type = 8, may_create = 0, multidevice = 0, flag = 1, err = 0 f2fs_map_blocks: dev = (254,54), ino = 18563, file offset = 1, start blkaddr = 0x0, len = 0x0, flags = 0, seg_type = 8, may_create = 0, multidevice = 0, flag = 1, err = 0 f2fs_map_blocks: dev = (254,54), ino = 18563, file offset = 2, start blkaddr = 0x0, len = 0x0, flags = 0, seg_type = 8, may_create = 0, multidevice = 0, flag = 1, err = 0 ...... f2fs_map_blocks: dev = (254,54), ino = 18563, file offset = 863, start blkaddr = 0x0, len = 0x0, flags = 0, seg_type = 8, may_create = 0, multidevice = 0, flag = 1, err = 0 f2fs_map_blocks: dev = (254,54), ino = 18563, file offset = 864, start blkaddr = 0x0, len = 0x0, flags = 0, seg_type = 8, may_create = 0, multidevice = 0, flag = 1, err = 0 f2fs_map_blocks: dev = (254,54), ino = 18563, file offset = 1882, start blkaddr = 0x0, len = 0x0, flags = 0, seg_type = 8, may_create = 0, multidevice = 0, flag = 1, err = 0 f2fs_map_blocks: dev = (254,54), ino = 18563, file offset = 2900, start blkaddr = 0x0, len = 0x0, flags = 0, seg_type = 8, may_create = 0, multidevice = 0, flag = 1, err = 0 f2fs_map_blocks: dev = (254,54), ino = 18563, file offset = 1039224, start blkaddr = 0x0, len = 0x0, flags = 0, seg_type = 8, may_create = 0, multidevice = 0, flag = 1, err = 0 f2fs_map_blocks: dev = (254,54), ino = 18563, file offset = 2075548, start blkaddr = 0x0, len = 0x0, flags = 0, seg_type = 8, may_create = 0, multidevice = 0, flag = 1, err = 0 [after] f2fs_map_blocks: dev = (254,54), ino = 19959, file offset = 0, start blkaddr = 0x0, len = 0x100, flags = 0, seg_type = 8, may_create = 0, multidevice = 0, flag = 1, err = 0 f2fs_map_blocks: dev = (254,54), ino = 19959, file offset = 256, start blkaddr = 0x0, len = 0x100, flags = 0, seg_type = 8, may_create = 0, multidevice = 0, flag = 1, err = 0 f2fs_map_blocks: dev = (254,54), ino = 19959, file offset = 512, start blkaddr = 0x0, len = 0x100, flags = 0, seg_type = 8, may_create = 0, multidevice = 0, flag = 1, err = 0 f2fs_map_blocks: dev = (254,54), ino = 19959, file offset = 768, start blkaddr = 0x0, len = 0x60, flags = 0, seg_type = 8, may_create = 0, multidevice = 0, flag = 1, err = 0 f2fs_map_blocks: dev = (254,54), ino = 19959, file offset = 1882, start blkaddr = 0x0, len = 0x0, flags = 0, seg_type = 8, may_create = 0, multidevice = 0, flag = 1, err = 0 f2fs_map_blocks: dev = (254,54), ino = 19959, file offset = 2900, start blkaddr = 0x0, len = 0x0, flags = 0, seg_type = 8, may_create = 0, multidevice = 0, flag = 1, err = 0 f2fs_map_blocks: dev = (254,54), ino = 19959, file offset = 1039224, start blkaddr = 0x0, len = 0x0, flags = 0, seg_type = 8, may_create = 0, multidevice = 0, flag = 1, err = 0 f2fs_map_blocks: dev = (254,54), ino = 19959, file offset = 2075548, start blkaddr = 0x0, len = 0x0, flags = 0, seg_type = 8, may_create = 0, multidevice = 0, flag = 1, err = 0 Signed-off-by: zangyangyang1 --- fs/f2fs/data.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) -- 2.43.2 #/******±¾Óʼþ¼°Æ丽¼þº¬ÓÐСÃ×¹«Ë¾µÄ±£ÃÜÐÅÏ¢£¬½öÏÞÓÚ·¢Ë͸øÉÏÃæµØÖ·ÖÐÁгöµÄ¸öÈË»òȺ×é¡£½ûÖ¹ÈκÎÆäËûÈËÒÔÈκÎÐÎʽʹÓ㨰üÀ¨µ«²»ÏÞÓÚÈ«²¿»ò²¿·ÖµØй¶¡¢¸´ÖÆ¡¢»òÉ¢·¢£©±¾ÓʼþÖеÄÐÅÏ¢¡£Èç¹ûÄú´íÊÕÁ˱¾Óʼþ£¬ÇëÄúÁ¢¼´µç»°»òÓʼþ֪ͨ·¢¼þÈ˲¢É¾³ý±¾Óʼþ£¡ This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/# diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index ee5614324df0..a7e82994e230 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1526,7 +1526,7 @@ static bool map_is_mergeable(struct f2fs_sb_info *sbi, return true; if (flag == F2FS_GET_BLOCK_PRE_DIO) return true; - if (flag == F2FS_GET_BLOCK_DIO && + if ((flag == F2FS_GET_BLOCK_DIO || flag == F2FS_GET_BLOCK_FIEMAP) && map->m_pblk == NULL_ADDR && blkaddr == NULL_ADDR) return true; return false; @@ -1648,11 +1648,8 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag) map->m_pblk = 0; goto sync_out; case F2FS_GET_BLOCK_FIEMAP: - if (blkaddr == NULL_ADDR) { - if (map->m_next_pgofs) - *map->m_next_pgofs = pgofs + 1; - goto sync_out; - } + if (blkaddr == NULL_ADDR && map->m_next_pgofs) + *map->m_next_pgofs = pgofs + 1; break; case F2FS_GET_BLOCK_DIO: if (map->m_next_pgofs) @@ -1676,8 +1673,12 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag) /* reserved delalloc block should be mapped for fiemap. */ if (blkaddr == NEW_ADDR) map->m_flags |= F2FS_MAP_DELALLOC; - /* DIO READ and hole case, should not map the blocks. */ - if (!(flag == F2FS_GET_BLOCK_DIO && is_hole && !map->m_may_create)) + /* + * DIO READ with hole case and fiemap with NULL address case, + * should not map the blocks. + */ + if (!((flag == F2FS_GET_BLOCK_DIO && is_hole && !map->m_may_create) || + (flag == F2FS_GET_BLOCK_FIEMAP && blkaddr == NULL_ADDR))) map->m_flags |= F2FS_MAP_MAPPED; map->m_pblk = blkaddr;