linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] f2fs: add mount option for segment allocation policy
@ 2018-02-26 17:47 Jaegeuk Kim
  2018-02-26 17:47 ` [PATCH 2/5] f2fs: add auto tuning for small devices Jaegeuk Kim
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Jaegeuk Kim @ 2018-02-26 17:47 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim

This patch adds an mount option, "alloc_mode=%s" having two options, "default"
and "reuse".

In "alloc_mode=reuse" case, f2fs starts to allocate segments from 0'th segment
all the time to reassign segments. It'd be useful for small-sized eMMC parts.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/f2fs.h    |  8 ++++++++
 fs/f2fs/segment.c |  5 +++++
 fs/f2fs/super.c   | 24 ++++++++++++++++++++++++
 3 files changed, 37 insertions(+)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 4e79a7b6f2e9..1ed17ec682ef 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1043,6 +1043,11 @@ enum {
 	WHINT_MODE_FS,		/* pass down hints with F2FS policy */
 };
 
+enum {
+	ALLOC_MODE_DEFAULT,	/* stay default */
+	ALLOC_MODE_REUSE,	/* reuse segments as much as possible */
+};
+
 struct f2fs_sb_info {
 	struct super_block *sb;			/* pointer to VFS super block */
 	struct proc_dir_entry *s_proc;		/* proc entry */
@@ -1229,6 +1234,9 @@ struct f2fs_sb_info {
 #endif
 	/* For which write hints are passed down to block layer */
 	int whint_mode;
+
+	/* segment allocation policy */
+	int alloc_mode;
 };
 
 #ifdef CONFIG_F2FS_FAULT_INJECTION
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 0646d5de8cd0..5e5e2936a26a 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2170,6 +2170,11 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)
 
 	if (SIT_I(sbi)->last_victim[ALLOC_NEXT])
 		return SIT_I(sbi)->last_victim[ALLOC_NEXT];
+
+	/* find segments from 0 to reuse freed segments */
+	if (sbi->alloc_mode == ALLOC_MODE_REUSE)
+		return 0;
+
 	return CURSEG_I(sbi, type)->segno;
 }
 
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 2e4f5673d65d..b7c0bdd1e532 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -130,6 +130,7 @@ enum {
 	Opt_jqfmt_vfsv0,
 	Opt_jqfmt_vfsv1,
 	Opt_whint,
+	Opt_alloc,
 	Opt_err,
 };
 
@@ -184,6 +185,7 @@ static match_table_t f2fs_tokens = {
 	{Opt_jqfmt_vfsv0, "jqfmt=vfsv0"},
 	{Opt_jqfmt_vfsv1, "jqfmt=vfsv1"},
 	{Opt_whint, "whint_mode=%s"},
+	{Opt_alloc, "alloc_mode=%s"},
 	{Opt_err, NULL},
 };
 
@@ -700,6 +702,23 @@ static int parse_options(struct super_block *sb, char *options)
 			}
 			kfree(name);
 			break;
+		case Opt_alloc:
+			name = match_strdup(&args[0]);
+			if (!name)
+				return -ENOMEM;
+
+			if (strlen(name) == 7 &&
+					!strncmp(name, "default", 7)) {
+				sbi->alloc_mode = ALLOC_MODE_DEFAULT;
+			} else if (strlen(name) == 5 &&
+					!strncmp(name, "reuse", 5)) {
+				sbi->alloc_mode = ALLOC_MODE_REUSE;
+			} else {
+				kfree(name);
+				return -EINVAL;
+			}
+			kfree(name);
+			break;
 		default:
 			f2fs_msg(sb, KERN_ERR,
 				"Unrecognized mount option \"%s\" or missing value",
@@ -1264,6 +1283,10 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
 	else if (sbi->whint_mode == WHINT_MODE_FS)
 		seq_printf(seq, ",whint_mode=%s", "fs-based");
 
+	if (sbi->alloc_mode == ALLOC_MODE_DEFAULT)
+		seq_printf(seq, ",alloc_mode=%s", "default");
+	else if (sbi->alloc_mode == ALLOC_MODE_REUSE)
+		seq_printf(seq, ",alloc_mode=%s", "reuse");
 	return 0;
 }
 
@@ -1273,6 +1296,7 @@ static void default_options(struct f2fs_sb_info *sbi)
 	sbi->active_logs = NR_CURSEG_TYPE;
 	sbi->inline_xattr_size = DEFAULT_INLINE_XATTR_ADDRS;
 	sbi->whint_mode = WHINT_MODE_OFF;
+	sbi->alloc_mode = ALLOC_MODE_DEFAULT;
 
 	set_opt(sbi, BG_GC);
 	set_opt(sbi, INLINE_XATTR);
-- 
2.15.0.531.g2ccb3012c9-goog

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

* [PATCH 2/5] f2fs: add auto tuning for small devices
  2018-02-26 17:47 [PATCH 1/5] f2fs: add mount option for segment allocation policy Jaegeuk Kim
@ 2018-02-26 17:47 ` Jaegeuk Kim
  2018-02-27 10:35   ` Chao Yu
  2018-02-26 17:47 ` [PATCH 3/5] f2fs: set readdir_ra by default Jaegeuk Kim
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Jaegeuk Kim @ 2018-02-26 17:47 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim

If f2fs is running on top of very small devices, it's worth to avoid abusing
free LBAs. In order to achieve that, this patch introduces some parameter
tuning.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/segment.h |  2 ++
 fs/f2fs/super.c   | 14 ++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index f11c4bc82c78..dbb774aaf387 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -596,6 +596,8 @@ static inline int utilization(struct f2fs_sb_info *sbi)
 #define DEF_MIN_FSYNC_BLOCKS	8
 #define DEF_MIN_HOT_BLOCKS	16
 
