All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] alloc_mode changed after remount on a small volume device
@ 2022-11-12  8:32 ` Yuwei Guan
  0 siblings, 0 replies; 20+ messages in thread
From: Yuwei Guan @ 2022-11-12  8:32 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, Yuwei.Guan

This series contains a fix patch for alloc_mode changed after remount
on a small volume device, and do cleanup for 'f2fs_tuning_parameters'
function.

The last one change type for sbi->readdir_ra.

Yuwei Guan (3):
  f2fs: fix to alloc_mode changed after remount on a small volume device
  f2fs: cleanup for 'f2fs_tuning_parameters' function
  f2fs: change type for 'sbi->readdir_ra'

 fs/f2fs/dir.c   |  7 +++----
 fs/f2fs/f2fs.h  |  2 +-
 fs/f2fs/super.c | 35 ++++++++++++++++++-----------------
 fs/f2fs/sysfs.c |  5 +++++
 4 files changed, 27 insertions(+), 22 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [f2fs-dev] [PATCH 0/3] alloc_mode changed after remount on a small volume device
@ 2022-11-12  8:32 ` Yuwei Guan
  0 siblings, 0 replies; 20+ messages in thread
From: Yuwei Guan @ 2022-11-12  8:32 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-kernel, linux-f2fs-devel

This series contains a fix patch for alloc_mode changed after remount
on a small volume device, and do cleanup for 'f2fs_tuning_parameters'
function.

The last one change type for sbi->readdir_ra.

Yuwei Guan (3):
  f2fs: fix to alloc_mode changed after remount on a small volume device
  f2fs: cleanup for 'f2fs_tuning_parameters' function
  f2fs: change type for 'sbi->readdir_ra'

 fs/f2fs/dir.c   |  7 +++----
 fs/f2fs/f2fs.h  |  2 +-
 fs/f2fs/super.c | 35 ++++++++++++++++++-----------------
 fs/f2fs/sysfs.c |  5 +++++
 4 files changed, 27 insertions(+), 22 deletions(-)

-- 
2.34.1



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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/3] f2fs: fix to alloc_mode changed after remount on a small volume device
  2022-11-12  8:32 ` [f2fs-dev] " Yuwei Guan
@ 2022-11-12  8:32   ` Yuwei Guan
  -1 siblings, 0 replies; 20+ messages in thread
From: Yuwei Guan @ 2022-11-12  8:32 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, Yuwei.Guan

The commit 84b89e5d943d8 ("f2fs: add auto tuning for small devices") add
tuning for small volume device, now support to tune alloce_mode to 'reuse'
if it's small size. But the alloc_mode will change to 'default' when do
remount on this small size dievce.

The commit 4cac90d5491c9 ("f2fs: relocate readdir_ra configure
initialization") relocates readdir_ra variable to tuning process.

This patch fo fix alloc_mode changed when do remount for a small volume
device.

For a small device,
- alloc_mode will keep 'reuse', if no alloc_mode option in remount
  command,
- alloc_mode will be set as remount command, if it has 'alloc_mode='.

Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
---
 fs/f2fs/super.c | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 3834ead04620..2f36824ff84b 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2190,6 +2190,23 @@ static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
 	f2fs_flush_ckpt_thread(sbi);
 }
 
+static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi, bool is_remount)
+{
+	struct f2fs_sm_info *sm_i = SM_I(sbi);
+
+	/* adjust parameters according to the volume size */
+	if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
+		F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
+		if (f2fs_block_unit_discard(sbi))
+			sm_i->dcc_info->discard_granularity = 1;
+		sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
+					1 << F2FS_IPU_HONOR_OPU_WRITE;
+	}
+
+	if (!is_remount)
+		sbi->readdir_ra = 1;
+}
+
 static int f2fs_remount(struct super_block *sb, int *flags, char *data)
 {
 	struct f2fs_sb_info *sbi = F2FS_SB(sb);
@@ -2248,6 +2265,8 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
 
 	default_options(sbi);
 
+	f2fs_tuning_parameters(sbi, true);
+
 	/* parse mount options */
 	err = parse_options(sb, data, true);
 	if (err)
@@ -4054,22 +4073,6 @@ static int f2fs_setup_casefold(struct f2fs_sb_info *sbi)
 	return 0;
 }
 
-static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi)
-{
-	struct f2fs_sm_info *sm_i = SM_I(sbi);
-
-	/* adjust parameters according to the volume size */
-	if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
-		F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
-		if (f2fs_block_unit_discard(sbi))
-			sm_i->dcc_info->discard_granularity = 1;
-		sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
-					1 << F2FS_IPU_HONOR_OPU_WRITE;
-	}
-
-	sbi->readdir_ra = 1;
-}
-
 static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 {
 	struct f2fs_sb_info *sbi;
@@ -4475,7 +4478,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 
 	f2fs_join_shrinker(sbi);
 
-	f2fs_tuning_parameters(sbi);
+	f2fs_tuning_parameters(sbi, false);
 
 	f2fs_notice(sbi, "Mounted with checkpoint version = %llx",
 		    cur_cp_version(F2FS_CKPT(sbi)));
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [f2fs-dev] [PATCH 1/3] f2fs: fix to alloc_mode changed after remount on a small volume device
@ 2022-11-12  8:32   ` Yuwei Guan
  0 siblings, 0 replies; 20+ messages in thread
From: Yuwei Guan @ 2022-11-12  8:32 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-kernel, linux-f2fs-devel

The commit 84b89e5d943d8 ("f2fs: add auto tuning for small devices") add
tuning for small volume device, now support to tune alloce_mode to 'reuse'
if it's small size. But the alloc_mode will change to 'default' when do
remount on this small size dievce.

The commit 4cac90d5491c9 ("f2fs: relocate readdir_ra configure
initialization") relocates readdir_ra variable to tuning process.

This patch fo fix alloc_mode changed when do remount for a small volume
device.

For a small device,
- alloc_mode will keep 'reuse', if no alloc_mode option in remount
  command,
- alloc_mode will be set as remount command, if it has 'alloc_mode='.

Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
---
 fs/f2fs/super.c | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 3834ead04620..2f36824ff84b 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2190,6 +2190,23 @@ static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
 	f2fs_flush_ckpt_thread(sbi);
 }
 
+static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi, bool is_remount)
+{
+	struct f2fs_sm_info *sm_i = SM_I(sbi);
+
+	/* adjust parameters according to the volume size */
+	if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
+		F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
+		if (f2fs_block_unit_discard(sbi))
+			sm_i->dcc_info->discard_granularity = 1;
+		sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
+					1 << F2FS_IPU_HONOR_OPU_WRITE;
+	}
+
+	if (!is_remount)
+		sbi->readdir_ra = 1;
+}
+
 static int f2fs_remount(struct super_block *sb, int *flags, char *data)
 {
 	struct f2fs_sb_info *sbi = F2FS_SB(sb);
@@ -2248,6 +2265,8 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
 
 	default_options(sbi);
 
+	f2fs_tuning_parameters(sbi, true);
+
 	/* parse mount options */
 	err = parse_options(sb, data, true);
 	if (err)
@@ -4054,22 +4073,6 @@ static int f2fs_setup_casefold(struct f2fs_sb_info *sbi)
 	return 0;
 }
 
-static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi)
-{
-	struct f2fs_sm_info *sm_i = SM_I(sbi);
-
-	/* adjust parameters according to the volume size */
-	if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
-		F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
-		if (f2fs_block_unit_discard(sbi))
-			sm_i->dcc_info->discard_granularity = 1;
-		sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
-					1 << F2FS_IPU_HONOR_OPU_WRITE;
-	}
-
-	sbi->readdir_ra = 1;
-}
-
 static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 {
 	struct f2fs_sb_info *sbi;
@@ -4475,7 +4478,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 
 	f2fs_join_shrinker(sbi);
 
-	f2fs_tuning_parameters(sbi);
+	f2fs_tuning_parameters(sbi, false);
 
 	f2fs_notice(sbi, "Mounted with checkpoint version = %llx",
 		    cur_cp_version(F2FS_CKPT(sbi)));
-- 
2.34.1



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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/3] f2fs: cleanup for 'f2fs_tuning_parameters' function
  2022-11-12  8:32 ` [f2fs-dev] " Yuwei Guan
@ 2022-11-12  8:32   ` Yuwei Guan
  -1 siblings, 0 replies; 20+ messages in thread
From: Yuwei Guan @ 2022-11-12  8:32 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, Yuwei.Guan

A cleanup patch for 'f2fs_tuning_parameters' function.

Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
---
 fs/f2fs/super.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 2f36824ff84b..f18ae5410b2c 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2192,14 +2192,12 @@ static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
 
 static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi, bool is_remount)
 {
-	struct f2fs_sm_info *sm_i = SM_I(sbi);
-
 	/* adjust parameters according to the volume size */
-	if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
+	if (MAIN_SEGS(sbi) <= SMALL_VOLUME_SEGMENTS) {
 		F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
 		if (f2fs_block_unit_discard(sbi))
-			sm_i->dcc_info->discard_granularity = 1;
-		sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
+			SM_I(sbi)->dcc_info->discard_granularity = 1;
+		SM_I(sbi)->ipu_policy = 1 << F2FS_IPU_FORCE |
 					1 << F2FS_IPU_HONOR_OPU_WRITE;
 	}
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [f2fs-dev] [PATCH 2/3] f2fs: cleanup for 'f2fs_tuning_parameters' function
@ 2022-11-12  8:32   ` Yuwei Guan
  0 siblings, 0 replies; 20+ messages in thread
From: Yuwei Guan @ 2022-11-12  8:32 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-kernel, linux-f2fs-devel

A cleanup patch for 'f2fs_tuning_parameters' function.

Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
---
 fs/f2fs/super.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 2f36824ff84b..f18ae5410b2c 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2192,14 +2192,12 @@ static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
 
 static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi, bool is_remount)
 {
-	struct f2fs_sm_info *sm_i = SM_I(sbi);
-
 	/* adjust parameters according to the volume size */
-	if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
+	if (MAIN_SEGS(sbi) <= SMALL_VOLUME_SEGMENTS) {
 		F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
 		if (f2fs_block_unit_discard(sbi))
-			sm_i->dcc_info->discard_granularity = 1;
-		sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
+			SM_I(sbi)->dcc_info->discard_granularity = 1;
+		SM_I(sbi)->ipu_policy = 1 << F2FS_IPU_FORCE |
 					1 << F2FS_IPU_HONOR_OPU_WRITE;
 	}
 
-- 
2.34.1



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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/3] f2fs: change type for 'sbi->readdir_ra'
  2022-11-12  8:32 ` [f2fs-dev] " Yuwei Guan
@ 2022-11-12  8:32   ` Yuwei Guan
  -1 siblings, 0 replies; 20+ messages in thread
