Throw an error when zone device info not found
PATCH 1/1 Throw an error when zone device info not found
From: Surbhi Palande <[email protected]>
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.
--- lib/libf2fs.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
lib/libf2fs.c +7 -1
@@ -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;
Signature · 8 lines
2.20.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
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:
BTW, I notice that your name of email address is cool! Very suitable for f2fs patch submission. ;)
Thanks,
Quoted 30 lines · Surbhi Palande
From: Surbhi Palande <[email protected]>
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 <[email protected]>--- lib/libf2fs.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)lib/libf2fs.c +1
-0@@ -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 {
lib/libf2fs.c int f2fs_get_device_info(void) · line 1152
Quoted 10 lines
lib/libf2fs.c +6
-1- 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 26 lines · Surbhi Palande
From: Surbhi Palande <[email protected]>
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 <[email protected]>--- lib/libf2fs.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)lib/libf2fs.c +1
-0@@ -16,6 +16,7 @@#include <errno.h> #include <unistd.h> #include <fcntl.h> +#include <libgen.h> #ifdef HAVE_MNTENT_H #include <mntent.h> #endif
lib/libf2fs.c int f2fs_get_device_info(void) · line 1145
Quoted 6 lines
lib/libf2fs.c +2
-1@@ -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 ?
lib/libf2fs.c int f2fs_get_device_info(void) · line 1147
Quoted 2 lines
lib/libf2fs.c +2
-0+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 ?
Quoted 6 lines
lib/libf2fs.c +2
-0+return -1 ; + } } c.segs_per_zone = c.segs_per_sec * c.secs_per_zone;
Signature · 8 lines
Damien Le Moal Western Digital Research _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
PATCH 1/1 libf2fs: Throw an error when zone dev info not found
From: Surbhi Palande <[email protected]>
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.
--- lib/libf2fs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
lib/libf2fs.c +6 -1
@@ -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;
Signature · 8 lines
2.20.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [f2fs-tools][PATCH] libf2fs: Throw an error when zone dev info not found
Quoted 29 lines · Surbhi Palande
From: Surbhi Palande <[email protected]>
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 <[email protected]>--- lib/libf2fs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)lib/libf2fs.c +1
-0@@ -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 ;
lib/libf2fs.c int f2fs_get_device_info(void) · line 1151
Quoted 10 lines
lib/libf2fs.c +5
-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;
Signature · 8 lines
Damien Le Moal Western Digital Research _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [f2fs-tools][PATCH] libf2fs: Throw an error when zone dev info not found
In reply to Surbhi PalandeQuoted 9 lines · Surbhi Palande
From: Surbhi Palande <[email protected]>
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 <[email protected]>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 6 lines · Surbhi Palande
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.
Quoted 3 lines
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.
Signature · 8 lines
Damien Le Moal Western Digital Research _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel