linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [f2fs-tools][PATCH] Throw an error when zone device info not found
@ 2019-08-01  1:26 Surbhi Palande
  2019-08-01  1:47 ` Chao Yu
  2019-08-01  2:56 ` Damien Le Moal
  0 siblings, 2 replies; 7+ messages in thread
From: Surbhi Palande @ 2019-08-01  1:26 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Surbhi Palande, Jaegeuk Kim, Damien Le Moal

From: Surbhi Palande <csurbhi@gmail.com>

When the -m option is specified to format a Zoned device,
do not fall back to the non-zoned mode in case information
about the device is not found.

Explicitly specify this error to the user.

Signed-off-by: Surbhi Palande <csurbhi@gmail.com>
---
 lib/libf2fs.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 6b5badf..2ea405e 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -16,6 +16,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <libgen.h>
 #ifdef HAVE_MNTENT_H
 #include <mntent.h>
 #endif
@@ -1140,7 +1141,12 @@ int f2fs_get_device_info(void)
 		c.segs_per_sec = c.zone_blocks / DEFAULT_BLOCKS_PER_SEGMENT;
 		c.secs_per_zone = 1;
 	} else {
-		c.zoned_mode = 0;
+		if(c.zoned_mode != 0) {
+			MSG(0, "\n Error: %s is not zoned (-m option)", c.devices[0].path);
+			MSG(1, "\n /sys/block/%s/queue/zoned not found \n",
+					basename(c.devices[0].path));
+			return -1;
+		}
 	}
 
 	c.segs_per_zone = c.segs_per_sec * c.secs_per_zone;
-- 
2.20.1



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

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

* Re: [f2fs-dev] [f2fs-tools][PATCH] Throw an error when zone device info not found
  2019-08-01  1:26 [f2fs-dev] [f2fs-tools][PATCH] Throw an error when zone device info not found Surbhi Palande
@ 2019-08-01  1:47 ` Chao Yu
  2019-08-01  2:56 ` Damien Le Moal
  1 sibling, 0 replies; 7+ messages in thread
From: Chao Yu @ 2019-08-01  1:47 UTC (permalink / raw)
  To: Surbhi Palande, linux-f2fs-devel
  Cc: Surbhi Palande, Jaegeuk Kim, Damien Le Moal

Hi Surbhi,

This patch looks good to me, unless we'd better change patch title a little as
"libf2fs: throw an ...." to indicate which part of f2fs we patched.

Anyway, please add below tag in your next version:

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

BTW, I notice that your name of email address is cool! Very suitable for f2fs
patch submission. ;)

Thanks,

On 2019/8/1 9:26, Surbhi Palande wrote:
> From: Surbhi Palande <csurbhi@gmail.com>
> 
> When the -m option is specified to format a Zoned device,
> do not fall back to the non-zoned mode in case information
> about the device is not found.
> 
> Explicitly specify this error to the user.
> 
> Signed-off-by: Surbhi Palande <csurbhi@gmail.com>
> ---
>  lib/libf2fs.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/libf2fs.c b/lib/libf2fs.c
> index 6b5badf..2ea405e 100644
> --- a/lib/libf2fs.c
> +++ b/lib/libf2fs.c
> @@ -16,6 +16,7 @@
>  #include <errno.h>
>  #include <unistd.h>
>  #include <fcntl.h>
> +#include <libgen.h>
>  #ifdef HAVE_MNTENT_H
>  #include <mntent.h>
>  #endif
> @@ -1140,7 +1141,12 @@ int f2fs_get_device_info(void)
>  		c.segs_per_sec = c.zone_blocks / DEFAULT_BLOCKS_PER_SEGMENT;
>  		c.secs_per_zone = 1;
>  	} else {
> -		c.zoned_mode = 0;
> +		if(c.zoned_mode != 0) {
> +			MSG(0, "\n Error: %s is not zoned (-m option)", c.devices[0].path);
> +			MSG(1, "\n /sys/block/%s/queue/zoned not found \n",
> +					basename(c.devices[0].path));
> +			return -1;
> +		}
>  	}
>  
>  	c.segs_per_zone = c.segs_per_sec * c.secs_per_zone;
> 


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

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

* Re: [f2fs-dev] [f2fs-tools][PATCH] Throw an error when zone device info not found
  2019-08-01  1:26 [f2fs-dev] [f2fs-tools][PATCH] Throw an error when zone device info not found Surbhi Palande
  2019-08-01  1:47 ` Chao Yu
@ 2019-08-01  2:56 ` Damien Le Moal
  2019-08-02  2:47   ` [f2fs-dev] [f2fs-tools][PATCH] libf2fs: Throw an error when zone dev " Surbhi Palande
       [not found]   ` <CAMBkX3cF9aQ28rJ2XYZRjfyYXNWBREmc9nZqgqMtimM2eHsEXQ@mail.gmail.com>
  1 sibling, 2 replies; 7+ messages in thread
From: Damien Le Moal @ 2019-08-01  2:56 UTC (permalink / raw)
  To: Surbhi Palande, linux-f2fs-devel; +Cc: Surbhi Palande, Jaegeuk Kim