From: Yuwei Guan @ 2022-11-12  8:32 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, Yuwei.Guan

Before this patch, the varibale 'readdir_ra' takes effect if it's equal
to '1' or not, so we can change type for it from 'int' to 'bool'.

Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
---
 fs/f2fs/dir.c   | 7 +++----
 fs/f2fs/f2fs.h  | 2 +-
 fs/f2fs/super.c | 2 +-
 fs/f2fs/sysfs.c | 5 +++++
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 21960a899b6a..06d9bf98f5ae 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -1000,13 +1000,12 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
 	struct fscrypt_str de_name = FSTR_INIT(NULL, 0);
 	struct f2fs_sb_info *sbi = F2FS_I_SB(d->inode);
 	struct blk_plug plug;
-	bool readdir_ra = sbi->readdir_ra == 1;
 	bool found_valid_dirent = false;
 	int err = 0;
 
 	bit_pos = ((unsigned long)ctx->pos % d->max);
 
-	if (readdir_ra)
+	if (sbi->readdir_ra)
 		blk_start_plug(&plug);
 
 	while (bit_pos < d->max) {
@@ -1064,14 +1063,14 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
 			goto out;
 		}
 
-		if (readdir_ra)
+		if (sbi->readdir_ra)
 			f2fs_ra_node_page(sbi, le32_to_cpu(de->ino));
 
 		ctx->pos = start_pos + bit_pos;
 		found_valid_dirent = true;
 	}
 out:
-	if (readdir_ra)
+	if (sbi->readdir_ra)
 		blk_finish_plug(&plug);
 	return err;
 }
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index e6355a5683b7..384840216e7f 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1693,7 +1693,7 @@ struct f2fs_sb_info {
 	unsigned int total_node_count;		/* total node block count */
 	unsigned int total_valid_node_count;	/* valid node block count */
 	int dir_level;				/* directory level */
-	int readdir_ra;				/* readahead inode in readdir */
+	bool readdir_ra;			/* readahead inode in readdir */
 	u64 max_io_bytes;			/* max io bytes to merge IOs */
 
 	block_t user_block_count;		/* # of user blocks */
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index f18ae5410b2c..da304861890f 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2202,7 +2202,7 @@ static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi, bool is_remount)
 	}
 
 	if (!is_remount)
-		sbi->readdir_ra = 1;
+		sbi->readdir_ra = true;
 }
 
 static int f2fs_remount(struct super_block *sb, int *flags, char *data)
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index df27afd71ef4..53fbbb87dd0f 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -649,6 +649,11 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
 		return count;
 	}
 
+	if (!strcmp(a->attr.name, "readdir_ra")) {
+		sbi->readdir_ra = !!t;
+		return count;
+	}
+
 	*ui = (unsigned int)t;
 
 	return count;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [f2fs-dev] [PATCH 3/3] f2fs: change type for 'sbi->readdir_ra'
@ 2022-11-12  8:32   ` Yuwei Guan
  0 siblings, 0 replies; 20+ messages in thread
From: Yuwei Guan @ 2022-11-12  8:32 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-kernel, linux-f2fs-devel

Before this patch, the varibale 'readdir_ra' takes effect if it's equal
to '1' or not, so we can change type for it from 'int' to 'bool'.

Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
---
 fs/f2fs/dir.c   | 7 +++----
 fs/f2fs/f2fs.h  | 2 +-
 fs/f2fs/super.c | 2 +-
 fs/f2fs/sysfs.c | 5 +++++
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 21960a899b6a..06d9bf98f5ae 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -1000,13 +1000,12 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
 	struct fscrypt_str de_name = FSTR_INIT(NULL, 0);
 	struct f2fs_sb_info *sbi = F2FS_I_SB(d->inode);
 	struct blk_plug plug;
-	bool readdir_ra = sbi->readdir_ra == 1;
 	bool found_valid_dirent = false;
 	int err = 0;
 
 	bit_pos = ((unsigned long)ctx->pos % d->max);
 
-	if (readdir_ra)
+	if (sbi->readdir_ra)
 		blk_start_plug(&plug);
 
 	while (bit_pos < d->max) {
@@ -1064,14 +1063,14 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
 			goto out;
 		}
 
-		if (readdir_ra)
+		if (sbi->readdir_ra)
 			f2fs_ra_node_page(sbi, le32_to_cpu(de->ino));
 
 		ctx->pos = start_pos + bit_pos;
 		found_valid_dirent = true;
 	}
 out:
-	if (readdir_ra)
+	if (sbi->readdir_ra)
 		blk_finish_plug(&plug);
 	return err;
 }
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index e6355a5683b7..384840216e7f 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1693,7 +1693,7 @@ struct f2fs_sb_info {
 	unsigned int total_node_count;		/* total node block count */
 	unsigned int total_valid_node_count;	/* valid node block count */
 	int dir_level;				/* directory level */
-	int readdir_ra;				/* readahead inode in readdir */
+	bool readdir_ra;			/* readahead inode in readdir */
 	u64 max_io_bytes;			/* max io bytes to merge IOs */
 
 	block_t user_block_count;		/* # of user blocks */
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index f18ae5410b2c..da304861890f 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2202,7 +2202,7 @@ static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi, bool is_remount)
 	}
 
 	if (!is_remount)
-		sbi->readdir_ra = 1;
+		sbi->readdir_ra = true;
 }
 
 static int f2fs_remount(struct super_block *sb, int *flags, char *data)
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index df27afd71ef4..53fbbb87dd0f 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -649,6 +649,11 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
 		return count;
 	}
 
+	if (!strcmp(a->attr.name, "readdir_ra")) {
+		sbi->readdir_ra = !!t;
+		return count;
+	}
+
 	*ui = (unsigned int)t;
 
 	return count;
-- 
2.34.1



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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] f2fs: fix to alloc_mode changed after remount on a small volume device
  2022-11-12  8:32   ` [f2fs-dev] " Yuwei Guan
