All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] f2fs: Zoned block device support
@ 2016-10-28  7:55 ` Damien Le Moal
  0 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

This series completes support for zoned block devices in f2fs. The core zoned
block device support was added to Jens linux-block tree, branch for-4.10/block.
(Please note that patch 1/9 is not specific to this series)

The core part of the zoned block device support was already implemented
by Jaegeuk with the addition of the "lfs" mode and atomic block allocation
and BIO issuing fixes. The patches in this series build on top of this
support, adding fixes for section discard and mount options checks.

Whereas older prototype ZBC support patch sets mapped discard to the reset
write pointer command for zoned block devices, the patches merged in Jens
for-4.10/block do not and a zone reset must be done with the function
blkdev_reset_zones. So in f2fs, the function f2fs_issue_discard is modified
to execute this function when the section to discard is stored in a sequential
zone. For sections stored in conventional zones, the regular discard operation
is used if the drive supports it.

This means that the zone type of each section is needed for discard. To avoid
a costly report zones execution before each section discard, the type of all
zones of the device is cached in the super block information. This cache is
initialized at mount time and does not need any update as the zone type of
zoned block devices is fixed.

For convenience and debugging, tracing of zone reset events is also added
similarly to the traces for regular discard events.

Damien Le Moal (9):
  f2fs: Add missing break in switch-case
  f2fs: Use generic zoned block device terminology
  f2fs: Check zoned block feature for host-managed zoned block devices
  f2fs: Suppress discard warning message for zoned block devices
  f2fs: Always enable discard for zoned blocks devices
  f2fs: Do not allow adaptive mode for host-managed zoned block devices
  f2fs: Cache zoned block devices zone type
  f2fs: Reset sequential zones on zoned block devices
  f2fs: Trace reset zone events

 fs/f2fs/data.c              |   2 +-
 fs/f2fs/f2fs.h              |  36 ++++++++++-----
 fs/f2fs/segment.c           |  61 +++++++++++++++++++++----
 fs/f2fs/super.c             | 106 +++++++++++++++++++++++++++++++++++++++++++-
 include/trace/events/f2fs.h |  21 +++++++++
 5 files changed, 205 insertions(+), 21 deletions(-)

-- 
2.7.4


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

* [PATCH 0/9] f2fs: Zoned block device support
@ 2016-10-28  7:55 ` Damien Le Moal
  0 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

This series completes support for zoned block devices in f2fs. The core zoned
block device support was added to Jens linux-block tree, branch for-4.10/block.
(Please note that patch 1/9 is not specific to this series)

The core part of the zoned block device support was already implemented
by Jaegeuk with the addition of the "lfs" mode and atomic block allocation
and BIO issuing fixes. The patches in this series build on top of this
support, adding fixes for section discard and mount options checks.

Whereas older prototype ZBC support patch sets mapped discard to the reset
write pointer command for zoned block devices, the patches merged in Jens
for-4.10/block do not and a zone reset must be done with the function
blkdev_reset_zones. So in f2fs, the function f2fs_issue_discard is modified
to execute this function when the section to discard is stored in a sequential
zone. For sections stored in conventional zones, the regular discard operation
is used if the drive supports it.

This means that the zone type of each section is needed for discard. To avoid
a costly report zones execution before each section discard, the type of all
zones of the device is cached in the super block information. This cache is
initialized at mount time and does not need any update as the zone type of
zoned block devices is fixed.

For convenience and debugging, tracing of zone reset events is also added
similarly to the traces for regular discard events.

Damien Le Moal (9):
  f2fs: Add missing break in switch-case
  f2fs: Use generic zoned block device terminology
  f2fs: Check zoned block feature for host-managed zoned block devices
  f2fs: Suppress discard warning message for zoned block devices
  f2fs: Always enable discard for zoned blocks devices
  f2fs: Do not allow adaptive mode for host-managed zoned block devices
  f2fs: Cache zoned block devices zone type
  f2fs: Reset sequential zones on zoned block devices
  f2fs: Trace reset zone events

 fs/f2fs/data.c              |   2 +-
 fs/f2fs/f2fs.h              |  36 ++++++++++-----
 fs/f2fs/segment.c           |  61 +++++++++++++++++++++----
 fs/f2fs/super.c             | 106 +++++++++++++++++++++++++++++++++++++++++++-
 include/trace/events/f2fs.h |  21 +++++++++
 5 files changed, 205 insertions(+), 21 deletions(-)

-- 
2.7.4


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

* [PATCH 1/9] f2fs: Add missing break in switch-case
  2016-10-28  7:55 ` Damien Le Moal
@ 2016-10-28  7:55   ` Damien Le Moal
  -1 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 fs/f2fs/super.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 6132b4c..f6379f5 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -420,6 +420,7 @@ static int parse_options(struct super_block *sb, char *options)
 			break;
 		case Opt_nodiscard:
 			clear_opt(sbi, DISCARD);
+			break;
 		case Opt_noheap:
 			set_opt(sbi, NOHEAP);
 			break;
-- 
2.7.4


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

* [PATCH 1/9] f2fs: Add missing break in switch-case
@ 2016-10-28  7:55   ` Damien Le Moal
  0 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 fs/f2fs/super.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 6132b4c..f6379f5 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -420,6 +420,7 @@ static int parse_options(struct super_block *sb, char *options)
 			break;
 		case Opt_nodiscard:
 			clear_opt(sbi, DISCARD);
+			break;
 		case Opt_noheap:
 			set_opt(sbi, NOHEAP);
 			break;
-- 
2.7.4


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

* [PATCH 2/9] f2fs: Use generic zoned block device terminology
  2016-10-28  7:55 ` Damien Le Moal
@ 2016-10-28  7:55   ` Damien Le Moal
  -1 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

SMR stands for "Shingled Magnetic Recording" which makes sense
only for hard disk drives (spinning rust). The ZBC/ZAC standards
enable management of SMR disks, but solid state drives may also
support those standards. So rename the HMSMR feature to BLKZONED
to avoid a HDD centric terminology. For the same reason, rename
f2fs_sb_mounted_hmsmr to f2fs_sb_mounted_blkzoned.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 fs/f2fs/data.c  | 2 +-
 fs/f2fs/f2fs.h  | 6 +++---
 fs/f2fs/super.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 9ae194f..803f30f 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -110,7 +110,7 @@ static inline void __submit_bio(struct f2fs_sb_info *sbi,
 {
 	if (!is_read_io(bio_op(bio))) {
 		atomic_inc(&sbi->nr_wb_bios);
-		if (f2fs_sb_mounted_hmsmr(sbi->sb) &&
+		if (f2fs_sb_mounted_blkzoned(sbi->sb) &&
 			current->plug && (type == DATA || type == NODE))
 			blk_finish_plug(current->plug);
 	}
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 9e8de18..2fc771a 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -103,7 +103,7 @@ struct f2fs_mount_info {
 };
 
 #define F2FS_FEATURE_ENCRYPT	0x0001
-#define F2FS_FEATURE_HMSMR	0x0002
+#define F2FS_FEATURE_BLKZONED	0x0002
 
 #define F2FS_HAS_FEATURE(sb, mask)					\
 	((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0)
@@ -2412,9 +2412,9 @@ static inline int f2fs_sb_has_crypto(struct super_block *sb)
 	return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_ENCRYPT);
 }
 
-static inline int f2fs_sb_mounted_hmsmr(struct super_block *sb)
+static inline int f2fs_sb_mounted_blkzoned(struct super_block *sb)
 {
-	return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_HMSMR);
+	return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_BLKZONED);
 }
 
 static inline void set_opt_mode(struct f2fs_sb_info *sbi, unsigned int mt)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index f6379f5..a83df29 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -975,7 +975,7 @@ static void default_options(struct f2fs_sb_info *sbi)
 	set_opt(sbi, EXTENT_CACHE);
 	sbi->sb->s_flags |= MS_LAZYTIME;
 	set_opt(sbi, FLUSH_MERGE);
-	if (f2fs_sb_mounted_hmsmr(sbi->sb)) {
+	if (f2fs_sb_mounted_blkzoned(sbi->sb)) {
 		set_opt_mode(sbi, F2FS_MOUNT_LFS);
 		set_opt(sbi, DISCARD);
 	} else {
-- 
2.7.4


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

* [PATCH 2/9] f2fs: Use generic zoned block device terminology
@ 2016-10-28  7:55   ` Damien Le Moal
  0 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

SMR stands for "Shingled Magnetic Recording" which makes sense
only for hard disk drives (spinning rust). The ZBC/ZAC standards
enable management of SMR disks, but solid state drives may also
support those standards. So rename the HMSMR feature to BLKZONED
to avoid a HDD centric terminology. For the same reason, rename
f2fs_sb_mounted_hmsmr to f2fs_sb_mounted_blkzoned.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 fs/f2fs/data.c  | 2 +-
 fs/f2fs/f2fs.h  | 6 +++---
 fs/f2fs/super.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 9ae194f..803f30f 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -110,7 +110,7 @@ static inline void __submit_bio(struct f2fs_sb_info *sbi,
 {
 	if (!is_read_io(bio_op(bio))) {
 		atomic_inc(&sbi->nr_wb_bios);
-		if (f2fs_sb_mounted_hmsmr(sbi->sb) &&
+		if (f2fs_sb_mounted_blkzoned(sbi->sb) &&
 			current->plug && (type == DATA || type == NODE))
 			blk_finish_plug(current->plug);
 	}
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 9e8de18..2fc771a 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -103,7 +103,7 @@ struct f2fs_mount_info {
 };
 
 #define F2FS_FEATURE_ENCRYPT	0x0001
-#define F2FS_FEATURE_HMSMR	0x0002
+#define F2FS_FEATURE_BLKZONED	0x0002
 
 #define F2FS_HAS_FEATURE(sb, mask)					\
 	((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0)
@@ -2412,9 +2412,9 @@ static inline int f2fs_sb_has_crypto(struct super_block *sb)
 	return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_ENCRYPT);
 }
 
-static inline int f2fs_sb_mounted_hmsmr(struct super_block *sb)
+static inline int f2fs_sb_mounted_blkzoned(struct super_block *sb)
 {
-	return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_HMSMR);
+	return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_BLKZONED);
 }
 
 static inline void set_opt_mode(struct f2fs_sb_info *sbi, unsigned int mt)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index f6379f5..a83df29 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -975,7 +975,7 @@ static void default_options(struct f2fs_sb_info *sbi)
 	set_opt(sbi, EXTENT_CACHE);
 	sbi->sb->s_flags |= MS_LAZYTIME;
 	set_opt(sbi, FLUSH_MERGE);