+#define SMALL_VOLUME_SEGMENTS	(16 * 512)	/* 16GB */
+
 enum {
 	F2FS_IPU_FORCE,
 	F2FS_IPU_SSR,
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index b7c0bdd1e532..9515c10eebad 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2512,6 +2512,18 @@ static int f2fs_scan_devices(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) {
+		sbi->alloc_mode = ALLOC_MODE_REUSE;
+		sm_i->dcc_info->discard_granularity = 1;
+		sm_i->ipu_policy = 1 << F2FS_IPU_FORCE;
+	}
+}
+
 static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 {
 	struct f2fs_sb_info *sbi;
@@ -2864,6 +2876,8 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 
 	f2fs_join_shrinker(sbi);
 
+	f2fs_tuning_parameters(sbi);
+
 	f2fs_msg(sbi->sb, KERN_NOTICE, "Mounted with checkpoint version = %llx",
 				cur_cp_version(F2FS_CKPT(sbi)));
 	f2fs_update_time(sbi, CP_TIME);
-- 
2.15.0.531.g2ccb3012c9-goog

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

* [PATCH 3/5] f2fs: set readdir_ra by default
  2018-02-26 17:47 [PATCH 1/5] f2fs: add mount option for segment allocation policy Jaegeuk Kim
  2018-02-26 17:47 ` [PATCH 2/5] f2fs: add auto tuning for small devices Jaegeuk Kim
@ 2018-02-26 17:47 ` Jaegeuk Kim
  2018-02-27 10:35   ` Chao Yu
  2018-02-26 17:47 ` [PATCH 4/5] f2fs: issue discard aggressively in the gc_urgent mode Jaegeuk Kim
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Jaegeuk Kim @ 2018-02-26 17:47 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim

It gives general readdir improvement.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/super.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 9515c10eebad..425eb4f6654a 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1297,6 +1297,7 @@ static void default_options(struct f2fs_sb_info *sbi)
 	sbi->inline_xattr_size = DEFAULT_INLINE_XATTR_ADDRS;
 	sbi->whint_mode = WHINT_MODE_OFF;
 	sbi->alloc_mode = ALLOC_MODE_DEFAULT;
+	sbi->readdir_ra = 1;
 
 	set_opt(sbi, BG_GC);
 	set_opt(sbi, INLINE_XATTR);
-- 
2.15.0.531.g2ccb3012c9-goog

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

* [PATCH 4/5] f2fs: issue discard aggressively in the gc_urgent mode
  2018-02-26 17:47 [PATCH 1/5] f2fs: add mount option for segment allocation policy Jaegeuk Kim
  2018-02-26 17:47 ` [PATCH 2/5] f2fs: add auto tuning for small devices Jaegeuk Kim
  2018-02-26 17:47 ` [PATCH 3/5] f2fs: set readdir_ra by default Jaegeuk Kim
@ 2018-02-26 17:47 ` Jaegeuk Kim
  2018-02-27 10:36   ` Chao Yu
  2018-03-01  2:37   ` Jaegeuk Kim
  2018-02-26 17:47 ` [PATCH 5/5] f2fs: don't stop GC if GC is contended Jaegeuk Kim
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 16+ messages in thread
From: Jaegeuk Kim @ 2018-02-26 17:47 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim

This patch avoids to skip discard commands when user sets gc_urgent mode.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/segment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 5e5e2936a26a..bda2ad048ea0 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1727,7 +1727,7 @@ void init_discard_policy(struct discard_policy *dpolicy,
 	} else if (discard_type == DPOLICY_FORCE) {
 		dpolicy->min_interval = DEF_MIN_DISCARD_ISSUE_TIME;
 		dpolicy->max_interval = DEF_MAX_DISCARD_ISSUE_TIME;
-		dpolicy->io_aware = true;
+		dpolicy->io_aware = false;
 	} else if (discard_type == DPOLICY_FSTRIM) {
 		dpolicy->io_aware = false;
 	} else if (discard_type == DPOLICY_UMOUNT) {
-- 
2.15.0.531.g2ccb3012c9-goog

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

* [PATCH 5/5] f2fs: don't stop GC if GC is contended
  2018-02-26 17:47 [PATCH 1/5] f2fs: add mount option for segment allocation policy Jaegeuk Kim
                   ` (2 preceding siblings ...)
  2018-02-26 17:47 ` [PATCH 4/5] f2fs: issue discard aggressively in the gc_urgent mode Jaegeuk Kim
@ 2018-02-26 17:47 ` Jaegeuk Kim
  2018-02-27 10:36   ` Chao Yu
  2018-02-27 10:33 ` [PATCH 1/5] f2fs: add mount option for segment allocation policy Chao Yu
  2018-02-28  5:09 ` [PATCH 1/5 v2] " Jaegeuk Kim
  5 siblings, 1 reply; 16+ messages in thread
From: Jaegeuk Kim @ 2018-02-26 17:47 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim

Let's do GC as much as possible, while gc_urgent is set.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/gc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index b9d93fd532a9..bc9420ce2275 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -76,14 +76,15 @@ static int gc_thread_func(void *data)
 		 * invalidated soon after by user update or deletion.
 		 * So, I'd like to wait some time to collect dirty segments.
 		 */
-		if (!mutex_trylock(&sbi->gc_mutex))
-			goto next;
-
 		if (gc_th->gc_urgent) {
 			wait_ms = gc_th->urgent_sleep_time;
+			mutex_lock(&sbi->gc_mutex);
 			goto do_gc;
 		}
 
+		if (!mutex_trylock(&sbi->gc_mutex))
+			goto next;
+
 		if (!is_idle(sbi)) {
 			increase_sleep_time(gc_th, &wait_ms);
 			mutex_unlock(&sbi->gc_mutex);
-- 
2.15.0.531.g2ccb3012c9-goog

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

* Re: [PATCH 1/5] f2fs: add mount option for segment allocation policy
  2018-02-26 17:47 [PATCH 1/5] f2fs: add mount option for segment allocation policy Jaegeuk Kim
                   ` (3 preceding siblings ...)
  2018-02-26 17:47 ` [PATCH 5/5] f2fs: don't stop GC if GC is contended Jaegeuk Kim
@ 2018-02-27 10:33 ` Chao Yu
  2018-02-28  5:09 ` [PATCH 1/5 v2] " Jaegeuk Kim
  5 siblings, 0 replies; 16+ messages in thread
From: Chao Yu @ 2018-02-27 10:33 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel

Hi Jaegeuk,

On 2018/2/27 1:47, Jaegeuk Kim wrote:
> This patch adds an mount option, "alloc_mode=%s" having two options, "default"
> and "reuse".
> 
> In "alloc_mode=reuse" case, f2fs starts to allocate segments from 0'th segment
> all the time to reassign segments. It'd be useful for small-sized eMMC parts.

We needs to add Doc for this mount option. ;)

Thanks,

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

* Re: [PATCH 2/5] f2fs: add auto tuning for small devices
  2018-02-26 17:47 ` [PATCH 2/5] f2fs: add auto tuning for small devices Jaegeuk Kim
@ 2018-02-27 10:35   ` Chao Yu
  0 siblings, 0 replies; 16+ messages in thread
From: Chao Yu @ 2018-02-27 10:35 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel

On 2018/2/27 1:47, Jaegeuk Kim wrote:
> If f2fs is running on top of very small devices, it's worth to avoid abusing
> free LBAs. In order to achieve that, this patch introduces some parameter
> tuning.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 3/5] f2fs: set readdir_ra by default
  2018-02-26 17:47 ` [PATCH 3/5] f2fs: set readdir_ra by default Jaegeuk Kim
@ 2018-02-27 10:35   ` Chao Yu
  0 siblings, 0 replies; 16+ messages in thread
From: Chao Yu @ 2018-02-27 10:35 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel

On 2018/2/27 1:47, Jaegeuk Kim wrote:
> It gives general readdir improvement.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 4/5] f2fs: issue discard aggressively in the gc_urgent mode
  2018-02-26 17:47 ` [PATCH 4/5] f2fs: issue discard aggressively in the gc_urgent mode Jaegeuk Kim
@ 2018-02-27 10:36   ` Chao Yu
  2018-03-01  2:37   ` Jaegeuk Kim
  1 sibling, 0 replies; 16+ messages in thread
From: Chao Yu @ 2018-02-27 10:36 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel

On 2018/2/27 1:47, Jaegeuk Kim wrote:
> This patch avoids to skip discard commands when user sets gc_urgent mode.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 5/5] f2fs: don't stop GC if GC is contended
  2018-02-26 17:47 ` [PATCH 5/5] f2fs: don't stop GC if GC is contended Jaegeuk Kim
