aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/nvme/nvme_ns.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/nvme/nvme_ns.c')
-rw-r--r--sys/dev/nvme/nvme_ns.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/sys/dev/nvme/nvme_ns.c b/sys/dev/nvme/nvme_ns.c
index e84d2066930e..4ebcc03c4f04 100644
--- a/sys/dev/nvme/nvme_ns.c
+++ b/sys/dev/nvme/nvme_ns.c
@@ -45,7 +45,7 @@
#include "nvme_private.h"
#include "nvme_linux.h"
-static void nvme_bio_child_inbed(struct bio *parent, int bio_error);
+static void nvme_bio_child_inbed(struct bio *parent, int abio_error);
static void nvme_bio_child_done(void *arg,
const struct nvme_completion *cpl);
static uint32_t nvme_get_num_segments(uint64_t addr, uint64_t size,
@@ -78,7 +78,7 @@ nvme_ns_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int flag,
break;
case NVME_PASSTHROUGH_CMD:
pt = (struct nvme_pt_command *)arg;
- return (nvme_ctrlr_passthrough_cmd(ctrlr, pt, ns->id,
+ return (nvme_ctrlr_passthrough_cmd(ctrlr, pt, ns->id,
1 /* is_user_buffer */, 0 /* is_admin_cmd */));
case NVME_GET_NSID:
{
@@ -88,6 +88,11 @@ nvme_ns_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int flag,
gnsid->nsid = ns->id;
break;
}
+ case DIOCGIDENT: {
+ uint8_t *sn = arg;
+ nvme_cdata_get_disk_ident(&ctrlr->cdata, sn);
+ break;
+ }
case DIOCGMEDIASIZE:
*(off_t *)arg = (off_t)nvme_ns_get_size(ns);
break;
@@ -137,10 +142,6 @@ nvme_ns_strategy_done(void *arg, const struct nvme_completion *cpl)
{
struct bio *bp = arg;
- /*
- * TODO: add more extensive translation of NVMe status codes
- * to different bio error codes (i.e. EIO, EINVAL, etc.)
- */
if (nvme_completion_is_error(cpl)) {
bp->bio_error = EIO;
bp->bio_flags |= BIO_ERROR;
@@ -274,14 +275,14 @@ nvme_ns_bio_done(void *arg, const struct nvme_completion *status)
}
static void
-nvme_bio_child_inbed(struct bio *parent, int bio_error)
+nvme_bio_child_inbed(struct bio *parent, int abio_error)
{
struct nvme_completion parent_cpl;
int children, inbed;
- if (bio_error != 0) {
+ if (abio_error != 0) {
parent->bio_flags |= BIO_ERROR;
- parent->bio_error = bio_error;
+ parent->bio_error = abio_error;
}
/*
@@ -308,12 +309,12 @@ nvme_bio_child_done(void *arg, const struct nvme_completion *cpl)
{
struct bio *child = arg;
struct bio *parent;
- int bio_error;
+ int abio_error;
parent = child->bio_parent;
g_destroy_bio(child);
- bio_error = nvme_completion_is_error(cpl) ? EIO : 0;
- nvme_bio_child_inbed(parent, bio_error);
+ abio_error = nvme_completion_is_error(cpl) ? EIO : 0;
+ nvme_bio_child_inbed(parent, abio_error);
}
static uint32_t
@@ -557,8 +558,10 @@ nvme_ns_construct(struct nvme_namespace *ns, uint32_t id,
* standard says the entire id will be zeros, so this is a
* cheap way to test for that.
*/
- if (ns->data.nsze == 0)
- return (ENXIO);
+ if (ns->data.nsze == 0) {
+ ns->flags |= NVME_NS_GONE;
+ return ((ns->flags & NVME_NS_ADDED) ? 0 : ENXIO);
+ }
flbas_fmt = NVMEV(NVME_NS_DATA_FLBAS_FORMAT, ns->data.flbas);
@@ -622,6 +625,7 @@ nvme_ns_construct(struct nvme_namespace *ns, uint32_t id,
ns->cdev->si_drv2 = make_dev_alias(ns->cdev, "%sns%d",
device_get_nameunit(ctrlr->dev), ns->id);
ns->cdev->si_flags |= SI_UNMAPPED;
+ ns->flags |= NVME_NS_ADDED;
return (0);
}