Add blkzonecmd and blkreport ZAC/ZBC drives
Subsystems (2)
PATCH v3 1/1 Add blkzonecmd and blkreport ZAC/ZBC drives
This patch adds:
- blkreset to issue Reset (Write Pointer) zone commands
- blkreport to retrieve drive zone information
---
Changes for v3:
- Renamed get_zone_size -> blkdev_chunk_sectors
- Use blkdev_get_sectors instead of open coded BLKGETSIZE64 (fixes broken byte to sector shift).
Changes for v2:
- Configure changes to require linux/blkzoned.h [Linux v4.10]
- Cleanup of man pages
- Removed redundant fall-back for missing linux/blkzoned.h
- Removed unused report option (not yet implemented by Linux kernel.
- Change report length to be (maximum) number of zones returned.
--- .gitignore | 2 + configure.ac | 11 +++ include/strutils.h | 2 + lib/strutils.c | 7 +- sys-utils/Makemodule.am | 17 ++++ sys-utils/blkreport.8 | 68 ++++++++++++++ sys-utils/blkreport.c | 245 ++++++++++++++++++++++++++++++++++++++++++++++++ sys-utils/blkreset.8 | 61 ++++++++++++ sys-utils/blkreset.c | 190 +++++++++++++++++++++++++++++++++++++ 9 files changed, 598 insertions(+), 5 deletions(-) create mode 100644 sys-utils/blkreport.8 create mode 100644 sys-utils/blkreport.c create mode 100644 sys-utils/blkreset.8 create mode 100644 sys-utils/blkreset.c
.gitignore +2 -0
@@ -62,6 +62,8 @@ update.log /addpart /agetty /blkdiscard +/blkreport +/blkreset /blkid /blockdev /cal
configure.ac +11 -0
@@ -276,6 +276,8 @@ AC_CHECK_HEADERS([security/pam_misc.h], #endif ]) +AC_CHECK_HEADERS([linux/blkzoned.h]) + AC_CHECK_HEADERS([security/openpam.h], [], [], [ #ifdef HAVE_SECURITY_PAM_APPL_H #include <security/pam_appl.h>
@@ -288,6 +290,7 @@ AC_CHECK_HEADERS([langinfo.h], dnl Convert some ac_cv_header_* variables to have_* dnl +have_linux_blkzoned_h=$ac_cv_header_linux_blkzoned_h have_linux_btrfs_h=$ac_cv_header_linux_btrfs_h have_linux_raw_h=$ac_cv_header_linux_raw_h have_linux_securebits_h=$ac_cv_header_linux_securebits_h
@@ -1564,6 +1567,14 @@ UL_BUILD_INIT([blkdiscard], [check]) UL_REQUIRES_LINUX([blkdiscard]) AM_CONDITIONAL([BUILD_BLKDISCARD], [test "x$build_blkdiscard" = xyes]) +UL_BUILD_INIT([blkreport], [check]) +UL_REQUIRES_HAVE([blkreport], [linux_blkzoned_h], [linux/blkzoned.h header]) +AM_CONDITIONAL([BUILD_BLKREPORT], [test "x$build_blkreport" = xyes]) + +UL_BUILD_INIT([blkreset], [check]) +UL_REQUIRES_HAVE([blkreset], [linux_blkzoned_h], [linux/blkzoned.h header]) +AM_CONDITIONAL([BUILD_BLKRESET], [test "x$build_blkreset" = xyes]) + UL_BUILD_INIT([ldattach], [check]) UL_REQUIRES_LINUX([ldattach]) AM_CONDITIONAL([BUILD_LDATTACH], [test "x$build_ldattach" = xyes])
include/strutils.h +2 -0
@@ -26,10 +26,12 @@ extern uint16_t strtox16_or_err(const char *str, const char *errmesg);extern int32_t strtos32_or_err (const char *str,const char *errmesg);extern uint32_t strtou32_or_err (const char *str,const char *errmesg);extern uint32_t strtox32_or_err (const char *str,const char *errmesg); +extern uint32_t _strtou32_or_err (const char *str,const char *errmesg,int base);extern int64_t strtos64_or_err (const char *str,const char *errmesg);extern uint64_t strtou64_or_err (const char *str,const char *errmesg);extern uint64_t strtox64_or_err (const char *str,const char *errmesg); +extern uint64_t _strtou64_or_err (const char *str,const char *errmesg,int base);extern double strtod_or_err (const char *str,const char *errmesg);
lib/strutils.c +2 -5
@@ -264,9 +264,6 @@ char *strndup(const char *s, size_t n) }#endif -static uint32_t _strtou32_or_err (const char *str,const char *errmesg,int base); -static uint64_t _strtou64_or_err (const char *str,const char *errmesg,int base); -int16_t strtos16_or_err (const char *str,const char *errmesg) {int32_t num =strtos32_or_err (str, errmesg);
@@ -310,7 +307,7 @@ int32_t strtos32_or_err(const char *str, const char *errmesg)return num; } -static uint32_t _strtou32_or_err (const char *str,const char *errmesg,int base) +uint32_t _strtou32_or_err (const char *str,const char *errmesg,int base) {uint64_t num =_strtou64_or_err (str, errmesg, base);
@@ -352,7 +349,7 @@ err:errx (STRTOXX_EXIT_CODE ,"%s: '%s'" , errmesg, str); } -static uint64_t _strtou64_or_err (const char *str,const char *errmesg,int base) +uint64_t _strtou64_or_err (const char *str,const char *errmesg,int base) {uintmax_t num;char *end =NULL ;
sys-utils/Makemodule.am +17 -0
@@ -126,6 +126,23 @@ blkdiscard_SOURCES = sys-utils/blkdiscard.c lib/monotonic.c blkdiscard_LDADD = $(LDADD) libcommon.la $(REALTIME_LIBS) endif +if BUILD_BLKREPORT +sbin_PROGRAMS += blkreport +dist_man_MANS += sys-utils/blkreport.8 +blkreport_SOURCES = sys-utils/blkreport.c +blkreport_LDADD = $(LDADD) libcommon.la $(REALTIME_LIBS) +endif + +if BUILD_BLKRESET +sbin_PROGRAMS += blkreset +dist_man_MANS += sys-utils/blkreset.8 +blkreset_SOURCES = sys-utils/blkreset.c +blkreset_LDADD = $(LDADD) libcommon.la $(REALTIME_LIBS) +if HAVE_UDEV +blkreset_LDADD += -ludev +endif +endif + if BUILD_LDATTACH usrsbin_exec_PROGRAMS += ldattach dist_man_MANS += sys-utils/ldattach.8
sys-utils/blkreport.8 new file +68 -0
68 lines not on this page · raw message
sys-utils/blkreport.c new file +245 -0
245 lines not on this page · raw message
sys-utils/blkreset.8 new file +61 -0
61 lines not on this page · raw message
sys-utils/blkreset.c new file +190 -0
190 lines not on this page · raw message
Signature · 1 line
2.7.4
Karel Zak
maintainerQuoted 9 lines · Shaun Tancheff
.gitignore | 2 + configure.ac | 11 +++ include/strutils.h | 2 + lib/strutils.c | 7 +- sys-utils/Makemodule.am | 17 ++++ sys-utils/blkreport.8 | 68 ++++++++++++++ sys-utils/blkreport.c | 245 ++++++++++++++++++++++++++++++++++++++++++++++++ sys-utils/blkreset.8 | 61 ++++++++++++ sys-utils/blkreset.c | 190 +++++++++++++++++++++++++++++++++++++
Applied with some changes (see below), thanks.
Please, please "git pull" and test it!
I have no HW to do any tests (but I have free space for a new disk in my workstation -- you know Seagate, right? :-)) Or is it possible to test for example by scsi_debug?
Quoted 1 line
+blkreset_LDADD += -ludev
Fixed, unnecessary.
Quoted 2 lines
+.BR \-z , " \-\-zone \fIoffset", " \-\-offset \fIoffset" +.BR \-c , " \-\-count \fIcount", " \-\-length \fIcount"
Fixed. I don't think we want to use aliases for the options (and one of the utils had the aliases only in man page). I have modified man pages and code to support
--zone <offset>
--count <length>
only.
Quoted 1 line
+#include "
monotonic.h"
Copy & past I guess ;-) Unnecessary. Fixed.
sys-utils/blkreport.c line 136
Quoted 7 lines
sys-utils/blkreport.c new file +7
-0+fputs (USAGE_OPTIONS , out); +fputs (_ (" -z, --zone <num> zone lba in 512 byte sectors\n" +" --offset <num> zone lba in 512 byte sectors\n" +" -c, --count <num> maximum number of zones in report\n" +" --length <num> maximum number of zones in report\n" +" -v, --verbose print aligned length and offset" ), + out);
Fixed.
sys-utils/blkreport.c line 190
Quoted 8 lines
sys-utils/blkreport.c new file +8
-0+case 'c' : + length =_strtou32_or_err (optarg, +_ ("failed to parse report count" ),0 ); +break ; +case 'z' : + offset =_strtou64_or_err (optarg, +_ ("failed to parse zone offset" ),0 ); +break ;
The function strtou64_or_err() does not support size suffixes. Fixed and replaced with strtosize_or_err().
sys-utils/blkreport.c line 222
Quoted 5 lines
sys-utils/blkreport.c new file +5
-0+ +if (ioctl (fd,BLKGETSIZE64 , &blksize)) +err (EXIT_FAILURE ,_ ("%s: BLKGETSIZE64 ioctl failed" ), path); +if (ioctl (fd,BLKSSZGET , &secsize)) +err (EXIT_FAILURE ,_ ("%s: BLKSSZGET ioctl failed" ), path);
replaced with blkdev.h functions (like you did in blkreset.c).
sys-utils/blkreset.c line 176
Quoted 7 lines
sys-utils/blkreset.c new file +7
-0+/* check offset alignment to the chunk size */ +if (zsector & (zsize -1 )) +errx (EXIT_FAILURE ,_ ("%s: zone %" PRIu64" is not aligned " +"to zone size %" PRIu64), path, zsector, zsize); +if (zsector > blksectors) +errx (EXIT_FAILURE ,_ ("%s: zone %" PRIu64" is too large " +"for device %" PRIu64), path, zsector, blksectors);
It seems nowhere (blkreset and blkreport) we check if
offset + length <= blksectors
it means we don't check the end of the area, I guess the end has to be within the block device.
Maybe we can add this if() to the code, objections?
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Damien Le Moal
Tested-byKarel, Shaun,
Tested on SAS and SATA host-managed drive. No problems detected. A few remarks though:
1) The term "lba" is being used throughout (command description and error messages). This is confusing when using 4K drives. Since in fact the unit used for the arguments and displayed results is the traditional 512B "sector", I think that "LBA" should be replaced by "sector" is all messages, command argument descriptions and man pages.
2) In kernel, the offset passed to the zone reset ioctl is indeed checked for alignment to the drive LBA size. So checking the offset passed to blkreset makes sense. However, the same check for report is a little too harsh since the kernel will accept an unaligned sector number (it will be aligned down to the containing zone start sector before issuing a report zones command to the drive). So we could get rid of that check I think.
Otherwise, please feel free to add:
Best regards.
Quoted 88 lines · Karel Zak
Quoted 9 lines · Shaun Tancheff
.gitignore | 2 + configure.ac | 11 +++ include/strutils.h | 2 + lib/strutils.c | 7 +- sys-utils/Makemodule.am | 17 ++++ sys-utils/blkreport.8 | 68 ++++++++++++++ sys-utils/blkreport.c | 245 ++++++++++++++++++++++++++++++++++++++++++++++++ sys-utils/blkreset.8 | 61 ++++++++++++ sys-utils/blkreset.c | 190 +++++++++++++++++++++++++++++++++++++Applied with some changes (see below), thanks.
Please, please "git pull" and test it!
I have no HW to do any tests (but I have free space for a new disk in my workstation -- you know Seagate, right? :-)) Or is it possible to test for example by
scsi_debug?Quoted 1 line
+blkreset_LDADD += -ludev
Fixed, unnecessary.
Quoted 2 lines
+.BR \-z , " \-\-zone \fIoffset", " \-\-offset \fIoffset" +.BR \-c , " \-\-count \fIcount", " \-\-length \fIcount"
Fixed. I don't think we want to use aliases for the options (and one of the utils had the aliases only in man page). I have modified man pages and code to support
--zone <offset>
--count <length>only.
Quoted 1 line
+#include "
monotonic.h"Copy & past I guess ;-) Unnecessary. Fixed.
sys-utils/blkreport.c line 136
Quoted 7 lines
sys-utils/blkreport.c new file +7
-0+fputs (USAGE_OPTIONS , out); +fputs (_ (" -z, --zone <num> zone lba in 512 byte sectors\n" +" --offset <num> zone lba in 512 byte sectors\n" +" -c, --count <num> maximum number of zones in report\n" +" --length <num> maximum number of zones in report\n" +" -v, --verbose print aligned length and offset" ), + out);Fixed.
sys-utils/blkreport.c line 190
Quoted 8 lines
sys-utils/blkreport.c new file +8
-0+case 'c' : + length =_strtou32_or_err (optarg, +_ ("failed to parse report count" ),0 ); +break ; +case 'z' : + offset =_strtou64_or_err (optarg, +_ ("failed to parse zone offset" ),0 ); +break ;The function
strtou64_or_err()does not support size suffixes. Fixed and replaced withstrtosize_or_err().sys-utils/blkreport.c line 222
Quoted 5 lines
sys-utils/blkreport.c new file +5
-0+ +if (ioctl (fd,BLKGETSIZE64 , &blksize)) +err (EXIT_FAILURE ,_ ("%s: BLKGETSIZE64 ioctl failed" ), path); +if (ioctl (fd,BLKSSZGET , &secsize)) +err (EXIT_FAILURE ,_ ("%s: BLKSSZGET ioctl failed" ), path);replaced with
blkdev.hfunctions (like you did inblkreset.c).sys-utils/blkreset.c line 176
Quoted 7 lines
sys-utils/blkreset.c new file +7
-0+/* check offset alignment to the chunk size */ +if (zsector & (zsize -1 )) +errx (EXIT_FAILURE ,_ ("%s: zone %" PRIu64" is not aligned " +"to zone size %" PRIu64), path, zsector, zsize); +if (zsector > blksectors) +errx (EXIT_FAILURE ,_ ("%s: zone %" PRIu64" is too large " +"for device %" PRIu64), path, zsector, blksectors);It seems nowhere (blkreset and blkreport) we check if
offset + length <= blksectors
it means we don't check the end of the area, I guess the end has to be within the block device.
Maybe we can add this
if()to the code, objections?Karel
Signature · 8 lines
Damien Le Moal, Ph.D. Sr. Manager, System Software Research Group, Western Digital Corporation [email protected] (+81) 0466-98-3593 (ext. 513593) 1 kirihara-cho, Fujisawa, Kanagawa, 252-0888 Japan www.wdc.com, www.hgst.com
Karel Zak
maintainerQuoted 10 lines · Damien Le Moal
Karel, Shaun,
Tested on SAS and SATA host-managed drive. No problems detected. A few remarks though:
1) The term "lba" is being used throughout (command description and error messages). This is confusing when using 4K drives. Since in fact the unit used for the arguments and displayed results is the traditional 512B "sector", I think that "LBA" should be replaced by "sector" is all messages, command argument descriptions and man pages.
Fixed.
Quoted 7 lines
2) In kernel, the offset passed to the zone reset ioctl is indeed checked for alignment to the drive LBA size. So checking the offset passed to blkreset makes sense. However, the same check for report is a little too harsh since the kernel will accept an unaligned sector number (it will be aligned down to the containing zone start sector before issuing a report zones command to the drive). So we could get rid of that check I think.
Fixed.
Quoted 2 lines
Otherwise, please feel free to add:
Tested-by Damien Le Moal <[email protected]>
Thanks.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Karel Zak
maintainerHi,
Quoted 2 lines · Shaun Tancheff
- blkreset to issue Reset (Write Pointer) zone commands
- blkreport to retrieve drive zone information
Shaun and Damien, what about to merge all to the 'blkzone' command? Something like:
blkzone report [--zone <offset>] [--count <length>] blkzone reset [--zone <offset>] [--count <length>]
if there is no objection I'll do it today or tomorrow.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Karel,
I am ok with merging.
One command to remember instead of two :)
And actually, we can in the future add open, close and finish this way too = when/if the ioctls are added to the kernel (no use for now so not added in = initial support).
Thanks !
Damien Le Moal
On Feb 16, 2017, at 19:33, Karel Zak <[email protected]> wrote:
Hi,
Quoted 3 lines · Shaun Tancheff
- blkreset to issue Reset (Write Pointer) zone commands
- blkreport to retrieve drive zone information
Shaun and Damien, what about to merge all to the 'blkzone' command? Something like:
blkzone report [--zone <offset>] [--count <length>] blkzone reset [--zone <offset>] [--count <length>]
if there is no objection I'll do it today or tomorrow.
Karel
-- =
Karel Zak <[email protected]>
http://karelzak.blogspot.com
Western Digital Corporation (and its subsidiaries) E-mail Confidentiality N= otice & Disclaimer:
This e-mail and any files transmitted with it may contain confidential or l= egally privileged information of WDC and/or its affiliates, and are intende= d solely for the use of the individual or entity to which they are addresse= d. If you are not the intended recipient, any disclosure, copying, distribu= tion or any action taken or omitted to be taken in reliance on it, is prohi= bited. If you have received this e-mail in error, please notify the sender = immediately and delete the e-mail in its entirety from your system.
Quoted 2 lines · Karel Zak
blkzone report [--zone <offset>] [--count <length>] blkzone reset [--zone <offset>] [--count <length>]
"blkzone --zone" feels a bit strange. I would suggest:
blkzone <command> [--offset <sector>] [--count <number>]
Benno
Signature · 1 line
http://www.fastmail.com - Same, same, but different...
Benno,
Quoted 8 lines · Benno Schulenberg
Quoted 2 lines · Karel Zak
blkzone report [--zone <offset>] [--count <length>] blkzone reset [--zone <offset>] [--count <length>]
"blkzone --zone" feels a bit strange. I would suggest:
blkzone <command> [--offset <sector>] [--count <number>]
Indeed, it is a little awkward. And to be consistent with other tools such as blkdiscard, I would also suggest --length instead of --count.
So:
blkzone report [--offset <offset>] [--length <length>] blkzone reset [--offset <offset>] [--length <length>]
Best regards.
Signature · 8 lines
Damien Le Moal, Ph.D. Sr. Manager, System Software Research Group, Western Digital Corporation [email protected] (+81) 0466-98-3593 (ext. 513593) 1 kirihara-cho, Fujisawa, Kanagawa, 252-0888 Japan www.wdc.com, www.hgst.com
Karel Zak
maintainerQuoted 12 lines · Damien Le Moal
Benno,
Quoted 8 lines · Benno Schulenberg
Quoted 2 lines · Karel Zak
blkzone report [--zone <offset>] [--count <length>] blkzone reset [--zone <offset>] [--count <length>]
"blkzone --zone" feels a bit strange. I would suggest:
blkzone <command> [--offset <sector>] [--count <number>]
Quoted 7 lines
Indeed, it is a little awkward. And to be consistent with other tools such as blkdiscard, I would also suggest --length instead of --count.
So:
blkzone report [--offset <offset>] [--length <length>] blkzone reset [--offset <offset>] [--length <length>]
blkzone(8) implemented, blkreset and blkreport removed.
Please, retest and review:
https://github.com/karelzak/util-linux/blob/master/sys-utils/blkzone.c
https://github.com/karelzak/util-linux/blob/master/sys-utils/blkzone.8
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Karel,
Please find attached 3 patches.
1) To be consistent with blkdiscard behavior, reset all zones of the device when length
is not specified.
2) Similarly, for report, report all zones of the device is length is unspecified on the command line.
3) Improve wording to match more closely the standards. ALos add "0x" to printed values to make it clear that these are hex.
Please review and let me know if you need more testing.
Best regards.
--
Damien Le Moal, Ph.D.
Sr. Manager, System Software Research Group, Western Digital [email protected]<mailto:[email protected]> (+81) 0466-98-3593 (ext. 513593)
1 kirihara-cho, Fujisawa,
Kanagawa, 252-0888 Japan
www.wdc.com, www.hgst.com
From: Karel Zak <[email protected]>
Date: Friday, February 24, 2017 at 01:33
To: Damien Le Moal <[email protected]>
Cc: Benno Schulenberg <[email protected]>, Shaun Tancheff <[email protected]>, Util-Linux <[email protected]>, Van Assche Bart <[email protected]>
Subject: Re: [PATCH v3] Add blkzonecmd and blkreport ZAC/ZBC drives
On Fri, Feb 17, 2017 at 09:12:29AM +0900, Damien Le Moal wrote:
Benno,
Quoted 8 lines · Benno Schulenberg
Quoted 2 lines · Karel Zak
blkzone report [--zone <offset>] [--count <length>] blkzone reset [--zone <offset>] [--count <length>]
"blkzone --zone" feels a bit strange. I would suggest:
blkzone <command> [--offset <sector>] [--count <number>]
Indeed, it is a little awkward. And to be consistent with other tools such as blkdiscard, I would also suggest --length instead of --count. So:
blkzone report [--offset <offset>] [--length <length>] blkzone reset [--offset <offset>] [--length <length>]
blkzone(8) implemented, blkreset and blkreport removed.
Please, retest and review:
https://github.com/karelzak/util-linux/blob/master/sys-utils/blkzone.c
https://github.com/karelzak/util-linux/blob/master/sys-utils/blkzone.8
Karel
--
Karel Zak <[email protected]<mailto:[email protected]>>
http://karelzak.blogspot.com
Western Digital Corporation (and its subsidiaries) E-mail Confidentiality Notice & Disclaimer:
This e-mail and any files transmitted with it may contain confidential or legally privileged information of WDC and/or its affiliates, and are intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited. If you have received this e-mail in error, please notify the sender immediately and delete the e-mail in its entirety from your system.
Forgot to attach the patches…
--
Damien Le Moal, Ph.D.
Sr. Manager, System Software Research Group,
Western Digital
[email protected]
(+81) 0466-98-3593 (ext. 513593)
1 kirihara-cho, Fujisawa,
Kanagawa, 252-0888 Japan
www.wdc.com, www.hgst.com
From: Damien Le Moal <[email protected]>
Date: Friday, February 24, 2017 at 13:10
To: Karel Zak <[email protected]>
Cc: Benno Schulenberg <[email protected]>, Shaun Tancheff <[email protected]>, Util-Linux <[email protected]>, Van Assche Bart <[email protected]>
Subject: Re: [PATCH v3] Add blkzonecmd and blkreport ZAC/ZBC drives
Karel,
Please find attached 3 patches.
1) To be consistent with blkdiscard behavior, reset all zones of the device when length
is not specified.
2) Similarly, for report, report all zones of the device is length is unspecified on the command line.
3) Improve wording to match more closely the standards. ALos add "0x" to printed values to make it clear that these are hex.
Please review and let me know if you need more testing.
Best regards.
--
Damien Le Moal, Ph.D.
Sr. Manager, System Software Research Group,
Western Digital
[email protected]
(+81) 0466-98-3593 (ext. 513593)
1 kirihara-cho, Fujisawa,
Kanagawa, 252-0888 Japan
www.wdc.com, www.hgst.com
From: Karel Zak <[email protected]>
Date: Friday, February 24, 2017 at 01:33
To: Damien Le Moal <[email protected]>
Cc: Benno Schulenberg <[email protected]>, Shaun Tancheff <[email protected]>, Util-Linux <[email protected]>, Van Assche Bart <[email protected]>
Subject: Re: [PATCH v3] Add blkzonecmd and blkreport ZAC/ZBC drives
On Fri, Feb 17, 2017 at 09:12:29AM +0900, Damien Le Moal wrote:
Benno,
Quoted 8 lines · Benno Schulenberg
Quoted 2 lines · Karel Zak
blkzone report [--zone <offset>] [--count <length>] blkzone reset [--zone <offset>] [--count <length>]
"blkzone --zone" feels a bit strange. I would suggest:
blkzone <command> [--offset <sector>] [--count <number>]
Indeed, it is a little awkward. And to be consistent with other tools such as blkdiscard, I would also suggest --length instead of --count. So:
blkzone report [--offset <offset>] [--length <length>] blkzone reset [--offset <offset>] [--length <length>]
blkzone(8) implemented, blkreset and blkreport removed.
Please, retest and review:
https://github.com/karelzak/util-linux/blob/master/sys-utils/blkzone.c
https://github.com/karelzak/util-linux/blob/master/sys-utils/blkzone.8
Karel
Signature · 3 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
From 481f3a45f6cb4817f4196eee1844dcaf25baca91 Mon Sep 17 00:00:00 2001
From: Damien Le Moal <[email protected]>
Date: Fri, 24 Feb 2017 11:48:45 +0900
Subject: [PATCH 1/3] blkzone: Reset all zones when length is not specified
If length is 0, operate on all zones starting from offset. This also fix the maximum length calculation from offset.
--- sys-utils/blkzone.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
sys-utils/blkzone.c +5 -3
@@ -235,10 +235,12 @@ static int blkzone_reset(struct blkzone_control *ctl)if (ctl->offset > ctl->total_sectors)errx (EXIT_FAILURE ,_ ("%s: offset is greater than device size" ), ctl->devname); - zlen = ctl->length * zonesize; - +if (!ctl->length) + zlen = ctl->total_sectors; +else + zlen = ctl->length * zonesize;if (ctl->offset + zlen > ctl->total_sectors) - zlen = ctl->total_sectors - ctl->length; + zlen = ctl->total_sectors - ctl->offset; za.sector = ctl->offset; za.nr_sectors = zlen;
Signature · 1 line
2.9.3
From 8549334fb5c62b95d97c73e08a4327bf23331b9b Mon Sep 17 00:00:00 2001
From: Damien Le Moal <[email protected]>
Date: Fri, 24 Feb 2017 12:36:08 +0900
Subject: [PATCH 2/3] blkzone: Report all zones if length is not specified
Report all zones of the block device when length is not specified on the command line. To do this, introduce an inner loop in blkzone_report to repeatedly issue report zone ioctl to the device.
--- sys-utils/blkzone.c | 126 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 72 insertions(+), 54 deletions(-)
sys-utils/blkzone.c +72 -54
161 lines not on this page · raw message
Signature · 1 line
2.9.3
From ac3f2b3a0a7e772b7883659023bf87b529afec65 Mon Sep 17 00:00:00 2001
From: Damien Le Moal <[email protected]>
Date: Fri, 24 Feb 2017 12:47:29 +0900
Subject: [PATCH 3/3] blkzone: Improve zone information print
Add "0x" to the zone start, length and write pointer print to make it always clear that the values are Hexadecimal.
Also update the zone condition string and associated comments to match more closely the wording in the standard document. The man page is also updated to match the new wording.
--- sys-utils/blkzone.8 | 39 ++++++++++++++++++--------------------- sys-utils/blkzone.c | 22 +++++++++++----------- 2 files changed, 29 insertions(+), 32 deletions(-)
sys-utils/blkzone.8 +18 -21
@@ -9,8 +9,8 @@ blkzone \- run zone command on a device .SH DESCRIPTION .B blkzone is used to run zone command on device that support the Zoned Block Commands -(ZBC) or Zoned-device ATA Commands (ZAC). The zones are addresses by the offset -and length options. +(ZBC) or Zoned-device ATA Commands (ZAC). The zones to operate on can be +specified using the offset and length options. .PP The .I device
@@ -40,15 +40,15 @@ type:Zone type .TS tab(:); left l l. -Cl:closed -cv:conventional zone -e0:empty -fu:full -Oe:open explicit -Oi:open implicit -OL:offline -ro:read only -x?:reserved conditions (should not be reported) +cl:Closed +nw:Not write pointer +em:Empty +fu:Full +oe:Explicitly opened +oi:Implicitly opened +ol:Offline +ro:Read only +x?:Reserved conditions (should not be reported) .TE .SS reset
@@ -56,23 +56,20 @@ The command \fBblkzone reset\fP is used to reset one or more zones. Unlike .BR sg_reset_wp (8) , this command operates from the block layer and can reset a range of zones. .PP -By default, the command will operate on the zone at device logical -sector 0. Options may be used to modify this behavior as well as specify the -operation to be performed on the zone, as explained below. +By default, the command will operate from the zone at device logical +sector 0 and reset all zones. Options may be used to modify this behavior +as well as specify the operation to be performed on the zone, as explained below. .PP -The default number of zones (options \fB\-\-length\fP) is 4096, the maximum 65536. +The default number of zones (option \fB\-\-length\fP) is all zones. .SH OPTIONS The -.I sector -and -.I count -option arguments may be followed by the multiplicative suffixes KiB (=1024), +.I offset +option argument may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB") or the suffixes KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB. -Additionally, the 0x prefix can be used to specify \fIsector\fR and -\fIcount\fR in hex. +Additionally, the 0x prefix can be used to specify \fIoffset\fR in hex. .TP .BR \-o , " \-\-offset "\fIsector\fP The starting zone specified as a sector offset. The provided offset in sector
sys-utils/blkzone.c +11 -11
@@ -147,15 +147,15 @@ static const char *type_text[] = { };static const char *condition_str[] = { -"cv" ,/* conventional zone */ -"e0" ,/* empty */ -"Oi" ,/* open implicit */ -"Oe" ,/* open explicit */ -"Cl" ,/* closed */ +"nw" ,/* Not write pointer */ +"em" ,/* Empty */ +"io" ,/* Implicitly opened */ +"eo" ,/* Explicitly opened */ +"cl" ,/* Closed */ "x5" ,"x6" ,"x7" ,"x8" ,"x9" ,"xA" ,"xB" ,/* xN: reserved */ -"ro" ,/* read only */ -"fu" ,/* full */ -"OL" /* offline */ +"ro" ,/* Read only */ +"fu" ,/* Full */ +"of" /* Offline */ };static int blkzone_report (struct blkzone_control *ctl)
@@ -188,7 +188,7 @@ static int blkzone_report(struct blkzone_control *ctl)err (EXIT_FAILURE ,_ ("%s: BLKREPORTZONE ioctl failed" ), ctl->devname);if (ctl->verbose) -printf (_ ("Found %d zones from %lx\n" ), +printf (_ ("Found %d zones from 0x%lx\n" ), zi->nr_zones, ctl->offset);if (!zi->nr_zones) {
@@ -209,9 +209,9 @@ static int blkzone_report(struct blkzone_control *ctl)break ; } -printf (_ (" start: %9lx, len %6lx, wptr %6lx" +printf (_ (" start: 0x%09lx, len 0x%06lx, wptr 0x%06lx" " reset:%u non-seq:%u, zcond:%2u(%s) [type: %u(%s)]\n" ), - start, len, wp - start, + start, len, (type ==0x1 ) ?0 : wp - start, entry->reset, entry->non_seq, cond, condition_str[cond &ARRAY_SIZE (condition_str)], type, type_text[type]);
Signature · 1 line
2.9.3
Karel Zak
maintainerQuoted 1 line · Damien Le Moal
Please find attached 3 patches.
All 4 patches applied, Thanks!
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Karel,
Added one more patch to the series.
The fourth patch changes the --length option to use a sector count (as expected from the name) and adds the --count option which can be used in place of --length (it is --length OR --count, both are not allowed on the command line).
All tested on several different host-managed drives with kernel 4.10. No problems detected.
Let me know what you think.
Best regards.
--
Damien Le Moal, Ph.D.
Sr. Manager, System Software Research Group,
Western Digital
[email protected]
(+81) 0466-98-3593 (ext. 513593)
1 kirihara-cho, Fujisawa,
Kanagawa, 252-0888 Japan
www.wdc.com, www.hgst.com
From: Karel Zak <[email protected]>
Date: Friday, February 24, 2017 at 01:33
To: Damien Le Moal <[email protected]>
Cc: Benno Schulenberg <[email protected]>, Shaun Tancheff <[email protected]>, Util-Linux <[email protected]>, Van Assche Bart <[email protected]>
Subject: Re: [PATCH v3] Add blkzonecmd and blkreport ZAC/ZBC drives
On Fri, Feb 17, 2017 at 09:12:29AM +0900, Damien Le Moal wrote:
Benno,
Quoted 8 lines · Benno Schulenberg
Quoted 2 lines · Karel Zak
blkzone report [--zone <offset>] [--count <length>] blkzone reset [--zone <offset>] [--count <length>]
"blkzone --zone" feels a bit strange. I would suggest:
blkzone <command> [--offset <sector>] [--count <number>]
Indeed, it is a little awkward. And to be consistent with other tools such as blkdiscard, I would also suggest --length instead of --count. So:
blkzone report [--offset <offset>] [--length <length>] blkzone reset [--offset <offset>] [--length <length>]
blkzone(8) implemented, blkreset and blkreport removed.
Please, retest and review:
https://github.com/karelzak/util-linux/blob/master/sys-utils/blkzone.c
https://github.com/karelzak/util-linux/blob/master/sys-utils/blkzone.8
Karel
Signature · 8 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com Western Digital Corporation (and its subsidiaries) E-mail Confidentiality Notice & Disclaimer: This e-mail and any files transmitted with it may contain confidential or legally privileged information of WDC and/or its affiliates, and are intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited. If you have received this e-mail in error, please notify the sender immediately and delete the e-mail in its entirety from your system.
From 481f3a45f6cb4817f4196eee1844dcaf25baca91 Mon Sep 17 00:00:00 2001
From: Damien Le Moal <[email protected]>
Date: Fri, 24 Feb 2017 11:48:45 +0900
Subject: [PATCH v2 1/4] blkzone: Reset all zones when length is not specified
If length is 0, operate on all zones starting from offset. This also fix the maximum length calculation from offset.
--- sys-utils/blkzone.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
sys-utils/blkzone.c +5 -3
@@ -235,10 +235,12 @@ static int blkzone_reset(struct blkzone_control *ctl)if (ctl->offset > ctl->total_sectors)errx (EXIT_FAILURE ,_ ("%s: offset is greater than device size" ), ctl->devname); - zlen = ctl->length * zonesize; - +if (!ctl->length) + zlen = ctl->total_sectors; +else + zlen = ctl->length * zonesize;if (ctl->offset + zlen > ctl->total_sectors) - zlen = ctl->total_sectors - ctl->length; + zlen = ctl->total_sectors - ctl->offset; za.sector = ctl->offset; za.nr_sectors = zlen;
Signature · 1 line
2.9.3
From 8549334fb5c62b95d97c73e08a4327bf23331b9b Mon Sep 17 00:00:00 2001
From: Damien Le Moal <[email protected]>
Date: Fri, 24 Feb 2017 12:36:08 +0900
Subject: [PATCH v2 2/4] blkzone: Report all zones if length is not specified
Report all zones of the block device when length is not specified on the command line. To do this, introduce an inner loop in blkzone_report to repeatedly issue report zone ioctl to the device.
--- sys-utils/blkzone.c | 126 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 72 insertions(+), 54 deletions(-)
sys-utils/blkzone.c +72 -54
161 lines not on this page · raw message
Signature · 1 line
2.9.3
From ac3f2b3a0a7e772b7883659023bf87b529afec65 Mon Sep 17 00:00:00 2001
From: Damien Le Moal <[email protected]>
Date: Fri, 24 Feb 2017 12:47:29 +0900
Subject: [PATCH v2 3/4] blkzone: Improve zone information print
Add "0x" to the zone start, length and write pointer print to make it always clear that the values are Hexadecimal.
Also update the zone condition string and associated comments to match more closely the wording in the standard document. The man page is also updated to match the new wording.
--- sys-utils/blkzone.8 | 39 ++++++++++++++++++--------------------- sys-utils/blkzone.c | 22 +++++++++++----------- 2 files changed, 29 insertions(+), 32 deletions(-)
sys-utils/blkzone.8 +18 -21
@@ -9,8 +9,8 @@ blkzone \- run zone command on a device .SH DESCRIPTION .B blkzone is used to run zone command on device that support the Zoned Block Commands -(ZBC) or Zoned-device ATA Commands (ZAC). The zones are addresses by the offset -and length options. +(ZBC) or Zoned-device ATA Commands (ZAC). The zones to operate on can be +specified using the offset and length options. .PP The .I device
@@ -40,15 +40,15 @@ type:Zone type .TS tab(:); left l l. -Cl:closed -cv:conventional zone -e0:empty -fu:full -Oe:open explicit -Oi:open implicit -OL:offline -ro:read only -x?:reserved conditions (should not be reported) +cl:Closed +nw:Not write pointer +em:Empty +fu:Full +oe:Explicitly opened +oi:Implicitly opened +ol:Offline +ro:Read only +x?:Reserved conditions (should not be reported) .TE .SS reset
@@ -56,23 +56,20 @@ The command \fBblkzone reset\fP is used to reset one or more zones. Unlike .BR sg_reset_wp (8) , this command operates from the block layer and can reset a range of zones. .PP -By default, the command will operate on the zone at device logical -sector 0. Options may be used to modify this behavior as well as specify the -operation to be performed on the zone, as explained below. +By default, the command will operate from the zone at device logical +sector 0 and reset all zones. Options may be used to modify this behavior +as well as specify the operation to be performed on the zone, as explained below. .PP -The default number of zones (options \fB\-\-length\fP) is 4096, the maximum 65536. +The default number of zones (option \fB\-\-length\fP) is all zones. .SH OPTIONS The -.I sector -and -.I count -option arguments may be followed by the multiplicative suffixes KiB (=1024), +.I offset +option argument may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB") or the suffixes KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB. -Additionally, the 0x prefix can be used to specify \fIsector\fR and -\fIcount\fR in hex. +Additionally, the 0x prefix can be used to specify \fIoffset\fR in hex. .TP .BR \-o , " \-\-offset "\fIsector\fP The starting zone specified as a sector offset. The provided offset in sector
sys-utils/blkzone.c +11 -11
@@ -147,15 +147,15 @@ static const char *type_text[] = { };static const char *condition_str[] = { -"cv" ,/* conventional zone */ -"e0" ,/* empty */ -"Oi" ,/* open implicit */ -"Oe" ,/* open explicit */ -"Cl" ,/* closed */ +"nw" ,/* Not write pointer */ +"em" ,/* Empty */ +"io" ,/* Implicitly opened */ +"eo" ,/* Explicitly opened */ +"cl" ,/* Closed */ "x5" ,"x6" ,"x7" ,"x8" ,"x9" ,"xA" ,"xB" ,/* xN: reserved */ -"ro" ,/* read only */ -"fu" ,/* full */ -"OL" /* offline */ +"ro" ,/* Read only */ +"fu" ,/* Full */ +"of" /* Offline */ };static int blkzone_report (struct blkzone_control *ctl)
@@ -188,7 +188,7 @@ static int blkzone_report(struct blkzone_control *ctl)err (EXIT_FAILURE ,_ ("%s: BLKREPORTZONE ioctl failed" ), ctl->devname);if (ctl->verbose) -printf (_ ("Found %d zones from %lx\n" ), +printf (_ ("Found %d zones from 0x%lx\n" ), zi->nr_zones, ctl->offset);if (!zi->nr_zones) {
@@ -209,9 +209,9 @@ static int blkzone_report(struct blkzone_control *ctl)break ; } -printf (_ (" start: %9lx, len %6lx, wptr %6lx" +printf (_ (" start: 0x%09lx, len 0x%06lx, wptr 0x%06lx" " reset:%u non-seq:%u, zcond:%2u(%s) [type: %u(%s)]\n" ), - start, len, wp - start, + start, len, (type ==0x1 ) ?0 : wp - start, entry->reset, entry->non_seq, cond, condition_str[cond &ARRAY_SIZE (condition_str)], type, type_text[type]);
Signature · 1 line
2.9.3
From 5623702061479ca0d37137ddbc369b6d848d1c75 Mon Sep 17 00:00:00 2001
From: Damien Le Moal <[email protected]>
Date: Fri, 24 Feb 2017 15:45:31 +0900
Subject: [PATCH v2 4/4] blkzone: Add --count option
The length option is used to specify the number of zones to operate on. To be more consistent with other tools, have this option use a number of sectors and introduce the --count option to allow users to specify a number of zones.
The --count and --length options cannot be used together on the command line.
--- sys-utils/blkzone.8 | 39 ++++++++++++++++----------- sys-utils/blkzone.c | 76 ++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 76 insertions(+), 39 deletions(-)
sys-utils/blkzone.8 +24 -15
@@ -10,7 +10,7 @@ blkzone \- run zone command on a device .B blkzone is used to run zone command on device that support the Zoned Block Commands (ZBC) or Zoned-device ATA Commands (ZAC). The zones to operate on can be -specified using the offset and length options. +specified using the offset, count and length options. .PP The .I device
@@ -19,8 +19,8 @@ argument is the pathname of the block device. .SS report The command \fBblkzone report\fP is used to report device zone information. .PP -By default, the command will report on up to 4k zones from the start of the -block device. Options may be used to modify this behavior, changing the +By default, the command will report all zones from the start of the +block device. Options may be used to modify this behavior, changing the starting zone or the size of the report, as explained below. .B Report output
@@ -52,34 +52,43 @@ x?:Reserved conditions (should not be reported) .TE .SS reset -The command \fBblkzone reset\fP is used to reset one or more zones. Unlike -.BR sg_reset_wp (8) , +The command \fBblkzone reset\fP is used to reset one or more zones. Unlike +.BR sg_reset_wp (8), this command operates from the block layer and can reset a range of zones. .PP -By default, the command will operate from the zone at device logical +By default, the command will operate from the zone at device sector 0 and reset all zones. Options may be used to modify this behavior as well as specify the operation to be performed on the zone, as explained below. -.PP -The default number of zones (option \fB\-\-length\fP) is all zones. .SH OPTIONS The .I offset -option argument may be followed by the multiplicative suffixes KiB (=1024), +and +.I length +option arguments may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB") or the suffixes KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB. -Additionally, the 0x prefix can be used to specify \fIoffset\fR in hex. +Additionally, the 0x prefix can be used to specify \fIoffset\fR and +\fIlength\fR in hex. .TP .BR \-o , " \-\-offset "\fIsector\fP -The starting zone specified as a sector offset. The provided offset in sector -units (512 bytes) should match the start of a zone. The default value is zero. +The starting zone specified as a sector offset. The provided offset in sector +units (512 bytes) should match the start of a zone. The default value is zero. +.TP +.BR \-l , " \-\-length "\fIsectors\fP +The maximum number of sectors the command should operate on. The default value +is the number of sectors remaining after \fIoffset\fR. This option cannot be +used together with the option \fB\-\-count\fP. .TP -.BR \-l , " \-\-length "\fIcount\fP -The maximum number of zones to be used for the command. +.BR \-l , " \-\-count "\fIcount\fP +The maximum number of zones the command should operate on. The default value +is the nuber of zones starting from \fIoffset\fR. This option cannot be +used together with the option \fB\-\-length\fP. .TP .BR \-v , " \-\-verbose" -Display the number of zones returned in the report. +Display the number of zones returned in the report or the range of sectors +reset.. .TP .BR \-V , " \-\-version" Display version information and exit.
sys-utils/blkzone.c +52 -24
181 lines not on this page · raw message
Signature · 1 line
2.9.3