On 2019/08/01 10:26, Surbhi Palande wrote:
> From: Surbhi Palande <csurbhi@gmail.com>
> 
> When the -m option is specified to format a Zoned device,
> do not fall back to the non-zoned mode in case information
> about the device is not found.
> 
> Explicitly specify this error to the user.
> 
> Signed-off-by: Surbhi Palande <csurbhi@gmail.com>
> ---
>  lib/libf2fs.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/libf2fs.c b/lib/libf2fs.c
> index 6b5badf..2ea405e 100644
> --- a/lib/libf2fs.c
> +++ b/lib/libf2fs.c
> @@ -16,6 +16,7 @@
>  #include <errno.h>
>  #include <unistd.h>
>  #include <fcntl.h>
> +#include <libgen.h>
>  #ifdef HAVE_MNTENT_H
>  #include <mntent.h>
>  #endif
> @@ -1140,7 +1141,12 @@ int f2fs_get_device_info(void)
>  		c.segs_per_sec = c.zone_blocks / DEFAULT_BLOCKS_PER_SEGMENT;
>  		c.secs_per_zone = 1;
>  	} else {
> -		c.zoned_mode = 0;
> +		if(c.zoned_mode != 0) {
> +			MSG(0, "\n Error: %s is not zoned (-m option)", c.devices[0].path);

May be spell out "is not a zoned block device" to be clear ?

> +			MSG(1, "\n /sys/block/%s/queue/zoned not found \n",
> +					basename(c.devices[0].path));

If this file does not exist, then the kernel is simply too old. It does not
necessarily mean that the device is not a zoned block device. It simply mean
that the device type cannot be determined. And if "zoned" file exist and says
"none", this message would be confusing. So maybe remove it ?

> +			return -1;
> +		}
>  	}
>  
>  	c.segs_per_zone = c.segs_per_sec * c.secs_per_zone;
> 

-- 
Damien Le Moal
Western Digital Research


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

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

* [f2fs-dev] [f2fs-tools][PATCH] libf2fs: Throw an error when zone dev info not found
  2019-08-01  2:56 ` Damien Le Moal
@ 2019-08-02  2:47   ` Surbhi Palande
  2019-08-02  3:19     ` Damien Le Moal
  2019-08-02  3:42     ` Chao Yu
       [not found]   ` <CAMBkX3cF9aQ28rJ2XYZRjfyYXNWBREmc9nZqgqMtimM2eHsEXQ@mail.gmail.com>
  1 sibling, 2 replies; 7+ messages in thread
From: Surbhi Palande @ 2019-08-02  2:47 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Surbhi Palande, Jaegeuk Kim, Damien Le Moal

From: Surbhi Palande <csurbhi@gmail.com>

When the -m option is specified to format a Zoned device,
do not fall back to the non-zoned mode in case information
about the device is not found.

Explicitly specify this error to the user.

Signed-off-by: Surbhi Palande <csurbhi@gmail.com>
---
 lib/libf2fs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 6b5badf..4966dee 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -16,6 +16,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <libgen.h>
 #ifdef HAVE_MNTENT_H
 #include <mntent.h>
 #endif
@@ -1140,7 +1141,11 @@ int f2fs_get_device_info(void)
 		c.segs_per_sec = c.zone_blocks / DEFAULT_BLOCKS_PER_SEGMENT;
 		c.secs_per_zone = 1;
 	} else {
-		c.zoned_mode = 0;
+		if(c.zoned_mode != 0) {
+			MSG(0, "\n Error: %s may not be a zoned block device \n",
+					c.devices[0].path);
+			return -1;
+		}
 	}
 
 	c.segs_per_zone = c.segs_per_sec * c.secs_per_zone;
-- 
2.20.1



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

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

* Re: [f2fs-dev] [f2fs-tools][PATCH] libf2fs: Throw an error when zone dev info not found
  2019-08-02  2:47   ` [f2fs-dev] [f2fs-tools][PATCH] libf2fs: Throw an error when zone dev " Surbhi Palande
@ 2019-08-02  3:19     ` Damien Le Moal
  2019-08-02  3:42     ` Chao Yu
  1 sibling, 0 replies; 7+ messages in thread
From: Damien Le Moal @ 2019-08-02  3:19 UTC (permalink / raw)
  To: Surbhi Palande, linux-f2fs-devel; +Cc: Surbhi Palande, Jaegeuk Kim

On 2019/08/02 11:48, Surbhi Palande wrote:
> From: Surbhi Palande <csurbhi@gmail.com>
> 
> When the -m option is specified to format a Zoned device,
> do not fall back to the non-zoned mode in case information
> about the device is not found.
> 
> Explicitly specify this error to the user.
> 
> Signed-off-by: Surbhi Palande <csurbhi@gmail.com>
> ---
>  lib/libf2fs.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/libf2fs.c b/lib/libf2fs.c
> index 6b5badf..4966dee 100644
> --- a/lib/libf2fs.c
> +++ b/lib/libf2fs.c
> @@ -16,6 +16,7 @@
>  #include <errno.h>
>  #include <unistd.h>
>  #include <fcntl.h>
> +#include <libgen.h>
>  #ifdef HAVE_MNTENT_H
>  #include <mntent.h>
>  #endif
> @@ -1140,7 +1141,11 @@ int f2fs_get_device_info(void)
>  		c.segs_per_sec = c.zone_blocks / DEFAULT_BLOCKS_PER_SEGMENT;
>  		c.secs_per_zone = 1;
>  	} else {
> -		c.zoned_mode = 0;
> +		if(c.zoned_mode != 0) {
> +			MSG(0, "\n Error: %s may not be a zoned block device \n",
> +					c.devices[0].path);
> +			return -1;
> +		}
>  	}
>  
>  	c.segs_per_zone = c.segs_per_sec * c.secs_per_zone;
> 

Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>

