From: Damien Le Moal <Damien.LeMoal@wdc.com>
To: Karel Zak <kzak@redhat.com>
Cc: "util-linux@vger.kernel.org" <util-linux@vger.kernel.org>,
Benno Schulenberg <bensberg@justemail.net>,
Aravind Ramesh <Aravind.Ramesh@wdc.com>,
Hans Holmberg <Hans.Holmberg@wdc.com>
Subject: Re: [PATCH v2] blkzone: add open/close/finish commands
Date: Wed, 25 Mar 2020 15:12:04 +0000 [thread overview]
Message-ID: <CO2PR04MB2343A0A15DAB638F4989CA22E7CE0@CO2PR04MB2343.namprd04.prod.outlook.com> (raw)
In-Reply-To: 20200325113604.j7qlb7zdzm2azxjm@ws.net.home
On 2020/03/25 20:36, Karel Zak wrote:
> On Tue, Mar 24, 2020 at 07:02:17PM +0900, Damien Le Moal wrote:
>> sys-utils/blkzone.8 | 27 +++++++++++++++--
>> sys-utils/blkzone.c | 74 ++++++++++++++++++++++++++++++++++++++++-----
>> 2 files changed, 91 insertions(+), 10 deletions(-)
>
> Applied, thanks.
>
>> static const struct blkzone_command commands[] = {
>> { "report", blkzone_report, N_("Report zone information about the given device") },
>> - { "reset", blkzone_reset, N_("Reset a range of zones.") }
>> + { "reset", blkzone_action, N_("Reset a range of zones.") },
>> + { "open", blkzone_action, N_("Open a range of zones.") },
>> + { "close", blkzone_action, N_("Close a range of zones.") },
>> + { "finish", blkzone_action, N_("Set a range of zones to Full.") }
>> +};
>> +
>> +/*
>> + * The action values must match the command index in the command array.
>> + */
>> +enum blkzone_action {
>> + BLK_ZONE_NO_ACTION = 0,
>> + BLK_ZONE_RESET,
>> + BLK_ZONE_OPEN,
>> + BLK_ZONE_CLOSE,
>> + BLK_ZONE_FINISH,
>> };
>
> If you add ioctl_cmd and ioctl_name to the struct blkzone_command,
> and you define commands[] as:
>
> commands[] = {
> {
> .name = "report",
> .handler = blkzone_report,
> .help = N_("Report zone information about the given device")
> },{
> .name = "reset",
> .handler = blkzone_action,
> .help = N_("Reset a range of zones."),
> .ioctl_cmd = BLKRESETZONE,
> .ioctl_name = "BLKRESETZONE"
> },
> ...
> };
>
> than you do not need this switch() and command_action()
>
>>
>> + switch (command_action(ctl->command)) {
>> + case BLK_ZONE_RESET:
>> + ioctl_cmd = BLKRESETZONE;
>> + ioctl_name = "BLKRESETZONE";
>> + break;
>> + case BLK_ZONE_OPEN:
>> + ioctl_cmd = BLKOPENZONE;
>> + ioctl_name = "BLKOPENZONE";
>> + break;
>> + case BLK_ZONE_CLOSE:
>> + ioctl_cmd = BLKCLOSEZONE;
>> + ioctl_name = "BLKCLOSEZONE";
>> + break;
>> + case BLK_ZONE_FINISH:
>> + ioctl_cmd = BLKFINISHZONE;
>> + ioctl_name = "BLKFINISHZONE";
>> + break;
>> + case BLK_ZONE_NO_ACTION:
>> + /* fallthrough */
>> + default:
>> + errx(EXIT_FAILURE, _("Invalid zone action"));
>
> but you can use ctl->command.ioclt_cmd etc.
>
> Just idea :-)
I just sent a V3 of the full patch with this cleanup.
Did you prefer an incremental change ?
(I did not see that you said you applied v2 above... Thanks !)
>
> Karel
>
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2020-03-25 15:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-24 10:02 [PATCH v2] blkzone: add open/close/finish commands Damien Le Moal
2020-03-25 11:36 ` Karel Zak
2020-03-25 11:37 ` Damien Le Moal
2020-03-25 15:12 ` Damien Le Moal [this message]
2020-03-25 16:56 ` Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CO2PR04MB2343A0A15DAB638F4989CA22E7CE0@CO2PR04MB2343.namprd04.prod.outlook.com \
--to=damien.lemoal@wdc.com \
--cc=Aravind.Ramesh@wdc.com \
--cc=Hans.Holmberg@wdc.com \
--cc=bensberg@justemail.net \
--cc=kzak@redhat.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).