All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <chao@kernel.org>
Cc: linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, Yangtao Li <frank.li@vivo.com>
Subject: Re: [f2fs-dev] [PATCH v4 1/3] f2fs: fix to set ipu policy
Date: Tue, 7 Feb 2023 10:46:34 -0800	[thread overview]
Message-ID: <Y+KcivkBV6rep3R0@google.com> (raw)
In-Reply-To: <5b47f58a-4c3c-a183-777c-d4750f6b4d6c@kernel.org>

On 02/07, Chao Yu wrote:
> On 2023/2/6 22:43, Yangtao Li wrote:
> > For LFS mode, it should update outplace and no need inplace update.
> > When using LFS mode for small-volume devices, IPU will not be used,
> > and the OPU writing method is actually used, but F2FS_IPU_FORCE can
> > be read from the ipu_policy node, which is different from the actual
> > situation. And remount to lfs mode should be disallowed when
> > f2fs ipu is enabled, let's fix it.
> > 
> > Fixes: 84b89e5d943d ("f2fs: add auto tuning for small devices")
> > Signed-off-by: Yangtao Li <frank.li@vivo.com>
> > ---
> > v4:
> > -allow set 0 in lfs mode for ipu_policy node
> >   fs/f2fs/segment.h | 10 +++++++++-
> >   fs/f2fs/super.c   | 17 +++++++++++------
> >   fs/f2fs/sysfs.c   |  9 +++++++++
> >   3 files changed, 29 insertions(+), 7 deletions(-)
> > 
> > diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
> > index 0f3f05cb8c29..8ee5e5db9287 100644
> > --- a/fs/f2fs/segment.h
> > +++ b/fs/f2fs/segment.h
> > @@ -670,6 +670,8 @@ static inline int utilization(struct f2fs_sb_info *sbi)
> >   #define SMALL_VOLUME_SEGMENTS	(16 * 512)	/* 16GB */
> > +#define F2FS_IPU_DISABLE	0
> > +
> >   enum {
> >   	F2FS_IPU_FORCE,
> >   	F2FS_IPU_SSR,
> > @@ -679,10 +681,16 @@ enum {
> >   	F2FS_IPU_ASYNC,
> >   	F2FS_IPU_NOCACHE,
> >   	F2FS_IPU_HONOR_OPU_WRITE,
> > +	F2FS_IPU_MAX,
> >   };
> > +static inline bool IS_F2FS_IPU_DISABLE(struct f2fs_sb_info *sbi)
> > +{
> > +	return SM_I(sbi)->ipu_policy == F2FS_IPU_DISABLE;
> > +}
> > +
> >   #define F2FS_IPU_POLICY(name)					\
> > -static inline int IS_##name(struct f2fs_sb_info *sbi)		\
> > +static inline bool IS_##name(struct f2fs_sb_info *sbi)		\
> >   {								\
> >   	return SM_I(sbi)->ipu_policy & BIT(name);		\
> >   }
> > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> > index 4ec2cbbc47eb..09696fc844ab 100644
> > --- a/fs/f2fs/super.c
> > +++ b/fs/f2fs/super.c
> > @@ -1346,12 +1346,12 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
> >   	}
> >   	if (test_opt(sbi, DISABLE_CHECKPOINT) && f2fs_lfs_mode(sbi)) {
> > -		f2fs_err(sbi, "LFS not compatible with checkpoint=disable");
> > +		f2fs_err(sbi, "LFS is not compatible with checkpoint=disable");
> >   		return -EINVAL;
> >   	}
> >   	if (test_opt(sbi, ATGC) && f2fs_lfs_mode(sbi)) {
> > -		f2fs_err(sbi, "LFS not compatible with ATGC");
> > +		f2fs_err(sbi, "LFS is not compatible with ATGC");
> >   		return -EINVAL;
> >   	}
> > @@ -2304,6 +2304,12 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
> >   		}
> >   	}
> >   #endif
> > +	if (f2fs_lfs_mode(sbi) && !IS_F2FS_IPU_DISABLE(sbi)) {
> > +		err = -EINVAL;
> > +		f2fs_warn(sbi, "LFS is not compatible with IPU");
> > +		goto restore_opts;
> > +	}
> > +
> >   	/* disallow enable atgc dynamically */
> >   	if (no_atgc == !!test_opt(sbi, ATGC)) {
> >   		err = -EINVAL;
> > @@ -4083,10 +4089,9 @@ static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi)
> >   	/* adjust parameters according to the volume size */
> >   	if (MAIN_SEGS(sbi) <= SMALL_VOLUME_SEGMENTS) {
> >   		if (f2fs_block_unit_discard(sbi))
> > -			SM_I(sbi)->dcc_info->discard_granularity =
> > -						MIN_DISCARD_GRANULARITY;
> > -		SM_I(sbi)->ipu_policy = BIT(F2FS_IPU_FORCE) |
> > -					BIT(F2FS_IPU_HONOR_OPU_WRITE);
> > +			SM_I(sbi)->dcc_info->discard_granularity = MIN_DISCARD_GRANULARITY;
> > +		if (!f2fs_lfs_mode(sbi))
> > +			SM_I(sbi)->ipu_policy = BIT(F2FS_IPU_FORCE) | BIT(F2FS_IPU_HONOR_OPU_WRITE);
> 
> 	SM_I(sbi)->ipu_policy = BIT(F2FS_IPU_FORCE) |
> 				BIT(F2FS_IPU_HONOR_OPU_WRITE);
> 
> I prefer to not exceed 80 lines, otherwise it looks good to me.

Applied.

> 
> Reviewed-by: Chao Yu <chao@kernel.org>
> 
> Thanks,
> 
> >   	}
> >   	sbi->readdir_ra = true;
> > diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> > index 575a5536c0e7..3c3dae3ce84e 100644
> > --- a/fs/f2fs/sysfs.c
> > +++ b/fs/f2fs/sysfs.c
> > @@ -706,6 +706,15 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
> >   		return count;
> >   	}
> > +	if (!strcmp(a->attr.name, "ipu_policy")) {
> > +		if (t >= BIT(F2FS_IPU_MAX))
> > +			return -EINVAL;
> > +		if (t && f2fs_lfs_mode(sbi))
> > +			return -EINVAL;
> > +		SM_I(sbi)->ipu_policy = (unsigned int)t;
> > +		return count;
> > +	}
> > +
> >   	*ui = (unsigned int)t;
> >   	return count;


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