@ 2018-02-27 10:36   ` Chao Yu
  0 siblings, 0 replies; 16+ messages in thread
From: Chao Yu @ 2018-02-27 10:36 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel

On 2018/2/27 1:47, Jaegeuk Kim wrote:
> Let's do GC as much as possible, while gc_urgent is set.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 1/5 v2] f2fs: add mount option for segment allocation policy
  2018-02-26 17:47 [PATCH 1/5] f2fs: add mount option for segment allocation policy Jaegeuk Kim
                   ` (4 preceding siblings ...)
  2018-02-27 10:33 ` [PATCH 1/5] f2fs: add mount option for segment allocation policy Chao Yu
@ 2018-02-28  5:09 ` Jaegeuk Kim
  2018-02-28  9:33   ` Chao Yu
                     ` (2 more replies)
  5 siblings, 3 replies; 16+ messages in thread
From: Jaegeuk Kim @ 2018-02-28  5:09 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel

Change log from v1:
 - add doc :)

This patch adds an mount option, "alloc_mode=%s" having two options, "default"
and "reuse".

In "alloc_mode=reuse" case, f2fs starts to allocate segments from 0'th segment
all the time to reassign segments. It'd be useful for small-sized eMMC parts.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 Documentation/filesystems/f2fs.txt |  2 ++
 fs/f2fs/f2fs.h                     |  8 ++++++++
 fs/f2fs/segment.c                  |  5 +++++
 fs/f2fs/super.c                    | 24 ++++++++++++++++++++++++
 4 files changed, 39 insertions(+)

diff --git a/Documentation/filesystems/f2fs.txt b/Documentation/filesystems/f2fs.txt
index 0caf7da0a532..0409c47584ea 100644
--- a/Documentation/filesystems/f2fs.txt
+++ b/Documentation/filesystems/f2fs.txt
@@ -180,6 +180,8 @@ whint_mode=%s          Control which write hints are passed down to block
                        down hints. In "user-based" mode, f2fs tries to pass
                        down hints given by users. And in "fs-based" mode, f2fs
                        passes down hints with its policy.
