Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp172704lqh; Thu, 30 May 2024 19:04:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWCvPPnYLqa6Bl1S75W06YBpPwpM9+bHuItgYni3Cg8DEu4IZsYa32YB5zRShPefKtM75W4KulsYGFLDiYYmlEa1TX5/RzweVp5EFPHiQ== X-Google-Smtp-Source: AGHT+IGbu+vaIZEEHVU+Zery9Oh7Eaw9oQ8fBYwbrhXePEC3vng/kCoh6YqNAttV3X/P8HY+NTF9 X-Received: by 2002:a19:9110:0:b0:52b:8417:fa95 with SMTP id 2adb3069b0e04-52b896b6e1emr194150e87.41.1717121092593; Thu, 30 May 2024 19:04:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717121092; cv=pass; d=google.com; s=arc-20160816; b=Ac86xVDgV8naV/DuGUhiLDQjIzWUbTCanPKJaquMlchJ54VO/ZINmrTtuOTbw1sO8z ZVTlZgcbYb1H1q712xRkoQEyP6CeJ/jy99M5++eKkamYKNDZ8EQ/ahyPjGUTZck+R/up jfc3DOzkd8RA+ffTymq7DmzszSiDSB1MrQh/FjsDv00ZC6zsESR4GBGyXj2h4RinZiVb iBF1QL45gHj4DXzB2dB5fdUd80/9hmHxgrfBfeC+8kpfaXmlzLGk736S+OS2CiRI3pu7 dzblbjs9hJbAT8CSAFu4C8F36n+h/aJ0ALVl8AXzmiOx6Ikd1g/Ig1JRa1zoq1mAywps aXBQ== 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=UtdKftBjLw1N9HC8G3+wc8ylanj54jMj75O7JP4SknQ=; fh=9FJpETW6RBsfAd64bWh5hRpm2kkz4OD2bSmy/HaUZa8=; b=wZx+VKFbGw1GGDFMWiOVxUEbd2p/Hs9B4OneNySeDGNlLoQWd/loIANeS9OK1gSk7A qdlGmUHnBqjLehZuCgYFayRlyBAJysaFCos6tWUKjcyP6wHrvLO+wUvpiX1jgr7LqRvk bDfqnjnAmLIwVNafNrUsskqF7+NWWUhZxuz4q0PyN1MhqNagxvfcOYfFb2wVH+VGCdQf XB19vJ9FhiaIPya/lTkU5pSLjORdaeL02DPO4hc0TbYetskV0oPmA2M3twnvADu6qx/3 mpXdV+dxdXVLbWtr48IH3ljKtTpKfK26ciDEZzZ1OC2gmPpjtECYJcI6aOC7blxRjJPP /ZvQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dthSPucG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-196177-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196177-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 a640c23a62f3a-a67e6f02679si37214566b.146.2024.05.30.19.04.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 19:04:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196177-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=dthSPucG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-196177-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196177-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 0D55B1F25F81 for ; Fri, 31 May 2024 02:04:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D9F5A757EE; Fri, 31 May 2024 02:04:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dthSPucG" 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 0813F6BFCA for ; Fri, 31 May 2024 02:04:43 +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=1717121084; cv=none; b=WAgOn/NYYsfVJ3tn3kc5Gs7eIiIwHQPG3QmuuHyX/sl6wTXr3klgEp+M/P/UhaCYXhGfE5naSX650WEbxiaDWViBhoJf9BAq2VzjwIQKKeA2k05n+vrN+ZMwMGDF8zQ7mWR6KnMWb93FL71D+piMcQacyABuSmaGXEJsP5OFexU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717121084; c=relaxed/simple; bh=xiHCzmsgzj4m4XKxXeex3wTFqjckwvLq3FtWszdZ62Y=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=MtGm7SgPZUDkF0RbiE6cTYveBoxNreeOCiXn+gkukZ/pBb3tlFp/IEasshIq3HgokVLuShNyib+h7agCTvTFN/XrHxaqQIQ8gbIJhDf8cAjUin4v+bkUD/IwKCsDe4Cq677K7KRbfqcosgNWOmN+eXdh72vSdTPojVQUI+c4TL0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dthSPucG; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FA47C2BBFC; Fri, 31 May 2024 02:04:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717121083; bh=xiHCzmsgzj4m4XKxXeex3wTFqjckwvLq3FtWszdZ62Y=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=dthSPucGRUGL+6aw3Cr9cas3+DxkbhNyIyN1/PH7mmiV73/90OJCM8/nxI+/tnvxw Y7KARKaNKWujrvoiX3d0RRZ1nY9I3oZoYBNVMVkbNiMoEB6P2xCESQ/QixPp8VUS/1 2osBAfjnU93cvJlFi6EupaA2yAK2aVC1R1mzvL+n4ZG3K9XhWiqENwehdEgJi2jN9p QRCp/uG7q3tq2qOpneBkwdFNgYiITg+oq2hN5C5FHCOdXPxfm3kGjjWFnQv/ezxL3X IvIjBG1lZYMBH5Yjv9LojBqBMCTUzzBD6Rg3OHaF5FWgoS7A4Cs2aBknhqLG0V2ske g9vcTww1K2bKg== Message-ID: <0a4b5b40-1532-44a4-a4d6-601ceced20a4@kernel.org> Date: Fri, 31 May 2024 10:04:39 +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: enable atgc if atgc_age_threshold from user is less than elapsed_time To: Zhiguo Niu Cc: Zhiguo Niu , jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, ke.wang@unisoc.com References: <1716204978-29455-1-git-send-email-zhiguo.niu@unisoc.com> <1d67715b-5f88-4940-969d-e098fd80ae2a@kernel.org> Content-Language: en-US From: Chao Yu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024/5/30 17:49, Zhiguo Niu wrote: > On Mon, May 27, 2024 at 12:07 PM Zhiguo Niu wrote: >> >> On Mon, May 27, 2024 at 11:49 AM Chao Yu wrote: >>> >>> On 2024/5/20 19:36, Zhiguo Niu wrote: >>>> Now atgc can be enabled based on the following conditions: >>>> -ATGC mount option is set >>>> -elapsed_time is more than atgc_age_threshold already >>>> but these conditions are check when umounted->mounted device again. >>>> If the device has not be umounted->mounted for a long time, atgc can >>>> not work even the above conditions met. >>> >>> Zhiguo, I didn't get it, can you please explain more about this issue? >>> >>> Thanks, >> Hi Chao, >> >> At present, the point of atgc enale is checked during the mount >> process. What I mean is that if a device has not been rebooted >> (re-mounted) for a long time, even if the above two conditions are >> met(ATGC mount option is set, and the device has been powered on long >> enough, more than atgc default threshold ), atgc cannot be dynamically >> enabled. >> >> If the user is used to not restarting the phone after turning it on, >> it will be difficult to use atgc. >> thanks! > Hi Chao, > Do you have any suggestions or comments on this? Zhiguo, I remember that atgc can not be enabled at runtime due to some reasons, but I need some time to recall and check the details... Thanks, > thanks! > >>> >>>> >>>> It is better to enable atgc dynamiclly when user change atgc_age_threshold >>>> meanwhile this vale is less than elapsed_time and ATGC mount option is on. >>>> >>>> Signed-off-by: Zhiguo Niu >>>> --- >>>> fs/f2fs/f2fs.h | 1 + >>>> fs/f2fs/segment.c | 9 ++++----- >>>> fs/f2fs/sysfs.c | 16 ++++++++++++++++ >>>> 3 files changed, 21 insertions(+), 5 deletions(-) >>>> >>>> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h >>>> index 1974b6a..e441d2d 100644 >>>> --- a/fs/f2fs/f2fs.h >>>> +++ b/fs/f2fs/f2fs.h >>>> @@ -3694,6 +3694,7 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi, >>>> int f2fs_init_inmem_curseg(struct f2fs_sb_info *sbi); >>>> void f2fs_save_inmem_curseg(struct f2fs_sb_info *sbi); >>>> void f2fs_restore_inmem_curseg(struct f2fs_sb_info *sbi); >>>> +int f2fs_init_atgc_curseg(struct f2fs_sb_info *sbi); >>>> int f2fs_allocate_segment_for_resize(struct f2fs_sb_info *sbi, int type, >>>> unsigned int start, unsigned int end); >>>> int f2fs_allocate_new_section(struct f2fs_sb_info *sbi, int type, bool force); >>>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c >>>> index 71dc8042..44923d4 100644 >>>> --- a/fs/f2fs/segment.c >>>> +++ b/fs/f2fs/segment.c >>>> @@ -2931,14 +2931,11 @@ static int get_atssr_segment(struct f2fs_sb_info *sbi, int type, >>>> return ret; >>>> } >>>> >>>> -static int __f2fs_init_atgc_curseg(struct f2fs_sb_info *sbi) >>>> +int f2fs_init_atgc_curseg(struct f2fs_sb_info *sbi) >>>> { >>>> struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_ALL_DATA_ATGC); >>>> int ret = 0; >>>> >>>> - if (!sbi->am.atgc_enabled) >>>> - return 0; >>>> - >>>> f2fs_down_read(&SM_I(sbi)->curseg_lock); >>>> >>>> mutex_lock(&curseg->curseg_mutex); >>>> @@ -2955,7 +2952,9 @@ static int __f2fs_init_atgc_curseg(struct f2fs_sb_info *sbi) >>>> } >>>> int f2fs_init_inmem_curseg(struct f2fs_sb_info *sbi) >>>> { >>>> - return __f2fs_init_atgc_curseg(sbi); >>>> + if (!sbi->am.atgc_enabled) >>>> + return 0; >>>> + return f2fs_init_atgc_curseg(sbi); >>>> } >>>> >>>> static void __f2fs_save_inmem_curseg(struct f2fs_sb_info *sbi, int type) >>>> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c >>>> index 09d3ecf..72676c5 100644 >>>> --- a/fs/f2fs/sysfs.c >>>> +++ b/fs/f2fs/sysfs.c >>>> @@ -673,6 +673,22 @@ static ssize_t __sbi_store(struct f2fs_attr *a, >>>> return count; >>>> } >>>> >>>> + if (!strcmp(a->attr.name, "atgc_age_threshold")) { >>>> + if (t < 0) >>>> + return -EINVAL; >>>> + sbi->am.age_threshold = t; >>>> + if (sbi->am.atgc_enabled) >>>> + return count; >>>> + >>>> + if (test_opt(sbi, ATGC) && >>>> + le64_to_cpu(sbi->ckpt->elapsed_time) >= t) { >>>> + if (f2fs_init_atgc_curseg(sbi)) >>>> + return -EINVAL; >>>> + sbi->am.atgc_enabled = true; >>>> + } >>>> + return count; >>>> + } >>>> + >>>> if (!strcmp(a->attr.name, "gc_segment_mode")) { >>>> if (t < MAX_GC_MODE) >>>> sbi->gc_segment_mode = t;