-	if (f2fs_sb_mounted_hmsmr(sbi->sb)) {
+	if (f2fs_sb_mounted_blkzoned(sbi->sb)) {
 		set_opt_mode(sbi, F2FS_MOUNT_LFS);
 		set_opt(sbi, DISCARD);
 	} else {
-- 
2.7.4


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

* [PATCH 3/9] f2fs: Check zoned block feature for host-managed zoned block devices
  2016-10-28  7:55 ` Damien Le Moal
@ 2016-10-28  7:55   ` Damien Le Moal
  -1 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

The F2FS_FEATURE_BLKZONED feature indicates that the drive was formatted
 with zone alignment optimization. This is optional for host-aware
devices, but mandatory for host-managed zoned block devices.
So check that the feature is set in this latter case.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 fs/f2fs/super.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index a83df29..c6e9b94 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1642,6 +1642,26 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 	sb->s_fs_info = sbi;
 	sbi->raw_super = raw_super;
 
+	/*
+	 * The BLKZONED feature indicates that the drive was formatted with
+	 * zone alignment optimization. This is optional for host-aware
+	 * devices, but mandatory for host-managed zoned block devices.
+	 */
+#ifndef CONFIG_BLK_DEV_ZONED
+	if (f2fs_sb_mounted_blkzoned(sb)) {
+		f2fs_msg(sb, KERN_ERR,
+			 "Zoned block device support is not enabled\n");
+		goto free_sb_buf;
+	}
+#else
+	if (bdev_zoned_model(sb->s_bdev) == BLK_ZONED_HM &&
+	    !f2fs_sb_mounted_blkzoned(sb)) {
+		f2fs_msg(sb, KERN_ERR,
+			 "Zoned block device feature not enabled\n");
+		goto free_sb_buf;
+	}
+#endif
+
 	default_options(sbi);
 	/* parse mount options */
 	options = kstrdup((const char *)data, GFP_KERNEL);
-- 
2.7.4


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

* [PATCH 3/9] f2fs: Check zoned block feature for host-managed zoned block devices
@ 2016-10-28  7:55   ` Damien Le Moal
  0 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

The F2FS_FEATURE_BLKZONED feature indicates that the drive was formatted
 with zone alignment optimization. This is optional for host-aware
devices, but mandatory for host-managed zoned block devices.
So check that the feature is set in this latter case.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 fs/f2fs/super.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index a83df29..c6e9b94 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1642,6 +1642,26 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 	sb->s_fs_info = sbi;
 	sbi->raw_super = raw_super;
 
+	/*
+	 * The BLKZONED feature indicates that the drive was formatted with
+	 * zone alignment optimization. This is optional for host-aware
+	 * devices, but mandatory for host-managed zoned block devices.
+	 */
+#ifndef CONFIG_BLK_DEV_ZONED
+	if (f2fs_sb_mounted_blkzoned(sb)) {
+		f2fs_msg(sb, KERN_ERR,
+			 "Zoned block device support is not enabled\n");
+		goto free_sb_buf;
+	}
+#else
+	if (bdev_zoned_model(sb->s_bdev) == BLK_ZONED_HM &&
+	    !f2fs_sb_mounted_blkzoned(sb)) {
+		f2fs_msg(sb, KERN_ERR,
+			 "Zoned block device feature not enabled\n");
+		goto free_sb_buf;
+	}
+#endif
+
 	default_options(sbi);
 	/* parse mount options */
 	options = kstrdup((const char *)data, GFP_KERNEL);
-- 
2.7.4


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

* [PATCH 4/9] f2fs: Suppress discard warning message for zoned block devices
  2016-10-28  7:55 ` Damien Le Moal
@ 2016-10-28  7:55   ` Damien Le Moal
  -1 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

For zoned block devices, discard is replaced by zone reset. So
do not warn if the device does not supports discard.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 fs/f2fs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index c6e9b94..2313234 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -412,7 +412,7 @@ static int parse_options(struct super_block *sb, char *options)
 			q = bdev_get_queue(sb->s_bdev);
 			if (blk_queue_discard(q)) {
 				set_opt(sbi, DISCARD);
-			} else {
+			} else if (!f2fs_sb_mounted_blkzoned(sb)) {
 				f2fs_msg(sb, KERN_WARNING,
 					"mounting with \"discard\" option, but "
 					"the device does not support discard");
-- 
2.7.4


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

* [PATCH 4/9] f2fs: Suppress discard warning message for zoned block devices
@ 2016-10-28  7:55   ` Damien Le Moal
  0 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

For zoned block devices, discard is replaced by zone reset. So
do not warn if the device does not supports discard.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 fs/f2fs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index c6e9b94..2313234 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -412,7 +412,7 @@ static int parse_options(struct super_block *sb, char *options)
 			q = bdev_get_queue(sb->s_bdev);
 			if (blk_queue_discard(q)) {
 				set_opt(sbi, DISCARD);
-			} else {
+			} else if (!f2fs_sb_mounted_blkzoned(sb)) {
 				f2fs_msg(sb, KERN_WARNING,
 					"mounting with \"discard\" option, but "
 					"the device does not support discard");
-- 
2.7.4


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

* [PATCH 5/9] f2fs: Always enable discard for zoned blocks devices
  2016-10-28  7:55 ` Damien Le Moal
@ 2016-10-28  7:55   ` Damien Le Moal
  -1 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

Zone write pointer reset acts as discard for zoned block
devices. So if the zoned block device feature is enabled,
always declare that discard is enabled, even if the device
does not actually support the command.
For the same reason, prevent the use the "nodicard" mount
option.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 fs/f2fs/f2fs.h  | 14 +++++++-------
 fs/f2fs/super.c |  5 +++++
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 2fc771a..beb2093 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1105,13 +1105,6 @@ static inline void clear_ckpt_flags(struct f2fs_sb_info *sbi, unsigned int f)
 	spin_unlock(&sbi->cp_lock);
 }
 
-static inline bool f2fs_discard_en(struct f2fs_sb_info *sbi)
-{
-	struct request_queue *q = bdev_get_queue(sbi->sb->s_bdev);
-
-	return blk_queue_discard(q);
-}
-
 static inline void f2fs_lock_op(struct f2fs_sb_info *sbi)
 {
 	down_read(&sbi->cp_rwsem);
@@ -2417,6 +2410,13 @@ static inline int f2fs_sb_mounted_blkzoned(struct super_block *sb)
 	return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_BLKZONED);
 }
 
+static inline bool f2fs_discard_en(struct f2fs_sb_info *sbi)
+{
+	struct request_queue *q = bdev_get_queue(sbi->sb->s_bdev);
+
+	return blk_queue_discard(q) || f2fs_sb_mounted_blkzoned(sbi->sb);
+}
+
 static inline void set_opt_mode(struct f2fs_sb_info *sbi, unsigned int mt)
 {
 	clear_opt(sbi, ADAPTIVE);
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 2313234..2c8a12e 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -419,6 +419,11 @@ static int parse_options(struct super_block *sb, char *options)
 			}
 			break;
 		case Opt_nodiscard:
+			if (f2fs_sb_mounted_blkzoned(sb)) {
+				f2fs_msg(sb, KERN_WARNING,
+					"discard is required for zoned block devices");
+				return -EINVAL;
+			}
 			clear_opt(sbi, DISCARD);
 			break;
 		case Opt_noheap:
-- 
2.7.4


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

* [PATCH 5/9] f2fs: Always enable discard for zoned blocks devices
@ 2016-10-28  7:55   ` Damien Le Moal
  0 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

Zone write pointer reset acts as discard for zoned block
devices. So if the zoned block device feature is enabled,
always declare that discard is enabled, even if the device
does not actually support the command.
For the same reason, prevent the use the "nodicard" mount
option.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 fs/f2fs/f2fs.h  | 14 +++++++-------
 fs/f2fs/super.c |  5 +++++
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 2fc771a..beb2093 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1105,13 +1105,6 @@ static inline void clear_ckpt_flags(struct f2fs_sb_info *sbi, unsigned int f)
 	spin_unlock(&sbi->cp_lock);
 }
 
-static inline bool f2fs_discard_en(struct f2fs_sb_info *sbi)
-{
-	struct request_queue *q = bdev_get_queue(sbi->sb->s_bdev);
-
-	return blk_queue_discard(q);
-}
-
 static inline void f2fs_lock_op(struct f2fs_sb_info *sbi)
 {
 	down_read(&sbi->cp_rwsem);
@@ -2417,6 +2410,13 @@ static inline int f2fs_sb_mounted_blkzoned(struct super_block *sb)
 	return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_BLKZONED);
 }
 
+static inline bool f2fs_discard_en(struct f2fs_sb_info *sbi)
+{
+	struct request_queue *q = bdev_get_queue(sbi->sb->s_bdev);
+
+	return blk_queue_discard(q) || f2fs_sb_mounted_blkzoned(sbi->sb);
+}
+
 static inline void set_opt_mode(struct f2fs_sb_info *sbi, unsigned int mt)
 {
 	clear_opt(sbi, ADAPTIVE);
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 2313234..2c8a12e 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -419,6 +419,11 @@ static int parse_options(struct super_block *sb, char *options)
 			}
 			break;
 		case Opt_nodiscard:
+			if (f2fs_sb_mounted_blkzoned(sb)) {
+				f2fs_msg(sb, KERN_WARNING,
+					"discard is required for zoned block devices");
+				return -EINVAL;
+			}
 			clear_opt(sbi, DISCARD);
 			break;
 		case Opt_noheap:
-- 
2.7.4


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

* [PATCH 6/9] f2fs: Do not allow adaptive mode for host-managed zoned block devices
  2016-10-28  7:55 ` Damien Le Moal
@ 2016-10-28  7:55   ` Damien Le Moal
  -1 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

The LFS mode is mandatory for host-managed zoned block devices as
update in place optimizations are not possible for segments in
sequential zones.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 fs/f2fs/super.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 2c8a12e..58fd69d 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -518,6 +518,13 @@ static int parse_options(struct super_block *sb, char *options)
 				return -ENOMEM;
 			if (strlen(name) == 8 &&
 					!strncmp(name, "adaptive", 8)) {
+				if (f2fs_sb_mounted_blkzoned(sb)) {
+					f2fs_msg(sb, KERN_WARNING,
+						 "adaptive mode is not allowed with "
+						 "zoned block device feature");
+					kfree(name);
+					return -EINVAL;
+				}
 				set_opt_mode(sbi, F2FS_MOUNT_ADAPTIVE);
 			} else if (strlen(name) == 3 &&
 					!strncmp(name, "lfs", 3)) {
-- 
2.7.4


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

* [PATCH 6/9] f2fs: Do not allow adaptive mode for host-managed zoned block devices
@ 2016-10-28  7:55   ` Damien Le Moal
  0 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

The LFS mode is mandatory for host-managed zoned block devices as
update in place optimizations are not possible for segments in
sequential zones.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 fs/f2fs/super.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 2c8a12e..58fd69d 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -518,6 +518,13 @@ static int parse_options(struct super_block *sb, char *options)
 				return -ENOMEM;
 			if (strlen(name) == 8 &&
 					!strncmp(name, "adaptive", 8)) {
+				if (f2fs_sb_mounted_blkzoned(sb)) {
+					f2fs_msg(sb, KERN_WARNING,
+						 "adaptive mode is not allowed with "
+						 "zoned block device feature");
+					kfree(name);
+					return -EINVAL;
+				}
 				set_opt_mode(sbi, F2FS_MOUNT_ADAPTIVE);
 			} else if (strlen(name) == 3 &&
 					!strncmp(name, "lfs", 3)) {
-- 
2.7.4


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

* [PATCH 7/9] f2fs: Cache zoned block devices zone type
  2016-10-28  7:55 ` Damien Le Moal
@ 2016-10-28  7:55   ` Damien Le Moal
  -1 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

With the zoned block device feature enabled, section discard
need to do a zone reset for sections contained in sequential
zones, and a regular discard (if supported) for sections
stored in conventional zones. Avoid the need for a costly
report zones to obtain a section zone type when discarding it
by caching the types of the device zones in the super block
information. This cache is initialized at mount time for mounts
with the zoned block device feature enabled.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 fs/f2fs/f2fs.h  | 16 +++++++++++++
 fs/f2fs/super.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index beb2093..1600f4b 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -750,6 +750,14 @@ struct f2fs_sb_info {
 	u8 key_prefix[F2FS_KEY_DESC_PREFIX_SIZE];
 	u8 key_prefix_size;
 #endif
+
+#ifdef CONFIG_BLK_DEV_ZONED
+	unsigned int nr_blkz;			/* Total number of zones */
+	unsigned int blocks_per_blkz;		/* F2FS blocks per zone */
+	unsigned int log_blocks_per_blkz;	/* log2 F2FS blocks per zone */
+	u8 *blkz_type;				/* Array of zones type */
+#endif
+
 	/* for node-related operations */
 	struct f2fs_nm_info *nm_info;		/* node manager */
 	struct inode *node_inode;		/* cache node blocks */
@@ -2410,6 +2418,14 @@ static inline int f2fs_sb_mounted_blkzoned(struct super_block *sb)
 	return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_BLKZONED);
 }
 
+static inline int get_blkz_type(struct f2fs_sb_info *sbi,
+				block_t blkaddr)
+{
+	unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz;
+
+	return sbi->blkz_type[zno];
+}
+
 static inline bool f2fs_discard_en(struct f2fs_sb_info *sbi)
 {
 	struct request_queue *q = bdev_get_queue(sbi->sb->s_bdev);
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 58fd69d..dacaa1b 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1515,6 +1515,66 @@ static int init_percpu_info(struct f2fs_sb_info *sbi)
 								GFP_KERNEL);
 }
 