+alloc_mode=%s          Adjust block allocation policy, which supports "reuse"
+                       and "default".
 
 ================================================================================
 DEBUGFS ENTRIES
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index f68ece08b5a2..d1bfdf691afc 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1043,6 +1043,11 @@ enum {
 	WHINT_MODE_FS,		/* pass down hints with F2FS policy */
 };
 
+enum {
+	ALLOC_MODE_DEFAULT,	/* stay default */
+	ALLOC_MODE_REUSE,	/* reuse segments as much as possible */
+};
+
 struct f2fs_sb_info {
 	struct super_block *sb;			/* pointer to VFS super block */
 	struct proc_dir_entry *s_proc;		/* proc entry */
@@ -1229,6 +1234,9 @@ struct f2fs_sb_info {
 #endif
 	/* For which write hints are passed down to block layer */
 	int whint_mode;
+
+	/* segment allocation policy */
+	int alloc_mode;
 };
 
 #ifdef CONFIG_F2FS_FAULT_INJECTION
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 0646d5de8cd0..5e5e2936a26a 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2170,6 +2170,11 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)
 
 	if (SIT_I(sbi)->last_victim[ALLOC_NEXT])
 		return SIT_I(sbi)->last_victim[ALLOC_NEXT];
+
+	/* find segments from 0 to reuse freed segments */
+	if (sbi->alloc_mode == ALLOC_MODE_REUSE)
+		return 0;
+
 	return CURSEG_I(sbi, type)->segno;
 }
 
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 2d832866720c..1345ef167140 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -130,6 +130,7 @@ enum {
 	Opt_jqfmt_vfsv0,
 	Opt_jqfmt_vfsv1,
 	Opt_whint,
+	Opt_alloc,
 	Opt_err,
 };
 
@@ -184,6 +185,7 @@ static match_table_t f2fs_tokens = {
 	{Opt_jqfmt_vfsv0, "jqfmt=vfsv0"},
 	{Opt_jqfmt_vfsv1, "jqfmt=vfsv1"},
 	{Opt_whint, "whint_mode=%s"},
+	{Opt_alloc, "alloc_mode=%s"},
 	{Opt_err, NULL},
 };
 
@@ -700,6 +702,23 @@ static int parse_options(struct super_block *sb, char *options)
 			}
 			kfree(name);
 			break;
+		case Opt_alloc:
+			name = match_strdup(&args[0]);
+			if (!name)
+				return -ENOMEM;
+
+			if (strlen(name) == 7 &&
+					!strncmp(name, "default", 7)) {
+				sbi->alloc_mode = ALLOC_MODE_DEFAULT;
+			} else if (strlen(name) == 5 &&
+					!strncmp(name, "reuse", 5)) {
+				sbi->alloc_mode = ALLOC_MODE_REUSE;
+			} else {
+				kfree(name);
+				return -EINVAL;
+			}
+			kfree(name);
+			break;
 		default:
 			f2fs_msg(sb, KERN_ERR,
 				"Unrecognized mount option \"%s\" or missing value",
@@ -1264,6 +1283,10 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
 	else if (sbi->whint_mode == WHINT_MODE_FS)
 		seq_printf(seq, ",whint_mode=%s", "fs-based");
 
+	if (sbi->alloc_mode == ALLOC_MODE_DEFAULT)
+		seq_printf(seq, ",alloc_mode=%s", "default");
+	else if (sbi->alloc_mode == ALLOC_MODE_REUSE)
+		seq_printf(seq, ",alloc_mode=%s", "reuse");
 	return 0;
 }
 
@@ -1273,6 +1296,7 @@ static void default_options(struct f2fs_sb_info *sbi)
 	sbi->active_logs = NR_CURSEG_TYPE;
 	sbi->inline_xattr_size = DEFAULT_INLINE_XATTR_ADDRS;
 	sbi->whint_mode = WHINT_MODE_OFF;
+	sbi->alloc_mode = ALLOC_MODE_DEFAULT;
 
 	set_opt(sbi, BG_GC);
 	set_opt(sbi, INLINE_XATTR);
-- 
2.15.0.531.g2ccb3012c9-goog

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

* Re: [PATCH 1/5 v2] f2fs: add mount option for segment allocation policy
  2018-02-28  5:09 ` [PATCH 1/5 v2] " Jaegeuk Kim
@ 2018-02-28  9:33   ` Chao Yu
  2018-02-28 13:47   ` [f2fs-dev] " Chao Yu
  2018-02-28 13:52   ` Chao Yu
  2 siblings, 0 replies; 16+ messages in thread
From: Chao Yu @ 2018-02-28  9:33 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel

On 2018/2/28 13:09, Jaegeuk Kim wrote:
> Change log from v1:
>  - add doc :)
> 
> This patch adds an mount option, "alloc_mode=%s" having two options, "default"
> and "reuse".
> 
> In "alloc_mode=reuse" case, f2fs starts to allocate segments from 0'th segment
> all the time to reassign segments. It'd be useful for small-sized eMMC parts.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [f2fs-dev] [PATCH 1/5 v2] f2fs: add mount option for segment allocation policy
  2018-02-28  5:09 ` [PATCH 1/5 v2] " Jaegeuk Kim
  2018-02-28  9:33   ` Chao Yu
