Commit 78467a35 authored by Karl Bonde Torp's avatar Karl Bonde Torp Committed by Konrad Sztyber
Browse files

bdev/nvme: add support for unrecognized csi



The intention is to enable the use of namespaces with unsupported/custom
NVMe command sets, e.g. KV, without having to implement support for a
specific csi.

These namespaces only support NVMe passthrough.

Change-Id: I5d13dc5ae749f428ea399cff929cb53c38493335
Signed-off-by: default avatarKarl Bonde Torp <k.torp@samsung.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24190


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
parent 9886052b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4113,6 +4113,7 @@ psk | Optional | string | Name of the pre-shared key
max_bdevs                  | Optional | number      | The size of the name array for newly created bdevs. Default is 128.
dhchap_key                 | Optional | string      | DH-HMAC-CHAP key name.
dhchap_ctrlr_key           | Optional | string      | DH-HMAC-CHAP controller key name.
allow_unrecognized_csi     | Optional | bool        | Allow attaching namespaces with unrecognized command set identifiers. These will only support NVMe passthrough.

#### Example

+6 −0
Original line number Diff line number Diff line
@@ -38,6 +38,12 @@ struct spdk_bdev_nvme_ctrlr_opts {
	char psk[PATH_MAX];
	const char *dhchap_key;
	const char *dhchap_ctrlr_key;

	/**
	 * Allow attaching namespaces with unrecognized command set identifiers.
	 * These will only support NVMe passthrough.
	 */
	bool allow_unrecognized_csi;
};

/**
+31 −0
Original line number Diff line number Diff line
@@ -3165,6 +3165,19 @@ bdev_nvme_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_i
	_bdev_nvme_submit_request(nbdev_ch, bdev_io);
}

static bool
bdev_nvme_is_supported_csi(enum spdk_nvme_csi csi)
{
	switch (csi) {
	case SPDK_NVME_CSI_NVM:
		return true;
	case SPDK_NVME_CSI_ZNS:
		return true;
	default:
		return false;
	}
}

static bool
bdev_nvme_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
{
@@ -3181,6 +3194,20 @@ bdev_nvme_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
		return false;
	}

	if (!bdev_nvme_is_supported_csi(spdk_nvme_ns_get_csi(ns))) {
		switch (io_type) {
		case SPDK_BDEV_IO_TYPE_NVME_ADMIN:
		case SPDK_BDEV_IO_TYPE_NVME_IO:
			return true;

		case SPDK_BDEV_IO_TYPE_NVME_IO_MD:
			return spdk_nvme_ns_get_md_size(ns) ? true : false;

		default:
			return false;
		}
	}

	ctrlr = spdk_nvme_ns_get_ctrlr(ns);

	switch (io_type) {
@@ -4117,6 +4144,10 @@ nvme_disk_create(struct spdk_bdev *disk, const char *base_name,
		disk->max_active_zones = spdk_nvme_zns_ns_get_max_active_zones(ns);
		break;
	default:
		if (bdev_opts->allow_unrecognized_csi) {
			disk->product_name = "NVMe Passthrough disk";
			break;
		}
		SPDK_ERRLOG("unsupported CSI: %u\n", csi);
		return -ENOTSUP;
	}
+1 −0
Original line number Diff line number Diff line
@@ -338,6 +338,7 @@ static const struct spdk_json_object_decoder rpc_bdev_nvme_attach_controller_dec
	{"max_bdevs", offsetof(struct rpc_bdev_nvme_attach_controller, max_bdevs), spdk_json_decode_uint32, true},
	{"dhchap_key", offsetof(struct rpc_bdev_nvme_attach_controller, dhchap_key), spdk_json_decode_string, true},
	{"dhchap_ctrlr_key", offsetof(struct rpc_bdev_nvme_attach_controller, dhchap_ctrlr_key), spdk_json_decode_string, true},
	{"allow_unrecognized_csi", offsetof(struct rpc_bdev_nvme_attach_controller, bdev_opts.allow_unrecognized_csi), spdk_json_decode_bool, true},
};

#define DEFAULT_MAX_BDEVS_PER_RPC 128
+6 −1
Original line number Diff line number Diff line
@@ -701,7 +701,8 @@ def bdev_nvme_attach_controller(client, name, trtype, traddr, adrfam=None, trsvc
                                hdgst=None, ddgst=None, fabrics_connect_timeout_us=None,
                                multipath=None, num_io_queues=None, ctrlr_loss_timeout_sec=None,
                                reconnect_delay_sec=None, fast_io_fail_timeout_sec=None,
                                psk=None, max_bdevs=None, dhchap_key=None, dhchap_ctrlr_key=None):
                                psk=None, max_bdevs=None, dhchap_key=None, dhchap_ctrlr_key=None,
                                allow_unrecognized_csi=None):
    """Construct block device for each NVMe namespace in the attached controller.
    Args:
        name: bdev name prefix; "n" + namespace ID will be appended to create unique names
@@ -739,6 +740,8 @@ def bdev_nvme_attach_controller(client, name, trtype, traddr, adrfam=None, trsvc
        max_bdevs: Size of the name array for newly created bdevs. Default is 128. (optional)
        dhchap_key: DH-HMAC-CHAP key name.
        dhchap_ctrlr_key: DH-HMAC-CHAP controller key name.
        allow_unrecognized_csi: Allow attaching namespaces with unrecognized command set identifiers. These will only support NVMe
        passthrough.
    Returns:
        Names of created block devices.
    """
@@ -788,6 +791,8 @@ def bdev_nvme_attach_controller(client, name, trtype, traddr, adrfam=None, trsvc
        params['dhchap_key'] = dhchap_key
    if dhchap_ctrlr_key is not None:
        params['dhchap_ctrlr_key'] = dhchap_ctrlr_key
    if allow_unrecognized_csi is not None:
        params['allow_unrecognized_csi'] = allow_unrecognized_csi
    return client.call('bdev_nvme_attach_controller', params)


Loading