Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f2d30680 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Nicholas Bellinger
Browse files

target: use 64-bit LUNs



As we're now using a list to hold the LUNs the target core
can now converted to use 64-bit LUNs internally.

Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent e34d3662
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -120,7 +120,7 @@ u8 iscsit_tmr_task_reassign(
	struct iscsi_tmr_req *tmr_req = cmd->tmr_req;
	struct iscsi_tmr_req *tmr_req = cmd->tmr_req;
	struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;
	struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;
	struct iscsi_tm *hdr = (struct iscsi_tm *) buf;
	struct iscsi_tm *hdr = (struct iscsi_tm *) buf;
	int ret, ref_lun;
	u64 ret, ref_lun;


	pr_debug("Got TASK_REASSIGN TMR ITT: 0x%08x,"
	pr_debug("Got TASK_REASSIGN TMR ITT: 0x%08x,"
		" RefTaskTag: 0x%08x, ExpDataSN: 0x%08x, CID: %hu\n",
		" RefTaskTag: 0x%08x, ExpDataSN: 0x%08x, CID: %hu\n",
@@ -164,7 +164,7 @@ u8 iscsit_tmr_task_reassign(
	ref_lun = scsilun_to_int(&hdr->lun);
	ref_lun = scsilun_to_int(&hdr->lun);
	if (ref_lun != ref_cmd->se_cmd.orig_fe_lun) {
	if (ref_lun != ref_cmd->se_cmd.orig_fe_lun) {
		pr_err("Unable to perform connection recovery for"
		pr_err("Unable to perform connection recovery for"
			" differing ref_lun: %d ref_cmd orig_fe_lun: %u\n",
			" differing ref_lun: %llu ref_cmd orig_fe_lun: %llu\n",
			ref_lun, ref_cmd->se_cmd.orig_fe_lun);
			ref_lun, ref_cmd->se_cmd.orig_fe_lun);
		return ISCSI_TMF_RSP_REJECTED;
		return ISCSI_TMF_RSP_REJECTED;
	}
	}
+2 −2
Original line number Original line Diff line number Diff line
@@ -215,7 +215,7 @@ static int tcm_loop_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc)
 * to struct scsi_device
 * to struct scsi_device
 */
 */
static int tcm_loop_issue_tmr(struct tcm_loop_tpg *tl_tpg,
static int tcm_loop_issue_tmr(struct tcm_loop_tpg *tl_tpg,
			      int lun, int task, enum tcm_tmreq_table tmr)
			      u64 lun, int task, enum tcm_tmreq_table tmr)
{
{
	struct se_cmd *se_cmd = NULL;
	struct se_cmd *se_cmd = NULL;
	struct se_session *se_sess;
	struct se_session *se_sess;
@@ -747,7 +747,7 @@ static void tcm_loop_port_unlink(
				se_lun->unpacked_lun);
				se_lun->unpacked_lun);
	if (!sd) {
	if (!sd) {
		pr_err("Unable to locate struct scsi_device for %d:%d:"
		pr_err("Unable to locate struct scsi_device for %d:%d:"
			"%d\n", 0, tl_tpg->tl_tpgt, se_lun->unpacked_lun);
			"%llu\n", 0, tl_tpg->tl_tpgt, se_lun->unpacked_lun);
		return;
		return;
	}
	}
	/*
	/*
+1 −1
Original line number Original line Diff line number Diff line
@@ -1257,7 +1257,7 @@ static int core_alua_update_tpg_secondary_metadata(struct se_lun *lun)
			atomic_read(&lun->lun_tg_pt_secondary_offline),
			atomic_read(&lun->lun_tg_pt_secondary_offline),
			lun->lun_tg_pt_secondary_stat);
			lun->lun_tg_pt_secondary_stat);


	snprintf(path, ALUA_METADATA_PATH_LEN, "/var/target/alua/%s/%s/lun_%u",
	snprintf(path, ALUA_METADATA_PATH_LEN, "/var/target/alua/%s/%s/lun_%llu",
			se_tpg->se_tpg_tfo->get_fabric_name(), wwn,
			se_tpg->se_tpg_tfo->get_fabric_name(), wwn,
			lun->unpacked_lun);
			lun->unpacked_lun);


+6 −6
Original line number Original line Diff line number Diff line
@@ -1438,7 +1438,7 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_holder_tg_port(
		tfo->tpg_get_wwn(se_tpg));
		tfo->tpg_get_wwn(se_tpg));
	len += sprintf(page+len, "SPC-3 Reservation: Relative Port"
	len += sprintf(page+len, "SPC-3 Reservation: Relative Port"
		" Identifier Tag: %hu %s Portal Group Tag: %hu"
		" Identifier Tag: %hu %s Portal Group Tag: %hu"
		" %s Logical Unit: %u\n", pr_reg->tg_pt_sep_rtpi,
		" %s Logical Unit: %llu\n", pr_reg->tg_pt_sep_rtpi,
		tfo->get_fabric_name(), tfo->tpg_get_tag(se_tpg),
		tfo->get_fabric_name(), tfo->tpg_get_tag(se_tpg),
		tfo->get_fabric_name(), pr_reg->pr_aptpl_target_lun);
		tfo->get_fabric_name(), pr_reg->pr_aptpl_target_lun);


@@ -1565,12 +1565,12 @@ static match_table_t tokens = {
	{Opt_res_type, "res_type=%d"},
	{Opt_res_type, "res_type=%d"},
	{Opt_res_scope, "res_scope=%d"},
	{Opt_res_scope, "res_scope=%d"},
	{Opt_res_all_tg_pt, "res_all_tg_pt=%d"},
	{Opt_res_all_tg_pt, "res_all_tg_pt=%d"},
	{Opt_mapped_lun, "mapped_lun=%d"},
	{Opt_mapped_lun, "mapped_lun=%lld"},
	{Opt_target_fabric, "target_fabric=%s"},
	{Opt_target_fabric, "target_fabric=%s"},
	{Opt_target_node, "target_node=%s"},
	{Opt_target_node, "target_node=%s"},
	{Opt_tpgt, "tpgt=%d"},
	{Opt_tpgt, "tpgt=%d"},
	{Opt_port_rtpi, "port_rtpi=%d"},
	{Opt_port_rtpi, "port_rtpi=%d"},
	{Opt_target_lun, "target_lun=%d"},
	{Opt_target_lun, "target_lun=%lld"},
	{Opt_err, NULL}
	{Opt_err, NULL}
};
};


@@ -1585,7 +1585,7 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata(
	substring_t args[MAX_OPT_ARGS];
	substring_t args[MAX_OPT_ARGS];
	unsigned long long tmp_ll;
	unsigned long long tmp_ll;
	u64 sa_res_key = 0;
	u64 sa_res_key = 0;
	u32 mapped_lun = 0, target_lun = 0;
	u64 mapped_lun = 0, target_lun = 0;
	int ret = -1, res_holder = 0, all_tg_pt = 0, arg, token;
	int ret = -1, res_holder = 0, all_tg_pt = 0, arg, token;
	u16 tpgt = 0;
	u16 tpgt = 0;
	u8 type = 0;
	u8 type = 0;
@@ -1675,7 +1675,7 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata(
			break;
			break;
		case Opt_mapped_lun:
		case Opt_mapped_lun:
			match_int(args, &arg);
			match_int(args, &arg);
			mapped_lun = (u32)arg;
			mapped_lun = (u64)arg;
			break;
			break;
		/*
		/*
		 * PR APTPL Metadata for Target Port
		 * PR APTPL Metadata for Target Port
@@ -1710,7 +1710,7 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata(
			break;
			break;
		case Opt_target_lun:
		case Opt_target_lun:
			match_int(args, &arg);
			match_int(args, &arg);
			target_lun = (u32)arg;
			target_lun = (u64)arg;
			break;
			break;
		default:
		default:
			break;
			break;
+15 −15
Original line number Original line Diff line number Diff line
@@ -56,7 +56,7 @@ static struct se_hba *lun0_hba;
struct se_device *g_lun0_dev;
struct se_device *g_lun0_dev;


sense_reason_t
sense_reason_t
transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 unpacked_lun)
transport_lookup_cmd_lun(struct se_cmd *se_cmd, u64 unpacked_lun)
{
{
	struct se_lun *se_lun = NULL;
	struct se_lun *se_lun = NULL;
	struct se_session *se_sess = se_cmd->se_sess;
	struct se_session *se_sess = se_cmd->se_sess;
@@ -74,7 +74,7 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 unpacked_lun)
		if ((se_cmd->data_direction == DMA_TO_DEVICE) &&
		if ((se_cmd->data_direction == DMA_TO_DEVICE) &&
		    (deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY)) {
		    (deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY)) {
			pr_err("TARGET_CORE[%s]: Detected WRITE_PROTECTED LUN"
			pr_err("TARGET_CORE[%s]: Detected WRITE_PROTECTED LUN"
				" Access for 0x%08x\n",
				" Access for 0x%08llx\n",
				se_cmd->se_tfo->get_fabric_name(),
				se_cmd->se_tfo->get_fabric_name(),
				unpacked_lun);
				unpacked_lun);
			rcu_read_unlock();
			rcu_read_unlock();
@@ -107,7 +107,7 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 unpacked_lun)
		 */
		 */
		if (unpacked_lun != 0) {
		if (unpacked_lun != 0) {
			pr_err("TARGET_CORE[%s]: Detected NON_EXISTENT_LUN"
			pr_err("TARGET_CORE[%s]: Detected NON_EXISTENT_LUN"
				" Access for 0x%08x\n",
				" Access for 0x%08llx\n",
				se_cmd->se_tfo->get_fabric_name(),
				se_cmd->se_tfo->get_fabric_name(),
				unpacked_lun);
				unpacked_lun);
			return TCM_NON_EXISTENT_LUN;
			return TCM_NON_EXISTENT_LUN;
@@ -147,7 +147,7 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 unpacked_lun)
}
}
EXPORT_SYMBOL(transport_lookup_cmd_lun);
EXPORT_SYMBOL(transport_lookup_cmd_lun);


int transport_lookup_tmr_lun(struct se_cmd *se_cmd, u32 unpacked_lun)
int transport_lookup_tmr_lun(struct se_cmd *se_cmd, u64 unpacked_lun)
{
{
	struct se_dev_entry *deve;
	struct se_dev_entry *deve;
	struct se_lun *se_lun = NULL;
	struct se_lun *se_lun = NULL;
@@ -172,7 +172,7 @@ int transport_lookup_tmr_lun(struct se_cmd *se_cmd, u32 unpacked_lun)


	if (!se_lun) {
	if (!se_lun) {
		pr_debug("TARGET_CORE[%s]: Detected NON_EXISTENT_LUN"
		pr_debug("TARGET_CORE[%s]: Detected NON_EXISTENT_LUN"
			" Access for 0x%08x\n",
			" Access for 0x%08llx\n",
			se_cmd->se_tfo->get_fabric_name(),
			se_cmd->se_tfo->get_fabric_name(),
			unpacked_lun);
			unpacked_lun);
		return -ENODEV;
		return -ENODEV;
@@ -260,7 +260,7 @@ void core_free_device_list_for_node(
}
}


void core_update_device_list_access(
void core_update_device_list_access(
	u32 mapped_lun,
	u64 mapped_lun,
	u32 lun_access,
	u32 lun_access,
	struct se_node_acl *nacl)
	struct se_node_acl *nacl)
{
{
@@ -283,7 +283,7 @@ void core_update_device_list_access(
/*
/*
 * Called with rcu_read_lock or nacl->device_list_lock held.
 * Called with rcu_read_lock or nacl->device_list_lock held.
 */
 */
struct se_dev_entry *target_nacl_find_deve(struct se_node_acl *nacl, u32 mapped_lun)
struct se_dev_entry *target_nacl_find_deve(struct se_node_acl *nacl, u64 mapped_lun)
{
{
	struct se_dev_entry *deve;
	struct se_dev_entry *deve;


@@ -309,7 +309,7 @@ void target_pr_kref_release(struct kref *kref)
int core_enable_device_list_for_node(
int core_enable_device_list_for_node(
	struct se_lun *lun,
	struct se_lun *lun,
	struct se_lun_acl *lun_acl,
	struct se_lun_acl *lun_acl,
	u32 mapped_lun,
	u64 mapped_lun,
	u32 lun_access,
	u32 lun_access,
	struct se_node_acl *nacl,
	struct se_node_acl *nacl,
	struct se_portal_group *tpg)
	struct se_portal_group *tpg)
@@ -550,7 +550,7 @@ int core_dev_add_lun(
	if (rc < 0)
	if (rc < 0)
		return rc;
		return rc;


	pr_debug("%s_TPG[%u]_LUN[%u] - Activated %s Logical Unit from"
	pr_debug("%s_TPG[%u]_LUN[%llu] - Activated %s Logical Unit from"
		" CORE HBA: %u\n", tpg->se_tpg_tfo->get_fabric_name(),
		" CORE HBA: %u\n", tpg->se_tpg_tfo->get_fabric_name(),
		tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun,
		tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun,
		tpg->se_tpg_tfo->get_fabric_name(), dev->se_hba->hba_id);
		tpg->se_tpg_tfo->get_fabric_name(), dev->se_hba->hba_id);
@@ -583,7 +583,7 @@ void core_dev_del_lun(
	struct se_portal_group *tpg,
	struct se_portal_group *tpg,
	struct se_lun *lun)
	struct se_lun *lun)
{
{
	pr_debug("%s_TPG[%u]_LUN[%u] - Deactivating %s Logical Unit from"
	pr_debug("%s_TPG[%u]_LUN[%llu] - Deactivating %s Logical Unit from"
		" device object\n", tpg->se_tpg_tfo->get_fabric_name(),
		" device object\n", tpg->se_tpg_tfo->get_fabric_name(),
		tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun,
		tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun,
		tpg->se_tpg_tfo->get_fabric_name());
		tpg->se_tpg_tfo->get_fabric_name());
@@ -594,7 +594,7 @@ void core_dev_del_lun(
struct se_lun_acl *core_dev_init_initiator_node_lun_acl(
struct se_lun_acl *core_dev_init_initiator_node_lun_acl(
	struct se_portal_group *tpg,
	struct se_portal_group *tpg,
	struct se_node_acl *nacl,
	struct se_node_acl *nacl,
	u32 mapped_lun,
	u64 mapped_lun,
	int *ret)
	int *ret)
{
{
	struct se_lun_acl *lacl;
	struct se_lun_acl *lacl;
@@ -646,7 +646,7 @@ int core_dev_add_initiator_node_lun_acl(
			lun_access, nacl, tpg) < 0)
			lun_access, nacl, tpg) < 0)
		return -EINVAL;
		return -EINVAL;


	pr_debug("%s_TPG[%hu]_LUN[%u->%u] - Added %s ACL for "
	pr_debug("%s_TPG[%hu]_LUN[%llu->%llu] - Added %s ACL for "
		" InitiatorNode: %s\n", tpg->se_tpg_tfo->get_fabric_name(),
		" InitiatorNode: %s\n", tpg->se_tpg_tfo->get_fabric_name(),
		tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun, lacl->mapped_lun,
		tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun, lacl->mapped_lun,
		(lun_access & TRANSPORT_LUNFLAGS_READ_WRITE) ? "RW" : "RO",
		(lun_access & TRANSPORT_LUNFLAGS_READ_WRITE) ? "RW" : "RO",
@@ -678,8 +678,8 @@ int core_dev_del_initiator_node_lun_acl(
		core_disable_device_list_for_node(lun, deve, nacl, tpg);
		core_disable_device_list_for_node(lun, deve, nacl, tpg);
	mutex_unlock(&nacl->lun_entry_mutex);
	mutex_unlock(&nacl->lun_entry_mutex);


	pr_debug("%s_TPG[%hu]_LUN[%u] - Removed ACL for"
	pr_debug("%s_TPG[%hu]_LUN[%llu] - Removed ACL for"
		" InitiatorNode: %s Mapped LUN: %u\n",
		" InitiatorNode: %s Mapped LUN: %llu\n",
		tpg->se_tpg_tfo->get_fabric_name(),
		tpg->se_tpg_tfo->get_fabric_name(),
		tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun,
		tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun,
		lacl->initiatorname, lacl->mapped_lun);
		lacl->initiatorname, lacl->mapped_lun);
@@ -692,7 +692,7 @@ void core_dev_free_initiator_node_lun_acl(
	struct se_lun_acl *lacl)
	struct se_lun_acl *lacl)
{
{
	pr_debug("%s_TPG[%hu] - Freeing ACL for %s InitiatorNode: %s"
	pr_debug("%s_TPG[%hu] - Freeing ACL for %s InitiatorNode: %s"
		" Mapped LUN: %u\n", tpg->se_tpg_tfo->get_fabric_name(),
		" Mapped LUN: %llu\n", tpg->se_tpg_tfo->get_fabric_name(),
		tpg->se_tpg_tfo->tpg_get_tag(tpg),
		tpg->se_tpg_tfo->tpg_get_tag(tpg),
		tpg->se_tpg_tfo->get_fabric_name(),
		tpg->se_tpg_tfo->get_fabric_name(),
		lacl->initiatorname, lacl->mapped_lun);
		lacl->initiatorname, lacl->mapped_lun);
Loading