From: Christoph Hellwig <hch@lst.de> To: Johannes Thumshirn <jthumshirn@suse.de> Cc: Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>, Keith Busch <keith.busch@intel.com>, Hannes Reinecke <hare@suse.de>, Max Gurtovoy <maxg@mellanox.com>, Linux NVMe Mailinglist <linux-nvme@lists.infradead.org>, Linux Kernel Mailinglist <linux-kernel@vger.kernel.org> Subject: Re: [PATCH v1 4/7] nvme: get list of namespace descriptors Date: Thu, 1 Jun 2017 08:49:12 +0200 [thread overview] Message-ID: <20170601064912.GD16778@lst.de> (raw) In-Reply-To: <f51d09c4e22189e8979a92a46faa98778034afe6.1496237370.git.jthumshirn@suse.de> > +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().
WARNING: multiple messages have this Message-ID (diff)
From: hch@lst.de (Christoph Hellwig) Subject: [PATCH v1 4/7] nvme: get list of namespace descriptors Date: Thu, 1 Jun 2017 08:49:12 +0200 [thread overview] Message-ID: <20170601064912.GD16778@lst.de> (raw) In-Reply-To: <f51d09c4e22189e8979a92a46faa98778034afe6.1496237370.git.jthumshirn@suse.de> > +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().
next prev parent reply other threads:[~2017-06-01 6:49 UTC|newest] Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-05-31 13:32 [PATCH v1 0/7] Implement NVMe Namespace Descriptor Identification Johannes Thumshirn 2017-05-31 13:32 ` Johannes Thumshirn 2017-05-31 13:32 ` [PATCH v1 1/7] nvme: rename uuid to nguid in nvme_ns Johannes Thumshirn 2017-05-31 13:32 ` Johannes Thumshirn 2017-06-01 6:33 ` Christoph Hellwig 2017-06-01 6:33 ` Christoph Hellwig 2017-05-31 13:32 ` [PATCH v1 2/7] nvmet: add uuid field to nvme_ns and populate via configfs Johannes Thumshirn 2017-05-31 13:32 ` Johannes Thumshirn 2017-06-01 6:34 ` Christoph Hellwig 2017-06-01 6:34 ` Christoph Hellwig 2017-05-31 13:32 ` [PATCH v1 3/7] nvmet: implement namespace identify descriptor list Johannes Thumshirn 2017-05-31 13:32 ` Johannes Thumshirn 2017-06-01 6:42 ` Christoph Hellwig 2017-06-01 6:42 ` Christoph Hellwig 2017-05-31 13:32 ` [PATCH v1 4/7] nvme: get list of namespace descriptors Johannes Thumshirn 2017-05-31 13:32 ` Johannes Thumshirn 2017-05-31 19:13 ` Max Gurtovoy 2017-05-31 19:13 ` Max Gurtovoy 2017-06-01 6:49 ` Christoph Hellwig [this message] 2017-06-01 6:49 ` Christoph Hellwig 2017-05-31 13:32 ` [PATCH v1 5/7] nvme: provide UUID value to userspace Johannes Thumshirn 2017-05-31 13:32 ` Johannes Thumshirn 2017-06-01 6:49 ` Christoph Hellwig 2017-06-01 6:49 ` Christoph Hellwig 2017-05-31 13:32 ` [PATCH v1 6/7] nvme: change magic 4096 to SZ_4K Johannes Thumshirn 2017-05-31 13:32 ` Johannes Thumshirn 2017-06-01 6:50 ` Christoph Hellwig 2017-06-01 6:50 ` Christoph Hellwig 2017-05-31 13:32 ` [PATCH v1 7/7] nvmet: allow overriding the NVMe VS via configfs Johannes Thumshirn 2017-05-31 13:32 ` Johannes Thumshirn 2017-06-01 6:52 ` Christoph Hellwig 2017-06-01 6:52 ` Christoph Hellwig 2017-06-01 6:59 ` Hannes Reinecke 2017-06-01 6:59 ` Hannes Reinecke
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=20170601064912.GD16778@lst.de \ --to=hch@lst.de \ --cc=hare@suse.de \ --cc=jthumshirn@suse.de \ --cc=keith.busch@intel.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-nvme@lists.infradead.org \ --cc=maxg@mellanox.com \ --cc=sagi@grimberg.me \ /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: linkBe 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.