All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: Chunhai Guo <guochunhai@vivo.com>, xiang@kernel.org
Cc: linux-kernel@vger.kernel.org, huyue2@coolpad.com,
	linux-erofs@lists.ozlabs.org
Subject: Re: [PATCH] erofs: add sysfs node to drop all compression-related caches
Date: Tue, 12 Nov 2024 17:42:30 +0800	[thread overview]
Message-ID: <fabdfe9f-9293-45c2-8cf2-3d86c248ab4c@linux.alibaba.com> (raw)
In-Reply-To: <20241112091403.586545-1-guochunhai@vivo.com>

Hi Chunhai,

On 2024/11/12 17:14, Chunhai Guo wrote:
> Add a sysfs node to drop all compression-related caches, including
> pclusters and attached compressed pages.

subject: erofs: add sysfs node to drop internal caches

Add a sysfs node to drop compression-related caches, currently
used to drop in-memory pclusters and compressed folios.

I don't think it really drops `compressed folios`, also see
my comment below:

> 
> Signed-off-by: Chunhai Guo <guochunhai@vivo.com>
> ---
>   Documentation/ABI/testing/sysfs-fs-erofs |  7 +++++++
>   fs/erofs/sysfs.c                         | 11 +++++++++++
>   2 files changed, 18 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-fs-erofs b/Documentation/ABI/testing/sysfs-fs-erofs
> index 284224d1b56f..b66a3f6d3fdf 100644
> --- a/Documentation/ABI/testing/sysfs-fs-erofs
> +++ b/Documentation/ABI/testing/sysfs-fs-erofs
> @@ -16,3 +16,10 @@ Description:	Control strategy of sync decompression:
>   		  readahead on atomic contexts only.
>   		- 1 (force on): enable for readpage and readahead.
>   		- 2 (force off): disable for all situations.
> +
> +What:		/sys/fs/erofs/<disk>/drop_caches
> +Date:		November 2024
> +Contact:	"Guo Chunhai" <guochunhai@vivo.com>
> +Description:	Writing 1 to this will cause the erofs to drop all
> +		compression-related caches, including pclusters and attached
> +		compressed pages. Any other value is invalid.
> diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c
> index 63cffd0fd261..f068f01437d5 100644
> --- a/fs/erofs/sysfs.c
> +++ b/fs/erofs/sysfs.c
> @@ -10,6 +10,7 @@
>   
>   enum {
>   	attr_feature,
> +	attr_drop_caches,
>   	attr_pointer_ui,
>   	attr_pointer_bool,
>   };
> @@ -57,11 +58,13 @@ static struct erofs_attr erofs_attr_##_name = {			\
>   
>   #ifdef CONFIG_EROFS_FS_ZIP
>   EROFS_ATTR_RW_UI(sync_decompress, erofs_mount_opts);
> +EROFS_ATTR_FUNC(drop_caches, 0200);
>   #endif
>   
>   static struct attribute *erofs_attrs[] = {
>   #ifdef CONFIG_EROFS_FS_ZIP
>   	ATTR_LIST(sync_decompress),
> +	ATTR_LIST(drop_caches),
>   #endif
>   	NULL,
>   };
> @@ -163,6 +166,14 @@ static ssize_t erofs_attr_store(struct kobject *kobj, struct attribute *attr,
>   			return -EINVAL;
>   		*(bool *)ptr = !!t;
>   		return len;
> +	case attr_drop_caches:
> +		ret = kstrtoul(skip_spaces(buf), 0, &t);
> +		if (ret)
> +			return ret;
> +		if (t != 1)
> +			return -EINVAL;

		if (t & 2)
			z_erofs_shrink_scan(sbi, ~0UL);

		if (t & 1)
			invalidate_mapping_pages(EROFS_I_SB(inode)->managed_cache->i_mapping, 0, -1);

or you could export MNGD_MAPPING macros again.

Thanks,
Gao Xiang

WARNING: multiple messages have this Message-ID (diff)
From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: Chunhai Guo <guochunhai@vivo.com>, xiang@kernel.org
Cc: chao@kernel.org, huyue2@coolpad.com, jefflexu@linux.alibaba.com,
	dhavale@google.com, linux-erofs@lists.ozlabs.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] erofs: add sysfs node to drop all compression-related caches
