From patchwork Fri Dec 27 07:10:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: zangyangyang1 X-Patchwork-Id: 13921544 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 9C23FE7718B for ; Fri, 27 Dec 2024 07:11:14 +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 1tR4V2-0004NN-N1; Fri, 27 Dec 2024 07:11:09 +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 1tR4V2-0004NH-18 for linux-f2fs-devel@lists.sourceforge.net; Fri, 27 Dec 2024 07:11:08 +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=OTKZ0FVYtxnXh9RcUstycXcLOB /Qw7Bf1faiEt0IFfaUP5AgEBJZwixxsagikhnch61DcgmJZolWBH2gHq4G18uNk49+xKuKG6x9MB4 u/vy1No4vxo2F1Z1QZ8lO8QnBWbcrXCtHu8o5EPagWy5FCGWz7OQ28iQS9C8eh3V8i5A=; 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=R 0ISur1mt2KKuxGzHb89CGktTL/B6U4B72+Pm5id+PNIMUgSFuXX/AY9Qw/8mbpzESYk7Bu4bw1kQs ODOXfelxrnT63PMPTxlBHkglC3biVah0PQPJemtDaNzVboPn0cxoeAWUwyVH2GCS0fvHmOO4IJ80V TohC28IZ/wy5qoOM=; Received: from outboundhk.mxmail.xiaomi.com ([207.226.244.122]) by sfi-mx-2.v28.lw.sourceforge.com with esmtp (Exim 4.95) id 1tR4Uy-00064i-Q4 for linux-f2fs-devel@lists.sourceforge.net; Fri, 27 Dec 2024 07:11:08 +0000 X-CSE-ConnectionGUID: jIiYQWDySTW7hWfBntg8sQ== X-CSE-MsgGUID: SrQGSM9bSUa/xTIST22XVw== X-IronPort-AV: E=Sophos;i="6.12,268,1728921600"; d="scan'208";a="129460933" To: Date: Fri, 27 Dec 2024 15:10:35 +0800 Message-ID: <20241227071035.3275287-1-zangyangyang1@xiaomi.com> X-Mailer: git-send-email 2.43.2 MIME-Version: 1.0 X-Originating-IP: [10.237.88.13] X-ClientProxiedBy: yz-mbx19.mioffice.cn (10.237.88.139) To bj-mbx11.mioffice.cn (10.237.8.131) X-Headers-End: 1tR4Uy-00064i-Q4 Subject: [f2fs-dev] [PATCH RESEND] 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;