@ 2018-02-28 13:47   ` Chao Yu
  2018-03-01  2:53     ` Jaegeuk Kim
  2018-02-28 13:52   ` Chao Yu
  2 siblings, 1 reply; 16+ messages in thread
From: Chao Yu @ 2018-02-28 13:47 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel

On 2018/2/28 13:09, Jaegeuk Kim wrote:
> Change log from v1:
>  - add doc :)
> 
> This patch adds an mount option, "alloc_mode=%s" having two options, "default"
> and "reuse".
> 
> In "alloc_mode=reuse" case, f2fs starts to allocate segments from 0'th segment
> all the time to reassign segments. It'd be useful for small-sized eMMC parts.

We have to restore old alloc_mode if we encounter any failure in ->remount, right?

Thanks,

> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  Documentation/filesystems/f2fs.txt |  2 ++
>  fs/f2fs/f2fs.h                     |  8 ++++++++
>  fs/f2fs/segment.c                  |  5 +++++
>  fs/f2fs/super.c                    | 24 ++++++++++++++++++++++++
>  4 files changed, 39 insertions(+)
> 
> diff --git a/Documentation/filesystems/f2fs.txt b/Documentation/filesystems/f2fs.txt
> index 0caf7da0a532..0409c47584ea 100644
> --- a/Documentation/filesystems/f2fs.txt
> +++ b/Documentation/filesystems/f2fs.txt
> @@ -180,6 +180,8 @@ whint_mode=%s          Control which write hints are passed down to block
>                         down hints. In "user-based" mode, f2fs tries to pass
>                         down hints given by users. And in "fs-based" mode, f2fs
>                         passes down hints with its policy.
> +alloc_mode=%s          Adjust block allocation policy, which supports "reuse"
> +                       and "default".
>  
>  ================================================================================
>  DEBUGFS ENTRIES
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index f68ece08b5a2..d1bfdf691afc 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -1043,6 +1043,11 @@ enum {
>  	WHINT_MODE_FS,		/* pass down hints with F2FS policy */
>  };
>  
> +enum {
> +	ALLOC_MODE_DEFAULT,	/* stay default */
> +	ALLOC_MODE_REUSE,	/* reuse segments as much as possible */
> +};
> +
>  struct f2fs_sb_info {
>  	struct super_block *sb;			/* pointer to VFS super block */
>  	struct proc_dir_entry *s_proc;		/* proc entry */
> @@ -1229,6 +1234,9 @@ struct f2fs_sb_info {
>  #endif
>  	/* For which write hints are passed down to block layer */
>  	int whint_mode;
> +
> +	/* segment allocation policy */
> +	int alloc_mode;
>  };
>  
>  #ifdef CONFIG_F2FS_FAULT_INJECTION
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 0646d5de8cd0..5e5e2936a26a 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -2170,6 +2170,11 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)
>  
>  	if (SIT_I(sbi)->last_victim[ALLOC_NEXT])
>  		return SIT_I(sbi)->last_victim[ALLOC_NEXT];
> +
> +	/* find segments from 0 to reuse freed segments */
> +	if (sbi->alloc_mode == ALLOC_MODE_REUSE)
> +		return 0;
> +
>  	return CURSEG_I(sbi, type)->segno;
>  }
>  
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 2d832866720c..1345ef167140 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -130,6 +130,7 @@ enum {
>  	Opt_jqfmt_vfsv0,
>  	Opt_jqfmt_vfsv1,
>  	Opt_whint,
> +	Opt_alloc,
>  	Opt_err,
>  };
>  
> @@ -184,6 +185,7 @@ static match_table_t f2fs_tokens = {
>  	{Opt_jqfmt_vfsv0, "jqfmt=vfsv0"},
>  	{Opt_jqfmt_vfsv1, "jqfmt=vfsv1"},
>  	{Opt_whint, "whint_mode=%s"},
> +	{Opt_alloc, "alloc_mode=%s"},
>  	{Opt_err, NULL},
>  };
>  
> @@ -700,6 +702,23 @@ static int parse_options(struct super_block *sb, char *options)
>  			}
>  			kfree(name);
>  			break;
> +		case Opt_alloc:
> +			name = match_strdup(&args[0]);
> +			if (!name)
> +				return -ENOMEM;
> +
> +			if (strlen(name) == 7 &&
> +					!strncmp(name, "default", 7)) {
> +				sbi->alloc_mode = ALLOC_MODE_DEFAULT;
> +			} else if (strlen(name) == 5 &&
> +					!strncmp(name, "reuse", 5)) {
> +				sbi->alloc_mode = ALLOC_MODE_REUSE;
> +			} else {
> +				kfree(name);
> +				return -EINVAL;
> +			}
> +			kfree(name);
> +			break;
>  		default:
>  			f2fs_msg(sb, KERN_ERR,
>  				"Unrecognized mount option \"%s\" or missing value",
> @@ -1264,6 +1283,10 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
>  	else if (sbi->whint_mode == WHINT_MODE_FS)
>  		seq_printf(seq, ",whint_mode=%s", "fs-based");
>  
> +	if (sbi->alloc_mode == ALLOC_MODE_DEFAULT)
> +		seq_printf(seq, ",alloc_mode=%s", "default");
> +	else if (sbi->alloc_mode == ALLOC_MODE_REUSE)
> +		seq_printf(seq, ",alloc_mode=%s", "reuse");
>  	return 0;
>  }
>  
> @@ -1273,6 +1296,7 @@ static void default_options(struct f2fs_sb_info *sbi)
>  	sbi->active_logs = NR_CURSEG_TYPE;
>  	sbi->inline_xattr_size = DEFAULT_INLINE_XATTR_ADDRS;
>  	sbi->whint_mode = WHINT_MODE_OFF;
> +	sbi->alloc_mode = ALLOC_MODE_DEFAULT;
>  
>  	set_opt(sbi, BG_GC);
>  	set_opt(sbi, INLINE_XATTR);
> 

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

* Re: [f2fs-dev] [PATCH 1/5 v2] f2fs: add mount option for segment allocation policy
  2018-02-28  5:09 ` [PATCH 1/5 v2] " Jaegeuk Kim
  2018-02-28  9:33   ` Chao Yu
  2018-02-28 13:47   ` [f2fs-dev] " Chao Yu