@ 2022-11-14 14:42     ` Chao Yu
  -1 siblings, 0 replies; 20+ messages in thread
From: Chao Yu @ 2022-11-14 14:42 UTC (permalink / raw)
  To: Yuwei Guan, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Yuwei.Guan

On 2022/11/12 16:32, Yuwei Guan wrote:
> The commit 84b89e5d943d8 ("f2fs: add auto tuning for small devices") add
> tuning for small volume device, now support to tune alloce_mode to 'reuse'
> if it's small size. But the alloc_mode will change to 'default' when do
> remount on this small size dievce.
> 
> The commit 4cac90d5491c9 ("f2fs: relocate readdir_ra configure
> initialization") relocates readdir_ra variable to tuning process.
> 
> This patch fo fix alloc_mode changed when do remount for a small volume
> device.
> 
> For a small device,
> - alloc_mode will keep 'reuse', if no alloc_mode option in remount
>    command,
> - alloc_mode will be set as remount command, if it has 'alloc_mode='.
> 
> Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
> ---
>   fs/f2fs/super.c | 37 ++++++++++++++++++++-----------------
>   1 file changed, 20 insertions(+), 17 deletions(-)
> 
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 3834ead04620..2f36824ff84b 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -2190,6 +2190,23 @@ static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
>   	f2fs_flush_ckpt_thread(sbi);
>   }
>   
> +static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi, bool is_remount)
> +{
> +	struct f2fs_sm_info *sm_i = SM_I(sbi);
> +
> +	/* adjust parameters according to the volume size */
> +	if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
> +		F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;

How about moving above logic into default_options()?

Thanks,

> +		if (f2fs_block_unit_discard(sbi))
> +			sm_i->dcc_info->discard_granularity = 1;
> +		sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
> +					1 << F2FS_IPU_HONOR_OPU_WRITE;
> +	}
> +
> +	if (!is_remount)
> +		sbi->readdir_ra = 1;
> +}
> +
>   static int f2fs_remount(struct super_block *sb, int *flags, char *data)
>   {
>   	struct f2fs_sb_info *sbi = F2FS_SB(sb);
> @@ -2248,6 +2265,8 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
>   
>   	default_options(sbi);
>   
> +	f2fs_tuning_parameters(sbi, true);
> +
>   	/* parse mount options */
>   	err = parse_options(sb, data, true);
>   	if (err)
> @@ -4054,22 +4073,6 @@ static int f2fs_setup_casefold(struct f2fs_sb_info *sbi)
>   	return 0;
>   }
>   
> -static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi)
> -{
> -	struct f2fs_sm_info *sm_i = SM_I(sbi);
> -
> -	/* adjust parameters according to the volume size */
> -	if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
> -		F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
> -		if (f2fs_block_unit_discard(sbi))
> -			sm_i->dcc_info->discard_granularity = 1;
> -		sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
> -					1 << F2FS_IPU_HONOR_OPU_WRITE;
> -	}
> -
> -	sbi->readdir_ra = 1;
> -}
> -
>   static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
>   {
>   	struct f2fs_sb_info *sbi;
> @@ -4475,7 +4478,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
>   
>   	f2fs_join_shrinker(sbi);
>   
> -	f2fs_tuning_parameters(sbi);
> +	f2fs_tuning_parameters(sbi, false);
>   
>   	f2fs_notice(sbi, "Mounted with checkpoint version = %llx",
>   		    cur_cp_version(F2FS_CKPT(sbi)));

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [f2fs-dev] [PATCH 1/3] f2fs: fix to alloc_mode changed after remount on a small volume device
@ 2022-11-14 14:42     ` Chao Yu
  0 siblings, 0 replies; 20+ messages in thread
From: Chao Yu @ 2022-11-14 14:42 UTC (permalink / raw)
  To: Yuwei Guan, jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

On 2022/11/12 16:32, Yuwei Guan wrote:
> The commit 84b89e5d943d8 ("f2fs: add auto tuning for small devices") add
> tuning for small volume device, now support to tune alloce_mode to 'reuse'
> if it's small size. But the alloc_mode will change to 'default' when do
> remount on this small size dievce.
> 
> The commit 4cac90d5491c9 ("f2fs: relocate readdir_ra configure
> initialization") relocates readdir_ra variable to tuning process.
> 
> This patch fo fix alloc_mode changed when do remount for a small volume
> device.
> 
> For a small device,
> - alloc_mode will keep 'reuse', if no alloc_mode option in remount
>    command,
> - alloc_mode will be set as remount command, if it has 'alloc_mode='.
> 
> Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
> ---
>   fs/f2fs/super.c | 37 ++++++++++++++++++++-----------------
>   1 file changed, 20 insertions(+), 17 deletions(-)
> 
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 3834ead04620..2f36824ff84b 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -2190,6 +2190,23 @@ static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
>   	f2fs_flush_ckpt_thread(sbi);
>   }
>   
> +static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi, bool is_remount)
> +{
> +	struct f2fs_sm_info *sm_i = SM_I(sbi);
> +
> +	/* adjust parameters according to the volume size */
> +	if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
> +		F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;

How about moving above logic into default_options()?

Thanks,

> +		if (f2fs_block_unit_discard(sbi))
> +			sm_i->dcc_info->discard_granularity = 1;
> +		sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
> +					1 << F2FS_IPU_HONOR_OPU_WRITE;
> +	}
> +
> +	if (!is_remount)
> +		sbi->readdir_ra = 1;
> +}
> +
>   static int f2fs_remount(struct super_block *sb, int *flags, char *data)
>   {
>   	struct f2fs_sb_info *sbi = F2FS_SB(sb);
> @@ -2248,6 +2265,8 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
>   
>   	default_options(sbi);
>   
> +	f2fs_tuning_parameters(sbi, true);
> +
>   	/* parse mount options */
>   	err = parse_options(sb, data, true);
>   	if (err)
> @@ -4054,22 +4073,6 @@ static int f2fs_setup_casefold(struct f2fs_sb_info *sbi)
>   	return 0;
>   }
>   
> -static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi)
> -{
> -	struct f2fs_sm_info *sm_i = SM_I(sbi);
> -
> -	/* adjust parameters according to the volume size */
> -	if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
> -		F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
> -		if (f2fs_block_unit_discard(sbi))
> -			sm_i->dcc_info->discard_granularity = 1;
> -		sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
> -					1 << F2FS_IPU_HONOR_OPU_WRITE;
> -	}
> -
> -	sbi->readdir_ra = 1;
> -}
> -
>   static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
>   {
>   	struct f2fs_sb_info *sbi;
> @@ -4475,7 +4478,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
>   
>   	f2fs_join_shrinker(sbi);
>   
> -	f2fs_tuning_parameters(sbi);
> +	f2fs_tuning_parameters(sbi, false);
>   
>   	f2fs_notice(sbi, "Mounted with checkpoint version = %llx",
>   		    cur_cp_version(F2FS_CKPT(sbi)));


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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [f2fs-dev] [PATCH 3/3] f2fs: change type for 'sbi->readdir_ra'
  2022-11-12  8:32   ` [f2fs-dev] " Yuwei Guan
@ 2022-11-14 14:59     ` Chao Yu
  -1 siblings, 0 replies; 20+ messages in thread
From: Chao Yu @ 2022-11-14 14:59 UTC (permalink / raw)
  To: Yuwei Guan, jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

On 2022/11/12 16:32, Yuwei Guan wrote:
> Before this patch, the varibale 'readdir_ra' takes effect if it's equal
> to '1' or not, so we can change type for it from 'int' to 'bool'.
> 
> Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
> ---
>   fs/f2fs/dir.c   | 7 +++----
>   fs/f2fs/f2fs.h  | 2 +-
>   fs/f2fs/super.c | 2 +-
>   fs/f2fs/sysfs.c | 5 +++++
>   4 files changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
> index 21960a899b6a..06d9bf98f5ae 100644
> --- a/fs/f2fs/dir.c
> +++ b/fs/f2fs/dir.c
> @@ -1000,13 +1000,12 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
>   	struct fscrypt_str de_name = FSTR_INIT(NULL, 0);
>   	struct f2fs_sb_info *sbi = F2FS_I_SB(d->inode);
>   	struct blk_plug plug;
> -	bool readdir_ra = sbi->readdir_ra == 1;
>   	bool found_valid_dirent = false;
>   	int err = 0;
>   
>   	bit_pos = ((unsigned long)ctx->pos % d->max);
>   
> -	if (readdir_ra)
> +	if (sbi->readdir_ra)
>   		blk_start_plug(&plug);
>   
>   	while (bit_pos < d->max) {
> @@ -1064,14 +1063,14 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
>   			goto out;
>   		}
>   
> -		if (readdir_ra)
> +		if (sbi->readdir_ra)
>   			f2fs_ra_node_page(sbi, le32_to_cpu(de->ino));
>   
>   		ctx->pos = start_pos + bit_pos;
>   		found_valid_dirent = true;
>   	}
>   out:
> -	if (readdir_ra)
> +	if (sbi->readdir_ra)

I don't think this is the right way... due to below case:

if (sbi->readdir_ra)	// readdir_ra is 1 by default
	blk_start_plug(&plug);

if (sbi->readdir_ra)	// readdir_ra is updated to 0, it will miss to unplug.
	blk_finish_plug(&plug);

Thanks,

