Commit 583e9699 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

scsi: remove lun name



There is no need to keep a lun name anymore - we always
use the bdev name as the lun name so it is not providing any
additional value. This also keeps us from associating
the same bdev with different LUNs on different iSCSI target
nodes or vhost-scsi controllers.

Side effect of this change is:

1) Use "bdev_name" across the APIs to make it more clear
   what these names refer to.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I3d42fde22087352ce1d5dc80178bd8c5cac8cb7c
Reviewed-on: https://review.gerrithub.io/390843


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent c3e890e9
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -61,8 +61,6 @@ extern "C" {

#define SPDK_SCSI_PORT_MAX_NAME_LENGTH		255

#define SPDK_SCSI_LUN_MAX_NAME_LENGTH		64

enum spdk_scsi_data_dir {
	SPDK_SCSI_DIR_NONE = 0,
	SPDK_SCSI_DIR_TO_DEV = 1,
@@ -153,7 +151,7 @@ int spdk_scsi_init(void);
void spdk_scsi_fini(void);

int spdk_scsi_lun_get_id(const struct spdk_scsi_lun *lun);
const char *spdk_scsi_lun_get_name(const struct spdk_scsi_lun *lun);
const char *spdk_scsi_lun_get_bdev_name(const struct spdk_scsi_lun *lun);
const struct spdk_scsi_dev *spdk_scsi_lun_get_dev(const struct spdk_scsi_lun *lun);

const char *spdk_scsi_dev_get_name(const struct spdk_scsi_dev *dev);
@@ -174,10 +172,8 @@ void spdk_scsi_dev_free_io_channels(struct spdk_scsi_dev *dev);
 * \brief Constructs a SCSI device object using the given parameters.
 *
 * \param name Name for the SCSI device.
 * \param queue_depth Queue depth for the SCSI device.  This queue depth is
 * 		      a combined queue depth for all LUNs in the device.
 * \param lun_list List of LUN objects for the SCSI device.  Caller is
 * 		   responsible for managing the memory containing this list.
 * \param bdev_name_list List of bdev names to attach to the LUNs for this SCSI
 *                       device.
 * \param lun_id_list List of LUN IDs for the LUN in this SCSI device.  Caller is
 *		      responsible for managing the memory containing this list.
 *		      lun_id_list[x] is the LUN ID for lun_list[x].
@@ -188,7 +184,7 @@ void spdk_scsi_dev_free_io_channels(struct spdk_scsi_dev *dev);
 * \return The constructed spdk_scsi_dev object.
 */
struct spdk_scsi_dev *spdk_scsi_dev_construct(const char *name,
		char *lun_name_list[],
		const char *bdev_name_list[],
		int *lun_id_list,
		int num_luns,
		uint8_t protocol_id,
+2 −2
Original line number Diff line number Diff line
@@ -175,11 +175,11 @@ int spdk_vhost_scsi_dev_remove(struct spdk_vhost_dev *vdev);
 *
 * \param vdev vhost SCSI device
 * \param scsi_tgt_num slot to attach to
 * \param lun_name name of the SPDK bdev to associate with SCSI LUN0
 * \param bdev_name name of the SPDK bdev to associate with SCSI LUN0
 * \return 0 on success, negative errno on error.
 */
int spdk_vhost_scsi_dev_add_tgt(struct spdk_vhost_dev *vdev, unsigned scsi_tgt_num,
				const char *lun_name);
				const char *bdev_name);

/**
 * Get SCSI target from vhost SCSI device on given slot. Max
+15 −15
Original line number Diff line number Diff line
@@ -305,8 +305,8 @@ spdk_rpc_get_target_nodes(struct spdk_jsonrpc_request *request,

			if (lun) {
				spdk_json_write_object_begin(w);
				spdk_json_write_name(w, "name");
				spdk_json_write_string(w, spdk_scsi_lun_get_name(lun));
				spdk_json_write_name(w, "bdev_name");
				spdk_json_write_string(w, spdk_scsi_lun_get_bdev_name(lun));
				spdk_json_write_name(w, "id");
				spdk_json_write_int32(w, spdk_scsi_lun_get_id(lun));
				spdk_json_write_object_end(w);
@@ -371,23 +371,23 @@ decode_rpc_ig_tags(const struct spdk_json_val *val, void *out)

#define RPC_CONSTRUCT_TARGET_NODE_MAX_LUN	64

struct rpc_lun_names {
struct rpc_bdev_names {
	size_t num_names;
	char *names[RPC_CONSTRUCT_TARGET_NODE_MAX_LUN];
};

static int
decode_rpc_lun_names(const struct spdk_json_val *val, void *out)
decode_rpc_bdev_names(const struct spdk_json_val *val, void *out)
{
	struct rpc_lun_names *lun_names = out;
	struct rpc_bdev_names *bdev_names = out;

	return spdk_json_decode_array(val, spdk_json_decode_string, lun_names->names,
	return spdk_json_decode_array(val, spdk_json_decode_string, bdev_names->names,
				      RPC_CONSTRUCT_TARGET_NODE_MAX_LUN,
				      &lun_names->num_names, sizeof(char *));
				      &bdev_names->num_names, sizeof(char *));
}

static void
free_rpc_lun_names(struct rpc_lun_names *r)
free_rpc_bdev_names(struct rpc_bdev_names *r)
{
	size_t i;

@@ -418,7 +418,7 @@ struct rpc_target_node {
	struct rpc_pg_tags pg_tags;
	struct rpc_ig_tags ig_tags;

	struct rpc_lun_names lun_names;
	struct rpc_bdev_names bdev_names;
	struct rpc_lun_ids lun_ids;

	int32_t queue_depth;
@@ -433,7 +433,7 @@ free_rpc_target_node(struct rpc_target_node *req)
{
	free(req->name);
	free(req->alias_name);
	free_rpc_lun_names(&req->lun_names);
	free_rpc_bdev_names(&req->bdev_names);
}

static const struct spdk_json_object_decoder rpc_target_node_decoders[] = {
@@ -441,7 +441,7 @@ static const struct spdk_json_object_decoder rpc_target_node_decoders[] = {
	{"alias_name", offsetof(struct rpc_target_node, alias_name), spdk_json_decode_string},
	{"pg_tags", offsetof(struct rpc_target_node, pg_tags), decode_rpc_pg_tags},
	{"ig_tags", offsetof(struct rpc_target_node, ig_tags), decode_rpc_ig_tags},
	{"lun_names", offsetof(struct rpc_target_node, lun_names), decode_rpc_lun_names},
	{"bdev_names", offsetof(struct rpc_target_node, bdev_names), decode_rpc_bdev_names},
	{"lun_ids", offsetof(struct rpc_target_node, lun_ids), decode_rpc_lun_ids},
	{"queue_depth", offsetof(struct rpc_target_node, queue_depth), spdk_json_decode_int32},
	{"chap_disabled", offsetof(struct rpc_target_node, chap_disabled), spdk_json_decode_int32},
@@ -470,8 +470,8 @@ spdk_rpc_construct_target_node(struct spdk_jsonrpc_request *request,
		goto invalid;
	}

	if (req.lun_names.num_names != req.lun_ids.num_ids) {
		SPDK_ERRLOG("lun_names/lun_ids count mismatch\n");
	if (req.bdev_names.num_names != req.lun_ids.num_ids) {
		SPDK_ERRLOG("bdev_names/lun_ids count mismatch\n");
		goto invalid;
	}

@@ -485,9 +485,9 @@ spdk_rpc_construct_target_node(struct spdk_jsonrpc_request *request,
					       req.pg_tags.tags,
					       req.ig_tags.tags,
					       req.pg_tags.num_tags,
					       req.lun_names.names,
					       (const char **)req.bdev_names.names,
					       req.lun_ids.ids,
					       req.lun_names.num_names,
					       req.bdev_names.num_names,
					       req.queue_depth,
					       req.chap_disabled,
					       req.chap_required,
+1 −1
Original line number Diff line number Diff line
@@ -299,7 +299,7 @@ spdk_iscsi_config_dump_target_nodes(FILE *fp)

			fprintf(fp, TARGET_NODE_LUN_TMPL,
				spdk_scsi_lun_get_id(lun),
				spdk_scsi_lun_get_name(lun));
				spdk_scsi_lun_get_bdev_name(lun));
		}

		fprintf(fp, TARGET_NODE_QD_TMPL,
+6 −8
Original line number Diff line number Diff line
@@ -847,7 +847,7 @@ _spdk_iscsi_tgt_node *
spdk_iscsi_tgt_node_construct(int target_index,
			      const char *name, const char *alias,
			      int *pg_tag_list, int *ig_tag_list, uint16_t num_maps,
			      char *lun_name_list[], int *lun_id_list, int num_luns,
			      const char *bdev_name_list[], int *lun_id_list, int num_luns,
			      int queue_depth,
			      int auth_chap_disabled, int auth_chap_required, int auth_chap_mutual, int auth_group,
			      int header_digest, int data_digest)
@@ -920,7 +920,7 @@ spdk_iscsi_tgt_node_construct(int target_index,
		}
	}

	target->dev = spdk_scsi_dev_construct(fullname, lun_name_list, lun_id_list, num_luns,
	target->dev = spdk_scsi_dev_construct(fullname, bdev_name_list, lun_id_list, num_luns,
					      SPDK_SPC_PROTOCOL_IDENTIFIER_ISCSI, NULL, NULL);
	if (!target->dev) {
		SPDK_ERRLOG("Could not construct SCSI device\n");
@@ -976,8 +976,7 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp)
	int auth_chap_disabled, auth_chap_required, auth_chap_mutual;
	int i;
	int lun_id_list[SPDK_SCSI_DEV_MAX_LUN];
	char lun_name_array[SPDK_SCSI_DEV_MAX_LUN][SPDK_SCSI_LUN_MAX_NAME_LENGTH] = {};
	char *lun_name_list[SPDK_SCSI_DEV_MAX_LUN];
	const char *bdev_name_list[SPDK_SCSI_DEV_MAX_LUN];
	int num_luns, queue_depth;

	target_num = spdk_conf_section_get_num(sp);
@@ -1150,8 +1149,7 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp)
			continue;
		}

		snprintf(lun_name_array[num_luns], SPDK_SCSI_LUN_MAX_NAME_LENGTH, "%s", val);
		lun_name_list[num_luns] = lun_name_array[num_luns];
		bdev_name_list[num_luns] = val;
		lun_id_list[num_luns] = i;
		num_luns++;
	}
@@ -1163,7 +1161,7 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp)

	target = spdk_iscsi_tgt_node_construct(target_num, name, alias,
					       pg_tag_list, ig_tag_list, num_target_maps,
					       lun_name_list, lun_id_list, num_luns, queue_depth,
					       bdev_name_list, lun_id_list, num_luns, queue_depth,
					       auth_chap_disabled, auth_chap_required,
					       auth_chap_mutual, auth_group,
					       header_digest, data_digest);
@@ -1180,7 +1178,7 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp)
			SPDK_INFOLOG(SPDK_LOG_ISCSI, "device %d: LUN%d %s\n",
				     spdk_scsi_dev_get_id(target->dev),
				     spdk_scsi_lun_get_id(lun),
				     spdk_scsi_lun_get_name(lun));
				     spdk_scsi_lun_get_bdev_name(lun));
		}
	}

Loading