Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1518053lqa; Mon, 29 Apr 2024 10:37:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVKJuyj9TZsRuND0wjMMA7HMz4aTsGOUTW2QO4VyDrwxw26udbxXFYh5CEkcYp3qT5O/5nTboD0cFhGl5rAARv7bkvQZGL6Y+AqFZcz8Q== X-Google-Smtp-Source: AGHT+IEy7Lsks2IcbWMXgqhp5YbJ/k34U079hho+MOdhdPfvHBTy1ETpe9VzSGYD9iksUlKd2YXi X-Received: by 2002:a05:6512:a8e:b0:51d:a541:733 with SMTP id m14-20020a0565120a8e00b0051da5410733mr3564361lfu.66.1714412252198; Mon, 29 Apr 2024 10:37:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714412252; cv=pass; d=google.com; s=arc-20160816; b=QdcITilPChZUZ1TfHx53Nq47AbppCg+ylD5g+EGAdTMj5SBDGPWtIgdT4cvMum58Rp sfJW0f9ukJCBCVpinJGzj9YLn47bQ4aiBMgPXCPVesRhfFQvP32olaVWmjh5+YwPgcix bIlfImGgNPzwGlkU/RiHYgZJYUO1n3LkDOq7gP7c4Esly+7F7os3QBd+gi9feeESwLN0 bRUJZLgjqmoKGCyJiktvmifyMajJasKctvEBS4/Bmsj8DfNxFhwc/Qvi0Pkd0AKl2cXI eh17mcRO8PxRi5CTfQFwyvV0L9ldha6/3keEL/42N9uqbqSLPwtk+JdMSr/kawEkUVzS AEvg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=4DIoUXQ0/J3S3hFKOFNHYQ4nr557nzeXraoDrvsPRdI=; fh=j9KA+UiqAzMfHR62XHp+FaOgurEE1pKUib/Qacutn6M=; b=iAMxBpjR6cY1zS1RRAJmLbfCzmy0u5klqFIAWVuWCWVidkTnfKN719wxcyMOqraLlX +wMV9sqbdtZJ3HfyuNv70bs4w2DnnErFwzi0Ep8TTU5rO0M1yI1lXORd8/b5Dm6W8hqC shLg4KZ7qbE03h07xz9ANAAbNP2Mt5fiTpuzt3/UMUaFXF3S32bOArrKlGGB8JdMPKJf jogS6uQUascMNCbCiiJazrR0b+mijIunY2QOWq+PCSqmQcz0JuObcKuCY2hl6KK+Cqul euGXigBIL5vBaPaK/oBN0Bicy/0z4TJIG/2GMzQHbRtioMXB5WfTOiW3d1cafkvBRRwD 5Prw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LuVzY315; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-162764-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162764-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hr19-20020a1709073f9300b00a55b336138bsi10815944ejc.935.2024.04.29.10.37.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 10:37:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162764-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LuVzY315; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-162764-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162764-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E357D1F2156B for ; Mon, 29 Apr 2024 17:37:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 45CDC381C7; Mon, 29 Apr 2024 17:37:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LuVzY315" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6EBCC8627D for ; Mon, 29 Apr 2024 17:37:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714412245; cv=none; b=CXTM3S1X5x/W4U/8td4aoUR9ewS/ZFNSkl5PU8lF8KmFBkOkm4gGEP4hXzBW5PWyR09oANADPaVQaokDwOI5bdD2AlkpdrVbahwqOQlQcWfdFutG6zDVznYGkgpNUiqAteaCE4T7IebciG5kNRMuxPrcwG5l8tLMr0Is27XK4Y8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714412245; c=relaxed/simple; bh=CmTPcX7OUPyQ3Hu3X55BRSo5T1RVAsPgJMLD9lcSEow=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=it8F++Dn9OT9a3dL/wytz8dBwmzmmEcYkAF7Y8rNemhQ421ck0FZWdMqUDOoFIwTb1FBafBq4I3fGfSATqKjNwOJEHKbywMNG4AndxfNmJZQSEajdbr4E+9hmOzZL41QEDiAVFolbeHG6fyd4o7+45HxmCu3+E/X1oKJ/CQoh5k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LuVzY315; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5194C113CD; Mon, 29 Apr 2024 17:37:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714412245; bh=CmTPcX7OUPyQ3Hu3X55BRSo5T1RVAsPgJMLD9lcSEow=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LuVzY315Qe6YQjT1RqPxGUFNH25uTyzjfgK0PmywwzC6G31QqPVrU/YIR/RBMizkj 1KAMudmN+EdonfHxGzFk68ciz3h9Aj+KfGOU3Z0CT5WA5Km2yWugWmLutUwhq03qvi f7+1xArapIraRHp4+NxHA72jPsFQ9uD8yJh1Yn8FEz63T/tRC7cZqt+YXlgRjQxTh+ x489L02XpNfhVvu1zE+HmxqgKxKn/XLcA/0/E/Rk/7+AZd9i40VJEnRwuKXLjZo97Q AKwHn5XHOpIDYEgHo2OGSck96vcq1CymDyIX6VcoqXoSso99i+KnzX+2dBpEujbIrI hbEpLoSayrqAw== Date: Mon, 29 Apr 2024 17:37:23 +0000 From: Jaegeuk Kim To: Wu Bo Cc: Chao Yu , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Wu Bo , Liao Yuanhong Subject: Re: [PATCH] f2fs: fix block migration when section is not aligned to pow2 Message-ID: References: <20240426104156.321701-1-bo.wu@vivo.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240426104156.321701-1-bo.wu@vivo.com> On 04/26, Wu Bo wrote: > As for zoned-UFS, f2fs section size is forced to zone size. And zone > size may not aligned to pow2. > > Fixes: 859fca6b706e ("f2fs: swap: support migrating swapfile in aligned write mode") > Signed-off-by: Liao Yuanhong > Signed-off-by: Wu Bo > --- > fs/f2fs/data.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index d9494b5fc7c1..7ff5ad3fd5dc 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -3904,7 +3904,6 @@ static int check_swap_activate(struct swap_info_struct *sis, > int nr_extents = 0; > unsigned long nr_pblocks; > unsigned int blks_per_sec = BLKS_PER_SEC(sbi); > - unsigned int sec_blks_mask = BLKS_PER_SEC(sbi) - 1; > unsigned int not_aligned = 0; > int ret = 0; > > @@ -3942,8 +3941,8 @@ 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) & sec_blks_mask || > - nr_pblocks & sec_blks_mask || > + if ((pblock - SM_I(sbi)->main_blkaddr) % blks_per_sec || > + nr_pblocks % blks_per_sec || Modified a bit to address udiv issue like below. Let's see. --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -3923,8 +3923,8 @@ static int check_swap_activate(struct swap_info_struct *sis, sector_t highest_pblock = 0; int nr_extents = 0; unsigned long nr_pblocks; + u32 align; unsigned int blks_per_sec = BLKS_PER_SEC(sbi); - unsigned int sec_blks_mask = BLKS_PER_SEC(sbi) - 1; unsigned int not_aligned = 0; int ret = 0; @@ -3961,10 +3961,10 @@ static int check_swap_activate(struct swap_info_struct *sis, pblock = map.m_pblk; nr_pblocks = map.m_len; + div_u64_rem(nr_pblocks, blks_per_sec, &align); - if ((pblock - SM_I(sbi)->main_blkaddr) & sec_blks_mask || - nr_pblocks & sec_blks_mask || - !f2fs_valid_pinned_area(sbi, pblock)) { + if ((pblock - SM_I(sbi)->main_blkaddr) % blks_per_sec || + align || !f2fs_valid_pinned_area(sbi, pblock)) { bool last_extent = false; not_aligned++; > !f2fs_valid_pinned_area(sbi, pblock)) { > bool last_extent = false; > > -- > 2.25.1