>   		blk_finish_plug(&plug);
>   	return err;
>   }
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index e6355a5683b7..384840216e7f 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -1693,7 +1693,7 @@ struct f2fs_sb_info {
>   	unsigned int total_node_count;		/* total node block count */
>   	unsigned int total_valid_node_count;	/* valid node block count */
>   	int dir_level;				/* directory level */
> -	int readdir_ra;				/* readahead inode in readdir */
> +	bool readdir_ra;			/* readahead inode in readdir */
>   	u64 max_io_bytes;			/* max io bytes to merge IOs */
>   
>   	block_t user_block_count;		/* # of user blocks */
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index f18ae5410b2c..da304861890f 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -2202,7 +2202,7 @@ static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi, bool is_remount)
>   	}
>   
>   	if (!is_remount)
> -		sbi->readdir_ra = 1;
> +		sbi->readdir_ra = true;
>   }
>   
>   static int f2fs_remount(struct super_block *sb, int *flags, char *data)
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index df27afd71ef4..53fbbb87dd0f 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -649,6 +649,11 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
>   		return count;
>   	}
>   
> +	if (!strcmp(a->attr.name, "readdir_ra")) {
> +		sbi->readdir_ra = !!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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/3] f2fs: change type for 'sbi->readdir_ra'
@ 2022-11-14 14:59     ` Chao Yu
  0 siblings, 0 replies; 20+ messages in thread
From: Chao Yu @ 2022-11-14 14:59 UTC (permalink / raw)
  To: Yuwei Guan, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Yuwei.Guan

On 2022/11/12 16:32, Yuwei Guan wrote:
> Before this patch, the varibale 'readdir_ra' takes effect if it's equal
> to '1' or not, so we can change type for it from 'int' to 'bool'.
> 
> Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
> ---
>   fs/f2fs/dir.c   | 7 +++----
>   fs/f2fs/f2fs.h  | 2 +-
>   fs/f2fs/super.c | 2 +-
>   fs/f2fs/sysfs.c | 5 +++++
>   4 files changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
> index 21960a899b6a..06d9bf98f5ae 100644
> --- a/fs/f2fs/dir.c
> +++ b/fs/f2fs/dir.c
> @@ -1000,13 +1000,12 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
>   	struct fscrypt_str de_name = FSTR_INIT(NULL, 0);
>   	struct f2fs_sb_info *sbi = F2FS_I_SB(d->inode);
>   	struct blk_plug plug;
> -	bool readdir_ra = sbi->readdir_ra == 1;
>   	bool found_valid_dirent = false;
>   	int err = 0;
>   
>   	bit_pos = ((unsigned long)ctx->pos % d->max);
>   
> -	if (readdir_ra)
> +	if (sbi->readdir_ra)
>   		blk_start_plug(&plug);
>   
>   	while (bit_pos < d->max) {
> @@ -1064,14 +1063,14 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
>   			goto out;
>   		}
>   
> -		if (readdir_ra)
> +		if (sbi->readdir_ra)
>   			f2fs_ra_node_page(sbi, le32_to_cpu(de->ino));
>   
>   		ctx->pos = start_pos + bit_pos;
>   		found_valid_dirent = true;
>   	}
>   out:
> -	if (readdir_ra)
> +	if (sbi->readdir_ra)

I don't think this is the right way... due to below case:

if (sbi->readdir_ra)	// readdir_ra is 1 by default
	blk_start_plug(&plug);

if (sbi->readdir_ra)	// readdir_ra is updated to 0, it will miss to unplug.
	blk_finish_plug(&plug);

Thanks,

>   		blk_finish_plug(&plug);
>   	return err;
>   }
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index e6355a5683b7..384840216e7f 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -1693,7 +1693,7 @@ struct f2fs_sb_info {
>   	unsigned int total_node_count;		/* total node block count */
>   	unsigned int total_valid_node_count;	/* valid node block count */
>   	int dir_level;				/* directory level */
> -	int readdir_ra;				/* readahead inode in readdir */
> +	bool readdir_ra;			/* readahead inode in readdir */
>   	u64 max_io_bytes;			/* max io bytes to merge IOs */
>   
>   	block_t user_block_count;		/* # of user blocks */
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index f18ae5410b2c..da304861890f 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -2202,7 +2202,7 @@ static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi, bool is_remount)
>   	}
>   
>   	if (!is_remount)
> -		sbi->readdir_ra = 1;
> +		sbi->readdir_ra = true;
>   }
>   
>   static int f2fs_remount(struct super_block *sb, int *flags, char *data)
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index df27afd71ef4..53fbbb87dd0f 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -649,6 +649,11 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
>   		return count;
>   	}
>   
> +	if (!strcmp(a->attr.name, "readdir_ra")) {
> +		sbi->readdir_ra = !!t;
> +		return count;
> +	}
> +
>   	*ui = (unsigned int)t;
>   
>   	return count;

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] f2fs: fix to alloc_mode changed after remount on a small volume device
  2022-11-14 14:42     ` [f2fs-dev] " Chao Yu
@ 2022-11-14 16:13       ` Yuwei Guan
  -1 siblings, 0 replies; 20+ messages in thread
From: Yuwei Guan @ 2022-11-14 16:13 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Yuwei.Guan


On 2022/11/14 22:42, Chao Yu wrote:
> On 2022/11/12 16:32, Yuwei Guan wrote:
>> The commit 84b89e5d943d8 ("f2fs: add auto tuning for small devices") add
>> tuning for small volume device, now support to tune alloce_mode to 
>> 'reuse'
>> if it's small size. But the alloc_mode will change to 'default' when do
>> remount on this small size dievce.
>>
>> The commit 4cac90d5491c9 ("f2fs: relocate readdir_ra configure
>> initialization") relocates readdir_ra variable to tuning process.
>>
>> This patch fo fix alloc_mode changed when do remount for a small volume
>> device.
>>
>> For a small device,
>> - alloc_mode will keep 'reuse', if no alloc_mode option in remount
>>    command,
>> - alloc_mode will be set as remount command, if it has 'alloc_mode='.
>>
>> Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
>> ---
>>   fs/f2fs/super.c | 37 ++++++++++++++++++++-----------------
>>   1 file changed, 20 insertions(+), 17 deletions(-)
>>
>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>> index 3834ead04620..2f36824ff84b 100644
>> --- a/fs/f2fs/super.c
>> +++ b/fs/f2fs/super.c
>> @@ -2190,6 +2190,23 @@ static void f2fs_enable_checkpoint(struct 
>> f2fs_sb_info *sbi)
>>       f2fs_flush_ckpt_thread(sbi);
>>   }
>>   +static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi, bool 
>> is_remount)
>> +{
>> +    struct f2fs_sm_info *sm_i = SM_I(sbi);
>> +
>> +    /* adjust parameters according to the volume size */
>> +    if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
>> +        F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
>
> How about moving above logic into default_options()?
>
Hi Chao,

'sm_i->main_segments' init in func 'f2fs_build_segment_manager()',

when do fill super process, so it cannot move into default_options().

> Thanks,
>
>> +        if (f2fs_block_unit_discard(sbi))
>> +            sm_i->dcc_info->discard_granularity = 1;
>> +        sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
>> +                    1 << F2FS_IPU_HONOR_OPU_WRITE;
>> +    }
>> +
>> +    if (!is_remount)
>> +        sbi->readdir_ra = 1;
>> +}
>> +
>>   static int f2fs_remount(struct super_block *sb, int *flags, char 
>> *data)
>>   {
>>       struct f2fs_sb_info *sbi = F2FS_SB(sb);
>> @@ -2248,6 +2265,8 @@ static int f2fs_remount(struct super_block *sb, 
>> int *flags, char *data)
>>         default_options(sbi);
>>   +    f2fs_tuning_parameters(sbi, true);
>> +
>>       /* parse mount options */
>>       err = parse_options(sb, data, true);
>>       if (err)
>> @@ -4054,22 +4073,6 @@ static int f2fs_setup_casefold(struct 
>> f2fs_sb_info *sbi)
>>       return 0;
>>   }
>>   -static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi)
>> -{
>> -    struct f2fs_sm_info *sm_i = SM_I(sbi);
>> -
>> -    /* adjust parameters according to the volume size */
>> -    if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
>> -        F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
>> -        if (f2fs_block_unit_discard(sbi))
>> -            sm_i->dcc_info->discard_granularity = 1;
>> -        sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
>> -                    1 << F2FS_IPU_HONOR_OPU_WRITE;
>> -    }
>> -
>> -    sbi->readdir_ra = 1;
>> -}
>> -
>>   static int f2fs_fill_super(struct super_block *sb, void *data, int 
>> silent)
>>   {
>>       struct f2fs_sb_info *sbi;
>> @@ -4475,7 +4478,7 @@ static int f2fs_fill_super(struct super_block 
>> *sb, void *data, int silent)
>>         f2fs_join_shrinker(sbi);
>>   -    f2fs_tuning_parameters(sbi);
>> +    f2fs_tuning_parameters(sbi, false);
>>         f2fs_notice(sbi, "Mounted with checkpoint version = %llx",
>>               cur_cp_version(F2FS_CKPT(sbi)));

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [f2fs-dev] [PATCH 1/3] f2fs: fix to alloc_mode changed after remount on a small volume device
@ 2022-11-14 16:13       ` Yuwei Guan
  0 siblings, 0 replies; 20+ messages in thread