+static int init_blkz_info(struct f2fs_sb_info *sbi)
+{
+#ifdef CONFIG_BLK_DEV_ZONED
+	struct block_device *bdev = sbi->sb->s_bdev;
+	sector_t nr_sectors = bdev->bd_part->nr_sects;
+	sector_t sector = 0;
+	struct blk_zone *zones;
+	unsigned int i, nr_zones;
+	unsigned int n = 0;
+	int err = -EIO;
+
+	if (!f2fs_sb_mounted_blkzoned(sbi->sb))
+		return 0;
+
+	sbi->blocks_per_blkz = SECTOR_TO_BLOCK(bdev_zone_size(bdev));
+	sbi->log_blocks_per_blkz = __ilog2_u32(sbi->blocks_per_blkz);
+	sbi->nr_blkz = SECTOR_TO_BLOCK(nr_sectors) >>
+		sbi->log_blocks_per_blkz;
+	if (nr_sectors & (bdev_zone_size(bdev) - 1))
+		sbi->nr_blkz++;
+
+	sbi->blkz_type = kmalloc(sbi->nr_blkz, GFP_KERNEL);
+	if (!sbi->blkz_type)
+		return -ENOMEM;
+
+#define F2FS_REPORT_NR_ZONES   4096
+
+	zones = kcalloc(F2FS_REPORT_NR_ZONES, sizeof(struct blk_zone),
+			GFP_KERNEL);
+	if (!zones)
+		return -ENOMEM;
+
+	/* Get block zones type */
+	while (zones && sector < nr_sectors) {
+
+		nr_zones = F2FS_REPORT_NR_ZONES;
+		err = blkdev_report_zones(bdev, sector,
+					  zones, &nr_zones,
+					  GFP_KERNEL);
+		if (err)
+			break;
+		if (!nr_zones) {
+			err = -EIO;
+			break;
+		}
+
+		for (i = 0; i < nr_zones; i++) {
+			sbi->blkz_type[n] = zones[i].type;
+			sector += zones[i].len;
+			n++;
+		}
+	}
+
+	kfree(zones);
+
+	return err;
+#endif
+	return 0;
+}
+
 /*
  * Read f2fs raw super block.
  * Because we have two copies of super block, so read both of them
@@ -1761,6 +1821,13 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 
 	init_ino_entry_info(sbi);
 
+	err = init_blkz_info(sbi);
+	if (err) {
+		f2fs_msg(sb, KERN_ERR,
+			"Failed to initialize F2FS blkzone information");
+		goto free_blkz;
+	}
+
 	/* setup f2fs internal modules */
 	err = build_segment_manager(sbi);
 	if (err) {
@@ -1932,6 +1999,8 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 	destroy_node_manager(sbi);
 free_sm:
 	destroy_segment_manager(sbi);
+free_blkz:
+	kfree(sbi->blkz_type);
 	kfree(sbi->ckpt);
 free_meta_inode:
 	make_bad_inode(sbi->meta_inode);
-- 
2.7.4


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

* [PATCH 7/9] f2fs: Cache zoned block devices zone type
@ 2016-10-28  7:55   ` Damien Le Moal
  0 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

With the zoned block device feature enabled, section discard
need to do a zone reset for sections contained in sequential
zones, and a regular discard (if supported) for sections
stored in conventional zones. Avoid the need for a costly
report zones to obtain a section zone type when discarding it
by caching the types of the device zones in the super block
information. This cache is initialized at mount time for mounts
with the zoned block device feature enabled.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 fs/f2fs/f2fs.h  | 16 +++++++++++++
 fs/f2fs/super.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index beb2093..1600f4b 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -750,6 +750,14 @@ struct f2fs_sb_info {
 	u8 key_prefix[F2FS_KEY_DESC_PREFIX_SIZE];
 	u8 key_prefix_size;
 #endif
+
+#ifdef CONFIG_BLK_DEV_ZONED
+	unsigned int nr_blkz;			/* Total number of zones */
+	unsigned int blocks_per_blkz;		/* F2FS blocks per zone */
+	unsigned int log_blocks_per_blkz;	/* log2 F2FS blocks per zone */
+	u8 *blkz_type;				/* Array of zones type */
+#endif
+
 	/* for node-related operations */
 	struct f2fs_nm_info *nm_info;		/* node manager */
 	struct inode *node_inode;		/* cache node blocks */
@@ -2410,6 +2418,14 @@ static inline int f2fs_sb_mounted_blkzoned(struct super_block *sb)
 	return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_BLKZONED);
 }
 
+static inline int get_blkz_type(struct f2fs_sb_info *sbi,
+				block_t blkaddr)
+{
+	unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz;
+
+	return sbi->blkz_type[zno];
+}
+
 static inline bool f2fs_discard_en(struct f2fs_sb_info *sbi)
 {
 	struct request_queue *q = bdev_get_queue(sbi->sb->s_bdev);
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 58fd69d..dacaa1b 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1515,6 +1515,66 @@ static int init_percpu_info(struct f2fs_sb_info *sbi)
 								GFP_KERNEL);
 }
 
+static int init_blkz_info(struct f2fs_sb_info *sbi)
+{
+#ifdef CONFIG_BLK_DEV_ZONED
+	struct block_device *bdev = sbi->sb->s_bdev;
+	sector_t nr_sectors = bdev->bd_part->nr_sects;
+	sector_t sector = 0;
+	struct blk_zone *zones;
+	unsigned int i, nr_zones;
+	unsigned int n = 0;
+	int err = -EIO;
+
+	if (!f2fs_sb_mounted_blkzoned(sbi->sb))
+		return 0;
+
+	sbi->blocks_per_blkz = SECTOR_TO_BLOCK(bdev_zone_size(bdev));
+	sbi->log_blocks_per_blkz = __ilog2_u32(sbi->blocks_per_blkz);
+	sbi->nr_blkz = SECTOR_TO_BLOCK(nr_sectors) >>
+		sbi->log_blocks_per_blkz;
+	if (nr_sectors & (bdev_zone_size(bdev) - 1))
+		sbi->nr_blkz++;
+
+	sbi->blkz_type = kmalloc(sbi->nr_blkz, GFP_KERNEL);
+	if (!sbi->blkz_type)
+		return -ENOMEM;
+
+#define F2FS_REPORT_NR_ZONES   4096
+
+	zones = kcalloc(F2FS_REPORT_NR_ZONES, sizeof(struct blk_zone),
+			GFP_KERNEL);
+	if (!zones)
+		return -ENOMEM;
+
+	/* Get block zones type */
+	while (zones && sector < nr_sectors) {
+
+		nr_zones = F2FS_REPORT_NR_ZONES;
+		err = blkdev_report_zones(bdev, sector,
+					  zones, &nr_zones,
+					  GFP_KERNEL);
+		if (err)
+			break;
+		if (!nr_zones) {
+			err = -EIO;
+			break;
+		}
+
+		for (i = 0; i < nr_zones; i++) {
+			sbi->blkz_type[n] = zones[i].type;
+			sector += zones[i].len;
+			n++;
+		}
+	}
+
+	kfree(zones);
+
+	return err;
+#endif
+	return 0;
+}
+
 /*
  * Read f2fs raw super block.
  * Because we have two copies of super block, so read both of them
@@ -1761,6 +1821,13 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 
 	init_ino_entry_info(sbi);
 
+	err = init_blkz_info(sbi);
+	if (err) {
+		f2fs_msg(sb, KERN_ERR,
+			"Failed to initialize F2FS blkzone information");
+		goto free_blkz;
+	}
+
 	/* setup f2fs internal modules */
 	err = build_segment_manager(sbi);
 	if (err) {
@@ -1932,6 +1999,8 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 	destroy_node_manager(sbi);
 free_sm:
 	destroy_segment_manager(sbi);
+free_blkz:
+	kfree(sbi->blkz_type);
 	kfree(sbi->ckpt);
 free_meta_inode:
 	make_bad_inode(sbi->meta_inode);
-- 
2.7.4


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

* [PATCH 8/9] f2fs: Reset sequential zones on zoned block devices
  2016-10-28  7:55 ` Damien Le Moal
@ 2016-10-28  7:55   ` Damien Le Moal
  -1 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

When a zoned block device is mounted, discarding sections
contained in sequential zones must reset the zone write pointer.
For sections contained in conventional zones, the regular discard
is used if the drive supports it.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 fs/f2fs/segment.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 52 insertions(+), 8 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index fc886f0..bce79e2 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -633,15 +633,19 @@ static void f2fs_submit_bio_wait_endio(struct bio *bio)
 }
 
 /* this function is copied from blkdev_issue_discard from block/blk-lib.c */
-int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi, sector_t sector,
-		sector_t nr_sects, gfp_t gfp_mask, unsigned long flags)
+static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi,
+					block_t blkstart, block_t blklen)
 {
 	struct block_device *bdev = sbi->sb->s_bdev;
 	struct bio *bio = NULL;
 	int err;
 
-	err = __blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, flags,
-			&bio);
+	trace_f2fs_issue_discard(sbi->sb, blkstart, blklen);
+
+	err = __blkdev_issue_discard(bdev,
+				     SECTOR_FROM_BLOCK(blkstart),
+				     SECTOR_FROM_BLOCK(blklen),
+				     GFP_NOFS, 0, &bio);
 	if (!err && bio) {
 		struct bio_entry *be = __add_bio_entry(sbi, bio);
 
@@ -654,11 +658,48 @@ int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi, sector_t sector,
 	return err;
 }
 
+static int f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
+					block_t blkstart, block_t blklen)
+{
+	sector_t sector = SECTOR_FROM_BLOCK(blkstart);
+	sector_t nr_sects = SECTOR_FROM_BLOCK(blklen);
+	struct block_device *bdev = sbi->sb->s_bdev;
+
+	if (nr_sects != bdev_zone_size(bdev)) {
+		f2fs_msg(sbi->sb, KERN_INFO,
+			 "Unaligned discard attempted (sector %llu + %llu)",
+			 (unsigned long long)sector,
+			 (unsigned long long)nr_sects);
+		return -EIO;
+	}
+
+	/*
+	 * We need to know the type of the zone: for conventional zones,
+	 * use regular discard if the drive supports it. For sequential
+	 * zones, reset the zone write pointer.
+	 */
+	switch (get_blkz_type(sbi, blkstart)) {
+
+	case BLK_ZONE_TYPE_CONVENTIONAL:
+		if (!blk_queue_discard(bdev_get_queue(bdev)))
+			return 0;
+		return __f2fs_issue_discard_async(sbi, blkstart,
+						  blklen);
+
+	case BLK_ZONE_TYPE_SEQWRITE_REQ:
+	case BLK_ZONE_TYPE_SEQWRITE_PREF:
+		return blkdev_reset_zones(bdev, sector,
+					  nr_sects, GFP_NOFS);
+
+	default:
+		/* Unknown zone type: broken device ? */
+		return -EIO;
+	}
+}
+
 static int f2fs_issue_discard(struct f2fs_sb_info *sbi,
 				block_t blkstart, block_t blklen)
 {
-	sector_t start = SECTOR_FROM_BLOCK(blkstart);
-	sector_t len = SECTOR_FROM_BLOCK(blklen);
 	struct seg_entry *se;
 	unsigned int offset;
 	block_t i;
@@ -670,8 +711,11 @@ static int f2fs_issue_discard(struct f2fs_sb_info *sbi,
 		if (!f2fs_test_and_set_bit(offset, se->discard_map))
 			sbi->discard_blks--;
 	}
-	trace_f2fs_issue_discard(sbi->sb, blkstart, blklen);
-	return __f2fs_issue_discard_async(sbi, start, len, GFP_NOFS, 0);
+
+	if (f2fs_sb_mounted_blkzoned(sbi->sb))
+		return f2fs_issue_discard_zone(sbi, blkstart, blklen);
+
+	return __f2fs_issue_discard_async(sbi, blkstart, blklen);
 }
 
 static void __add_discard_entry(struct f2fs_sb_info *sbi,
-- 
2.7.4


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

* [PATCH 8/9] f2fs: Reset sequential zones on zoned block devices
@ 2016-10-28  7:55   ` Damien Le Moal
  0 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

When a zoned block device is mounted, discarding sections
contained in sequential zones must reset the zone write pointer.
For sections contained in conventional zones, the regular discard
is used if the drive supports it.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 fs/f2fs/segment.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 52 insertions(+), 8 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index fc886f0..bce79e2 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -633,15 +633,19 @@ static void f2fs_submit_bio_wait_endio(struct bio *bio)
 }
 
 /* this function is copied from blkdev_issue_discard from block/blk-lib.c */