@ 2018-02-28 13:52   ` Chao Yu
  2 siblings, 0 replies; 16+ messages in thread
From: Chao Yu @ 2018-02-28 13:52 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel

On 2018/2/28 13:09, Jaegeuk Kim wrote:
> Change log from v1:
>  - add doc :)
> 
> This patch adds an mount option, "alloc_mode=%s" having two options, "default"
> and "reuse".
> 
> In "alloc_mode=reuse" case, f2fs starts to allocate segments from 0'th segment
> all the time to reassign segments. It'd be useful for small-sized eMMC parts.

We have to restore old alloc_mode if we encounter any failure in ->remount, right?

Thanks,

> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  Documentation/filesystems/f2fs.txt |  2 ++
>  fs/f2fs/f2fs.h                     |  8 ++++++++
>  fs/f2fs/segment.c                  |  5 +++++
>  fs/f2fs/super.c                    | 24 ++++++++++++++++++++++++
>  4 files changed, 39 insertions(+)
> 
> diff --git a/Documentation/filesystems/f2fs.txt b/Documentation/filesystems/f2fs.txt
> index 0caf7da0a532..0409c47584ea 100644
> --- a/Documentation/filesystems/f2fs.txt
> +++ b/Documentation/filesystems/f2fs.txt
> @@ -180,6 +180,8 @@ whint_mode=%s          Control which write hints are passed down to block
>                         down hints. In "user-based" mode, f2fs tries to pass
>                         down hints given by users. And in "fs-based" mode, f2fs
>                         passes down hints with its policy.
> +alloc_mode=%s          Adjust block allocation policy, which supports "reuse"
> +                       and "default".
>  
>  ================================================================================
>  DEBUGFS ENTRIES
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index f68ece08b5a2..d1bfdf691afc 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -1043,6 +1043,11 @@ enum {
>  	WHINT_MODE_FS,		/* pass down hints with F2FS policy */
>  };
>  
> +enum {
> +	ALLOC_MODE_DEFAULT,	/* stay default */
> +	ALLOC_MODE_REUSE,	/* reuse segments as much as possible */
> +};
> +
>  struct f2fs_sb_info {
>  	struct super_block *sb;			/* pointer to VFS super block */
>  	struct proc_dir_entry *s_proc;		/* proc entry */
> @@ -1229,6 +1234,9 @@ struct f2fs_sb_info {
>  #endif
>  	/* For which write hints are passed down to block layer */
>  	int whint_mode;
> +
> +	/* segment allocation policy */
> +	int alloc_mode;
>  };
>  
>  #ifdef CONFIG_F2FS_FAULT_INJECTION
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 0646d5de8cd0..5e5e2936a26a 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -2170,6 +2170,11 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)
>  
>  	if (SIT_I(sbi)->last_victim[ALLOC_NEXT])
>  		return SIT_I(sbi)->last_victim[ALLOC_NEXT];
> +
> +	/* find segments from 0 to reuse freed segments */
> +	if (sbi->alloc_mode == ALLOC_MODE_REUSE)
> +		return 0;
> +
>  	return CURSEG_I(sbi, type)->segno;
>  }
>  
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 2d832866720c..1345ef167140 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -130,6 +130,7 @@ enum {
>  	Opt_jqfmt_vfsv0,
>  	Opt_jqfmt_vfsv1,
>  	Opt_whint,
> +	Opt_alloc,
>  	Opt_err,
>  };
>  
> @@ -184,6 +185,7 @@ static match_table_t f2fs_tokens = {
>  	{Opt_jqfmt_vfsv0, "jqfmt=vfsv0"},
>  	{Opt_jqfmt_vfsv1, "jqfmt=vfsv1"},
>  	{Opt_whint, "whint_mode=%s"},
> +	{Opt_alloc, "alloc_mode=%s"},
>  	{Opt_err, NULL},
>  };
>  
> @@ -700,6 +702,23 @@ static int parse_options(struct super_block *sb, char *options)
>  			}
>  			kfree(name);
>  			break;
> +		case Opt_alloc:
> +			name = match_strdup(&args[0]);
> +			if (!name)
> +				return -ENOMEM;
> +
> +			if (strlen(name) == 7 &&
> +					!strncmp(name, "default", 7)) {
> +				sbi->alloc_mode = ALLOC_MODE_DEFAULT;
> +			} else if (strlen(name) == 5 &&
> +					!strncmp(name, "reuse", 5)) {
> +				sbi->alloc_mode = ALLOC_MODE_REUSE;
> +			} else {
> +				kfree(name);
> +				return -EINVAL;
> +			}
> +			kfree(name);
> +			break;
>  		default:
>  			f2fs_msg(sb, KERN_ERR,
>  				"Unrecognized mount option \"%s\" or missing value",
> @@ -1264,6 +1283,10 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
>  	else if (sbi->whint_mode == WHINT_MODE_FS)
>  		seq_printf(seq, ",whint_mode=%s", "fs-based");
>  
> +	if (sbi->alloc_mode == ALLOC_MODE_DEFAULT)
> +		seq_printf(seq, ",alloc_mode=%s", "default");
> +	else if (sbi->alloc_mode == ALLOC_MODE_REUSE)
> +		seq_printf(seq, ",alloc_mode=%s", "reuse");
>  	return 0;
>  }
>  
> @@ -1273,6 +1296,7 @@ static void default_options(struct f2fs_sb_info *sbi)
>  	sbi->active_logs = NR_CURSEG_TYPE;
>  	sbi->inline_xattr_size = DEFAULT_INLINE_XATTR_ADDRS;
>  	sbi->whint_mode = WHINT_MODE_OFF;
> +	sbi->alloc_mode = ALLOC_MODE_DEFAULT;
>  
>  	set_opt(sbi, BG_GC);
>  	set_opt(sbi, INLINE_XATTR);
> 

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

* Re: [PATCH 4/5] f2fs: issue discard aggressively in the gc_urgent mode
  2018-02-26 17:47 ` [PATCH 4/5] f2fs: issue discard aggressively in the gc_urgent mode Jaegeuk Kim
  2018-02-27 10:36   ` Chao Yu
@ 2018-03-01  2:37   ` Jaegeuk Kim
  1 sibling, 0 replies; 16+ messages in thread
