From patchwork Wed May 15 08:24:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liao Yuanhong X-Patchwork-Id: 13664860 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 73C99C25B75 for ; Wed, 15 May 2024 08:25:18 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1s79ws-0005BH-DQ; Wed, 15 May 2024 08:25:17 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1s79wr-0005BA-HP for linux-f2fs-devel@lists.sourceforge.net; Wed, 15 May 2024 08:25:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=MIME-Version:Content-Type:Content-Transfer-Encoding :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=eLb19zrwrtWxdUekpCcCFsMvmSfizVpyDVNcEFOfkzo=; b=Djgzw3dDLbBSbboYehvWbiDoJU mNwhixDFj5ctWaXnxytaC4XhF8vMlw4UsjG0uj9vswD1QwkuObPb63a5+kw/WYozBVw4U+qyUBJNE uPZ8xIkPp2QExgFIOl9FbOxIwEj8HKGR29OWnQNMVIZevlHh/Tn3OT9jYb32HVFxPGQ4=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=MIME-Version:Content-Type:Content-Transfer-Encoding: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=eLb19zrwrtWxdUekpCcCFsMvmSfizVpyDVNcEFOfkzo=; b=Q 8uFftLhi3xo2BQ1gH4a/g1D0uWlgIJ/s5KZ5TRKLBIRrA2N2CO/4+7XyN0Zu210ZEV0Gy224pw1RN 79tNTP7MbrsTmPWqjoiGqaOj1oJk9xjVEn+7xJC38b3jODYex3AHHM7PxEUL+/3GiRGTav93AzBHc DxmGs1p4m/f5WmwQ=; Received: from mail-eastasiaazon11011004.outbound.protection.outlook.com ([52.101.128.4] helo=HK3PR03CU002.outbound.protection.outlook.com) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1s79wq-0006LG-UU for linux-f2fs-devel@lists.sourceforge.net; Wed, 15 May 2024 08:25:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aXfrBBOPbRIOPGnIvHz19cTHyDnyPcevDDGT6fXflSp1fCyuTiZQWCs7A936wnCeNG5bB0XM10HjP/97xX/y9xotl6fSHpS8fnQhm/fs8+dLYJ3jhJAC2A/qUCEQZ2qPfpIo15LmZZARsPKVzGBlXkXwoXGZJKFrtYaq3Tvfc9LZhN46DOY2+9gfxHijPrbmG07a1OHX93IlzX1R7y/drJkKn/2p8QNNWNbr+sVRyj579fJT2q+KoEMB6VQXbxN/67gndZ7eVn+3xAHfW+mNUB3dayhLZHOdiGr2+c8FO+rfLGd8AEEQyRXQmP4FlCcz5xA3Xgk5RIKxglJiouUkLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eLb19zrwrtWxdUekpCcCFsMvmSfizVpyDVNcEFOfkzo=; b=FRd/8n4Z7uJ04gxVg4SaEVH2W609fdD6qmvzk3xZxK0Dv/QDXAVhKhpnubNeA/nTZV5lK8x066XLRRjLZwEZ57rjUj6cTNfPKQizgNb6idLB0S3DqgUp5iBABz7bewAyAtepA0lnN+NQIipe87CcSYRxOhUfJcsStfvg0Fiy+t2Zey/p1pnuViW09iOEk+ytqtDt3cLjcm0912W/UsIgXefgfTO71wZpBZwyFFgUzYIGwgXIfrjFnMq8q01vdrkdDqlpqPFbCXsJP7bAMvG0rdg5hgiY8Dh0yMSOmCC3CO/qw2Pwug3rznIaCTbUSpc3s95lv6dB6NnVvLlSKZqnfQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eLb19zrwrtWxdUekpCcCFsMvmSfizVpyDVNcEFOfkzo=; b=pagpeMSf+Axjjx2vdBi9vc7xA6Vyfv5IwTJFadYldMmSzmSyWRIC47+1mQJkUkiLGIU86DWRw7KRwAY0u3kWfOHicSNN7oeq0Vmc4Ckqkzc8Dp0lUMopWLdGM6ddRgQPnrBoGJbv0r8owhNLOk4pmO3bB9Op50zNe924k4VrE0tn2wuLF8h3nVpeEdbH+MzBrOcjAjtvunUbPqi1gygtgjlmZu/ts3JV7cQa3bZFwciYF5j4GcnWYrwwX6Ou43PkoSChn53fiLuKj4dVysecU3XLDreaqY0D52j4f20IQowhelLmDr/mJMynQOrniZ2WOf0hQuTvpzjyK82CUVyKEA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5576.apcprd06.prod.outlook.com (2603:1096:101:c9::14) by SEYPR06MB6034.apcprd06.prod.outlook.com (2603:1096:101:d8::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.27; Wed, 15 May 2024 08:25:02 +0000 Received: from SEZPR06MB5576.apcprd06.prod.outlook.com ([fe80::5c0a:2748:6a72:99b6]) by SEZPR06MB5576.apcprd06.prod.outlook.com ([fe80::5c0a:2748:6a72:99b6%6]) with mapi id 15.20.7544.052; Wed, 15 May 2024 08:25:02 +0000 To: Jaegeuk Kim , Chao Yu Date: Wed, 15 May 2024 16:24:33 +0800 Message-Id: <20240515082433.24411-1-liaoyuanhong@vivo.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: SG2PR04CA0177.apcprd04.prod.outlook.com (2603:1096:4:14::15) To SEZPR06MB5576.apcprd06.prod.outlook.com (2603:1096:101:c9::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5576:EE_|SEYPR06MB6034:EE_ X-MS-Office365-Filtering-Correlation-Id: 47b4a625-fba0-4604-3d66-08dc74b8845b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|366007|376005|1800799015|52116005|38350700005; X-Microsoft-Antispam-Message-Info: WhdEF8XT/F9of28aE5XF/cKiZl9CfFaqK6LuxemC7vosozfWPOv8GpaiNRHToilL/uION7q2t94PW10DFQudTRiDG2NfczhP8B22pxzzO+qojAZZU2C2zVMygSFNA2IITHF59QJJ04XfTC5lxTrPvNVJWqEsJP/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nqHYBJ/uIjsm3n3GDRapEvmblKiVDADPwWlOY0BM9JAYXjLEwMStZj8YnQGHR019VECmn1lEouj3r6IoyiGViE3GxtH5YGxxRV2vkLTfmFZBNSUhqoRMGODUt2lkOjQVgg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SEZPR06MB5576.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366007)(376005)(1800799015)(52116005)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GiSNvt+xHbh/neSpHfvhwOEReMNZk2m+E3Fq/xsSECyZuZJAmYnDYnd5Uyy+qqIJcNALAGsfUATbUH8ozRDZdKEkTRqKGuZwlEUQVslKNP8bW/Aqcf8bGxYZNjyPmIn1Gm9oRdKiTbwLTMJUvucbG8Y7S9picD4Ik6WJiYPM49x1OmfV0Znzo269q4xoaDLkyQYBMSClCgIoUi6N8KBXGBQUzzIqlirzeUvC3nkOX1GbW4ApvJij8f0Rc1TegBpUmWq7MJHdzdtaODbDESxh53JJQsg4dz7Cs+QYqa+E538yiWRXvP0pkAAO0ipUR3vBOcmfeDHbPcAVEolX6CO3tEPw0F97SRuMsKp6ij2Jb2Yk7WeqXwOL3q2b1pzQWWTYM6a4E5LT0lI1DiftPcxcDAd+kwVlEu6Oa5XbpeEhH4yGgkGPWeU+F+h7s82Cz3HC3+yoj54oCbJMO7CmKj3bR9hVzInMwlND9R4EftC1vuzeuKQQ/Ffzf7e4EYehJ1Hn8DAEnLpb4GtGMjEUlBHPquGJ4DNbKgPSoI+abYdEKwlW4T+aDa65N73n2Jzj75bxrFvdEiBOF7AXBTRMI11TQCfSP3wSs+FniXUW0F2IkAwh7j9UbmkTD2jsXO7Zc8Or/3Ex82LQQZ8m4HumuKOwZrvxJCHJSWFC5tUpA0lrhItqQvkl1nYT95RTe9TW8zaCGjed24zbEq4Y7/jcwj5SZ1CrFS5hZI5jpNd96sh3NzoN17gucBmrui4PiCsZyasTQ7tban0vrv46EYyI30gcxUU9bK9TLfRevWzEsc0wg41BEFfvW1K+YUDEfltlVnKWJnFphbDoyXLonj66H0wbW/7NjuSE+aSQ89M4kYn8alPQ4V2kWT6/Oh4zjJf36Pj2fN5yZohBa7hnCBC5Tw8iVCG8x0tygqvy7snAL0U2N2+jA0+6oaitefiAml21pf2m7nn5qNq0bLJyfFr9mb+5BlAMoKf/oPnzZtODZ7xZOoSTc2jolboAYP0IjyN3yEJQ++ApaDLTCAdvNjY9qwvVRdGxaQ91QgZ+GBWVYDHdSfGBB8atlNJ4sejQBf/1e5eVlkfwK1+gzRwBqYQILySqZsvvcdRt4llBzFs/UijwAhdwaNKxzkRkQYf1gdbTzA3jw07hrdlvGH5wTj9a9FTRGPKNvxxgDvt1ztuD5uHlDPFiw4jn4dye8gfbQj2wHJz7XvQIjJ87ckoNS/bhcz2ovVjXO+pTbcycykd3X1bzVPbxBlHcHo7X3uJ4QYhkuvKt2relLjvgLtkjUlevBd+paSoTCUGbYn8vrXaYshs4dtGtWPjUGC+ZiwNDnYR4t+aowIc1S6TicKMMs/uVBtB1GKHxi9US0VTnt51rK3LvGvyDMRUmPryb9/MpUisHUwouo80Enagb9OBnUBoVz0dppmEWDHjqjG+9dLfZN4MoVkSKgk1zCK9nb8vQhP7nrGA7kNC0m64ukZV+xQfrAKyylTMwJRevTBPgQGpiMR26N6gGuBjBhEaAVD9G/PvX5Tlz0pWiFTFdqqfBotwF5eLMevGuZ3BSJhhZeH1dCHfZqO8JCl65UIweTSGZ/SjfLsVK X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47b4a625-fba0-4604-3d66-08dc74b8845b X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5576.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2024 08:25:02.5512 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: o4srkLdgiOKQcPI1wow6M1irGtRSV4ZFBdiqx/ZtgImQuJxv46cs2zIUT2XJCov6YQ1rzEoymc0YlnfdkjDB+Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB6034 X-Headers-End: 1s79wq-0006LG-UU Subject: [f2fs-dev] [PATCH] f2fs:modify the entering condition for f2fs_migrate_blocks() 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: Liao Yuanhong via Linux-f2fs-devel From: Liao Yuanhong Reply-To: Liao Yuanhong Cc: Liao Yuanhong , linux-kernel@vger.kernel.org, bo.wu@vivo.com, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Currently, when we allocating a swap file on zone UFS, this file will created on conventional UFS. If the swap file size is not aligned with the zone size, the last extent will enter f2fs_migrate_blocks(), resulting in significant additional I/O overhead and prolonged lock occupancy. In most cases, this is unnecessary, because on Conventional UFS, as long as the start block of the swap file is aligned with zone, it is sequentially aligned.To circumvent this issue, we have altered the conditions for entering f2fs_migrate_blocks(). Now, if the start block of the last extent is aligned with the start of zone, we avoids entering f2fs_migrate_blocks(). Signed-off-by: Liao Yuanhong Signed-off-by: Wu Bo --- fs/f2fs/data.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 50ceb25b3..4d58fb6c2 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -3925,10 +3925,12 @@ static int check_swap_activate(struct swap_info_struct *sis, block_t pblock; block_t lowest_pblock = -1; block_t highest_pblock = 0; + block_t blk_start; int nr_extents = 0; unsigned int nr_pblocks; unsigned int blks_per_sec = BLKS_PER_SEC(sbi); unsigned int not_aligned = 0; + unsigned int cur_sec; int ret = 0; /* @@ -3965,23 +3967,39 @@ static int check_swap_activate(struct swap_info_struct *sis, pblock = map.m_pblk; nr_pblocks = map.m_len; - if ((pblock - SM_I(sbi)->main_blkaddr) % blks_per_sec || + blk_start = pblock - SM_I(sbi)->main_blkaddr; + + if (blk_start % blks_per_sec || nr_pblocks % blks_per_sec || !f2fs_valid_pinned_area(sbi, pblock)) { bool last_extent = false; not_aligned++; + cur_sec = (blk_start + nr_pblocks) / BLKS_PER_SEC(sbi); nr_pblocks = roundup(nr_pblocks, blks_per_sec); - if (cur_lblock + nr_pblocks > sis->max) + if (cur_lblock + nr_pblocks > sis->max) { nr_pblocks -= blks_per_sec; + /* the start address is aligned to section */ + if (!(blk_start % blks_per_sec)) + last_extent = true; + } + /* this extent is last one */ if (!nr_pblocks) { nr_pblocks = last_lblock - cur_lblock; last_extent = true; } + /* + * the last extent which located on conventional UFS doesn't + * need migrate + */ + if (last_extent && f2fs_sb_has_blkzoned(sbi) && + cur_sec < GET_SEC_FROM_SEG(sbi, first_zoned_segno(sbi))) + goto next; + ret = f2fs_migrate_blocks(inode, cur_lblock, nr_pblocks); if (ret) { @@ -3994,6 +4012,7 @@ static int check_swap_activate(struct swap_info_struct *sis, goto retry; } +next: if (cur_lblock + nr_pblocks >= sis->max) nr_pblocks = sis->max - cur_lblock;