From: "Martin K. Petersen" <martin.petersen@oracle.com>
To: Douglas Gilbert <dgilbert@interlog.com>
Cc: linux-scsi@vger.kernel.org, martin.petersen@oracle.com,
jejb@linux.vnet.ibm.com, hare@suse.de, Damien.LeMoal@wdc.com
Subject: Re: [PATCH v4 09/14] scsi_debug: add zbc parameter
Date: Tue, 14 Apr 2020 22:10:36 -0400 [thread overview]
Message-ID: <yq1lfmxpkgz.fsf@oracle.com> (raw)
In-Reply-To: <20200225062351.21267-10-dgilbert@interlog.com> (Douglas Gilbert's message of "Tue, 25 Feb 2020 01:23:46 -0500")
Doug,
Forgot to comment on this:
> +MODULE_PARM_DESC(zbc, "'none' [0]; 'aware' [1]; 'managed' [2] (def=0). Can have 'host_' prefix");
[...]
> +static int sdeb_zbc_model_str(const char *cp)
> +{
> + int res = -EINVAL;
> +
> + if (isalpha(cp[0])) {
> + if (strstr(cp, "none"))
> + res = BLK_ZONED_NONE;
> + else if (strstr(cp, "aware"))
> + res = BLK_ZONED_HA;
> + else if (strstr(cp, "managed"))
> + res = BLK_ZONED_HM;
> + } else {
> + int n, ret;
> +
> + ret = kstrtoint(cp, 0, &n);
> + if (ret)
> + return ret;
> + if (n >= 0 || n <= 2)
> + res = n;
> + }
> + return res;
> +}
> +
> +static ssize_t zbc_show(struct device_driver *ddp, char *buf)
> +{
> + switch (sdeb_zbc_model) {
> + case BLK_ZONED_NONE: /* 0 */
> + return scnprintf(buf, PAGE_SIZE, "none\n");
> + case BLK_ZONED_HA: /* 1, not yet supported */
> + return scnprintf(buf, PAGE_SIZE, "host_aware\n");
> + case BLK_ZONED_HM: /* 2 */
> + return scnprintf(buf, PAGE_SIZE, "host_managed\n");
> + default:
> + return scnprintf(buf, PAGE_SIZE, "unknown_zbc_model [0x%x]\n",
> + (unsigned int)sdeb_zbc_model);
> + }
> +}
static const char *zbc_model[] = {
[BLK_ZONED_NONE] = "none",
[BLK_ZONED_HA] = "host_aware",
[BLK_ZONED_HM] = "host_managed",
};
[...]
And then in parameter parsing you can do:
sdeb_zbc_model = sysfs_match_string(zbc_model, buf);
if (sdeb_zbc_model < 0)
return -EINVAL;
zbc_show() can go away and you can do:
pr_info(".... %s\n", zbc_model[sdeb_zbc_model]);
--
Martin K. Petersen Oracle Linux Engineering
next prev parent reply other threads:[~2020-04-15 2:10 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-25 6:23 [PATCH v4 00/14] scsi_debug: host managed ZBC + doublestore Douglas Gilbert
2020-02-25 6:23 ` [PATCH v4 01/14] scsi_debug: randomize command completion time Douglas Gilbert
2020-04-13 22:24 ` Martin K. Petersen
2020-02-25 6:23 ` [PATCH v4 02/14] scsi_debug: add doublestore option Douglas Gilbert
2020-04-13 22:36 ` Martin K. Petersen
2020-02-25 6:23 ` [PATCH v4 03/14] scsi_debug: implement verify(10), add verify(16) Douglas Gilbert
2020-04-13 22:48 ` Martin K. Petersen
2020-02-25 6:23 ` [PATCH v4 04/14] scsi_debug: weaken rwlock around ramdisk access Douglas Gilbert
2020-02-25 6:23 ` [PATCH v4 05/14] scsi_debug: improve command duration calculation Douglas Gilbert
2020-04-13 22:50 ` Martin K. Petersen
2020-02-25 6:23 ` [PATCH v4 06/14] scsi_debug: implement pre-fetch commands Douglas Gilbert
2020-04-13 22:57 ` Martin K. Petersen
2020-04-19 18:01 ` Douglas Gilbert
2020-04-19 18:22 ` Julian Wiedmann
2020-04-19 21:53 ` Douglas Gilbert
2020-02-25 6:23 ` [PATCH v4 07/14] scsi_debug: expand zbc support Douglas Gilbert
2020-04-13 23:00 ` Martin K. Petersen
2020-04-13 23:05 ` Damien Le Moal
2020-04-13 23:06 ` Damien Le Moal
2020-04-14 1:55 ` Martin K. Petersen
2020-04-14 5:38 ` Damien Le Moal
2020-02-25 6:23 ` [PATCH v4 08/14] scsi_debug: add zone commands Douglas Gilbert
2020-02-25 6:23 ` [PATCH v4 09/14] scsi_debug: add zbc parameter Douglas Gilbert
2020-04-15 2:10 ` Martin K. Petersen [this message]
2020-02-25 6:23 ` [PATCH v4 10/14] scsi_debug: re-arrange parameters alphabetically Douglas Gilbert
2020-02-25 6:23 ` [PATCH v4 11/14] scsi_debug: zone_max_open module parameter Douglas Gilbert
2020-02-25 6:23 ` [PATCH v4 12/14] scsi_debug: zone_nr_conv " Douglas Gilbert
2020-02-25 6:23 ` [PATCH v4 13/14] scsi_debug: zone_size_mb " Douglas Gilbert
2020-02-25 6:23 ` [PATCH v4 14/14] scsi_debug: bump to version 1.89 Douglas Gilbert
2020-04-13 23:19 ` [PATCH v4 00/14] scsi_debug: host managed ZBC + doublestore Martin K. Petersen
2020-04-14 2:49 ` Douglas Gilbert
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=yq1lfmxpkgz.fsf@oracle.com \
--to=martin.petersen@oracle.com \
--cc=Damien.LeMoal@wdc.com \
--cc=dgilbert@interlog.com \
--cc=hare@suse.de \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-scsi@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 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.