From: Jaegeuk Kim @ 2018-03-01  2:37 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel

Change log from v1:
- relax more to issue discard commands

This patch avoids to skip discard commands when user sets gc_urgent mode.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/segment.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 5e5e2936a26a..1e3dd3de4ecc 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1411,12 +1411,11 @@ static int issue_discard_thread(void *data)
 		if (kthread_should_stop())
 			return 0;
 
-		if (dcc->discard_wake) {
+		if (dcc->discard_wake)
 			dcc->discard_wake = 0;
-			if (sbi->gc_thread && sbi->gc_thread->gc_urgent)
-				init_discard_policy(&dpolicy,
-							DPOLICY_FORCE, 1);
-		}
+
+		if (sbi->gc_thread && sbi->gc_thread->gc_urgent)
+			init_discard_policy(&dpolicy, DPOLICY_FORCE, 1);
 
 		sb_start_intwrite(sbi->sb);
 
@@ -1727,7 +1726,7 @@ void init_discard_policy(struct discard_policy *dpolicy,
 	} else if (discard_type == DPOLICY_FORCE) {
 		dpolicy->min_interval = DEF_MIN_DISCARD_ISSUE_TIME;
 		dpolicy->max_interval = DEF_MAX_DISCARD_ISSUE_TIME;
-		dpolicy->io_aware = true;
+		dpolicy->io_aware = false;
 	} else if (discard_type == DPOLICY_FSTRIM) {
 		dpolicy->io_aware = false;
 	} else if (discard_type == DPOLICY_UMOUNT) {
-- 
2.15.0.531.g2ccb3012c9-goog

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

* Re: [f2fs-dev] [PATCH 1/5 v2] f2fs: add mount option for segment allocation policy
  2018-02-28 13:47   ` [f2fs-dev] " Chao Yu
@ 2018-03-01  2:53     ` Jaegeuk Kim
  0 siblings, 0 replies; 16+ messages in thread
From: Jaegeuk Kim @ 2018-03-01  2:53 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel

On 02/28, Chao Yu wrote:
> On 2018/2/28 13:09, Jaegeuk Kim wrote:
> > Change log from v1:
> >  - add doc :)
> > 
> > This patch adds an mount option, "alloc_mode=%s" having two options, "default"
> > and "reuse".
> > 
> > In "alloc_mode=reuse" case, f2fs starts to allocate segments from 0'th segment
> > all the time to reassign segments. It'd be useful for small-sized eMMC parts.
> 
> We have to restore old alloc_mode if we encounter any failure in ->remount, right?

Yup, done.

