Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp130495lqo; Thu, 16 May 2024 01:08:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXtfYTazhGhKLbawaPQfvk3KzIPxvPuTi6NwI+WUiig8wUMbrtvQED8/8od2g7D2vkPxBxh+zx6b/9FxuCpnkv/OVjdsquiNhaoP1UMNw== X-Google-Smtp-Source: AGHT+IEexy9bo7u7IBIyP67xmtoBvkJazsaZOYY4y4Mu9zWrEyNvnef61s4qFgdrMoBmzhl1Ay9i X-Received: by 2002:a05:6214:3114:b0:6a0:7f0f:5856 with SMTP id 6a1803df08f44-6a1680bdc87mr216054466d6.0.1715846881313; Thu, 16 May 2024 01:08:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715846881; cv=pass; d=google.com; s=arc-20160816; b=hPTKLsVn4pOR9w13/qgbCVgVRbRgMzoK7hFyonx9L7ERs3ekfnxJHtyoCDAls0SNPF J/iSN5fFxCPC+WDhO/snWDhzwpfJeD9gyhcvlFQWT5e4yXnNt32P8AJrZqT5o/+JZ7Yu qHqN+wtDMijiTG1jYOTwwUL2KIDWu10BB4ZFCSGwQC2lWD3sz7whUgJyY+VrkIIicX8+ csJCbLp5lR9mtOpwkpYex1K1S9taaCzlrpc6/Pk3pFlRUHJI4/6v4oBn+649qemqaNDk aqJxdyN9b9AyiktUtchAZHwXRMRdZX6rCGvd3djYrzWiPs2GILVHABMhIKmbK7wsIyV8 k9aA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=S4cZJXilPFReiDfTtuJk20G3/oAWwraZSP3dwHi93c0=; fh=y+SwDKitldk+0lmxuFszEXeuG7K2E8tJkCKNfW+i/jY=; b=Kxo9VSRHjmmdHp41mBAVOtuJj3J4igT/Bdv9yj2mjd/rfU4pzpwYoL3OmmEifCCcYr HYx19WpT/sayH5pdtl+N8ZTWIIdlTkCY6iP1IXCXhlrpDPgkIm7jwUvh3SwKwBfTPAEz YqN18Hn/AknGnQLgvdXs2DfysTMpruyXU6CT3KwP1i2+iaa7BnS7fYJZm1xoNLUiEX1T lGaGxrZZV7i8hdfb2awTOwFNPUt5DwjeVryHuxauMCrBJMqb2jlJmUNwUkuGkZyEfXZT vwAUQiLvfBlD9p5NreOK3WpTRbGEvilGwiG3PSsvHOLc/xzO5ok2cVFRDH7E6l5KCzzq /MpQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Vco1HtXF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-180738-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180738-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f2a1868si160518576d6.312.2024.05.16.01.08.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 01:08:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180738-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Vco1HtXF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-180738-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180738-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0D91E1C20A6D for ; Thu, 16 May 2024 08:08:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 14DBD13777C; Thu, 16 May 2024 08:06:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Vco1HtXF" 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 3AB4813443C for ; Thu, 16 May 2024 08:06:38 +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=1715846799; cv=none; b=nETfXPLSkrjNH0Anfw1pqGa1y/HfZDVVJTqckaLpCGv7FvLWTqKdf5Q0q7jfKWfzGjZuJMCDQFfisMyzmyI08arKXI1rFjyX3YdPfDUJCZW9gt73Ympcvjj5GbgtJjqnfDUoFAwMMtIgRVWuWin2HhF684ZzS4Vpd2+9kDA3Kps= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715846799; c=relaxed/simple; bh=Cpes2UwySJ5Ss9+H0DDEAlFZX5mKWDHgKLb1yKMu3OI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=JQg0e+NmB1XdSJtaOh8QPHQH0BUJXzxjf2OXwYtJmBwTQ2iScIWsVKsm4cbEnA66Zc7t696xfVrhDc6ahpYRgDCKcDDzeJsJQhunWNUK1bmxS278HinV3LvjWrmQkhR5kUF7VZgpJaC1t7eNpxNpqbj1vvjF7uabjlnCSEsw0lc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Vco1HtXF; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61C0BC32781; Thu, 16 May 2024 08:06:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715846798; bh=Cpes2UwySJ5Ss9+H0DDEAlFZX5mKWDHgKLb1yKMu3OI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Vco1HtXF/lVJfAJo4GYPqv/q5dp57R2B9PypCmBdhq/n/3Hjebue4fGhBUEUb1m8o EInyD9fNStefU14k2Q3xO5GKF44UFEphHfSSAXqGp7SzkdtDybBhupHbbg9J+XHmz4 AAGA0oHGuyV5ET5zZ59HFjz/gfmxAbWFhQHhuzZCaV4TjeLxjjtU+b05Eyg0QgkIrM iQOBy30ImeILZIL/HRvUdxZIKyC3a0+9d2fszXSdRUJwvQC1zuP00MxJcDxI6PBXa+ hrkgdVbbJQ2E8uJJhAJb+HjZb8cfBeLqRpi42fN49u+OQPqjg029NZelaC2Hoq2SQJ Kgmq4h6LRsRzg== Message-ID: Date: Thu, 16 May 2024 16:06:34 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] f2fs:modify the entering condition for f2fs_migrate_blocks() To: Liao Yuanhong , Jaegeuk Kim Cc: bo.wu@vivo.com, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <20240515082433.24411-1-liaoyuanhong@vivo.com> Content-Language: en-US From: Chao Yu In-Reply-To: <20240515082433.24411-1-liaoyuanhong@vivo.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/5/15 16:24, Liao Yuanhong wrote: > 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(). Hi, Is it possible that we can pin swapfile, and fallocate on it aligned to zone size, then mkswap and swapon? Thanks, > > 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; > > -- > 2.25.1 >