Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1825669lqb; Sun, 26 May 2024 20:49:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU5ZOOGC6p5bssK72R7rA44p/3MsB9thXAgmO5qx6CMN2058kAq9bSefyETHx3rFpqTCyVu6bazivasmGai2z/lj0GhleAtA3ZTqgBqkA== X-Google-Smtp-Source: AGHT+IExrJ8puETPj2pNU2Zb7GPVFH2N6xZqF9KcnPEGFj6S/deukCNGsMyObC7Lvx7BY57zwsFD X-Received: by 2002:a05:6a20:dc95:b0:1af:ba46:a3eb with SMTP id adf61e73a8af0-1b212df0682mr7310396637.38.1716781760381; Sun, 26 May 2024 20:49:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716781760; cv=pass; d=google.com; s=arc-20160816; b=nEtB6yP8/WgpJVwDd+sdKZ0uvllz4ey5B1PZ7EjnFYbDKhx+Lv/IdD48p3ivwxIi5n m5RgEP8LnQoow9zWoB2nodxEdpArgmwq5JxkLoh8xhTNuThl71TOW6M4JRepaHsD3Atk L9YTsueLVKGZPBpX5jWHPQX9bfa5EJnToVzMhFr0zPT5rNWGBaM/BVFMUn860sZJlNDT 9V7aoz+GG1/z50X6e5s2b38HQ+9yI+U772C9hHxVUXdVsmewxmkl4DCy+/qIwoLbCsdZ cEJpOdRTUnL+KHHf6MwgaO0NBzNXiFp4kQWHdbHiAQPD3kjU84y4QOeQsL5sLLyd9o5c 4rXQ== 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=ZCxT5L6JSXe2UV9jfQqCsj2TLcP4b0wXa4ucf3o6RzY=; fh=zQ4KyqolXqQO+yNFGVuXxCeSvQq3rubOak+k9IB2PKU=; b=nP2/RNckV2sRez7mM75xOY/gxgEz3jt7LEUdnMjl2AldJEb7i7I2P56v6sVW8zCBWy FM3aWZF2YlgDxU1AotrRURHL6ygrpYUbLOoFn+a0TomDm2qdJhtPFj8SXvtzu7psPz/r X5w7O98ikaYaZhMHDB1MknJ9HXgwsUzudzq1d9LzUpHmt63znNDaHC5bUGYITfLz051A oum9Yc6bfEuHqATA7861atXRpNOQ3FhT9zgWkYlAnPq9RFeabcReW1FbEqjUSoBZ3lA/ nAjBAm/Ao0SCa4xKtp6sl6/a/648edU5hRPVC6jbBq7iv4D4aTGqU7uzabNencCfrJtc SXKw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="U/ST8/4y"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-189995-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189995-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2bf7c9593fesi3292371a91.189.2024.05.26.20.49.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 20:49:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189995-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="U/ST8/4y"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-189995-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189995-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id F108C280F77 for ; Mon, 27 May 2024 03:49:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF1CA79F0; Mon, 27 May 2024 03:49:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="U/ST8/4y" 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 E743B10E5 for ; Mon, 27 May 2024 03:49:13 +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=1716781754; cv=none; b=oS5Da9RBVtuwdKF16SkSgOnJwuvcIvk+7p1JSB2S27aR08k+2Y9GKH4Rgt3zAuradICUCeG+sC0OK/OJwWFkn1Twh/Gofi5y3O6xxB/ZNa5laK9KXiMv384G2kA52YuJn0pUNcXp6ftV8yhAf4NR+EGBzzIN00L6a9Kj6LsihCk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716781754; c=relaxed/simple; bh=1roAnXoBpmfOOOh02YvPm+SdLLwFEfO7YksTC91triA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=b5JNtdZ+ctirIo64yhyr+ctPd9q01jcmzDfY1GwWQqhjSotXSsOQrx7XkoLHyHNs/nKJE19SK+nE1JENuIXBSBP/PMnRKry694ceC08vouxI8nbADqGPzFLYRzcLtZBHYD/pUWEiNtgWIP02umjLrs4yXUpfOLbc+aDfojwFf2U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U/ST8/4y; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51419C2BBFC; Mon, 27 May 2024 03:49:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716781753; bh=1roAnXoBpmfOOOh02YvPm+SdLLwFEfO7YksTC91triA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=U/ST8/4yylKhLjgKzkNG/1idVDlnSQjdKf3hMftU6u3hkmLp6IynYgeoWIPIHexsS PqniFw1wqP2gm4lKPn8VkrwcLbjgqfHGhgbw0VBy9Xhdy288jKmaBJvsjHZbACae9t ujQ8S5x643S0t4sqxNRRnkk/kE0Omb7aEtypSd8rqiZQEvT1GBWxbXK13v6LthwsvC Wi3rH4igYS7eXlkXpYS6PC29I1AF5OgktwPmDtr8kZhp4mwT+qqUX7zZj9K7S3yZFW LqDxUZf0YZ+Ol4AE8+EnKyLyxO+whGpx212VpUzFg4PcRBJMdocPHylV7TztZqBO/9 dUJv/2Y+t0OMw== Message-ID: <1d67715b-5f88-4940-969d-e098fd80ae2a@kernel.org> Date: Mon, 27 May 2024 11:49:07 +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 , jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, niuzhiguo84@gmail.com, ke.wang@unisoc.com References: <1716204978-29455-1-git-send-email-zhiguo.niu@unisoc.com> Content-Language: en-US From: Chao Yu In-Reply-To: <1716204978-29455-1-git-send-email-zhiguo.niu@unisoc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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, > > 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;