> 
> Thanks,
> 
> > 
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> >  Documentation/filesystems/f2fs.txt |  2 ++
> >  fs/f2fs/f2fs.h                     |  8 ++++++++
> >  fs/f2fs/segment.c                  |  5 +++++
> >  fs/f2fs/super.c                    | 24 ++++++++++++++++++++++++
> >  4 files changed, 39 insertions(+)
> > 
> > diff --git a/Documentation/filesystems/f2fs.txt b/Documentation/filesystems/f2fs.txt
> > index 0caf7da0a532..0409c47584ea 100644
> > --- a/Documentation/filesystems/f2fs.txt
> > +++ b/Documentation/filesystems/f2fs.txt
> > @@ -180,6 +180,8 @@ whint_mode=%s          Control which write hints are passed down to block
> >                         down hints. In "user-based" mode, f2fs tries to pass
> >                         down hints given by users. And in "fs-based" mode, f2fs
> >                         passes down hints with its policy.
> > +alloc_mode=%s          Adjust block allocation policy, which supports "reuse"
> > +                       and "default".
> >  
> >  ================================================================================
> >  DEBUGFS ENTRIES
> > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> > index f68ece08b5a2..d1bfdf691afc 100644
> > --- a/fs/f2fs/f2fs.h
> > +++ b/fs/f2fs/f2fs.h
> > @@ -1043,6 +1043,11 @@ enum {
> >  	WHINT_MODE_FS,		/* pass down hints with F2FS policy */
> >  };
> >  
> > +enum {
> > +	ALLOC_MODE_DEFAULT,	/* stay default */
> > +	ALLOC_MODE_REUSE,	/* reuse segments as much as possible */
> > +};
> > +
> >  struct f2fs_sb_info {
> >  	struct super_block *sb;			/* pointer to VFS super block */
> >  	struct proc_dir_entry *s_proc;		/* proc entry */
> > @@ -1229,6 +1234,9 @@ struct f2fs_sb_info {
> >  #endif
> >  	/* For which write hints are passed down to block layer */
> >  	int whint_mode;
> > +
> > +	/* segment allocation policy */
> > +	int alloc_mode;
> >  };
> >  
> >  #ifdef CONFIG_F2FS_FAULT_INJECTION
> > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> > index 0646d5de8cd0..5e5e2936a26a 100644
> > --- a/fs/f2fs/segment.c
> > +++ b/fs/f2fs/segment.c
> > @@ -2170,6 +2170,11 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)
> >  
> >  	if (SIT_I(sbi)->last_victim[ALLOC_NEXT])
> >  		return SIT_I(sbi)->last_victim[ALLOC_NEXT];
> > +
> > +	/* find segments from 0 to reuse freed segments */
> > +	if (sbi->alloc_mode == ALLOC_MODE_REUSE)
> > +		return 0;
> > +
> >  	return CURSEG_I(sbi, type)->segno;
> >  }
> >  
> > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> > index 2d832866720c..1345ef167140 100644
> > --- a/fs/f2fs/super.c
> > +++ b/fs/f2fs/super.c
> > @@ -130,6 +130,7 @@ enum {
> >  	Opt_jqfmt_vfsv0,
> >  	Opt_jqfmt_vfsv1,
> >  	Opt_whint,
> > +	Opt_alloc,
> >  	Opt_err,
> >  };
> >  
> > @@ -184,6 +185,7 @@ static match_table_t f2fs_tokens = {
> >  	{Opt_jqfmt_vfsv0, "jqfmt=vfsv0"},
> >  	{Opt_jqfmt_vfsv1, "jqfmt=vfsv1"},
> >  	{Opt_whint, "whint_mode=%s"},
> > +	{Opt_alloc, "alloc_mode=%s"},
> >  	{Opt_err, NULL},
> >  };
> >  
> > @@ -700,6 +702,23 @@ static int parse_options(struct super_block *sb, char *options)
> >  			}
> >  			kfree(name);
> >  			break;
> > +		case Opt_alloc:
> > +			name = match_strdup(&args[0]);
> > +			if (!name)
> > +				return -ENOMEM;
> > +
> > +			if (strlen(name) == 7 &&
> > +					!strncmp(name, "default", 7)) {
> > +				sbi->alloc_mode = ALLOC_MODE_DEFAULT;
> > +			} else if (strlen(name) == 5 &&
> > +					!strncmp(name, "reuse", 5)) {
> > +				sbi->alloc_mode = ALLOC_MODE_REUSE;
> > +			} else {
> > +				kfree(name);
> > +				return -EINVAL;
> > +			}
> > +			kfree(name);
> > +			break;
> >  		default:
> >  			f2fs_msg(sb, KERN_ERR,
> >  				"Unrecognized mount option \"%s\" or missing value",
> > @@ -1264,6 +1283,10 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
> >  	else if (sbi->whint_mode == WHINT_MODE_FS)
> >  		seq_printf(seq, ",whint_mode=%s", "fs-based");
> >  
> > +	if (sbi->alloc_mode == ALLOC_MODE_DEFAULT)
> > +		seq_printf(seq, ",alloc_mode=%s", "default");
> > +	else if (sbi->alloc_mode == ALLOC_MODE_REUSE)
> > +		seq_printf(seq, ",alloc_mode=%s", "reuse");
> >  	return 0;
> >  }
> >  
> > @@ -1273,6 +1296,7 @@ static void default_options(struct f2fs_sb_info *sbi)
> >  	sbi->active_logs = NR_CURSEG_TYPE;
> >  	sbi->inline_xattr_size = DEFAULT_INLINE_XATTR_ADDRS;
> >  	sbi->whint_mode = WHINT_MODE_OFF;
> > +	sbi->alloc_mode = ALLOC_MODE_DEFAULT;
> >  
> >  	set_opt(sbi, BG_GC);
> >  	set_opt(sbi, INLINE_XATTR);
> > 

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

end of thread, other threads:[~2018-03-01  2:53 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-26 17:47 [PATCH 1/5] f2fs: add mount option for segment allocation policy Jaegeuk Kim
2018-02-26 17:47 ` [PATCH 2/5] f2fs: add auto tuning for small devices Jaegeuk Kim
2018-02-27 10:35   ` Chao Yu
2018-02-26 17:47 ` [PATCH 3/5] f2fs: set readdir_ra by default Jaegeuk Kim
2018-02-27 10:35   ` Chao Yu
2018-02-26 17:47 ` [PATCH 4/5] f2fs: issue discard aggressively in the gc_urgent mode Jaegeuk Kim
2018-02-27 10:36   ` Chao Yu
2018-03-01  2:37   ` Jaegeuk Kim
2018-02-26 17:47 ` [PATCH 5/5] f2fs: don't stop GC if GC is contended Jaegeuk Kim
2018-02-27 10:36   ` Chao Yu
2018-02-27 10:33 ` [PATCH 1/5] f2fs: add mount option for segment allocation policy Chao Yu
2018-02-28  5:09 ` [PATCH 1/5 v2] " Jaegeuk Kim
2018-02-28  9:33   ` Chao Yu
2018-02-28 13:47   ` [f2fs-dev] " Chao Yu
2018-03-01  2:53     ` Jaegeuk Kim
2018-02-28 13:52   ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).