Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1654851
| From | Christoph Hellwig <hch@lst.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v1 4/7] nvme: get list of namespace descriptors |
| Date | 2017-06-01 08:50 +0200 |
| Message-ID | <tNs5I-7t1-5@gated-at.bofh.it> (permalink) |
| References | <tNc0W-5nk-3@gated-at.bofh.it> <tNc0W-5nk-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
> +static void nvme_parse_ns_descs(struct nvme_ns *ns, void *ns_nid)
> +{
> + struct nvme_ns_nid *cur;
> + const u8 *p;
> + int pos = 0;
> + int len;
> +
> + p = (u8 *)ns_nid;
No need for the cast. But we can do void pointer arithmetics in the
kernel anyway, so possible we could just declare this void.
And maybe just call the argument data and operate on that.
> +
> + for (;;) {
> + cur = (struct nvme_ns_nid *)p;
for (pos = 0; pos < NVME_ID_DATA_SIZE; pos += len) {
struct nvme_ns_nid *cur = data + pos;
> +
> + switch (cur->nidl) {
> + case 0:
> + return;
> + case 8:
> + case 16:
> + break;
> + default:
> + dev_warn(ns->ctrl->dev,
> + "Target returned bogus Namespace Identification Descriptor length: %d\n",
> + cur->nidl);
> + return;
> +
> + }
This needs to be verified based on the type.
> + if (ns->ctrl->vs >= NVME_VS(1, 3, 0)) {
> + void *ns_nid;
> + int ret;
> +
> +
> + ns_nid = kzalloc(SZ_4K, GFP_KERNEL);
> + if (!ns_nid) {
> + dev_warn(ns->ctrl->dev,
> + "%s: Identify Descriptors failed\n", __func__);
> + return 0;
> + }
> +
> + ret = nvme_identify_ns_descs(ns->ctrl, ns->ns_id, ns_nid);
> + if (ret) {
> + dev_warn(ns->ctrl->dev,
> + "%s: Identify Descriptors failed\n", __func__);
> + /* Don't treat error as fatal we potentially
> + * already have a NGUID or EUI-64 */
> + return 0;
> + }
> + nvme_parse_ns_descs(ns, ns_nid);
> + kfree(ns_nid);
Please move all this code into nvme_identify_ns_descs().
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH v1 4/7] nvme: get list of namespace descriptors Johannes Thumshirn <jthumshirn@suse.de> - 2017-05-31 15:40 +0200 Re: [PATCH v1 4/7] nvme: get list of namespace descriptors Christoph Hellwig <hch@lst.de> - 2017-06-01 08:50 +0200
csiph-web