From: Yuwei Guan @ 2022-11-14 16:13 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: linux-kernel, linux-f2fs-devel


On 2022/11/14 22:42, Chao Yu wrote:
> On 2022/11/12 16:32, Yuwei Guan wrote:
>> The commit 84b89e5d943d8 ("f2fs: add auto tuning for small devices") add
>> tuning for small volume device, now support to tune alloce_mode to 
>> 'reuse'
>> if it's small size. But the alloc_mode will change to 'default' when do
>> remount on this small size dievce.
>>
>> The commit 4cac90d5491c9 ("f2fs: relocate readdir_ra configure
>> initialization") relocates readdir_ra variable to tuning process.
>>
>> This patch fo fix alloc_mode changed when do remount for a small volume
>> device.
>>
>> For a small device,
>> - alloc_mode will keep 'reuse', if no alloc_mode option in remount
>>    command,
>> - alloc_mode will be set as remount command, if it has 'alloc_mode='.
>>
>> Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
>> ---
>>   fs/f2fs/super.c | 37 ++++++++++++++++++++-----------------
>>   1 file changed, 20 insertions(+), 17 deletions(-)
>>
>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>> index 3834ead04620..2f36824ff84b 100644
>> --- a/fs/f2fs/super.c
>> +++ b/fs/f2fs/super.c
>> @@ -2190,6 +2190,23 @@ static void f2fs_enable_checkpoint(struct 
>> f2fs_sb_info *sbi)
>>       f2fs_flush_ckpt_thread(sbi);
>>   }
>>   +static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi, bool 
>> is_remount)
>> +{
>> +    struct f2fs_sm_info *sm_i = SM_I(sbi);
>> +
>> +    /* adjust parameters according to the volume size */
>> +    if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
>> +        F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
>
> How about moving above logic into default_options()?
>
Hi Chao,

'sm_i->main_segments' init in func 'f2fs_build_segment_manager()',

when do fill super process, so it cannot move into default_options().

> Thanks,
>
>> +        if (f2fs_block_unit_discard(sbi))
>> +            sm_i->dcc_info->discard_granularity = 1;
>> +        sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
>> +                    1 << F2FS_IPU_HONOR_OPU_WRITE;
>> +    }
>> +
>> +    if (!is_remount)
>> +        sbi->readdir_ra = 1;
>> +}
>> +
>>   static int f2fs_remount(struct super_block *sb, int *flags, char 
>> *data)
>>   {
>>       struct f2fs_sb_info *sbi = F2FS_SB(sb);
>> @@ -2248,6 +2265,8 @@ static int f2fs_remount(struct super_block *sb, 
>> int *flags, char *data)
>>         default_options(sbi);
>>   +    f2fs_tuning_parameters(sbi, true);
>> +
>>       /* parse mount options */
>>       err = parse_options(sb, data, true);
>>       if (err)
>> @@ -4054,22 +4073,6 @@ static int f2fs_setup_casefold(struct 
>> f2fs_sb_info *sbi)
>>       return 0;
>>   }
>>   -static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi)
>> -{
>> -    struct f2fs_sm_info *sm_i = SM_I(sbi);
>> -
>> -    /* adjust parameters according to the volume size */
>> -    if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
>> -        F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
>> -        if (f2fs_block_unit_discard(sbi))
>> -            sm_i->dcc_info->discard_granularity = 1;
>> -        sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
>> -                    1 << F2FS_IPU_HONOR_OPU_WRITE;
>> -    }
>> -
>> -    sbi->readdir_ra = 1;
>> -}
>> -
>>   static int f2fs_fill_super(struct super_block *sb, void *data, int 
>> silent)
>>   {
>>       struct f2fs_sb_info *sbi;
>> @@ -4475,7 +4478,7 @@ static int f2fs_fill_super(struct super_block 
>> *sb, void *data, int silent)
>>         f2fs_join_shrinker(sbi);
>>   -    f2fs_tuning_parameters(sbi);
>> +    f2fs_tuning_parameters(sbi, false);
>>         f2fs_notice(sbi, "Mounted with checkpoint version = %llx",
>>               cur_cp_version(F2FS_CKPT(sbi)));


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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/3] f2fs: change type for 'sbi->readdir_ra'
  2022-11-14 14:59     ` Chao Yu
@ 2022-11-14 16:27       ` Yuwei Guan
  -1 siblings, 0 replies; 20+ messages in thread
From: Yuwei Guan @ 2022-11-14 16:27 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Yuwei.Guan