Date: Tue, 12 Nov 2024 17:42:30 +0800	[thread overview]
Message-ID: <fabdfe9f-9293-45c2-8cf2-3d86c248ab4c@linux.alibaba.com> (raw)
In-Reply-To: <20241112091403.586545-1-guochunhai@vivo.com>

Hi Chunhai,

On 2024/11/12 17:14, Chunhai Guo wrote:
> Add a sysfs node to drop all compression-related caches, including
> pclusters and attached compressed pages.

subject: erofs: add sysfs node to drop internal caches

Add a sysfs node to drop compression-related caches, currently
used to drop in-memory pclusters and compressed folios.

I don't think it really drops `compressed folios`, also see
my comment below:

> 
> Signed-off-by: Chunhai Guo <guochunhai@vivo.com>
> ---
>   Documentation/ABI/testing/sysfs-fs-erofs |  7 +++++++
>   fs/erofs/sysfs.c                         | 11 +++++++++++
>   2 files changed, 18 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-fs-erofs b/Documentation/ABI/testing/sysfs-fs-erofs
> index 284224d1b56f..b66a3f6d3fdf 100644
> --- a/Documentation/ABI/testing/sysfs-fs-erofs
> +++ b/Documentation/ABI/testing/sysfs-fs-erofs
> @@ -16,3 +16,10 @@ Description:	Control strategy of sync decompression:
>   		  readahead on atomic contexts only.
>   		- 1 (force on): enable for readpage and readahead.
>   		- 2 (force off): disable for all situations.
> +
> +What:		/sys/fs/erofs/<disk>/drop_caches
> +Date:		November 2024
> +Contact:	"Guo Chunhai" <guochunhai@vivo.com>
> +Description:	Writing 1 to this will cause the erofs to drop all
> +		compression-related caches, including pclusters and attached
> +		compressed pages. Any other value is invalid.
> diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c
> index 63cffd0fd261..f068f01437d5 100644
> --- a/fs/erofs/sysfs.c
> +++ b/fs/erofs/sysfs.c
> @@ -10,6 +10,7 @@
>   
>   enum {
>   	attr_feature,
> +	attr_drop_caches,
>   	attr_pointer_ui,
>   	attr_pointer_bool,
>   };
> @@ -57,11 +58,13 @@ static struct erofs_attr erofs_attr_##_name = {			\
>   
>   #ifdef CONFIG_EROFS_FS_ZIP
>   EROFS_ATTR_RW_UI(sync_decompress, erofs_mount_opts);
> +EROFS_ATTR_FUNC(drop_caches, 0200);
>   #endif
>   
>   static struct attribute *erofs_attrs[] = {
>   #ifdef CONFIG_EROFS_FS_ZIP
>   	ATTR_LIST(sync_decompress),
> +	ATTR_LIST(drop_caches),
>   #endif
>   	NULL,
>   };
> @@ -163,6 +166,14 @@ static ssize_t erofs_attr_store(struct kobject *kobj, struct attribute *attr,
>   			return -EINVAL;
>   		*(bool *)ptr = !!t;
>   		return len;
> +	case attr_drop_caches:
> +		ret = kstrtoul(skip_spaces(buf), 0, &t);
> +		if (ret)
> +			return ret;
> +		if (t != 1)
> +			return -EINVAL;

		if (t & 2)
			z_erofs_shrink_scan(sbi, ~0UL);

		if (t & 1)
			invalidate_mapping_pages(EROFS_I_SB(inode)->managed_cache->i_mapping, 0, -1);

or you could export MNGD_MAPPING macros again.

Thanks,
Gao Xiang

  reply	other threads:[~2024-11-12  9:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-12  9:14 [PATCH] erofs: add sysfs node to drop all compression-related caches Chunhai Guo via Linux-erofs
2024-11-12  9:14 ` Chunhai Guo
2024-11-12  9:42 ` Gao Xiang [this message]
2024-11-12  9:42   ` Gao Xiang
2024-11-12 14:51 ` kernel test robot
2024-11-12 14:51   ` kernel test robot
2024-11-12 16:57 ` kernel test robot
2024-11-12 16:57   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fabdfe9f-9293-45c2-8cf2-3d86c248ab4c@linux.alibaba.com \
    --to=hsiangkao@linux.alibaba.com \
    --cc=guochunhai@vivo.com \
    --cc=huyue2@coolpad.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xiang@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.