-int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi, sector_t sector,
-		sector_t nr_sects, gfp_t gfp_mask, unsigned long flags)
+static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi,
+					block_t blkstart, block_t blklen)
 {
 	struct block_device *bdev = sbi->sb->s_bdev;
 	struct bio *bio = NULL;
 	int err;
 
-	err = __blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, flags,
-			&bio);
+	trace_f2fs_issue_discard(sbi->sb, blkstart, blklen);
+
+	err = __blkdev_issue_discard(bdev,
+				     SECTOR_FROM_BLOCK(blkstart),
+				     SECTOR_FROM_BLOCK(blklen),
+				     GFP_NOFS, 0, &bio);
 	if (!err && bio) {
 		struct bio_entry *be = __add_bio_entry(sbi, bio);
 
@@ -654,11 +658,48 @@ int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi, sector_t sector,
 	return err;
 }
 
+static int f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
+					block_t blkstart, block_t blklen)
+{
+	sector_t sector = SECTOR_FROM_BLOCK(blkstart);
+	sector_t nr_sects = SECTOR_FROM_BLOCK(blklen);
+	struct block_device *bdev = sbi->sb->s_bdev;
+
+	if (nr_sects != bdev_zone_size(bdev)) {
+		f2fs_msg(sbi->sb, KERN_INFO,
+			 "Unaligned discard attempted (sector %llu + %llu)",
+			 (unsigned long long)sector,
+			 (unsigned long long)nr_sects);
+		return -EIO;
+	}
+
+	/*
+	 * We need to know the type of the zone: for conventional zones,
+	 * use regular discard if the drive supports it. For sequential
+	 * zones, reset the zone write pointer.
+	 */
+	switch (get_blkz_type(sbi, blkstart)) {
+
+	case BLK_ZONE_TYPE_CONVENTIONAL:
+		if (!blk_queue_discard(bdev_get_queue(bdev)))
+			return 0;
+		return __f2fs_issue_discard_async(sbi, blkstart,
+						  blklen);
+
+	case BLK_ZONE_TYPE_SEQWRITE_REQ:
+	case BLK_ZONE_TYPE_SEQWRITE_PREF:
+		return blkdev_reset_zones(bdev, sector,
+					  nr_sects, GFP_NOFS);
+
+	default:
+		/* Unknown zone type: broken device ? */
+		return -EIO;
+	}
+}
+
 static int f2fs_issue_discard(struct f2fs_sb_info *sbi,
 				block_t blkstart, block_t blklen)
 {
-	sector_t start = SECTOR_FROM_BLOCK(blkstart);
-	sector_t len = SECTOR_FROM_BLOCK(blklen);
 	struct seg_entry *se;
 	unsigned int offset;
 	block_t i;
@@ -670,8 +711,11 @@ static int f2fs_issue_discard(struct f2fs_sb_info *sbi,
 		if (!f2fs_test_and_set_bit(offset, se->discard_map))
 			sbi->discard_blks--;
 	}
-	trace_f2fs_issue_discard(sbi->sb, blkstart, blklen);
-	return __f2fs_issue_discard_async(sbi, start, len, GFP_NOFS, 0);
+
+	if (f2fs_sb_mounted_blkzoned(sbi->sb))
+		return f2fs_issue_discard_zone(sbi, blkstart, blklen);
+
+	return __f2fs_issue_discard_async(sbi, blkstart, blklen);
 }
 
 static void __add_discard_entry(struct f2fs_sb_info *sbi,
-- 
2.7.4


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

* [PATCH 9/9] f2fs: Trace reset zone events
  2016-10-28  7:55 ` Damien Le Moal
@ 2016-10-28  7:55   ` Damien Le Moal
  -1 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

Similarly to the regular discard, trace zone reset events.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 fs/f2fs/segment.c           |  1 +
 include/trace/events/f2fs.h | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index bce79e2..064a78b 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -688,6 +688,7 @@ static int f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
 
 	case BLK_ZONE_TYPE_SEQWRITE_REQ:
 	case BLK_ZONE_TYPE_SEQWRITE_PREF:
+		trace_f2fs_issue_reset_zone(sbi->sb, blkstart);
 		return blkdev_reset_zones(bdev, sector,
 					  nr_sects, GFP_NOFS);
 
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index 903a091..a2193e3 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -1113,6 +1113,27 @@ TRACE_EVENT(f2fs_issue_discard,
 		(unsigned long long)__entry->blklen)
 );
 