-- 
Damien Le Moal
Western Digital Research


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

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

* Re: [f2fs-dev] [f2fs-tools][PATCH] Throw an error when zone device info not found
       [not found]   ` <CAMBkX3cF9aQ28rJ2XYZRjfyYXNWBREmc9nZqgqMtimM2eHsEXQ@mail.gmail.com>
@ 2019-08-02  3:32     ` Damien Le Moal
  0 siblings, 0 replies; 7+ messages in thread
From: Damien Le Moal @ 2019-08-02  3:32 UTC (permalink / raw)
  To: Surbhi Palande; +Cc: Jaegeuk Kim, linux-f2fs-devel

On 2019/08/02 11:53, Surbhi Palande wrote:
> Hi Damien,
> 
> I have resent the patch making the suggested corrections.
> 
> I cannot see the "/sys/block/%s/queue/zoned" link being formed when I create a
> partition on the HM-SMR drive using fdisk.

There is no sysfs /sys/block entries for partition block devices. This is normal.

> I can see this for the entire drive but not for the partition created.
> 
> How can one format f2fs on a zoned partition?

Good point. For a partition device, a little gymnastic is necessary to get to
the containing device sysfs block attributes and get the zoned model, as well as
any other parameter. This code is indeed currently lacking from libf2fs_zoned.c
and so formatting f2fs on a partition of a zoned block device will not work.
libblkid has helpers to get a container block device from a partition. This is
not hard to implement.

But we did not implement it because partitioning a zoned block device is not the
typical use case. Several other reasons too:
1) Partitioning tools do not support zoned block devices currently. I.e writing
the backup GPT partition table entries at the end of the disk would hit a
sequential zones, so the writing needs to be special to end at the end of the
device LBA range.
2) f2fs needs conventional zones and these zones are generally all starting from
sector 0. So these zones can be assigned to the first partition, but remaining
partitions would only have sequential zones, preventing formatting with f2fs.
Using dm-linear to split both conventional zones and sequential zones into
different smaller drives is a far better solution for creating multiple FS
volumes on a single disk.

All of the above can of course be fixed. The kernel already accept partitions on
zoned block devices and will check zone alignment of partitions. But the
remaining bits in user space (gparted etc) need patching. And f2fslib_zoned.c
needs some more work too.

But again, partitions are really not the typical use case for large SMR disks,
so this is all low priority on our todo list as we have not received any request
for such support.

Best regards.

-- 
Damien Le Moal
Western Digital Research


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

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

* Re: [f2fs-dev] [f2fs-tools][PATCH] libf2fs: Throw an error when zone dev info not found
  2019-08-02  2:47   ` [f2fs-dev] [f2fs-tools][PATCH] libf2fs: Throw an error when zone dev " Surbhi Palande
  2019-08-02  3:19     ` Damien Le Moal
@ 2019-08-02  3:42     ` Chao Yu
  1 sibling, 0 replies; 7+ messages in thread
From: Chao Yu @ 2019-08-02  3:42 UTC (permalink / raw)
  To: Surbhi Palande, linux-f2fs-devel
  Cc: Surbhi Palande, Jaegeuk Kim, Damien Le Moal

On 2019/8/2 10:47, Surbhi Palande wrote:
> From: Surbhi Palande <csurbhi@gmail.com>
> 
> When the -m option is specified to format a Zoned device,
> do not fall back to the non-zoned mode in case information
> about the device is not found.
> 
> Explicitly specify this error to the user.
> 
> Signed-off-by: Surbhi Palande <csurbhi@gmail.com>

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

Thanks,


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

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

end of thread, other threads:[~2019-08-02  3:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-01  1:26 [f2fs-dev] [f2fs-tools][PATCH] Throw an error when zone device info not found Surbhi Palande
2019-08-01  1:47 ` Chao Yu
2019-08-01  2:56 ` Damien Le Moal
2019-08-02  2:47   ` [f2fs-dev] [f2fs-tools][PATCH] libf2fs: Throw an error when zone dev " Surbhi Palande
2019-08-02  3:19     ` Damien Le Moal
2019-08-02  3:42     ` Chao Yu
     [not found]   ` <CAMBkX3cF9aQ28rJ2XYZRjfyYXNWBREmc9nZqgqMtimM2eHsEXQ@mail.gmail.com>
2019-08-02  3:32     ` [f2fs-dev] [f2fs-tools][PATCH] Throw an error when zone device " Damien Le Moal

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).