nvme: add cuse support for RESCAN IOCTL
Nvme-cli submits a RESCAN IOCTL after a format command to update any information that may have changed during the format, such as LBA Format. This patch adds support for RESCAN by executing nvme_ctrlr_update_namespaces to update the controller information. Fixes: #1964 Change-Id: I9f03e00a7f39339947ff02390f69ce806e1cfa0e Signed-off-by: Curt Bruns <curt.e.bruns@gmail.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8146 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ziye Yang <ziye.yang@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
47a6578ee5
commit
522faef3e2
@ -2533,7 +2533,7 @@ nvme_ctrlr_destruct_namespaces(struct spdk_nvme_ctrlr *ctrlr)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
nvme_ctrlr_update_namespaces(struct spdk_nvme_ctrlr *ctrlr)
|
||||
{
|
||||
uint32_t i, nn = ctrlr->cdata.nn;
|
||||
|
@ -313,6 +313,36 @@ cuse_nvme_reset(fuse_req_t req, int cmd, void *arg,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cuse_nvme_rescan_execute(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid, void *arg)
|
||||
{
|
||||
fuse_req_t req = arg;
|
||||
|
||||
nvme_ctrlr_update_namespaces(ctrlr);
|
||||
fuse_reply_ioctl_iov(req, 0, NULL, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
cuse_nvme_rescan(fuse_req_t req, int cmd, void *arg,
|
||||
struct fuse_file_info *fi, unsigned flags,
|
||||
const void *in_buf, size_t in_bufsz, size_t out_bufsz)
|
||||
{
|
||||
int rv;
|
||||
struct cuse_device *cuse_device = fuse_req_userdata(req);
|
||||
|
||||
if (cuse_device->nsid) {
|
||||
SPDK_ERRLOG("Namespace rescan not supported\n");
|
||||
fuse_reply_err(req, EINVAL);
|
||||
return;
|
||||
}
|
||||
|
||||
rv = nvme_io_msg_send(cuse_device->ctrlr, cuse_device->nsid, cuse_nvme_rescan_execute, (void *)req);
|
||||
if (rv) {
|
||||
SPDK_ERRLOG("Cannot send rescan\n");
|
||||
fuse_reply_err(req, EINVAL);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Namespace IO requests
|
||||
*/
|
||||
@ -615,6 +645,11 @@ cuse_ctrlr_ioctl(fuse_req_t req, int cmd, void *arg,
|
||||
cuse_nvme_reset(req, cmd, arg, fi, flags, in_buf, in_bufsz, out_bufsz);
|
||||
break;
|
||||
|
||||
case NVME_IOCTL_RESCAN:
|
||||
SPDK_DEBUGLOG(nvme_cuse, "NVME_IOCTL_RESCAN\n");
|
||||
cuse_nvme_rescan(req, cmd, arg, fi, flags, in_buf, in_bufsz, out_bufsz);
|
||||
break;
|
||||
|
||||
default:
|
||||
SPDK_ERRLOG("Unsupported IOCTL 0x%X.\n", cmd);
|
||||
fuse_reply_err(req, EINVAL);
|
||||
|
@ -1318,6 +1318,7 @@ const struct spdk_nvme_transport *nvme_get_transport(const char *transport_name)
|
||||
const struct spdk_nvme_transport *nvme_get_first_transport(void);
|
||||
const struct spdk_nvme_transport *nvme_get_next_transport(const struct spdk_nvme_transport
|
||||
*transport);
|
||||
void nvme_ctrlr_update_namespaces(struct spdk_nvme_ctrlr *ctrlr);
|
||||
|
||||
/* Transport specific functions */
|
||||
struct spdk_nvme_ctrlr *nvme_transport_ctrlr_construct(const struct spdk_nvme_transport_id *trid,
|
||||
|
@ -91,6 +91,8 @@ DEFINE_STUB(nvme_io_msg_ctrlr_register, int,
|
||||
DEFINE_STUB_V(nvme_io_msg_ctrlr_unregister,
|
||||
(struct spdk_nvme_ctrlr *ctrlr, struct nvme_io_msg_producer *io_msg_producer));
|
||||
|
||||
DEFINE_STUB_V(nvme_ctrlr_update_namespaces, (struct spdk_nvme_ctrlr *ctrlr));
|
||||
|
||||
static bool
|
||||
wait_for_file(char *filename, bool exists)
|
||||
{
|
||||
|
@ -81,6 +81,8 @@ DEFINE_STUB(spdk_nvme_ctrlr_is_active_ns, bool,
|
||||
|
||||
DEFINE_STUB(fuse_reply_err, int, (fuse_req_t req, int err), 0);
|
||||
|
||||
DEFINE_STUB_V(nvme_ctrlr_update_namespaces, (struct spdk_nvme_ctrlr *ctrlr));
|
||||
|
||||
struct cuse_io_ctx *g_ut_ctx;
|
||||
struct spdk_nvme_ctrlr *g_ut_ctrlr;
|
||||
uint32_t g_ut_nsid;
|
||||
|
Loading…
Reference in New Issue
Block a user