+TRACE_EVENT(f2fs_issue_reset_zone,
+
+	TP_PROTO(struct super_block *sb, block_t blkstart),
+
+	TP_ARGS(sb, blkstart),
+
+	TP_STRUCT__entry(
+		__field(dev_t,	dev)
+		__field(block_t, blkstart)
+	),
+
+	TP_fast_assign(
+		__entry->dev	= sb->s_dev;
+		__entry->blkstart = blkstart;
+	),
+
+	TP_printk("dev = (%d,%d), reset zone at block = 0x%llx",
+		show_dev(__entry),
+		(unsigned long long)__entry->blkstart)
+);
+
 TRACE_EVENT(f2fs_issue_flush,
 
 	TP_PROTO(struct super_block *sb, unsigned int nobarrier,
-- 
2.7.4


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

* [PATCH 9/9] f2fs: Trace reset zone events
@ 2016-10-28  7:55   ` Damien Le Moal
  0 siblings, 0 replies; 28+ messages in thread
From: Damien Le Moal @ 2016-10-28  7:55 UTC (permalink / raw)
  To: jaegeuk, yuchao0
  Cc: linux-fsdevel, linux-f2fs-devel, Hannes Reinecke, Shaun Tancheff,
	Damien Le Moal

Similarly to the regular discard, trace zone reset events.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 fs/f2fs/segment.c           |  1 +
 include/trace/events/f2fs.h | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index bce79e2..064a78b 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -688,6 +688,7 @@ static int f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
 
 	case BLK_ZONE_TYPE_SEQWRITE_REQ:
 	case BLK_ZONE_TYPE_SEQWRITE_PREF:
+		trace_f2fs_issue_reset_zone(sbi->sb, blkstart);
 		return blkdev_reset_zones(bdev, sector,
 					  nr_sects, GFP_NOFS);
 
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index 903a091..a2193e3 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -1113,6 +1113,27 @@ TRACE_EVENT(f2fs_issue_discard,
 		(unsigned long long)__entry->blklen)
 );
 
+TRACE_EVENT(f2fs_issue_reset_zone,
+
+	TP_PROTO(struct super_block *sb, block_t blkstart),
+
+	TP_ARGS(sb, blkstart),
+
+	TP_STRUCT__entry(
+		__field(dev_t,	dev)
+		__field(block_t, blkstart)
+	),
+
+	TP_fast_assign(
+		__entry->dev	= sb->s_dev;
+		__entry->blkstart = blkstart;
+	),
+
+	TP_printk("dev = (%d,%d), reset zone at block = 0x%llx",
+		show_dev(__entry),
+		(unsigned long long)__entry->blkstart)
+);
+
 TRACE_EVENT(f2fs_issue_flush,
 
 	TP_PROTO(struct super_block *sb, unsigned int nobarrier,
-- 
2.7.4


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

* Re: [PATCH 8/9] f2fs: Reset sequential zones on zoned block devices
  2016-10-28  7:55   ` Damien Le Moal
@ 2016-10-28  8:19     ` kbuild test robot
  -1 siblings, 0 replies; 28+ messages in thread
From: kbuild test robot @ 2016-10-28  8:19 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: kbuild-all, jaegeuk, yuchao0, linux-fsdevel, linux-f2fs-devel,
	Hannes Reinecke, Shaun Tancheff, Damien Le Moal

[-- Attachment #1: Type: text/plain, Size: 4025 bytes --]

Hi Damien,

[auto build test WARNING on v4.9-rc2]
[cannot apply to f2fs/dev next-20161028]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url:    https://github.com/0day-ci/linux/commits/Damien-Le-Moal/f2fs-Zoned-block-device-support/20161028-160349
config: x86_64-randconfig-x017-201643 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   In file included from fs/f2fs/segment.c:20:0:
   fs/f2fs/f2fs.h: In function 'get_blkz_type':
   fs/f2fs/f2fs.h:2424:35: error: 'struct f2fs_sb_info' has no member named 'log_blocks_per_blkz'; did you mean 'log_blocks_per_seg'?
     unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz;
                                      ^~
   fs/f2fs/f2fs.h:2426:12: error: 'struct f2fs_sb_info' has no member named 'blkz_type'
     return sbi->blkz_type[zno];
               ^~
   In file included from include/linux/linkage.h:4:0,
                    from include/linux/fs.h:4,
                    from fs/f2fs/segment.c:11:
   fs/f2fs/segment.c: In function 'f2fs_issue_discard_zone':
   fs/f2fs/segment.c:668:18: error: implicit declaration of function 'bdev_zone_size' [-Werror=implicit-function-declaration]
     if (nr_sects != bdev_zone_size(bdev)) {
                     ^
   include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> fs/f2fs/segment.c:668:2: note: in expansion of macro 'if'
     if (nr_sects != bdev_zone_size(bdev)) {
     ^~
   fs/f2fs/segment.c:683:7: error: 'BLK_ZONE_TYPE_CONVENTIONAL' undeclared (first use in this function)
     case BLK_ZONE_TYPE_CONVENTIONAL:
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/f2fs/segment.c:683:7: note: each undeclared identifier is reported only once for each function it appears in
   fs/f2fs/segment.c:689:7: error: 'BLK_ZONE_TYPE_SEQWRITE_REQ' undeclared (first use in this function)
     case BLK_ZONE_TYPE_SEQWRITE_REQ:
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/f2fs/segment.c:690:7: error: 'BLK_ZONE_TYPE_SEQWRITE_PREF' undeclared (first use in this function)
     case BLK_ZONE_TYPE_SEQWRITE_PREF:
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/f2fs/segment.c:691:10: error: implicit declaration of function 'blkdev_reset_zones' [-Werror=implicit-function-declaration]
      return blkdev_reset_zones(bdev, sector,
             ^~~~~~~~~~~~~~~~~~
   In file included from fs/f2fs/segment.c:20:0:
   fs/f2fs/f2fs.h: In function 'get_blkz_type':
   fs/f2fs/f2fs.h:2427:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
   cc1: some warnings being treated as errors

vim +/if +668 fs/f2fs/segment.c

   652			bio->bi_private = be;
   653			bio->bi_end_io = f2fs_submit_bio_wait_endio;
   654			bio->bi_opf |= REQ_SYNC;
   655			submit_bio(bio);
   656		}
   657	
   658		return err;
   659	}
   660	
   661	static int f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
   662						block_t blkstart, block_t blklen)
   663	{
   664		sector_t sector = SECTOR_FROM_BLOCK(blkstart);
   665		sector_t nr_sects = SECTOR_FROM_BLOCK(blklen);
   666		struct block_device *bdev = sbi->sb->s_bdev;
   667	
 > 668		if (nr_sects != bdev_zone_size(bdev)) {
   669			f2fs_msg(sbi->sb, KERN_INFO,
   670				 "Unaligned discard attempted (sector %llu + %llu)",
   671				 (unsigned long long)sector,
   672				 (unsigned long long)nr_sects);
   673			return -EIO;
   674		}
   675	
   676		/*

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30300 bytes --]

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

* Re: [PATCH 8/9] f2fs: Reset sequential zones on zoned block devices
@ 2016-10-28  8:19     ` kbuild test robot
  0 siblings, 0 replies; 28+ messages in thread
From: kbuild test robot @ 2016-10-28  8:19 UTC (permalink / raw)
  Cc: kbuild-all, jaegeuk, yuchao0, linux-fsdevel, linux-f2fs-devel,
	Hannes Reinecke, Shaun Tancheff, Damien Le Moal

[-- Attachment #1: Type: text/plain, Size: 4025 bytes --]

Hi Damien,

[auto build test WARNING on v4.9-rc2]
[cannot apply to f2fs/dev next-20161028]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url:    https://github.com/0day-ci/linux/commits/Damien-Le-Moal/f2fs-Zoned-block-device-support/20161028-160349
config: x86_64-randconfig-x017-201643 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   In file included from fs/f2fs/segment.c:20:0:
   fs/f2fs/f2fs.h: In function 'get_blkz_type':
   fs/f2fs/f2fs.h:2424:35: error: 'struct f2fs_sb_info' has no member named 'log_blocks_per_blkz'; did you mean 'log_blocks_per_seg'?
     unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz;
                                      ^~
   fs/f2fs/f2fs.h:2426:12: error: 'struct f2fs_sb_info' has no member named 'blkz_type'
     return sbi->blkz_type[zno];
               ^~
   In file included from include/linux/linkage.h:4:0,
                    from include/linux/fs.h:4,
                    from fs/f2fs/segment.c:11:
   fs/f2fs/segment.c: In function 'f2fs_issue_discard_zone':
   fs/f2fs/segment.c:668:18: error: implicit declaration of function 'bdev_zone_size' [-Werror=implicit-function-declaration]
     if (nr_sects != bdev_zone_size(bdev)) {
                     ^
   include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> fs/f2fs/segment.c:668:2: note: in expansion of macro 'if'
     if (nr_sects != bdev_zone_size(bdev)) {
     ^~
   fs/f2fs/segment.c:683:7: error: 'BLK_ZONE_TYPE_CONVENTIONAL' undeclared (first use in this function)
     case BLK_ZONE_TYPE_CONVENTIONAL:
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/f2fs/segment.c:683:7: note: each undeclared identifier is reported only once for each function it appears in
   fs/f2fs/segment.c:689:7: error: 'BLK_ZONE_TYPE_SEQWRITE_REQ' undeclared (first use in this function)
     case BLK_ZONE_TYPE_SEQWRITE_REQ:
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/f2fs/segment.c:690:7: error: 'BLK_ZONE_TYPE_SEQWRITE_PREF' undeclared (first use in this function)
     case BLK_ZONE_TYPE_SEQWRITE_PREF:
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/f2fs/segment.c:691:10: error: implicit declaration of function 'blkdev_reset_zones' [-Werror=implicit-function-declaration]
      return blkdev_reset_zones(bdev, sector,
             ^~~~~~~~~~~~~~~~~~
   In file included from fs/f2fs/segment.c:20:0:
   fs/f2fs/f2fs.h: In function 'get_blkz_type':
   fs/f2fs/f2fs.h:2427:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
   cc1: some warnings being treated as errors

vim +/if +668 fs/f2fs/segment.c

   652			bio->bi_private = be;
   653			bio->bi_end_io = f2fs_submit_bio_wait_endio;
   654			bio->bi_opf |= REQ_SYNC;
   655			submit_bio(bio);
   656		}
   657	
   658		return err;
   659	}
   660	
   661	static int f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
   662						block_t blkstart, block_t blklen)
   663	{
   664		sector_t sector = SECTOR_FROM_BLOCK(blkstart);
   665		sector_t nr_sects = SECTOR_FROM_BLOCK(blklen);
   666		struct block_device *bdev = sbi->sb->s_bdev;
   667	
 > 668		if (nr_sects != bdev_zone_size(bdev)) {
   669			f2fs_msg(sbi->sb, KERN_INFO,
   670				 "Unaligned discard attempted (sector %llu + %llu)",
   671				 (unsigned long long)sector,
   672				 (unsigned long long)nr_sects);
   673			return -EIO;
   674		}
   675	
   676		/*

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30300 bytes --]

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

* Re: [PATCH 7/9] f2fs: Cache zoned block devices zone type
  2016-10-28  7:55   ` Damien Le Moal
@ 2016-10-28  8:48     ` kbuild test robot
  -1 siblings, 0 replies; 28+ messages in thread
From: kbuild test robot @ 2016-10-28  8:48 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: kbuild-all, jaegeuk, yuchao0, linux-fsdevel, linux-f2fs-devel,
	Hannes Reinecke, Shaun Tancheff, Damien Le Moal

[-- Attachment #1: Type: text/plain, Size: 2492 bytes --]

Hi Damien,

[auto build test ERROR on v4.9-rc2]
[also build test ERROR on next-20161028]
[cannot apply to f2fs/dev]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url:    https://github.com/0day-ci/linux/commits/Damien-Le-Moal/f2fs-Zoned-block-device-support/20161028-160349
config: x86_64-randconfig-x014-201643 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   In file included from fs/f2fs/dir.c:13:0:
   fs/f2fs/f2fs.h: In function 'get_blkz_type':
>> fs/f2fs/f2fs.h:2424:35: error: 'struct f2fs_sb_info' has no member named 'log_blocks_per_blkz'; did you mean 'log_blocks_per_seg'?
     unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz;
                                      ^~
>> fs/f2fs/f2fs.h:2426:12: error: 'struct f2fs_sb_info' has no member named 'blkz_type'
     return sbi->blkz_type[zno];
               ^~
--
   In file included from fs/f2fs/super.c:28:0:
   fs/f2fs/f2fs.h: In function 'get_blkz_type':
>> fs/f2fs/f2fs.h:2424:35: error: 'struct f2fs_sb_info' has no member named 'log_blocks_per_blkz'; did you mean 'log_blocks_per_seg'?
     unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz;
                                      ^~
>> fs/f2fs/f2fs.h:2426:12: error: 'struct f2fs_sb_info' has no member named 'blkz_type'
     return sbi->blkz_type[zno];
               ^~
   fs/f2fs/super.c: In function 'f2fs_fill_super':
>> fs/f2fs/super.c:2003:11: error: 'struct f2fs_sb_info' has no member named 'blkz_type'
     kfree(sbi->blkz_type);
              ^~

vim +2424 fs/f2fs/f2fs.h

  2418		return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_BLKZONED);
  2419	}
  2420	
  2421	static inline int get_blkz_type(struct f2fs_sb_info *sbi,
  2422					block_t blkaddr)
  2423	{
> 2424		unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz;
  2425	
> 2426		return sbi->blkz_type[zno];
  2427	}
  2428	
  2429	static inline bool f2fs_discard_en(struct f2fs_sb_info *sbi)

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32223 bytes --]

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

* Re: [PATCH 7/9] f2fs: Cache zoned block devices zone type
@ 2016-10-28  8:48     ` kbuild test robot
  0 siblings, 0 replies; 28+ messages in thread
From: kbuild test robot @ 2016-10-28  8:48 UTC (permalink / raw)
  Cc: kbuild-all, jaegeuk, yuchao0, linux-fsdevel, linux-f2fs-devel,
	Hannes Reinecke, Shaun Tancheff, Damien Le Moal

[-- Attachment #1: Type: text/plain, Size: 2492 bytes --]

Hi Damien,

[auto build test ERROR on v4.9-rc2]
[also build test ERROR on next-20161028]
[cannot apply to f2fs/dev]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url:    https://github.com/0day-ci/linux/commits/Damien-Le-Moal/f2fs-Zoned-block-device-support/20161028-160349
config: x86_64-randconfig-x014-201643 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   In file included from fs/f2fs/dir.c:13:0:
   fs/f2fs/f2fs.h: In function 'get_blkz_type':
>> fs/f2fs/f2fs.h:2424:35: error: 'struct f2fs_sb_info' has no member named 'log_blocks_per_blkz'; did you mean 'log_blocks_per_seg'?
     unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz;
                                      ^~
>> fs/f2fs/f2fs.h:2426:12: error: 'struct f2fs_sb_info' has no member named 'blkz_type'
     return sbi->blkz_type[zno];
               ^~
--
   In file included from fs/f2fs/super.c:28:0:
   fs/f2fs/f2fs.h: In function 'get_blkz_type':
>> fs/f2fs/f2fs.h:2424:35: error: 'struct f2fs_sb_info' has no member named 'log_blocks_per_blkz'; did you mean 'log_blocks_per_seg'?
     unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz;
                                      ^~
>> fs/f2fs/f2fs.h:2426:12: error: 'struct f2fs_sb_info' has no member named 'blkz_type'
     return sbi->blkz_type[zno];
               ^~
   fs/f2fs/super.c: In function 'f2fs_fill_super':
>> fs/f2fs/super.c:2003:11: error: 'struct f2fs_sb_info' has no member named 'blkz_type'
     kfree(sbi->blkz_type);
              ^~

vim +2424 fs/f2fs/f2fs.h

  2418		return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_BLKZONED);
  2419	}
  2420	
  2421	static inline int get_blkz_type(struct f2fs_sb_info *sbi,
  2422					block_t blkaddr)
  2423	{
> 2424		unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz;
  2425	
> 2426		return sbi->blkz_type[zno];
  2427	}
  2428	
  2429	static inline bool f2fs_discard_en(struct f2fs_sb_info *sbi)

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32223 bytes --]

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

* Re: [PATCH 8/9] f2fs: Reset sequential zones on zoned block devices
  2016-10-28  7:55   ` Damien Le Moal
@ 2016-10-28  9:02     ` kbuild test robot
  -1 siblings, 0 replies; 28+ messages in thread
From: kbuild test robot @ 2016-10-28  9:02 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: kbuild-all, jaegeuk, yuchao0, linux-fsdevel, linux-f2fs-devel,
	Hannes Reinecke, Shaun Tancheff, Damien Le Moal

[-- Attachment #1: Type: text/plain, Size: 4010 bytes --]

Hi Damien,

[auto build test ERROR on v4.9-rc2]
[cannot apply to f2fs/dev next-20161028]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url:    https://github.com/0day-ci/linux/commits/Damien-Le-Moal/f2fs-Zoned-block-device-support/20161028-160349
config: x86_64-randconfig-x014-201643 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

   In file included from fs/f2fs/segment.c:20:0:
   fs/f2fs/f2fs.h: In function 'get_blkz_type':
   fs/f2fs/f2fs.h:2424:35: error: 'struct f2fs_sb_info' has no member named 'log_blocks_per_blkz'; did you mean 'log_blocks_per_seg'?
     unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz;
                                      ^~
   fs/f2fs/f2fs.h:2426:12: error: 'struct f2fs_sb_info' has no member named 'blkz_type'
     return sbi->blkz_type[zno];
               ^~
   fs/f2fs/segment.c: In function 'f2fs_issue_discard_zone':
>> fs/f2fs/segment.c:668:18: error: implicit declaration of function 'bdev_zone_size' [-Werror=implicit-function-declaration]
     if (nr_sects != bdev_zone_size(bdev)) {
                     ^~~~~~~~~~~~~~
>> fs/f2fs/segment.c:683:7: error: 'BLK_ZONE_TYPE_CONVENTIONAL' undeclared (first use in this function)
     case BLK_ZONE_TYPE_CONVENTIONAL:
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/f2fs/segment.c:683:7: note: each undeclared identifier is reported only once for each function it appears in
>> fs/f2fs/segment.c:689:7: error: 'BLK_ZONE_TYPE_SEQWRITE_REQ' undeclared (first use in this function)
     case BLK_ZONE_TYPE_SEQWRITE_REQ:
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
>> fs/f2fs/segment.c:690:7: error: 'BLK_ZONE_TYPE_SEQWRITE_PREF' undeclared (first use in this function)
     case BLK_ZONE_TYPE_SEQWRITE_PREF:
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>> fs/f2fs/segment.c:691:10: error: implicit declaration of function 'blkdev_reset_zones' [-Werror=implicit-function-declaration]
      return blkdev_reset_zones(bdev, sector,
             ^~~~~~~~~~~~~~~~~~
   In file included from fs/f2fs/segment.c:20:0:
   fs/f2fs/f2fs.h: In function 'get_blkz_type':
>> fs/f2fs/f2fs.h:2427:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
   cc1: some warnings being treated as errors

vim +/bdev_zone_size +668 fs/f2fs/segment.c

   662						block_t blkstart, block_t blklen)
   663	{
   664		sector_t sector = SECTOR_FROM_BLOCK(blkstart);
   665		sector_t nr_sects = SECTOR_FROM_BLOCK(blklen);
   666		struct block_device *bdev = sbi->sb->s_bdev;
   667	
 > 668		if (nr_sects != bdev_zone_size(bdev)) {
   669			f2fs_msg(sbi->sb, KERN_INFO,
   670				 "Unaligned discard attempted (sector %llu + %llu)",
   671				 (unsigned long long)sector,
   672				 (unsigned long long)nr_sects);
   673			return -EIO;
   674		}
   675	
   676		/*
   677		 * We need to know the type of the zone: for conventional zones,
   678		 * use regular discard if the drive supports it. For sequential
   679		 * zones, reset the zone write pointer.
   680		 */
   681		switch (get_blkz_type(sbi, blkstart)) {
   682	
 > 683		case BLK_ZONE_TYPE_CONVENTIONAL:
   684			if (!blk_queue_discard(bdev_get_queue(bdev)))
   685				return 0;
   686			return __f2fs_issue_discard_async(sbi, blkstart,
   687							  blklen);
   688	
 > 689		case BLK_ZONE_TYPE_SEQWRITE_REQ:
 > 690		case BLK_ZONE_TYPE_SEQWRITE_PREF:
 > 691			return blkdev_reset_zones(bdev, sector,
   692						  nr_sects, GFP_NOFS);
   693	
   694		default:

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32223 bytes --]

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

* Re: [PATCH 8/9] f2fs: Reset sequential zones on zoned block devices
@ 2016-10-28  9:02     ` kbuild test robot
  0 siblings, 0 replies; 28+ messages in thread
From: kbuild test robot @ 2016-10-28  9:02 UTC (permalink / raw)
  Cc: kbuild-all, jaegeuk, yuchao0, linux-fsdevel, linux-f2fs-devel,
	Hannes Reinecke, Shaun Tancheff, Damien Le Moal

[-- Attachment #1: Type: text/plain, Size: 4010 bytes --]

Hi Damien,

[auto build test ERROR on v4.9-rc2]
[cannot apply to f2fs/dev next-20161028]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url:    https://github.com/0day-ci/linux/commits/Damien-Le-Moal/f2fs-Zoned-block-device-support/20161028-160349
config: x86_64-randconfig-x014-201643 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

   In file included from fs/f2fs/segment.c:20:0:
   fs/f2fs/f2fs.h: In function 'get_blkz_type':
   fs/f2fs/f2fs.h:2424:35: error: 'struct f2fs_sb_info' has no member named 'log_blocks_per_blkz'; did you mean 'log_blocks_per_seg'?
     unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz;
                                      ^~
   fs/f2fs/f2fs.h:2426:12: error: 'struct f2fs_sb_info' has no member named 'blkz_type'
     return sbi->blkz_type[zno];
               ^~
   fs/f2fs/segment.c: In function 'f2fs_issue_discard_zone':
>> fs/f2fs/segment.c:668:18: error: implicit declaration of function 'bdev_zone_size' [-Werror=implicit-function-declaration]
     if (nr_sects != bdev_zone_size(bdev)) {
                     ^~~~~~~~~~~~~~
>> fs/f2fs/segment.c:683:7: error: 'BLK_ZONE_TYPE_CONVENTIONAL' undeclared (first use in this function)
     case BLK_ZONE_TYPE_CONVENTIONAL:
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/f2fs/segment.c:683:7: note: each undeclared identifier is reported only once for each function it appears in
>> fs/f2fs/segment.c:689:7: error: 'BLK_ZONE_TYPE_SEQWRITE_REQ' undeclared (first use in this function)
     case BLK_ZONE_TYPE_SEQWRITE_REQ:
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
>> fs/f2fs/segment.c:690:7: error: 'BLK_ZONE_TYPE_SEQWRITE_PREF' undeclared (first use in this function)
     case BLK_ZONE_TYPE_SEQWRITE_PREF:
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>> fs/f2fs/segment.c:691:10: error: implicit declaration of function 'blkdev_reset_zones' [-Werror=implicit-function-declaration]
      return blkdev_reset_zones(bdev, sector,
             ^~~~~~~~~~~~~~~~~~
   In file included from fs/f2fs/segment.c:20:0:
   fs/f2fs/f2fs.h: In function 'get_blkz_type':
>> fs/f2fs/f2fs.h:2427:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
   cc1: some warnings being treated as errors

vim +/bdev_zone_size +668 fs/f2fs/segment.c

   662						block_t blkstart, block_t blklen)
   663	{
   664		sector_t sector = SECTOR_FROM_BLOCK(blkstart);
   665		sector_t nr_sects = SECTOR_FROM_BLOCK(blklen);
   666		struct block_device *bdev = sbi->sb->s_bdev;
   667	
 > 668		if (nr_sects != bdev_zone_size(bdev)) {
   669			f2fs_msg(sbi->sb, KERN_INFO,
   670				 "Unaligned discard attempted (sector %llu + %llu)",
   671				 (unsigned long long)sector,
   672				 (unsigned long long)nr_sects);
   673			return -EIO;
   674		}
   675	
   676		/*
   677		 * We need to know the type of the zone: for conventional zones,
   678		 * use regular discard if the drive supports it. For sequential
   679		 * zones, reset the zone write pointer.
   680		 */
   681		switch (get_blkz_type(sbi, blkstart)) {
   682	
 > 683		case BLK_ZONE_TYPE_CONVENTIONAL:
   684			if (!blk_queue_discard(bdev_get_queue(bdev)))
   685				return 0;
   686			return __f2fs_issue_discard_async(sbi, blkstart,
   687							  blklen);
   688	
 > 689		case BLK_ZONE_TYPE_SEQWRITE_REQ:
 > 690		case BLK_ZONE_TYPE_SEQWRITE_PREF:
 > 691			return blkdev_reset_zones(bdev, sector,
   692						  nr_sects, GFP_NOFS);
   693	
   694		default:

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32223 bytes --]

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

* Re: [PATCH 8/9] f2fs: Reset sequential zones on zoned block devices
  2016-10-28  7:55   ` Damien Le Moal
@ 2016-10-28  9:38     ` kbuild test robot
  -1 siblings, 0 replies; 28+ messages in thread
From: kbuild test robot @ 2016-10-28  9:38 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: kbuild-all, jaegeuk, yuchao0, linux-fsdevel, linux-f2fs-devel,
	Hannes Reinecke, Shaun Tancheff, Damien Le Moal

Hi Damien,

[auto build test WARNING on v4.9-rc2]
[cannot apply to f2fs/dev next-20161028]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url:    https://github.com/0day-ci/linux/commits/Damien-Le-Moal/f2fs-Zoned-block-device-support/20161028-160349
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

   include/linux/compiler.h:253:8: sparse: attribute 'no_sanitize_address': unknown attribute
   fs/f2fs/segment.c:668:25: sparse: undefined identifier 'bdev_zone_size'
   fs/f2fs/f2fs.h:2424:42: sparse: no member 'log_blocks_per_blkz' in struct f2fs_sb_info
   fs/f2fs/f2fs.h:2426:19: sparse: no member 'blkz_type' in struct f2fs_sb_info
   fs/f2fs/segment.c:683:14: sparse: undefined identifier 'BLK_ZONE_TYPE_CONVENTIONAL'
   fs/f2fs/segment.c:689:14: sparse: undefined identifier 'BLK_ZONE_TYPE_SEQWRITE_REQ'
   fs/f2fs/segment.c:690:14: sparse: undefined identifier 'BLK_ZONE_TYPE_SEQWRITE_PREF'
   fs/f2fs/segment.c:691:24: sparse: undefined identifier 'blkdev_reset_zones'
>> fs/f2fs/segment.c:683:14: sparse: incompatible types for 'case' statement
   fs/f2fs/segment.c:689:14: sparse: incompatible types for 'case' statement
   fs/f2fs/segment.c:690:14: sparse: incompatible types for 'case' statement
   fs/f2fs/segment.c:683:14: sparse: Expected constant expression in case statement
   fs/f2fs/segment.c:689:14: sparse: Expected constant expression in case statement
   fs/f2fs/segment.c:690:14: sparse: Expected constant expression in case statement
   In file included from fs/f2fs/segment.c:20:0:
   fs/f2fs/f2fs.h: In function 'get_blkz_type':
   fs/f2fs/f2fs.h:2424:35: error: 'struct f2fs_sb_info' has no member named 'log_blocks_per_blkz'; did you mean 'log_blocks_per_seg'?
     unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz;
                                      ^~
   fs/f2fs/f2fs.h:2426:12: error: 'struct f2fs_sb_info' has no member named 'blkz_type'
     return sbi->blkz_type[zno];
               ^~
   fs/f2fs/segment.c: In function 'f2fs_issue_discard_zone':
   fs/f2fs/segment.c:668:18: error: implicit declaration of function 'bdev_zone_size' [-Werror=implicit-function-declaration]
     if (nr_sects != bdev_zone_size(bdev)) {
                     ^~~~~~~~~~~~~~
   fs/f2fs/segment.c:683:7: error: 'BLK_ZONE_TYPE_CONVENTIONAL' undeclared (first use in this function)
     case BLK_ZONE_TYPE_CONVENTIONAL:
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/f2fs/segment.c:683:7: note: each undeclared identifier is reported only once for each function it appears in
   fs/f2fs/segment.c:689:7: error: 'BLK_ZONE_TYPE_SEQWRITE_REQ' undeclared (first use in this function)
     case BLK_ZONE_TYPE_SEQWRITE_REQ:
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/f2fs/segment.c:690:7: error: 'BLK_ZONE_TYPE_SEQWRITE_PREF' undeclared (first use in this function)
     case BLK_ZONE_TYPE_SEQWRITE_PREF:
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/f2fs/segment.c:691:10: error: implicit declaration of function 'blkdev_reset_zones' [-Werror=implicit-function-declaration]
      return blkdev_reset_zones(bdev, sector,
             ^~~~~~~~~~~~~~~~~~
   In file included from fs/f2fs/segment.c:20:0:
   fs/f2fs/f2fs.h: In function 'get_blkz_type':
   fs/f2fs/f2fs.h:2427:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
   cc1: some warnings being treated as errors

vim +/case +683 fs/f2fs/segment.c

   662						block_t blkstart, block_t blklen)
   663	{
   664		sector_t sector = SECTOR_FROM_BLOCK(blkstart);
   665		sector_t nr_sects = SECTOR_FROM_BLOCK(blklen);
   666		struct block_device *bdev = sbi->sb->s_bdev;
   667	
 > 668		if (nr_sects != bdev_zone_size(bdev)) {
   669			f2fs_msg(sbi->sb, KERN_INFO,
   670				 "Unaligned discard attempted (sector %llu + %llu)",
   671				 (unsigned long long)sector,
   672				 (unsigned long long)nr_sects);
   673			return -EIO;
   674		}
   675	
   676		/*
   677		 * We need to know the type of the zone: for conventional zones,
   678		 * use regular discard if the drive supports it. For sequential
   679		 * zones, reset the zone write pointer.
   680		 */
   681		switch (get_blkz_type(sbi, blkstart)) {
   682	
 > 683		case BLK_ZONE_TYPE_CONVENTIONAL:
   684			if (!blk_queue_discard(bdev_get_queue(bdev)))
   685				return 0;
   686			return __f2fs_issue_discard_async(sbi, blkstart,

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

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

* Re: [PATCH 8/9] f2fs: Reset sequential zones on zoned block devices
@ 2016-10-28  9:38     ` kbuild test robot
  0 siblings, 0 replies; 28+ messages in thread
From: kbuild test robot @ 2016-10-28  9:38 UTC (permalink / raw)
  Cc: kbuild-all, jaegeuk, yuchao0, linux-fsdevel, linux-f2fs-devel,
	Hannes Reinecke, Shaun Tancheff, Damien Le Moal

Hi Damien,

[auto build test WARNING on v4.9-rc2]
[cannot apply to f2fs/dev next-20161028]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url:    https://github.com/0day-ci/linux/commits/Damien-Le-Moal/f2fs-Zoned-block-device-support/20161028-160349
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

   include/linux/compiler.h:253:8: sparse: attribute 'no_sanitize_address': unknown attribute
   fs/f2fs/segment.c:668:25: sparse: undefined identifier 'bdev_zone_size'
   fs/f2fs/f2fs.h:2424:42: sparse: no member 'log_blocks_per_blkz' in struct f2fs_sb_info
   fs/f2fs/f2fs.h:2426:19: sparse: no member 'blkz_type' in struct f2fs_sb_info
   fs/f2fs/segment.c:683:14: sparse: undefined identifier 'BLK_ZONE_TYPE_CONVENTIONAL'
   fs/f2fs/segment.c:689:14: sparse: undefined identifier 'BLK_ZONE_TYPE_SEQWRITE_REQ'
   fs/f2fs/segment.c:690:14: sparse: undefined identifier 'BLK_ZONE_TYPE_SEQWRITE_PREF'
   fs/f2fs/segment.c:691:24: sparse: undefined identifier 'blkdev_reset_zones'
>> fs/f2fs/segment.c:683:14: sparse: incompatible types for 'case' statement
   fs/f2fs/segment.c:689:14: sparse: incompatible types for 'case' statement
   fs/f2fs/segment.c:690:14: sparse: incompatible types for 'case' statement
   fs/f2fs/segment.c:683:14: sparse: Expected constant expression in case statement
   fs/f2fs/segment.c:689:14: sparse: Expected constant expression in case statement
   fs/f2fs/segment.c:690:14: sparse: Expected constant expression in case statement
   In file included from fs/f2fs/segment.c:20:0:
   fs/f2fs/f2fs.h: In function 'get_blkz_type':
   fs/f2fs/f2fs.h:2424:35: error: 'struct f2fs_sb_info' has no member named 'log_blocks_per_blkz'; did you mean 'log_blocks_per_seg'?
     unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz;
                                      ^~
   fs/f2fs/f2fs.h:2426:12: error: 'struct f2fs_sb_info' has no member named 'blkz_type'
     return sbi->blkz_type[zno];
               ^~
   fs/f2fs/segment.c: In function 'f2fs_issue_discard_zone':
   fs/f2fs/segment.c:668:18: error: implicit declaration of function 'bdev_zone_size' [-Werror=implicit-function-declaration]
     if (nr_sects != bdev_zone_size(bdev)) {
                     ^~~~~~~~~~~~~~
   fs/f2fs/segment.c:683:7: error: 'BLK_ZONE_TYPE_CONVENTIONAL' undeclared (first use in this function)
     case BLK_ZONE_TYPE_CONVENTIONAL:
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/f2fs/segment.c:683:7: note: each undeclared identifier is reported only once for each function it appears in
   fs/f2fs/segment.c:689:7: error: 'BLK_ZONE_TYPE_SEQWRITE_REQ' undeclared (first use in this function)
     case BLK_ZONE_TYPE_SEQWRITE_REQ:
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/f2fs/segment.c:690:7: error: 'BLK_ZONE_TYPE_SEQWRITE_PREF' undeclared (first use in this function)
     case BLK_ZONE_TYPE_SEQWRITE_PREF:
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/f2fs/segment.c:691:10: error: implicit declaration of function 'blkdev_reset_zones' [-Werror=implicit-function-declaration]
      return blkdev_reset_zones(bdev, sector,
             ^~~~~~~~~~~~~~~~~~
   In file included from fs/f2fs/segment.c:20:0:
   fs/f2fs/f2fs.h: In function 'get_blkz_type':
   fs/f2fs/f2fs.h:2427:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
   cc1: some warnings being treated as errors

vim +/case +683 fs/f2fs/segment.c

   662						block_t blkstart, block_t blklen)
   663	{
   664		sector_t sector = SECTOR_FROM_BLOCK(blkstart);
   665		sector_t nr_sects = SECTOR_FROM_BLOCK(blklen);
   666		struct block_device *bdev = sbi->sb->s_bdev;
   667	
 > 668		if (nr_sects != bdev_zone_size(bdev)) {
   669			f2fs_msg(sbi->sb, KERN_INFO,
   670				 "Unaligned discard attempted (sector %llu + %llu)",
   671				 (unsigned long long)sector,
   672				 (unsigned long long)nr_sects);
   673			return -EIO;
   674		}
   675	
   676		/*
   677		 * We need to know the type of the zone: for conventional zones,
   678		 * use regular discard if the drive supports it. For sequential
   679		 * zones, reset the zone write pointer.
   680		 */
   681		switch (get_blkz_type(sbi, blkstart)) {
   682	
 > 683		case BLK_ZONE_TYPE_CONVENTIONAL:
   684			if (!blk_queue_discard(bdev_get_queue(bdev)))
   685				return 0;
   686			return __f2fs_issue_discard_async(sbi, blkstart,

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

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

end of thread, other threads:[~2016-10-28  9:39 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-28  7:55 [PATCH 0/9] f2fs: Zoned block device support Damien Le Moal
2016-10-28  7:55 ` Damien Le Moal
2016-10-28  7:55 ` [PATCH 1/9] f2fs: Add missing break in switch-case Damien Le Moal
2016-10-28  7:55   ` Damien Le Moal
2016-10-28  7:55 ` [PATCH 2/9] f2fs: Use generic zoned block device terminology Damien Le Moal
2016-10-28  7:55   ` Damien Le Moal
2016-10-28  7:55 ` [PATCH 3/9] f2fs: Check zoned block feature for host-managed zoned block devices Damien Le Moal
2016-10-28  7:55   ` Damien Le Moal
2016-10-28  7:55 ` [PATCH 4/9] f2fs: Suppress discard warning message for " Damien Le Moal
2016-10-28  7:55   ` Damien Le Moal
2016-10-28  7:55 ` [PATCH 5/9] f2fs: Always enable discard for zoned blocks devices Damien Le Moal
2016-10-28  7:55   ` Damien Le Moal
2016-10-28  7:55 ` [PATCH 6/9] f2fs: Do not allow adaptive mode for host-managed zoned block devices Damien Le Moal
2016-10-28  7:55   ` Damien Le Moal
2016-10-28  7:55 ` [PATCH 7/9] f2fs: Cache zoned block devices zone type Damien Le Moal
2016-10-28  7:55   ` Damien Le Moal
2016-10-28  8:48   ` kbuild test robot
2016-10-28  8:48     ` kbuild test robot
2016-10-28  7:55 ` [PATCH 8/9] f2fs: Reset sequential zones on zoned block devices Damien Le Moal
2016-10-28  7:55   ` Damien Le Moal
2016-10-28  8:19   ` kbuild test robot
2016-10-28  8:19     ` kbuild test robot
2016-10-28  9:02   ` kbuild test robot
2016-10-28  9:02     ` kbuild test robot
2016-10-28  9:38   ` kbuild test robot
2016-10-28  9:38     ` kbuild test robot
2016-10-28  7:55 ` [PATCH 9/9] f2fs: Trace reset zone events Damien Le Moal
2016-10-28  7:55   ` Damien Le Moal

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.