On 2022/11/14 22:59, Chao Yu wrote:
> On 2022/11/12 16:32, Yuwei Guan wrote:
>> Before this patch, the varibale 'readdir_ra' takes effect if it's equal
>> to '1' or not, so we can change type for it from 'int' to 'bool'.
>>
>> Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
>> ---
>>   fs/f2fs/dir.c   | 7 +++----
>>   fs/f2fs/f2fs.h  | 2 +-
>>   fs/f2fs/super.c | 2 +-
>>   fs/f2fs/sysfs.c | 5 +++++
>>   4 files changed, 10 insertions(+), 6 deletions(-)
>>
>> diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
>> index 21960a899b6a..06d9bf98f5ae 100644
>> --- a/fs/f2fs/dir.c
>> +++ b/fs/f2fs/dir.c
>> @@ -1000,13 +1000,12 @@ int f2fs_fill_dentries(struct dir_context 
>> *ctx, struct f2fs_dentry_ptr *d,
>>       struct fscrypt_str de_name = FSTR_INIT(NULL, 0);
>>       struct f2fs_sb_info *sbi = F2FS_I_SB(d->inode);
>>       struct blk_plug plug;
>> -    bool readdir_ra = sbi->readdir_ra == 1;
>>       bool found_valid_dirent = false;
>>       int err = 0;
>>         bit_pos = ((unsigned long)ctx->pos % d->max);
>>   -    if (readdir_ra)
>> +    if (sbi->readdir_ra)
>>           blk_start_plug(&plug);
>>         while (bit_pos < d->max) {
>> @@ -1064,14 +1063,14 @@ int f2fs_fill_dentries(struct dir_context 
>> *ctx, struct f2fs_dentry_ptr *d,
>>               goto out;
>>           }
>>   -        if (readdir_ra)
>> +        if (sbi->readdir_ra)
>>               f2fs_ra_node_page(sbi, le32_to_cpu(de->ino));
>>             ctx->pos = start_pos + bit_pos;
>>           found_valid_dirent = true;
>>       }
>>   out:
>> -    if (readdir_ra)
>> +    if (sbi->readdir_ra)
>
> I don't think this is the right way... due to below case:
>
> if (sbi->readdir_ra)    // readdir_ra is 1 by default
>     blk_start_plug(&plug);
>
> if (sbi->readdir_ra)    // readdir_ra is updated to 0, it will miss to 
> unplug.
>     blk_finish_plug(&plug);
>
Hi Chao,

Thanks for the review and pointing it out.

I will update it and send v1.

> Thanks,
>
>>           blk_finish_plug(&plug);
>>       return err;
>>   }
>> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
>> index e6355a5683b7..384840216e7f 100644
>> --- a/fs/f2fs/f2fs.h
>> +++ b/fs/f2fs/f2fs.h
>> @@ -1693,7 +1693,7 @@ struct f2fs_sb_info {
>>       unsigned int total_node_count;        /* total node block count */
>>       unsigned int total_valid_node_count;    /* valid node block 
>> count */
>>       int dir_level;                /* directory level */
>> -    int readdir_ra;                /* readahead inode in readdir */
>> +    bool readdir_ra;            /* readahead inode in readdir */
>>       u64 max_io_bytes;            /* max io bytes to merge IOs */
>>         block_t user_block_count;        /* # of user blocks */
>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>> index f18ae5410b2c..da304861890f 100644
>> --- a/fs/f2fs/super.c
>> +++ b/fs/f2fs/super.c
>> @@ -2202,7 +2202,7 @@ static void f2fs_tuning_parameters(struct 
>> f2fs_sb_info *sbi, bool is_remount)
>>       }
>>         if (!is_remount)
>> -        sbi->readdir_ra = 1;
>> +        sbi->readdir_ra = true;
>>   }
>>     static int f2fs_remount(struct super_block *sb, int *flags, char 
>> *data)
>> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
>> index df27afd71ef4..53fbbb87dd0f 100644
>> --- a/fs/f2fs/sysfs.c
>> +++ b/fs/f2fs/sysfs.c
>> @@ -649,6 +649,11 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
>>           return count;
>>       }
>>   +    if (!strcmp(a->attr.name, "readdir_ra")) {
>> +        sbi->readdir_ra = !!t;
>> +        return count;
>> +    }
>> +
>>       *ui = (unsigned int)t;
>>         return count;

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [f2fs-dev] [PATCH 3/3] f2fs: change type for 'sbi->readdir_ra'
@ 2022-11-14 16:27       ` Yuwei Guan
  0 siblings, 0 replies; 20+ messages in thread
From: Yuwei Guan @ 2022-11-14 16:27 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: linux-kernel, linux-f2fs-devel


On 2022/11/14 22:59, Chao Yu wrote:
> On 2022/11/12 16:32, Yuwei Guan wrote:
>> Before this patch, the varibale 'readdir_ra' takes effect if it's equal
>> to '1' or not, so we can change type for it from 'int' to 'bool'.
>>
>> Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
>> ---
>>   fs/f2fs/dir.c   | 7 +++----
>>   fs/f2fs/f2fs.h  | 2 +-
>>   fs/f2fs/super.c | 2 +-
>>   fs/f2fs/sysfs.c | 5 +++++
>>   4 files changed, 10 insertions(+), 6 deletions(-)
>>
>> diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
>> index 21960a899b6a..06d9bf98f5ae 100644
>> --- a/fs/f2fs/dir.c
>> +++ b/fs/f2fs/dir.c
>> @@ -1000,13 +1000,12 @@ int f2fs_fill_dentries(struct dir_context 
>> *ctx, struct f2fs_dentry_ptr *d,
>>       struct fscrypt_str de_name = FSTR_INIT(NULL, 0);
>>       struct f2fs_sb_info *sbi = F2FS_I_SB(d->inode);
>>       struct blk_plug plug;
>> -    bool readdir_ra = sbi->readdir_ra == 1;
>>       bool found_valid_dirent = false;
>>       int err = 0;
>>         bit_pos = ((unsigned long)ctx->pos % d->max);
>>   -    if (readdir_ra)
>> +    if (sbi->readdir_ra)
>>           blk_start_plug(&plug);
>>         while (bit_pos < d->max) {
>> @@ -1064,14 +1063,14 @@ int f2fs_fill_dentries(struct dir_context 
>> *ctx, struct f2fs_dentry_ptr *d,
>>               goto out;
>>           }
>>   -        if (readdir_ra)
>> +        if (sbi->readdir_ra)
>>               f2fs_ra_node_page(sbi, le32_to_cpu(de->ino));
>>             ctx->pos = start_pos + bit_pos;
>>           found_valid_dirent = true;
>>       }
>>   out:
>> -    if (readdir_ra)
>> +    if (sbi->readdir_ra)
>
> I don't think this is the right way... due to below case:
>
> if (sbi->readdir_ra)    // readdir_ra is 1 by default
>     blk_start_plug(&plug);
>
> if (sbi->readdir_ra)    // readdir_ra is updated to 0, it will miss to 
> unplug.
>     blk_finish_plug(&plug);
>
Hi Chao,

Thanks for the review and pointing it out.

I will update it and send v1.

> Thanks,
>
>>           blk_finish_plug(&plug);
>>       return err;
>>   }
>> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
>> index e6355a5683b7..384840216e7f 100644
>> --- a/fs/f2fs/f2fs.h
>> +++ b/fs/f2fs/f2fs.h
>> @@ -1693,7 +1693,7 @@ struct f2fs_sb_info {
>>       unsigned int total_node_count;        /* total node block count */
>>       unsigned int total_valid_node_count;    /* valid node block 
>> count */
>>       int dir_level;                /* directory level */
>> -    int readdir_ra;                /* readahead inode in readdir */
>> +    bool readdir_ra;            /* readahead inode in readdir */
>>       u64 max_io_bytes;            /* max io bytes to merge IOs */
>>         block_t user_block_count;        /* # of user blocks */
>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>> index f18ae5410b2c..da304861890f 100644
>> --- a/fs/f2fs/super.c
>> +++ b/fs/f2fs/super.c
>> @@ -2202,7 +2202,7 @@ static void f2fs_tuning_parameters(struct 
>> f2fs_sb_info *sbi, bool is_remount)
>>       }
>>         if (!is_remount)
>> -        sbi->readdir_ra = 1;
>> +        sbi->readdir_ra = true;
>>   }
>>     static int f2fs_remount(struct super_block *sb, int *flags, char 
>> *data)
>> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
>> index df27afd71ef4..53fbbb87dd0f 100644
>> --- a/fs/f2fs/sysfs.c
>> +++ b/fs/f2fs/sysfs.c
>> @@ -649,6 +649,11 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
>>           return count;
>>       }
>>   +    if (!strcmp(a->attr.name, "readdir_ra")) {
>> +        sbi->readdir_ra = !!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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] f2fs: fix to alloc_mode changed after remount on a small volume device
  2022-11-14 16:13       ` [f2fs-dev] " Yuwei Guan
@ 2022-11-15  1:23         ` Chao Yu
  -1 siblings, 0 replies; 20+ messages in thread
From: Chao Yu @ 2022-11-15  1:23 UTC (permalink / raw)
  To: Yuwei Guan, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Yuwei.Guan

On 2022/11/15 0:13, Yuwei Guan wrote:
> 
> On 2022/11/14 22:42, Chao Yu wrote:
>> On 2022/11/12 16:32, Yuwei Guan wrote:
>>> The commit 84b89e5d943d8 ("f2fs: add auto tuning for small devices") add
>>> tuning for small volume device, now support to tune alloce_mode to 'reuse'
>>> if it's small size. But the alloc_mode will change to 'default' when do
>>> remount on this small size dievce.
>>>
>>> The commit 4cac90d5491c9 ("f2fs: relocate readdir_ra configure
>>> initialization") relocates readdir_ra variable to tuning process.
>>>
>>> This patch fo fix alloc_mode changed when do remount for a small volume
>>> device.
>>>
>>> For a small device,
>>> - alloc_mode will keep 'reuse', if no alloc_mode option in remount
>>>    command,
>>> - alloc_mode will be set as remount command, if it has 'alloc_mode='.
>>>
>>> Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
>>> ---
>>>   fs/f2fs/super.c | 37 ++++++++++++++++++++-----------------
>>>   1 file changed, 20 insertions(+), 17 deletions(-)
>>>
>>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>>> index 3834ead04620..2f36824ff84b 100644
>>> --- a/fs/f2fs/super.c
>>> +++ b/fs/f2fs/super.c
>>> @@ -2190,6 +2190,23 @@ static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
>>>       f2fs_flush_ckpt_thread(sbi);
>>>   }
>>>   +static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi, bool is_remount)
>>> +{
>>> +    struct f2fs_sm_info *sm_i = SM_I(sbi);
>>> +
>>> +    /* adjust parameters according to the volume size */
>>> +    if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
>>> +        F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
>>
>> How about moving above logic into default_options()?
>>
> Hi Chao,
> 
> 'sm_i->main_segments' init in func 'f2fs_build_segment_manager()',
> 
> when do fill super process, so it cannot move into default_options().

How about checking le32_to_cpu(raw_super->segment_count_main) directly?

Thanks,

> 
>> Thanks,
>>
>>> +        if (f2fs_block_unit_discard(sbi))
>>> +            sm_i->dcc_info->discard_granularity = 1;
>>> +        sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
>>> +                    1 << F2FS_IPU_HONOR_OPU_WRITE;
>>> +    }
>>> +
>>> +    if (!is_remount)
>>> +        sbi->readdir_ra = 1;
>>> +}
>>> +
>>>   static int f2fs_remount(struct super_block *sb, int *flags, char *data)
>>>   {
>>>       struct f2fs_sb_info *sbi = F2FS_SB(sb);
>>> @@ -2248,6 +2265,8 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
>>>         default_options(sbi);
>>>   +    f2fs_tuning_parameters(sbi, true);
>>> +
>>>       /* parse mount options */
>>>       err = parse_options(sb, data, true);
>>>       if (err)
>>> @@ -4054,22 +4073,6 @@ static int f2fs_setup_casefold(struct f2fs_sb_info *sbi)
>>>       return 0;
>>>   }
>>>   -static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi)
>>> -{
>>> -    struct f2fs_sm_info *sm_i = SM_I(sbi);
>>> -
>>> -    /* adjust parameters according to the volume size */
>>> -    if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
>>> -        F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
>>> -        if (f2fs_block_unit_discard(sbi))
>>> -            sm_i->dcc_info->discard_granularity = 1;
>>> -        sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
>>> -                    1 << F2FS_IPU_HONOR_OPU_WRITE;
>>> -    }
>>> -
>>> -    sbi->readdir_ra = 1;
>>> -}
>>> -
>>>   static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
>>>   {
>>>       struct f2fs_sb_info *sbi;
>>> @@ -4475,7 +4478,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
>>>         f2fs_join_shrinker(sbi);
>>>   -    f2fs_tuning_parameters(sbi);
>>> +    f2fs_tuning_parameters(sbi, false);
>>>         f2fs_notice(sbi, "Mounted with checkpoint version = %llx",
>>>               cur_cp_version(F2FS_CKPT(sbi)));

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [f2fs-dev] [PATCH 1/3] f2fs: fix to alloc_mode changed after remount on a small volume device
@ 2022-11-15  1:23         ` Chao Yu
  0 siblings, 0 replies; 20+ messages in thread