WARNING: multiple messages have this Message-ID (diff)
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <chao@kernel.org>
Cc: Yangtao Li <frank.li@vivo.com>,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/3] f2fs: fix to set ipu policy
Date: Tue, 7 Feb 2023 10:46:34 -0800	[thread overview]
Message-ID: <Y+KcivkBV6rep3R0@google.com> (raw)
In-Reply-To: <5b47f58a-4c3c-a183-777c-d4750f6b4d6c@kernel.org>

On 02/07, Chao Yu wrote:
> On 2023/2/6 22:43, Yangtao Li wrote:
> > For LFS mode, it should update outplace and no need inplace update.
> > When using LFS mode for small-volume devices, IPU will not be used,
> > and the OPU writing method is actually used, but F2FS_IPU_FORCE can
> > be read from the ipu_policy node, which is different from the actual
> > situation. And remount to lfs mode should be disallowed when
> > f2fs ipu is enabled, let's fix it.
> > 
> > Fixes: 84b89e5d943d ("f2fs: add auto tuning for small devices")
> > Signed-off-by: Yangtao Li <frank.li@vivo.com>
> > ---
> > v4:
> > -allow set 0 in lfs mode for ipu_policy node
> >   fs/f2fs/segment.h | 10 +++++++++-
> >   fs/f2fs/super.c   | 17 +++++++++++------
> >   fs/f2fs/sysfs.c   |  9 +++++++++
> >   3 files changed, 29 insertions(+), 7 deletions(-)
> > 
> > diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
> > index 0f3f05cb8c29..8ee5e5db9287 100644
> > --- a/fs/f2fs/segment.h
> > +++ b/fs/f2fs/segment.h
> > @@ -670,6 +670,8 @@ static inline int utilization(struct f2fs_sb_info *sbi)
> >   #define SMALL_VOLUME_SEGMENTS	(16 * 512)	/* 16GB */
> > +#define F2FS_IPU_DISABLE	0
> > +
> >   enum {
> >   	F2FS_IPU_FORCE,
> >   	F2FS_IPU_SSR,
> > @@ -679,10 +681,16 @@ enum {
> >   	F2FS_IPU_ASYNC,
> >   	F2FS_IPU_NOCACHE,
> >   	F2FS_IPU_HONOR_OPU_WRITE,
> > +	F2FS_IPU_MAX,
> >   };
> > +static inline bool IS_F2FS_IPU_DISABLE(struct f2fs_sb_info *sbi)
> > +{
> > +	return SM_I(sbi)->ipu_policy == F2FS_IPU_DISABLE;
> > +}
> > +
> >   #define F2FS_IPU_POLICY(name)					\
> > -static inline int IS_##name(struct f2fs_sb_info *sbi)		\
> > +static inline bool IS_##name(struct f2fs_sb_info *sbi)		\
> >   {								\
> >   	return SM_I(sbi)->ipu_policy & BIT(name);		\
> >   }
> > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> > index 4ec2cbbc47eb..09696fc844ab 100644
> > --- a/fs/f2fs/super.c
> > +++ b/fs/f2fs/super.c
> > @@ -1346,12 +1346,12 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
> >   	}
> >   	if (test_opt(sbi, DISABLE_CHECKPOINT) && f2fs_lfs_mode(sbi)) {
> > -		f2fs_err(sbi, "LFS not compatible with checkpoint=disable");
> > +		f2fs_err(sbi, "LFS is not compatible with checkpoint=disable");
> >   		return -EINVAL;
> >   	}
> >   	if (test_opt(sbi, ATGC) && f2fs_lfs_mode(sbi)) {
> > -		f2fs_err(sbi, "LFS not compatible with ATGC");
> > +		f2fs_err(sbi, "LFS is not compatible with ATGC");
> >   		return -EINVAL;
> >   	}
> > @@ -2304,6 +2304,12 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
> >   		}
> >   	}
> >   #endif
> > +	if (f2fs_lfs_mode(sbi) && !IS_F2FS_IPU_DISABLE(sbi)) {
> > +		err = -EINVAL;
> > +		f2fs_warn(sbi, "LFS is not compatible with IPU");
> > +		goto restore_opts;
> > +	}
> > +
> >   	/* disallow enable atgc dynamically */
> >   	if (no_atgc == !!test_opt(sbi, ATGC)) {
> >   		err = -EINVAL;
> > @@ -4083,10 +4089,9 @@ static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi)
> >   	/* adjust parameters according to the volume size */
> >   	if (MAIN_SEGS(sbi) <= SMALL_VOLUME_SEGMENTS) {
> >   		if (f2fs_block_unit_discard(sbi))
> > -			SM_I(sbi)->dcc_info->discard_granularity =
> > -						MIN_DISCARD_GRANULARITY;
> > -		SM_I(sbi)->ipu_policy = BIT(F2FS_IPU_FORCE) |
> > -					BIT(F2FS_IPU_HONOR_OPU_WRITE);
> > +			SM_I(sbi)->dcc_info->discard_granularity = MIN_DISCARD_GRANULARITY;
> > +		if (!f2fs_lfs_mode(sbi))
> > +			SM_I(sbi)->ipu_policy = BIT(F2FS_IPU_FORCE) | BIT(F2FS_IPU_HONOR_OPU_WRITE);
> 
> 	SM_I(sbi)->ipu_policy = BIT(F2FS_IPU_FORCE) |
> 				BIT(F2FS_IPU_HONOR_OPU_WRITE);
> 
> I prefer to not exceed 80 lines, otherwise it looks good to me.

Applied.

> 
> Reviewed-by: Chao Yu <chao@kernel.org>
> 
> Thanks,
> 
> >   	}
> >   	sbi->readdir_ra = true;
> > diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> > index 575a5536c0e7..3c3dae3ce84e 100644
> > --- a/fs/f2fs/sysfs.c
> > +++ b/fs/f2fs/sysfs.c
> > @@ -706,6 +706,15 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
> >   		return count;
> >   	}
> > +	if (!strcmp(a->attr.name, "ipu_policy")) {
> > +		if (t >= BIT(F2FS_IPU_MAX))
> > +			return -EINVAL;
> > +		if (t && f2fs_lfs_mode(sbi))
> > +			return -EINVAL;
> > +		SM_I(sbi)->ipu_policy = (unsigned int)t;
> > +		return count;
> > +	}
> > +
> >   	*ui = (unsigned int)t;
> >   	return count;

  reply	other threads:[~2023-02-07 18:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-06 14:43 [f2fs-dev] [PATCH v4 1/3] f2fs: fix to set ipu policy Yangtao Li via Linux-f2fs-devel
2023-02-06 14:43 ` Yangtao Li
2023-02-06 14:43 ` [f2fs-dev] [PATCH v4 2/3] f2fs: add missing description for ipu_policy node Yangtao Li via Linux-f2fs-devel
2023-02-06 14:43   ` Yangtao Li
2023-02-06 14:43 ` [f2fs-dev] [PATCH v4 3/3] f2fs: introduce ipu_mode sysfs node Yangtao Li via Linux-f2fs-devel
2023-02-06 14:43   ` Yangtao Li
2023-02-07 18:50   ` [f2fs-dev] " Jaegeuk Kim
2023-02-07 18:50     ` Jaegeuk Kim
2023-02-07 13:24 ` [f2fs-dev] [PATCH v4 1/3] f2fs: fix to set ipu policy Chao Yu
2023-02-07 13:24   ` Chao Yu
2023-02-07 18:46   ` Jaegeuk Kim [this message]
2023-02-07 18:46     ` Jaegeuk Kim
2023-02-07 19:00 ` [f2fs-dev] " patchwork-bot+f2fs
2023-02-07 19:00   ` patchwork-bot+f2fs

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=Y+KcivkBV6rep3R0@google.com \
    --to=jaegeuk@kernel.org \
    --cc=chao@kernel.org \
    --cc=frank.li@vivo.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.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.