From: Chao Yu @ 2022-11-15  1:23 UTC (permalink / raw)
  To: Yuwei Guan, jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

On 2022/11/15 0:13, Yuwei Guan wrote:
> 
> On 2022/11/14 22:42, Chao Yu wrote:
>> On 2022/11/12 16:32, Yuwei Guan wrote:
>>> The commit 84b89e5d943d8 ("f2fs: add auto tuning for small devices") add
>>> tuning for small volume device, now support to tune alloce_mode to 'reuse'
>>> if it's small size. But the alloc_mode will change to 'default' when do
>>> remount on this small size dievce.
>>>
>>> The commit 4cac90d5491c9 ("f2fs: relocate readdir_ra configure
>>> initialization") relocates readdir_ra variable to tuning process.
>>>
>>> This patch fo fix alloc_mode changed when do remount for a small volume
>>> device.
>>>
>>> For a small device,
>>> - alloc_mode will keep 'reuse', if no alloc_mode option in remount
>>>    command,
>>> - alloc_mode will be set as remount command, if it has 'alloc_mode='.
>>>
>>> Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
>>> ---
>>>   fs/f2fs/super.c | 37 ++++++++++++++++++++-----------------
>>>   1 file changed, 20 insertions(+), 17 deletions(-)
>>>
>>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>>> index 3834ead04620..2f36824ff84b 100644
>>> --- a/fs/f2fs/super.c
>>> +++ b/fs/f2fs/super.c
>>> @@ -2190,6 +2190,23 @@ static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
>>>       f2fs_flush_ckpt_thread(sbi);
>>>   }
>>>   +static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi, bool is_remount)
>>> +{
>>> +    struct f2fs_sm_info *sm_i = SM_I(sbi);
>>> +
>>> +    /* adjust parameters according to the volume size */
>>> +    if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
>>> +        F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
>>
>> How about moving above logic into default_options()?
>>
> Hi Chao,
> 
> 'sm_i->main_segments' init in func 'f2fs_build_segment_manager()',
> 
> when do fill super process, so it cannot move into default_options().

How about checking le32_to_cpu(raw_super->segment_count_main) directly?

Thanks,

> 
>> Thanks,
>>
>>> +        if (f2fs_block_unit_discard(sbi))
>>> +            sm_i->dcc_info->discard_granularity = 1;
>>> +        sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
>>> +                    1 << F2FS_IPU_HONOR_OPU_WRITE;
>>> +    }
>>> +
>>> +    if (!is_remount)
>>> +        sbi->readdir_ra = 1;
>>> +}
>>> +
>>>   static int f2fs_remount(struct super_block *sb, int *flags, char *data)
>>>   {
>>>       struct f2fs_sb_info *sbi = F2FS_SB(sb);
>>> @@ -2248,6 +2265,8 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
>>>         default_options(sbi);
>>>   +    f2fs_tuning_parameters(sbi, true);
>>> +
>>>       /* parse mount options */
>>>       err = parse_options(sb, data, true);
>>>       if (err)
>>> @@ -4054,22 +4073,6 @@ static int f2fs_setup_casefold(struct f2fs_sb_info *sbi)
>>>       return 0;
>>>   }
>>>   -static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi)
>>> -{
>>> -    struct f2fs_sm_info *sm_i = SM_I(sbi);
>>> -
>>> -    /* adjust parameters according to the volume size */
>>> -    if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
>>> -        F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
>>> -        if (f2fs_block_unit_discard(sbi))
>>> -            sm_i->dcc_info->discard_granularity = 1;
>>> -        sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
>>> -                    1 << F2FS_IPU_HONOR_OPU_WRITE;
>>> -    }
>>> -
>>> -    sbi->readdir_ra = 1;
>>> -}
>>> -
>>>   static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
>>>   {
>>>       struct f2fs_sb_info *sbi;
>>> @@ -4475,7 +4478,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
>>>         f2fs_join_shrinker(sbi);
>>>   -    f2fs_tuning_parameters(sbi);
>>> +    f2fs_tuning_parameters(sbi, false);
>>>         f2fs_notice(sbi, "Mounted with checkpoint version = %llx",
>>>               cur_cp_version(F2FS_CKPT(sbi)));


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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] f2fs: fix to alloc_mode changed after remount on a small volume device
  2022-11-15  1:23         ` [f2fs-dev] " Chao Yu
@ 2022-11-15  6:01           ` Yuwei Guan
  -1 siblings, 0 replies; 20+ messages in thread
From: Yuwei Guan @ 2022-11-15  6:01 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Yuwei.Guan


On 2022/11/15 9:23, Chao Yu wrote:
> On 2022/11/15 0:13, Yuwei Guan wrote:
>>
>> On 2022/11/14 22:42, Chao Yu wrote:
>>> On 2022/11/12 16:32, Yuwei Guan wrote:
>>>> The commit 84b89e5d943d8 ("f2fs: add auto tuning for small 
>>>> devices") add
>>>> tuning for small volume device, now support to tune alloce_mode to 
>>>> 'reuse'
>>>> if it's small size. But the alloc_mode will change to 'default' 
>>>> when do
>>>> remount on this small size dievce.
>>>>
>>>> The commit 4cac90d5491c9 ("f2fs: relocate readdir_ra configure
>>>> initialization") relocates readdir_ra variable to tuning process.
>>>>
>>>> This patch fo fix alloc_mode changed when do remount for a small 
>>>> volume
>>>> device.
>>>>
>>>> For a small device,
>>>> - alloc_mode will keep 'reuse', if no alloc_mode option in remount
>>>>    command,
>>>> - alloc_mode will be set as remount command, if it has 'alloc_mode='.
>>>>
>>>> Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
>>>> ---
>>>>   fs/f2fs/super.c | 37 ++++++++++++++++++++-----------------
>>>>   1 file changed, 20 insertions(+), 17 deletions(-)
>>>>
>>>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>>>> index 3834ead04620..2f36824ff84b 100644
>>>> --- a/fs/f2fs/super.c
>>>> +++ b/fs/f2fs/super.c
>>>> @@ -2190,6 +2190,23 @@ static void f2fs_enable_checkpoint(struct 
>>>> f2fs_sb_info *sbi)
>>>>       f2fs_flush_ckpt_thread(sbi);
>>>>   }
>>>>   +static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi, 
>>>> bool is_remount)
>>>> +{
>>>> +    struct f2fs_sm_info *sm_i = SM_I(sbi);
>>>> +
>>>> +    /* adjust parameters according to the volume size */
>>>> +    if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
>>>> +        F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
>>>
>>> How about moving above logic into default_options()?
>>>
>> Hi Chao,
>>
>> 'sm_i->main_segments' init in func 'f2fs_build_segment_manager()',
>>
>> when do fill super process, so it cannot move into default_options().
>
> How about checking le32_to_cpu(raw_super->segment_count_main) directly?
>
Hi Chao,

Thanks a lot for it, I will update with v1 patch.

> Thanks,
>
>>
>>> Thanks,
>>>
>>>> +        if (f2fs_block_unit_discard(sbi))
>>>> +            sm_i->dcc_info->discard_granularity = 1;
>>>> +        sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
>>>> +                    1 << F2FS_IPU_HONOR_OPU_WRITE;
>>>> +    }
>>>> +
>>>> +    if (!is_remount)
>>>> +        sbi->readdir_ra = 1;
>>>> +}
>>>> +
>>>>   static int f2fs_remount(struct super_block *sb, int *flags, char 
>>>> *data)
>>>>   {
>>>>       struct f2fs_sb_info *sbi = F2FS_SB(sb);
>>>> @@ -2248,6 +2265,8 @@ static int f2fs_remount(struct super_block 
>>>> *sb, int *flags, char *data)
>>>>         default_options(sbi);
>>>>   +    f2fs_tuning_parameters(sbi, true);
>>>> +
>>>>       /* parse mount options */
>>>>       err = parse_options(sb, data, true);
>>>>       if (err)
>>>> @@ -4054,22 +4073,6 @@ static int f2fs_setup_casefold(struct 
>>>> f2fs_sb_info *sbi)
>>>>       return 0;
>>>>   }
>>>>   -static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi)
>>>> -{
>>>> -    struct f2fs_sm_info *sm_i = SM_I(sbi);
>>>> -
>>>> -    /* adjust parameters according to the volume size */
>>>> -    if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
>>>> -        F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
>>>> -        if (f2fs_block_unit_discard(sbi))
>>>> -            sm_i->dcc_info->discard_granularity = 1;
>>>> -        sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
>>>> -                    1 << F2FS_IPU_HONOR_OPU_WRITE;
>>>> -    }
>>>> -
>>>> -    sbi->readdir_ra = 1;
>>>> -}
>>>> -
>>>>   static int f2fs_fill_super(struct super_block *sb, void *data, 
>>>> int silent)
>>>>   {
>>>>       struct f2fs_sb_info *sbi;
>>>> @@ -4475,7 +4478,7 @@ static int f2fs_fill_super(struct super_block 
>>>> *sb, void *data, int silent)
>>>>         f2fs_join_shrinker(sbi);
>>>>   -    f2fs_tuning_parameters(sbi);
>>>> +    f2fs_tuning_parameters(sbi, false);
>>>>         f2fs_notice(sbi, "Mounted with checkpoint version = %llx",
>>>>               cur_cp_version(F2FS_CKPT(sbi)));

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [f2fs-dev] [PATCH 1/3] f2fs: fix to alloc_mode changed after remount on a small volume device
@ 2022-11-15  6:01           ` Yuwei Guan
  0 siblings, 0 replies; 20+ messages in thread
From: Yuwei Guan @ 2022-11-15  6:01 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: linux-kernel, linux-f2fs-devel


On 2022/11/15 9:23, Chao Yu wrote:
> On 2022/11/15 0:13, Yuwei Guan wrote:
>>
>> On 2022/11/14 22:42, Chao Yu wrote:
>>> On 2022/11/12 16:32, Yuwei Guan wrote:
>>>> The commit 84b89e5d943d8 ("f2fs: add auto tuning for small 
>>>> devices") add
>>>> tuning for small volume device, now support to tune alloce_mode to 
>>>> 'reuse'
>>>> if it's small size. But the alloc_mode will change to 'default' 
>>>> when do
>>>> remount on this small size dievce.
>>>>
>>>> The commit 4cac90d5491c9 ("f2fs: relocate readdir_ra configure
>>>> initialization") relocates readdir_ra variable to tuning process.
>>>>
>>>> This patch fo fix alloc_mode changed when do remount for a small 
>>>> volume
>>>> device.
>>>>
>>>> For a small device,
>>>> - alloc_mode will keep 'reuse', if no alloc_mode option in remount
>>>>    command,
>>>> - alloc_mode will be set as remount command, if it has 'alloc_mode='.
>>>>
>>>> Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
>>>> ---
>>>>   fs/f2fs/super.c | 37 ++++++++++++++++++++-----------------
>>>>   1 file changed, 20 insertions(+), 17 deletions(-)
>>>>
>>>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>>>> index 3834ead04620..2f36824ff84b 100644
>>>> --- a/fs/f2fs/super.c
>>>> +++ b/fs/f2fs/super.c
>>>> @@ -2190,6 +2190,23 @@ static void f2fs_enable_checkpoint(struct 
>>>> f2fs_sb_info *sbi)
>>>>       f2fs_flush_ckpt_thread(sbi);
>>>>   }
>>>>   +static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi, 
>>>> bool is_remount)
>>>> +{
>>>> +    struct f2fs_sm_info *sm_i = SM_I(sbi);
>>>> +
>>>> +    /* adjust parameters according to the volume size */
>>>> +    if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
>>>> +        F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
>>>
>>> How about moving above logic into default_options()?
>>>
>> Hi Chao,
>>
>> 'sm_i->main_segments' init in func 'f2fs_build_segment_manager()',
>>
>> when do fill super process, so it cannot move into default_options().
>
> How about checking le32_to_cpu(raw_super->segment_count_main) directly?
>
Hi Chao,

Thanks a lot for it, I will update with v1 patch.

> Thanks,
>
>>
>>> Thanks,
>>>
>>>> +        if (f2fs_block_unit_discard(sbi))
>>>> +            sm_i->dcc_info->discard_granularity = 1;
>>>> +        sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
>>>> +                    1 << F2FS_IPU_HONOR_OPU_WRITE;
>>>> +    }
>>>> +
>>>> +    if (!is_remount)
>>>> +        sbi->readdir_ra = 1;
>>>> +}
>>>> +
>>>>   static int f2fs_remount(struct super_block *sb, int *flags, char 
>>>> *data)
>>>>   {
>>>>       struct f2fs_sb_info *sbi = F2FS_SB(sb);
>>>> @@ -2248,6 +2265,8 @@ static int f2fs_remount(struct super_block 
>>>> *sb, int *flags, char *data)
>>>>         default_options(sbi);
>>>>   +    f2fs_tuning_parameters(sbi, true);
>>>> +
>>>>       /* parse mount options */
>>>>       err = parse_options(sb, data, true);
>>>>       if (err)
>>>> @@ -4054,22 +4073,6 @@ static int f2fs_setup_casefold(struct 
>>>> f2fs_sb_info *sbi)
>>>>       return 0;
>>>>   }
>>>>   -static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi)
>>>> -{
>>>> -    struct f2fs_sm_info *sm_i = SM_I(sbi);
>>>> -
>>>> -    /* adjust parameters according to the volume size */
>>>> -    if (sm_i->main_segments <= SMALL_VOLUME_SEGMENTS) {
>>>> -        F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
>>>> -        if (f2fs_block_unit_discard(sbi))
>>>> -            sm_i->dcc_info->discard_granularity = 1;
>>>> -        sm_i->ipu_policy = 1 << F2FS_IPU_FORCE |
>>>> -                    1 << F2FS_IPU_HONOR_OPU_WRITE;
>>>> -    }
>>>> -
>>>> -    sbi->readdir_ra = 1;
>>>> -}
>>>> -
>>>>   static int f2fs_fill_super(struct super_block *sb, void *data, 
>>>> int silent)
>>>>   {
>>>>       struct f2fs_sb_info *sbi;
>>>> @@ -4475,7 +4478,7 @@ static int f2fs_fill_super(struct super_block 
>>>> *sb, void *data, int silent)
>>>>         f2fs_join_shrinker(sbi);
>>>>   -    f2fs_tuning_parameters(sbi);
>>>> +    f2fs_tuning_parameters(sbi, false);
>>>>         f2fs_notice(sbi, "Mounted with checkpoint version = %llx",
>>>>               cur_cp_version(F2FS_CKPT(sbi)));


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

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2022-11-15  6:01 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-12  8:32 [PATCH 0/3] alloc_mode changed after remount on a small volume device Yuwei Guan
2022-11-12  8:32 ` [f2fs-dev] " Yuwei Guan
2022-11-12  8:32 ` [PATCH 1/3] f2fs: fix to " Yuwei Guan
2022-11-12  8:32   ` [f2fs-dev] " Yuwei Guan
2022-11-14 14:42   ` Chao Yu
2022-11-14 14:42     ` [f2fs-dev] " Chao Yu
2022-11-14 16:13     ` Yuwei Guan
2022-11-14 16:13       ` [f2fs-dev] " Yuwei Guan
2022-11-15  1:23       ` Chao Yu
2022-11-15  1:23         ` [f2fs-dev] " Chao Yu
2022-11-15  6:01         ` Yuwei Guan
2022-11-15  6:01           ` [f2fs-dev] " Yuwei Guan
2022-11-12  8:32 ` [PATCH 2/3] f2fs: cleanup for 'f2fs_tuning_parameters' function Yuwei Guan
2022-11-12  8:32   ` [f2fs-dev] " Yuwei Guan
2022-11-12  8:32 ` [PATCH 3/3] f2fs: change type for 'sbi->readdir_ra' Yuwei Guan
2022-11-12  8:32   ` [f2fs-dev] " Yuwei Guan
2022-11-14 14:59   ` Chao Yu
2022-11-14 14:59     ` Chao Yu
2022-11-14 16:27     ` Yuwei Guan
2022-11-14 16:27       ` [f2fs-dev] " Yuwei Guan

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.