Commit e3d6f909 authored by Andy Grover's avatar Andy Grover Committed by Nicholas Bellinger

target: Core cleanups from AGrover (round 1)

This patch contains the squashed version of a number of cleanups and
minor fixes from Andy's initial series (round 1) for target core this
past spring.  The condensed log looks like:

target: use errno values instead of returning -1 for everything
target: Rename transport_calc_sg_num to transport_init_task_sg
target: Fix leak in error path in transport_init_task_sg
target/pscsi: Remove pscsi_get_sh() usage
target: Make two runtime checks into WARN_ONs
target: Remove hba queue depth and convert to spin_lock_irq usage
target: dev->dev_status_queue_obj is unused
target: Make struct se_queue_req.cmd type struct se_cmd *
target: Remove __transport_get_qr_from_queue()
target: Rename se_dev->g_se_dev_list to se_dev_node
target: Remove struct se_global
target: Simplify scsi mib index table code
target: Make dev_queue_obj a member of se_device instead of a pointer
target: remove extraneous returns at end of void functions
target: Ensure transport_dump_vpd_ident_type returns null-terminated str
target: Function pointers don't need to use '&' to be assigned
target: Fix comment in __transport_execute_tasks()
target: Misc style cleanups
target: rename struct pr_reservation_template to pr_reservation
target: Remove #defines that just perform indirection
target: Inline transport_get_task_from_execute_queue()
target: Minor header comment fixes
Signed-off-by: default avatarAndy Grover <agrover@redhat.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent a8c6da90
...@@ -118,7 +118,7 @@ static struct se_cmd *tcm_loop_allocate_core_cmd( ...@@ -118,7 +118,7 @@ static struct se_cmd *tcm_loop_allocate_core_cmd(
* Signal BIDI usage with T_TASK(cmd)->t_tasks_bidi * Signal BIDI usage with T_TASK(cmd)->t_tasks_bidi
*/ */
if (scsi_bidi_cmnd(sc)) if (scsi_bidi_cmnd(sc))
T_TASK(se_cmd)->t_tasks_bidi = 1; se_cmd->t_task->t_tasks_bidi = 1;
/* /*
* Locate the struct se_lun pointer and attach it to struct se_cmd * Locate the struct se_lun pointer and attach it to struct se_cmd
*/ */
...@@ -176,7 +176,7 @@ static int tcm_loop_new_cmd_map(struct se_cmd *se_cmd) ...@@ -176,7 +176,7 @@ static int tcm_loop_new_cmd_map(struct se_cmd *se_cmd)
* For BIDI commands, pass in the extra READ buffer * For BIDI commands, pass in the extra READ buffer
* to transport_generic_map_mem_to_cmd() below.. * to transport_generic_map_mem_to_cmd() below..
*/ */
if (T_TASK(se_cmd)->t_tasks_bidi) { if (se_cmd->t_task->t_tasks_bidi) {
struct scsi_data_buffer *sdb = scsi_in(sc); struct scsi_data_buffer *sdb = scsi_in(sc);
mem_bidi_ptr = (void *)sdb->table.sgl; mem_bidi_ptr = (void *)sdb->table.sgl;
...@@ -1402,9 +1402,9 @@ static int tcm_loop_register_configfs(void) ...@@ -1402,9 +1402,9 @@ static int tcm_loop_register_configfs(void)
* Register the top level struct config_item_type with TCM core * Register the top level struct config_item_type with TCM core
*/ */
fabric = target_fabric_configfs_init(THIS_MODULE, "loopback"); fabric = target_fabric_configfs_init(THIS_MODULE, "loopback");
if (!fabric) { if (IS_ERR(fabric)) {
printk(KERN_ERR "tcm_loop_register_configfs() failed!\n"); printk(KERN_ERR "tcm_loop_register_configfs() failed!\n");
return -1; return PTR_ERR(fabric);
} }
/* /*
* Setup the fabric API of function pointers used by target_core_mod * Setup the fabric API of function pointers used by target_core_mod
......
...@@ -46,6 +46,14 @@ static int core_alua_set_tg_pt_secondary_state( ...@@ -46,6 +46,14 @@ static int core_alua_set_tg_pt_secondary_state(
struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem, struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem,
struct se_port *port, int explict, int offline); struct se_port *port, int explict, int offline);
static u16 alua_lu_gps_counter;
static u32 alua_lu_gps_count;
static DEFINE_SPINLOCK(lu_gps_lock);
static LIST_HEAD(lu_gps_list);
struct t10_alua_lu_gp *default_lu_gp;
/* /*
* REPORT_TARGET_PORT_GROUPS * REPORT_TARGET_PORT_GROUPS
* *
...@@ -53,16 +61,16 @@ static int core_alua_set_tg_pt_secondary_state( ...@@ -53,16 +61,16 @@ static int core_alua_set_tg_pt_secondary_state(
*/ */
int core_emulate_report_target_port_groups(struct se_cmd *cmd) int core_emulate_report_target_port_groups(struct se_cmd *cmd)
{ {
struct se_subsystem_dev *su_dev = SE_DEV(cmd)->se_sub_dev; struct se_subsystem_dev *su_dev = cmd->se_lun->lun_se_dev->se_sub_dev;
struct se_port *port; struct se_port *port;
struct t10_alua_tg_pt_gp *tg_pt_gp; struct t10_alua_tg_pt_gp *tg_pt_gp;
struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem; struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem;
unsigned char *buf = (unsigned char *)T_TASK(cmd)->t_task_buf; unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf;
u32 rd_len = 0, off = 4; /* Skip over RESERVED area to first u32 rd_len = 0, off = 4; /* Skip over RESERVED area to first
Target port group descriptor */ Target port group descriptor */
spin_lock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_lock(&su_dev->t10_alua.tg_pt_gps_lock);
list_for_each_entry(tg_pt_gp, &T10_ALUA(su_dev)->tg_pt_gps_list, list_for_each_entry(tg_pt_gp, &su_dev->t10_alua.tg_pt_gps_list,
tg_pt_gp_list) { tg_pt_gp_list) {
/* /*
* PREF: Preferred target port bit, determine if this * PREF: Preferred target port bit, determine if this
...@@ -124,7 +132,7 @@ int core_emulate_report_target_port_groups(struct se_cmd *cmd) ...@@ -124,7 +132,7 @@ int core_emulate_report_target_port_groups(struct se_cmd *cmd)
} }
spin_unlock(&tg_pt_gp->tg_pt_gp_lock); spin_unlock(&tg_pt_gp->tg_pt_gp_lock);
} }
spin_unlock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_unlock(&su_dev->t10_alua.tg_pt_gps_lock);
/* /*
* Set the RETURN DATA LENGTH set in the header of the DataIN Payload * Set the RETURN DATA LENGTH set in the header of the DataIN Payload
*/ */
...@@ -143,13 +151,13 @@ int core_emulate_report_target_port_groups(struct se_cmd *cmd) ...@@ -143,13 +151,13 @@ int core_emulate_report_target_port_groups(struct se_cmd *cmd)
*/ */
int core_emulate_set_target_port_groups(struct se_cmd *cmd) int core_emulate_set_target_port_groups(struct se_cmd *cmd)
{ {
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_subsystem_dev *su_dev = SE_DEV(cmd)->se_sub_dev; struct se_subsystem_dev *su_dev = dev->se_sub_dev;
struct se_port *port, *l_port = SE_LUN(cmd)->lun_sep; struct se_port *port, *l_port = cmd->se_lun->lun_sep;
struct se_node_acl *nacl = SE_SESS(cmd)->se_node_acl; struct se_node_acl *nacl = cmd->se_sess->se_node_acl;
struct t10_alua_tg_pt_gp *tg_pt_gp = NULL, *l_tg_pt_gp; struct t10_alua_tg_pt_gp *tg_pt_gp = NULL, *l_tg_pt_gp;
struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem, *l_tg_pt_gp_mem; struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem, *l_tg_pt_gp_mem;
unsigned char *buf = (unsigned char *)T_TASK(cmd)->t_task_buf; unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf;
unsigned char *ptr = &buf[4]; /* Skip over RESERVED area in header */ unsigned char *ptr = &buf[4]; /* Skip over RESERVED area in header */
u32 len = 4; /* Skip over RESERVED area in header */ u32 len = 4; /* Skip over RESERVED area in header */
int alua_access_state, primary = 0, rc; int alua_access_state, primary = 0, rc;
...@@ -224,9 +232,9 @@ int core_emulate_set_target_port_groups(struct se_cmd *cmd) ...@@ -224,9 +232,9 @@ int core_emulate_set_target_port_groups(struct se_cmd *cmd)
* Locate the matching target port group ID from * Locate the matching target port group ID from
* the global tg_pt_gp list * the global tg_pt_gp list
*/ */
spin_lock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_lock(&su_dev->t10_alua.tg_pt_gps_lock);
list_for_each_entry(tg_pt_gp, list_for_each_entry(tg_pt_gp,
&T10_ALUA(su_dev)->tg_pt_gps_list, &su_dev->t10_alua.tg_pt_gps_list,
tg_pt_gp_list) { tg_pt_gp_list) {
if (!(tg_pt_gp->tg_pt_gp_valid_id)) if (!(tg_pt_gp->tg_pt_gp_valid_id))
continue; continue;
...@@ -236,18 +244,18 @@ int core_emulate_set_target_port_groups(struct se_cmd *cmd) ...@@ -236,18 +244,18 @@ int core_emulate_set_target_port_groups(struct se_cmd *cmd)
atomic_inc(&tg_pt_gp->tg_pt_gp_ref_cnt); atomic_inc(&tg_pt_gp->tg_pt_gp_ref_cnt);
smp_mb__after_atomic_inc(); smp_mb__after_atomic_inc();
spin_unlock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_unlock(&su_dev->t10_alua.tg_pt_gps_lock);
rc = core_alua_do_port_transition(tg_pt_gp, rc = core_alua_do_port_transition(tg_pt_gp,
dev, l_port, nacl, dev, l_port, nacl,
alua_access_state, 1); alua_access_state, 1);
spin_lock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_lock(&su_dev->t10_alua.tg_pt_gps_lock);
atomic_dec(&tg_pt_gp->tg_pt_gp_ref_cnt); atomic_dec(&tg_pt_gp->tg_pt_gp_ref_cnt);
smp_mb__after_atomic_dec(); smp_mb__after_atomic_dec();
break; break;
} }
spin_unlock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_unlock(&su_dev->t10_alua.tg_pt_gps_lock);
/* /*
* If not matching target port group ID can be located * If not matching target port group ID can be located
* throw an exception with ASCQ: INVALID_PARAMETER_LIST * throw an exception with ASCQ: INVALID_PARAMETER_LIST
...@@ -464,7 +472,7 @@ static int core_alua_state_check( ...@@ -464,7 +472,7 @@ static int core_alua_state_check(
unsigned char *cdb, unsigned char *cdb,
u8 *alua_ascq) u8 *alua_ascq)
{ {
struct se_lun *lun = SE_LUN(cmd); struct se_lun *lun = cmd->se_lun;
struct se_port *port = lun->lun_sep; struct se_port *port = lun->lun_sep;
struct t10_alua_tg_pt_gp *tg_pt_gp; struct t10_alua_tg_pt_gp *tg_pt_gp;
struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem; struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem;
...@@ -522,7 +530,7 @@ static int core_alua_state_check( ...@@ -522,7 +530,7 @@ static int core_alua_state_check(
default: default:
printk(KERN_ERR "Unknown ALUA access state: 0x%02x\n", printk(KERN_ERR "Unknown ALUA access state: 0x%02x\n",
out_alua_state); out_alua_state);
return -1; return -EINVAL;
} }
return 0; return 0;
...@@ -553,7 +561,7 @@ static int core_alua_check_transition(int state, int *primary) ...@@ -553,7 +561,7 @@ static int core_alua_check_transition(int state, int *primary)
break; break;
default: default:
printk(KERN_ERR "Unknown ALUA access state: 0x%02x\n", state); printk(KERN_ERR "Unknown ALUA access state: 0x%02x\n", state);
return -1; return -EINVAL;
} }
return 0; return 0;
...@@ -866,9 +874,9 @@ int core_alua_do_port_transition( ...@@ -866,9 +874,9 @@ int core_alua_do_port_transition(
smp_mb__after_atomic_inc(); smp_mb__after_atomic_inc();
spin_unlock(&lu_gp->lu_gp_lock); spin_unlock(&lu_gp->lu_gp_lock);
spin_lock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_lock(&su_dev->t10_alua.tg_pt_gps_lock);
list_for_each_entry(tg_pt_gp, list_for_each_entry(tg_pt_gp,
&T10_ALUA(su_dev)->tg_pt_gps_list, &su_dev->t10_alua.tg_pt_gps_list,
tg_pt_gp_list) { tg_pt_gp_list) {
if (!(tg_pt_gp->tg_pt_gp_valid_id)) if (!(tg_pt_gp->tg_pt_gp_valid_id))
...@@ -893,7 +901,7 @@ int core_alua_do_port_transition( ...@@ -893,7 +901,7 @@ int core_alua_do_port_transition(
} }
atomic_inc(&tg_pt_gp->tg_pt_gp_ref_cnt); atomic_inc(&tg_pt_gp->tg_pt_gp_ref_cnt);
smp_mb__after_atomic_inc(); smp_mb__after_atomic_inc();
spin_unlock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_unlock(&su_dev->t10_alua.tg_pt_gps_lock);
/* /*
* core_alua_do_transition_tg_pt() will always return * core_alua_do_transition_tg_pt() will always return
* success. * success.
...@@ -901,11 +909,11 @@ int core_alua_do_port_transition( ...@@ -901,11 +909,11 @@ int core_alua_do_port_transition(
core_alua_do_transition_tg_pt(tg_pt_gp, port, core_alua_do_transition_tg_pt(tg_pt_gp, port,
nacl, md_buf, new_state, explict); nacl, md_buf, new_state, explict);
spin_lock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_lock(&su_dev->t10_alua.tg_pt_gps_lock);
atomic_dec(&tg_pt_gp->tg_pt_gp_ref_cnt); atomic_dec(&tg_pt_gp->tg_pt_gp_ref_cnt);
smp_mb__after_atomic_dec(); smp_mb__after_atomic_dec();
} }
spin_unlock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_unlock(&su_dev->t10_alua.tg_pt_gps_lock);
spin_lock(&lu_gp->lu_gp_lock); spin_lock(&lu_gp->lu_gp_lock);
atomic_dec(&lu_gp_mem->lu_gp_mem_ref_cnt); atomic_dec(&lu_gp_mem->lu_gp_mem_ref_cnt);
...@@ -942,11 +950,11 @@ static int core_alua_update_tpg_secondary_metadata( ...@@ -942,11 +950,11 @@ static int core_alua_update_tpg_secondary_metadata(
memset(wwn, 0, ALUA_SECONDARY_METADATA_WWN_LEN); memset(wwn, 0, ALUA_SECONDARY_METADATA_WWN_LEN);
len = snprintf(wwn, ALUA_SECONDARY_METADATA_WWN_LEN, "%s", len = snprintf(wwn, ALUA_SECONDARY_METADATA_WWN_LEN, "%s",
TPG_TFO(se_tpg)->tpg_get_wwn(se_tpg)); se_tpg->se_tpg_tfo->tpg_get_wwn(se_tpg));
if (TPG_TFO(se_tpg)->tpg_get_tag != NULL) if (se_tpg->se_tpg_tfo->tpg_get_tag != NULL)
snprintf(wwn+len, ALUA_SECONDARY_METADATA_WWN_LEN-len, "+%hu", snprintf(wwn+len, ALUA_SECONDARY_METADATA_WWN_LEN-len, "+%hu",
TPG_TFO(se_tpg)->tpg_get_tag(se_tpg)); se_tpg->se_tpg_tfo->tpg_get_tag(se_tpg));
len = snprintf(md_buf, md_buf_len, "alua_tg_pt_offline=%d\n" len = snprintf(md_buf, md_buf_len, "alua_tg_pt_offline=%d\n"
"alua_tg_pt_status=0x%02x\n", "alua_tg_pt_status=0x%02x\n",
...@@ -954,7 +962,7 @@ static int core_alua_update_tpg_secondary_metadata( ...@@ -954,7 +962,7 @@ static int core_alua_update_tpg_secondary_metadata(
port->sep_tg_pt_secondary_stat); port->sep_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_%u",
TPG_TFO(se_tpg)->get_fabric_name(), wwn, se_tpg->se_tpg_tfo->get_fabric_name(), wwn,
port->sep_lun->unpacked_lun); port->sep_lun->unpacked_lun);
return core_alua_write_tpg_metadata(path, md_buf, len); return core_alua_write_tpg_metadata(path, md_buf, len);
...@@ -977,7 +985,7 @@ static int core_alua_set_tg_pt_secondary_state( ...@@ -977,7 +985,7 @@ static int core_alua_set_tg_pt_secondary_state(
spin_unlock(&tg_pt_gp_mem->tg_pt_gp_mem_lock); spin_unlock(&tg_pt_gp_mem->tg_pt_gp_mem_lock);
printk(KERN_ERR "Unable to complete secondary state" printk(KERN_ERR "Unable to complete secondary state"
" transition\n"); " transition\n");
return -1; return -EINVAL;
} }
trans_delay_msecs = tg_pt_gp->tg_pt_gp_trans_delay_msecs; trans_delay_msecs = tg_pt_gp->tg_pt_gp_trans_delay_msecs;
/* /*
...@@ -1015,7 +1023,7 @@ static int core_alua_set_tg_pt_secondary_state( ...@@ -1015,7 +1023,7 @@ static int core_alua_set_tg_pt_secondary_state(
if (!(md_buf)) { if (!(md_buf)) {
printk(KERN_ERR "Unable to allocate md_buf for" printk(KERN_ERR "Unable to allocate md_buf for"
" secondary ALUA access metadata\n"); " secondary ALUA access metadata\n");
return -1; return -ENOMEM;
} }
mutex_lock(&port->sep_tg_pt_md_mutex); mutex_lock(&port->sep_tg_pt_md_mutex);
core_alua_update_tpg_secondary_metadata(tg_pt_gp_mem, port, core_alua_update_tpg_secondary_metadata(tg_pt_gp_mem, port,
...@@ -1038,15 +1046,15 @@ core_alua_allocate_lu_gp(const char *name, int def_group) ...@@ -1038,15 +1046,15 @@ core_alua_allocate_lu_gp(const char *name, int def_group)
printk(KERN_ERR "Unable to allocate struct t10_alua_lu_gp\n"); printk(KERN_ERR "Unable to allocate struct t10_alua_lu_gp\n");
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
INIT_LIST_HEAD(&lu_gp->lu_gp_list); INIT_LIST_HEAD(&lu_gp->lu_gp_node);
INIT_LIST_HEAD(&lu_gp->lu_gp_mem_list); INIT_LIST_HEAD(&lu_gp->lu_gp_mem_list);
spin_lock_init(&lu_gp->lu_gp_lock); spin_lock_init(&lu_gp->lu_gp_lock);
atomic_set(&lu_gp->lu_gp_ref_cnt, 0); atomic_set(&lu_gp->lu_gp_ref_cnt, 0);
if (def_group) { if (def_group) {
lu_gp->lu_gp_id = se_global->alua_lu_gps_counter++; lu_gp->lu_gp_id = alua_lu_gps_counter++;
lu_gp->lu_gp_valid_id = 1; lu_gp->lu_gp_valid_id = 1;
se_global->alua_lu_gps_count++; alua_lu_gps_count++;
} }
return lu_gp; return lu_gp;
...@@ -1062,22 +1070,22 @@ int core_alua_set_lu_gp_id(struct t10_alua_lu_gp *lu_gp, u16 lu_gp_id) ...@@ -1062,22 +1070,22 @@ int core_alua_set_lu_gp_id(struct t10_alua_lu_gp *lu_gp, u16 lu_gp_id)
if (lu_gp->lu_gp_valid_id) { if (lu_gp->lu_gp_valid_id) {
printk(KERN_WARNING "ALUA LU Group already has a valid ID," printk(KERN_WARNING "ALUA LU Group already has a valid ID,"
" ignoring request\n"); " ignoring request\n");
return -1; return -EINVAL;
} }
spin_lock(&se_global->lu_gps_lock); spin_lock(&lu_gps_lock);
if (se_global->alua_lu_gps_count == 0x0000ffff) { if (alua_lu_gps_count == 0x0000ffff) {
printk(KERN_ERR "Maximum ALUA se_global->alua_lu_gps_count:" printk(KERN_ERR "Maximum ALUA alua_lu_gps_count:"
" 0x0000ffff reached\n"); " 0x0000ffff reached\n");
spin_unlock(&se_global->lu_gps_lock); spin_unlock(&lu_gps_lock);
kmem_cache_free(t10_alua_lu_gp_cache, lu_gp); kmem_cache_free(t10_alua_lu_gp_cache, lu_gp);
return -1; return -ENOSPC;
} }
again: again:
lu_gp_id_tmp = (lu_gp_id != 0) ? lu_gp_id : lu_gp_id_tmp = (lu_gp_id != 0) ? lu_gp_id :
se_global->alua_lu_gps_counter++; alua_lu_gps_counter++;
list_for_each_entry(lu_gp_tmp, &se_global->g_lu_gps_list, lu_gp_list) { list_for_each_entry(lu_gp_tmp, &lu_gps_list, lu_gp_node) {
if (lu_gp_tmp->lu_gp_id == lu_gp_id_tmp) { if (lu_gp_tmp->lu_gp_id == lu_gp_id_tmp) {
if (!(lu_gp_id)) if (!(lu_gp_id))
goto again; goto again;
...@@ -1085,16 +1093,16 @@ int core_alua_set_lu_gp_id(struct t10_alua_lu_gp *lu_gp, u16 lu_gp_id) ...@@ -1085,16 +1093,16 @@ int core_alua_set_lu_gp_id(struct t10_alua_lu_gp *lu_gp, u16 lu_gp_id)
printk(KERN_WARNING "ALUA Logical Unit Group ID: %hu" printk(KERN_WARNING "ALUA Logical Unit Group ID: %hu"
" already exists, ignoring request\n", " already exists, ignoring request\n",
lu_gp_id); lu_gp_id);
spin_unlock(&se_global->lu_gps_lock); spin_unlock(&lu_gps_lock);
return -1; return -EINVAL;
} }
} }
lu_gp->lu_gp_id = lu_gp_id_tmp; lu_gp->lu_gp_id = lu_gp_id_tmp;
lu_gp->lu_gp_valid_id = 1; lu_gp->lu_gp_valid_id = 1;
list_add_tail(&lu_gp->lu_gp_list, &se_global->g_lu_gps_list); list_add_tail(&lu_gp->lu_gp_node, &lu_gps_list);
se_global->alua_lu_gps_count++; alua_lu_gps_count++;
spin_unlock(&se_global->lu_gps_lock); spin_unlock(&lu_gps_lock);
return 0; return 0;
} }
...@@ -1130,11 +1138,11 @@ void core_alua_free_lu_gp(struct t10_alua_lu_gp *lu_gp) ...@@ -1130,11 +1138,11 @@ void core_alua_free_lu_gp(struct t10_alua_lu_gp *lu_gp)
* no associations can be made while we are releasing * no associations can be made while we are releasing
* struct t10_alua_lu_gp. * struct t10_alua_lu_gp.
*/ */
spin_lock(&se_global->lu_gps_lock); spin_lock(&lu_gps_lock);
atomic_set(&lu_gp->lu_gp_shutdown, 1); atomic_set(&lu_gp->lu_gp_shutdown, 1);
list_del(&lu_gp->lu_gp_list); list_del(&lu_gp->lu_gp_node);
se_global->alua_lu_gps_count--; alua_lu_gps_count--;
spin_unlock(&se_global->lu_gps_lock); spin_unlock(&lu_gps_lock);
/* /*
* Allow struct t10_alua_lu_gp * referenced by core_alua_get_lu_gp_by_name() * Allow struct t10_alua_lu_gp * referenced by core_alua_get_lu_gp_by_name()
* in target_core_configfs.c:target_core_store_alua_lu_gp() to be * in target_core_configfs.c:target_core_store_alua_lu_gp() to be
...@@ -1165,9 +1173,9 @@ void core_alua_free_lu_gp(struct t10_alua_lu_gp *lu_gp) ...@@ -1165,9 +1173,9 @@ void core_alua_free_lu_gp(struct t10_alua_lu_gp *lu_gp)
* we want to re-assocate a given lu_gp_mem with default_lu_gp. * we want to re-assocate a given lu_gp_mem with default_lu_gp.
*/ */
spin_lock(&lu_gp_mem->lu_gp_mem_lock); spin_lock(&lu_gp_mem->lu_gp_mem_lock);
if (lu_gp != se_global->default_lu_gp) if (lu_gp != default_lu_gp)
__core_alua_attach_lu_gp_mem(lu_gp_mem, __core_alua_attach_lu_gp_mem(lu_gp_mem,
se_global->default_lu_gp); default_lu_gp);
else else
lu_gp_mem->lu_gp = NULL; lu_gp_mem->lu_gp = NULL;
spin_unlock(&lu_gp_mem->lu_gp_mem_lock); spin_unlock(&lu_gp_mem->lu_gp_mem_lock);
...@@ -1182,7 +1190,7 @@ void core_alua_free_lu_gp(struct t10_alua_lu_gp *lu_gp) ...@@ -1182,7 +1190,7 @@ void core_alua_free_lu_gp(struct t10_alua_lu_gp *lu_gp)
void core_alua_free_lu_gp_mem(struct se_device *dev) void core_alua_free_lu_gp_mem(struct se_device *dev)
{ {
struct se_subsystem_dev *su_dev = dev->se_sub_dev; struct se_subsystem_dev *su_dev = dev->se_sub_dev;
struct t10_alua *alua = T10_ALUA(su_dev); struct t10_alua *alua = &su_dev->t10_alua;
struct t10_alua_lu_gp *lu_gp; struct t10_alua_lu_gp *lu_gp;
struct t10_alua_lu_gp_member *lu_gp_mem; struct t10_alua_lu_gp_member *lu_gp_mem;
...@@ -1218,27 +1226,27 @@ struct t10_alua_lu_gp *core_alua_get_lu_gp_by_name(const char *name) ...@@ -1218,27 +1226,27 @@ struct t10_alua_lu_gp *core_alua_get_lu_gp_by_name(const char *name)
struct t10_alua_lu_gp *lu_gp; struct t10_alua_lu_gp *lu_gp;
struct config_item *ci; struct config_item *ci;
spin_lock(&se_global->lu_gps_lock); spin_lock(&lu_gps_lock);
list_for_each_entry(lu_gp, &se_global->g_lu_gps_list, lu_gp_list) { list_for_each_entry(lu_gp, &lu_gps_list, lu_gp_node) {
if (!(lu_gp->lu_gp_valid_id)) if (!(lu_gp->lu_gp_valid_id))
continue; continue;
ci = &lu_gp->lu_gp_group.cg_item; ci = &lu_gp->lu_gp_group.cg_item;
if (!(strcmp(config_item_name(ci), name))) { if (!(strcmp(config_item_name(ci), name))) {
atomic_inc(&lu_gp->lu_gp_ref_cnt); atomic_inc(&lu_gp->lu_gp_ref_cnt);
spin_unlock(&se_global->lu_gps_lock); spin_unlock(&lu_gps_lock);
return lu_gp; return lu_gp;
} }
} }
spin_unlock(&se_global->lu_gps_lock); spin_unlock(&lu_gps_lock);
return NULL; return NULL;
} }
void core_alua_put_lu_gp_from_name(struct t10_alua_lu_gp *lu_gp) void core_alua_put_lu_gp_from_name(struct t10_alua_lu_gp *lu_gp)
{ {
spin_lock(&se_global->lu_gps_lock); spin_lock(&lu_gps_lock);
atomic_dec(&lu_gp->lu_gp_ref_cnt); atomic_dec(&lu_gp->lu_gp_ref_cnt);
spin_unlock(&se_global->lu_gps_lock); spin_unlock(&lu_gps_lock);
} }
/* /*
...@@ -1304,14 +1312,14 @@ struct t10_alua_tg_pt_gp *core_alua_allocate_tg_pt_gp( ...@@ -1304,14 +1312,14 @@ struct t10_alua_tg_pt_gp *core_alua_allocate_tg_pt_gp(
tg_pt_gp->tg_pt_gp_trans_delay_msecs = ALUA_DEFAULT_TRANS_DELAY_MSECS; tg_pt_gp->tg_pt_gp_trans_delay_msecs = ALUA_DEFAULT_TRANS_DELAY_MSECS;
if (def_group) { if (def_group) {
spin_lock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_lock(&su_dev->t10_alua.tg_pt_gps_lock);
tg_pt_gp->tg_pt_gp_id = tg_pt_gp->tg_pt_gp_id =
T10_ALUA(su_dev)->alua_tg_pt_gps_counter++; su_dev->t10_alua.alua_tg_pt_gps_counter++;
tg_pt_gp->tg_pt_gp_valid_id = 1; tg_pt_gp->tg_pt_gp_valid_id = 1;
T10_ALUA(su_dev)->alua_tg_pt_gps_count++; su_dev->t10_alua.alua_tg_pt_gps_count++;
list_add_tail(&tg_pt_gp->tg_pt_gp_list, list_add_tail(&tg_pt_gp->tg_pt_gp_list,
&T10_ALUA(su_dev)->tg_pt_gps_list); &su_dev->t10_alua.tg_pt_gps_list);
spin_unlock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_unlock(&su_dev->t10_alua.tg_pt_gps_lock);
} }
return tg_pt_gp; return tg_pt_gp;
...@@ -1330,22 +1338,22 @@ int core_alua_set_tg_pt_gp_id( ...@@ -1330,22 +1338,22 @@ int core_alua_set_tg_pt_gp_id(
if (tg_pt_gp->tg_pt_gp_valid_id) { if (tg_pt_gp->tg_pt_gp_valid_id) {
printk(KERN_WARNING "ALUA TG PT Group already has a valid ID," printk(KERN_WARNING "ALUA TG PT Group already has a valid ID,"
" ignoring request\n"); " ignoring request\n");
return -1; return -EINVAL;
} }
spin_lock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_lock(&su_dev->t10_alua.tg_pt_gps_lock);
if (T10_ALUA(su_dev)->alua_tg_pt_gps_count == 0x0000ffff) { if (su_dev->t10_alua.alua_tg_pt_gps_count == 0x0000ffff) {
printk(KERN_ERR "Maximum ALUA alua_tg_pt_gps_count:" printk(KERN_ERR "Maximum ALUA alua_tg_pt_gps_count:"
" 0x0000ffff reached\n"); " 0x0000ffff reached\n");
spin_unlock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_unlock(&su_dev->t10_alua.tg_pt_gps_lock);
kmem_cache_free(t10_alua_tg_pt_gp_cache, tg_pt_gp); kmem_cache_free(t10_alua_tg_pt_gp_cache, tg_pt_gp);
return -1; return -ENOSPC;
} }
again: again:
tg_pt_gp_id_tmp = (tg_pt_gp_id != 0) ? tg_pt_gp_id : tg_pt_gp_id_tmp = (tg_pt_gp_id != 0) ? tg_pt_gp_id :
T10_ALUA(su_dev)->alua_tg_pt_gps_counter++; su_dev->t10_alua.alua_tg_pt_gps_counter++;
list_for_each_entry(tg_pt_gp_tmp, &T10_ALUA(su_dev)->tg_pt_gps_list, list_for_each_entry(tg_pt_gp_tmp, &su_dev->t10_alua.tg_pt_gps_list,
tg_pt_gp_list) { tg_pt_gp_list) {
if (tg_pt_gp_tmp->tg_pt_gp_id == tg_pt_gp_id_tmp) { if (tg_pt_gp_tmp->tg_pt_gp_id == tg_pt_gp_id_tmp) {
if (!(tg_pt_gp_id)) if (!(tg_pt_gp_id))
...@@ -1353,17 +1361,17 @@ int core_alua_set_tg_pt_gp_id( ...@@ -1353,17 +1361,17 @@ int core_alua_set_tg_pt_gp_id(
printk(KERN_ERR "ALUA Target Port Group ID: %hu already" printk(KERN_ERR "ALUA Target Port Group ID: %hu already"
" exists, ignoring request\n", tg_pt_gp_id); " exists, ignoring request\n", tg_pt_gp_id);
spin_unlock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_unlock(&su_dev->t10_alua.tg_pt_gps_lock);
return -1; return -EINVAL;
} }
} }
tg_pt_gp->tg_pt_gp_id = tg_pt_gp_id_tmp; tg_pt_gp->tg_pt_gp_id = tg_pt_gp_id_tmp;
tg_pt_gp->tg_pt_gp_valid_id = 1; tg_pt_gp->tg_pt_gp_valid_id = 1;
list_add_tail(&tg_pt_gp->tg_pt_gp_list, list_add_tail(&tg_pt_gp->tg_pt_gp_list,
&T10_ALUA(su_dev)->tg_pt_gps_list); &su_dev->t10_alua.tg_pt_gps_list);
T10_ALUA(su_dev)->alua_tg_pt_gps_count++; su_dev->t10_alua.alua_tg_pt_gps_count++;
spin_unlock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_unlock(&su_dev->t10_alua.tg_pt_gps_lock);
return 0; return 0;
} }
...@@ -1403,10 +1411,10 @@ void core_alua_free_tg_pt_gp( ...@@ -1403,10 +1411,10 @@ void core_alua_free_tg_pt_gp(
* no assications *OR* explict ALUA via SET_TARGET_PORT_GROUPS * no assications *OR* explict ALUA via SET_TARGET_PORT_GROUPS
* can be made while we are releasing struct t10_alua_tg_pt_gp. * can be made while we are releasing struct t10_alua_tg_pt_gp.
*/ */
spin_lock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_lock(&su_dev->t10_alua.tg_pt_gps_lock);
list_del(&tg_pt_gp->tg_pt_gp_list); list_del(&tg_pt_gp->tg_pt_gp_list);
T10_ALUA(su_dev)->alua_tg_pt_gps_counter--; su_dev->t10_alua.alua_tg_pt_gps_counter--;
spin_unlock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_unlock(&su_dev->t10_alua.tg_pt_gps_lock);
/* /*
* Allow a struct t10_alua_tg_pt_gp_member * referenced by * Allow a struct t10_alua_tg_pt_gp_member * referenced by
* core_alua_get_tg_pt_gp_by_name() in * core_alua_get_tg_pt_gp_by_name() in
...@@ -1438,9 +1446,9 @@ void core_alua_free_tg_pt_gp( ...@@ -1438,9 +1446,9 @@ void core_alua_free_tg_pt_gp(
* default_tg_pt_gp. * default_tg_pt_gp.
*/ */
spin_lock(&tg_pt_gp_mem->tg_pt_gp_mem_lock); spin_lock(&tg_pt_gp_mem->tg_pt_gp_mem_lock);
if (tg_pt_gp != T10_ALUA(su_dev)->default_tg_pt_gp) { if (tg_pt_gp != su_dev->t10_alua.default_tg_pt_gp) {
__core_alua_attach_tg_pt_gp_mem(tg_pt_gp_mem, __core_alua_attach_tg_pt_gp_mem(tg_pt_gp_mem,
T10_ALUA(su_dev)->default_tg_pt_gp); su_dev->t10_alua.default_tg_pt_gp);
} else } else
tg_pt_gp_mem->tg_pt_gp = NULL; tg_pt_gp_mem->tg_pt_gp = NULL;
spin_unlock(&tg_pt_gp_mem->tg_pt_gp_mem_lock); spin_unlock(&tg_pt_gp_mem->tg_pt_gp_mem_lock);
...@@ -1455,7 +1463,7 @@ void core_alua_free_tg_pt_gp( ...@@ -1455,7 +1463,7 @@ void core_alua_free_tg_pt_gp(
void core_alua_free_tg_pt_gp_mem(struct se_port *port) void core_alua_free_tg_pt_gp_mem(struct se_port *port)
{ {
struct se_subsystem_dev *su_dev = port->sep_lun->lun_se_dev->se_sub_dev; struct se_subsystem_dev *su_dev = port->sep_lun->lun_se_dev->se_sub_dev;
struct t10_alua *alua = T10_ALUA(su_dev); struct t10_alua *alua = &su_dev->t10_alua;
struct t10_alua_tg_pt_gp *tg_pt_gp; struct t10_alua_tg_pt_gp *tg_pt_gp;
struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem; struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem;
...@@ -1493,19 +1501,19 @@ static struct t10_alua_tg_pt_gp *core_alua_get_tg_pt_gp_by_name( ...@@ -1493,19 +1501,19 @@ static struct t10_alua_tg_pt_gp *core_alua_get_tg_pt_gp_by_name(
struct t10_alua_tg_pt_gp *tg_pt_gp; struct t10_alua_tg_pt_gp *tg_pt_gp;
struct config_item *ci; struct config_item *ci;
spin_lock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_lock(&su_dev->t10_alua.tg_pt_gps_lock);
list_for_each_entry(tg_pt_gp, &T10_ALUA(su_dev)->tg_pt_gps_list, list_for_each_entry(tg_pt_gp, &su_dev->t10_alua.tg_pt_gps_list,
tg_pt_gp_list) { tg_pt_gp_list) {
if (!(tg_pt_gp->tg_pt_gp_valid_id)) if (!(tg_pt_gp->tg_pt_gp_valid_id))
continue; continue;
ci = &tg_pt_gp->tg_pt_gp_group.cg_item; ci = &tg_pt_gp->tg_pt_gp_group.cg_item;
if (!(strcmp(config_item_name(ci), name))) { if (!(strcmp(config_item_name(ci), name))) {
atomic_inc(&tg_pt_gp->tg_pt_gp_ref_cnt); atomic_inc(&tg_pt_gp->tg_pt_gp_ref_cnt);
spin_unlock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_unlock(&su_dev->t10_alua.tg_pt_gps_lock);
return tg_pt_gp; return tg_pt_gp;
} }
} }
spin_unlock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_unlock(&su_dev->t10_alua.tg_pt_gps_lock);
return NULL; return NULL;
} }
...@@ -1515,9 +1523,9 @@ static void core_alua_put_tg_pt_gp_from_name( ...@@ -1515,9 +1523,9 @@ static void core_alua_put_tg_pt_gp_from_name(
{ {
struct se_subsystem_dev *su_dev = tg_pt_gp->tg_pt_gp_su_dev; struct se_subsystem_dev *su_dev = tg_pt_gp->tg_pt_gp_su_dev;
spin_lock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_lock(&su_dev->t10_alua.tg_pt_gps_lock);
atomic_dec(&tg_pt_gp->tg_pt_gp_ref_cnt); atomic_dec(&tg_pt_gp->tg_pt_gp_ref_cnt);
spin_unlock(&T10_ALUA(su_dev)->tg_pt_gps_lock); spin_unlock(&su_dev->t10_alua.tg_pt_gps_lock);
} }
/* /*
...@@ -1555,7 +1563,7 @@ ssize_t core_alua_show_tg_pt_gp_info(struct se_port *port, char *page) ...@@ -1555,7 +1563,7 @@ ssize_t core_alua_show_tg_pt_gp_info(struct se_port *port, char *page)
{ {
struct se_subsystem_dev *su_dev = port->sep_lun->lun_se_dev->se_sub_dev; struct se_subsystem_dev *su_dev = port->sep_lun->lun_se_dev->se_sub_dev;
struct config_item *tg_pt_ci; struct config_item *tg_pt_ci;
struct t10_alua *alua = T10_ALUA(su_dev); struct t10_alua *alua = &su_dev->t10_alua;
struct t10_alua_tg_pt_gp *tg_pt_gp; struct t10_alua_tg_pt_gp *tg_pt_gp;
struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem; struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem;
ssize_t len = 0; ssize_t len = 0;
...@@ -1605,10 +1613,10 @@ ssize_t core_alua_store_tg_pt_gp_info( ...@@ -1605,10 +1613,10 @@ ssize_t core_alua_store_tg_pt_gp_info(
tpg = port->sep_tpg; tpg = port->sep_tpg;
lun = port->sep_lun; lun = port->sep_lun;
if (T10_ALUA(su_dev)->alua_type != SPC3_ALUA_EMULATED) { if (su_dev->t10_alua.alua_type != SPC3_ALUA_EMULATED) {
printk(KERN_WARNING "SPC3_ALUA_EMULATED not enabled for" printk(KERN_WARNING "SPC3_ALUA_EMULATED not enabled for"
" %s/tpgt_%hu/%s\n", TPG_TFO(tpg)->tpg_get_wwn(tpg), " %s/tpgt_%hu/%s\n", tpg->se_tpg_tfo->tpg_get_wwn(tpg),
TPG_TFO(tpg)->tpg_get_tag(tpg), tpg->se_tpg_tfo->tpg_get_tag(tpg),
config_item_name(&lun->lun_group.cg_item)); config_item_name(&lun->lun_group.cg_item));
return -EINVAL; return -EINVAL;
} }
...@@ -1654,8 +1662,8 @@ ssize_t core_alua_store_tg_pt_gp_info( ...@@ -1654,8 +1662,8 @@ ssize_t core_alua_store_tg_pt_gp_info(
" %s/tpgt_%hu/%s from ALUA Target Port Group:" " %s/tpgt_%hu/%s from ALUA Target Port Group:"
" alua/%s, ID: %hu back to" " alua/%s, ID: %hu back to"
" default_tg_pt_gp\n", " default_tg_pt_gp\n",
TPG_TFO(tpg)->tpg_get_wwn(tpg), tpg->se_tpg_tfo->tpg_get_wwn(tpg),
TPG_TFO(tpg)->tpg_get_tag(tpg), tpg->se_tpg_tfo->tpg_get_tag(tpg),
config_item_name(&lun->lun_group.cg_item), config_item_name(&lun->lun_group.cg_item),
config_item_name( config_item_name(
&tg_pt_gp->tg_pt_gp_group.cg_item), &tg_pt_gp->tg_pt_gp_group.cg_item),
...@@ -1663,7 +1671,7 @@ ssize_t core_alua_store_tg_pt_gp_info( ...@@ -1663,7 +1671,7 @@ ssize_t core_alua_store_tg_pt_gp_info(
__core_alua_drop_tg_pt_gp_mem(tg_pt_gp_mem, tg_pt_gp); __core_alua_drop_tg_pt_gp_mem(tg_pt_gp_mem, tg_pt_gp);
__core_alua_attach_tg_pt_gp_mem(tg_pt_gp_mem, __core_alua_attach_tg_pt_gp_mem(tg_pt_gp_mem,
T10_ALUA(su_dev)->default_tg_pt_gp); su_dev->t10_alua.default_tg_pt_gp);
spin_unlock(&tg_pt_gp_mem->tg_pt_gp_mem_lock); spin_unlock(&tg_pt_gp_mem->tg_pt_gp_mem_lock);
return count; return count;
...@@ -1681,8 +1689,8 @@ ssize_t core_alua_store_tg_pt_gp_info( ...@@ -1681,8 +1689,8 @@ ssize_t core_alua_store_tg_pt_gp_info(
spin_unlock(&tg_pt_gp_mem->tg_pt_gp_mem_lock); spin_unlock(&tg_pt_gp_mem->tg_pt_gp_mem_lock);
printk(KERN_INFO "Target_Core_ConfigFS: %s %s/tpgt_%hu/%s to ALUA" printk(KERN_INFO "Target_Core_ConfigFS: %s %s/tpgt_%hu/%s to ALUA"
" Target Port Group: alua/%s, ID: %hu\n", (move) ? " Target Port Group: alua/%s, ID: %hu\n", (move) ?
"Moving" : "Adding", TPG_TFO(tpg)->tpg_get_wwn(tpg), "Moving" : "Adding", tpg->se_tpg_tfo->tpg_get_wwn(tpg),
TPG_TFO(tpg)->tpg_get_tag(tpg), tpg->se_tpg_tfo->tpg_get_tag(tpg),
config_item_name(&lun->lun_group.cg_item), config_item_name(&lun->lun_group.cg_item),
config_item_name(&tg_pt_gp_new->tg_pt_gp_group.cg_item), config_item_name(&tg_pt_gp_new->tg_pt_gp_group.cg_item),
tg_pt_gp_new->tg_pt_gp_id); tg_pt_gp_new->tg_pt_gp_id);
...@@ -1939,7 +1947,7 @@ ssize_t core_alua_store_secondary_write_metadata( ...@@ -1939,7 +1947,7 @@ ssize_t core_alua_store_secondary_write_metadata(
int core_setup_alua(struct se_device *dev, int force_pt) int core_setup_alua(struct se_device *dev, int force_pt)
{ {
struct se_subsystem_dev *su_dev = dev->se_sub_dev; struct se_subsystem_dev *su_dev = dev->se_sub_dev;
struct t10_alua *alua = T10_ALUA(su_dev); struct t10_alua *alua = &su_dev->t10_alua;
struct t10_alua_lu_gp_member *lu_gp_mem; struct t10_alua_lu_gp_member *lu_gp_mem;
/* /*
* If this device is from Target_Core_Mod/pSCSI, use the ALUA logic * If this device is from Target_Core_Mod/pSCSI, use the ALUA logic
...@@ -1947,44 +1955,44 @@ int core_setup_alua(struct se_device *dev, int force_pt) ...@@ -1947,44 +1955,44 @@ int core_setup_alua(struct se_device *dev, int force_pt)
* cause a problem because libata and some SATA RAID HBAs appear * cause a problem because libata and some SATA RAID HBAs appear
* under Linux/SCSI, but emulate SCSI logic themselves. * under Linux/SCSI, but emulate SCSI logic themselves.
*/ */
if (((TRANSPORT(dev)->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) && if (((dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) &&
!(DEV_ATTRIB(dev)->emulate_alua)) || force_pt) { !(dev->se_sub_dev->se_dev_attrib.emulate_alua)) || force_pt) {
alua->alua_type = SPC_ALUA_PASSTHROUGH; alua->alua_type = SPC_ALUA_PASSTHROUGH;
alua->alua_state_check = &core_alua_state_check_nop; alua->alua_state_check = &core_alua_state_check_nop;
printk(KERN_INFO "%s: Using SPC_ALUA_PASSTHROUGH, no ALUA" printk(KERN_INFO "%s: Using SPC_ALUA_PASSTHROUGH, no ALUA"
" emulation\n", TRANSPORT(dev)->name); " emulation\n", dev->transport->name);
return 0; return 0;
} }
/* /*
* If SPC-3 or above is reported by real or emulated struct se_device, * If SPC-3 or above is reported by real or emulated struct se_device,
* use emulated ALUA. * use emulated ALUA.
*/ */
if (TRANSPORT(dev)->get_device_rev(dev) >= SCSI_3) { if (dev->transport->get_device_rev(dev) >= SCSI_3) {
printk(KERN_INFO "%s: Enabling ALUA Emulation for SPC-3" printk(KERN_INFO "%s: Enabling ALUA Emulation for SPC-3"
" device\n", TRANSPORT(dev)->name); " device\n", dev->transport->name);
/* /*
* Associate this struct se_device with the default ALUA * Associate this struct se_device with the default ALUA
* LUN Group. * LUN Group.
*/ */
lu_gp_mem = core_alua_allocate_lu_gp_mem(dev); lu_gp_mem = core_alua_allocate_lu_gp_mem(dev);
if (IS_ERR(lu_gp_mem) || !lu_gp_mem) if (IS_ERR(lu_gp_mem))
return -1; return PTR_ERR(lu_gp_mem);
alua->alua_type = SPC3_ALUA_EMULATED; alua->alua_type = SPC3_ALUA_EMULATED;
alua->alua_state_check = &core_alua_state_check; alua->alua_state_check = &core_alua_state_check;
spin_lock(&lu_gp_mem->lu_gp_mem_lock); spin_lock(&lu_gp_mem->lu_gp_mem_lock);
__core_alua_attach_lu_gp_mem(lu_gp_mem, __core_alua_attach_lu_gp_mem(lu_gp_mem,
se_global->default_lu_gp); default_lu_gp);
spin_unlock(&lu_gp_mem->lu_gp_mem_lock); spin_unlock(&lu_gp_mem->lu_gp_mem_lock);
printk(KERN_INFO "%s: Adding to default ALUA LU Group:" printk(KERN_INFO "%s: Adding to default ALUA LU Group:"
" core/alua/lu_gps/default_lu_gp\n", " core/alua/lu_gps/default_lu_gp\n",
TRANSPORT(dev)->name); dev->transport->name);
} else { } else {
alua->alua_type = SPC2_ALUA_DISABLED; alua->alua_type = SPC2_ALUA_DISABLED;
alua->alua_state_check = &core_alua_state_check_nop; alua->alua_state_check = &core_alua_state_check_nop;
printk(KERN_INFO "%s: Disabling ALUA Emulation for SPC-2" printk(KERN_INFO "%s: Disabling ALUA Emulation for SPC-2"
" device\n", TRANSPORT(dev)->name); " device\n", dev->transport->name);
} }
return 0; return 0;
......
...@@ -64,8 +64,8 @@ target_fill_alua_data(struct se_port *port, unsigned char *buf) ...@@ -64,8 +64,8 @@ target_fill_alua_data(struct se_port *port, unsigned char *buf)
static int static int
target_emulate_inquiry_std(struct se_cmd *cmd) target_emulate_inquiry_std(struct se_cmd *cmd)
{ {
struct se_lun *lun = SE_LUN(cmd); struct se_lun *lun = cmd->se_lun;
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
unsigned char *buf = cmd->t_task->t_task_buf; unsigned char *buf = cmd->t_task->t_task_buf;
/* /*
...@@ -75,7 +75,7 @@ target_emulate_inquiry_std(struct se_cmd *cmd) ...@@ -75,7 +75,7 @@ target_emulate_inquiry_std(struct se_cmd *cmd)
if (cmd->data_length < 6) { if (cmd->data_length < 6) {
printk(KERN_ERR "SCSI Inquiry payload length: %u" printk(KERN_ERR "SCSI Inquiry payload length: %u"
" too small for EVPD=0\n", cmd->data_length); " too small for EVPD=0\n", cmd->data_length);
return -1; return -EINVAL;
} }
buf[0] = dev->transport->get_device_type(dev); buf[0] = dev->transport->get_device_type(dev);
...@@ -86,7 +86,7 @@ target_emulate_inquiry_std(struct se_cmd *cmd) ...@@ -86,7 +86,7 @@ target_emulate_inquiry_std(struct se_cmd *cmd)
/* /*
* Enable SCCS and TPGS fields for Emulated ALUA * Enable SCCS and TPGS fields for Emulated ALUA
*/ */
if (T10_ALUA(dev->se_sub_dev)->alua_type == SPC3_ALUA_EMULATED) if (dev->se_sub_dev->t10_alua.alua_type == SPC3_ALUA_EMULATED)
target_fill_alua_data(lun->lun_sep, buf); target_fill_alua_data(lun->lun_sep, buf);
if (cmd->data_length < 8) { if (cmd->data_length < 8) {
...@@ -107,9 +107,9 @@ target_emulate_inquiry_std(struct se_cmd *cmd) ...@@ -107,9 +107,9 @@ target_emulate_inquiry_std(struct se_cmd *cmd)
snprintf((unsigned char *)&buf[8], 8, "LIO-ORG"); snprintf((unsigned char *)&buf[8], 8, "LIO-ORG");
snprintf((unsigned char *)&buf[16], 16, "%s", snprintf((unsigned char *)&buf[16], 16, "%s",
&DEV_T10_WWN(dev)->model[0]); &dev->se_sub_dev->t10_wwn.model[0]);
snprintf((unsigned char *)&buf[32], 4, "%s", snprintf((unsigned char *)&buf[32], 4, "%s",
&DEV_T10_WWN(dev)->revision[0]); &dev->se_sub_dev->t10_wwn.revision[0]);
buf[4] = 31; /* Set additional length to 31 */ buf[4] = 31; /* Set additional length to 31 */
return 0; return 0;
} }
...@@ -128,7 +128,7 @@ target_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf) ...@@ -128,7 +128,7 @@ target_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf)
* Registered Extended LUN WWN has been set via ConfigFS * Registered Extended LUN WWN has been set via ConfigFS
* during device creation/restart. * during device creation/restart.
*/ */
if (SE_DEV(cmd)->se_sub_dev->su_dev_flags & if (cmd->se_lun->lun_se_dev->se_sub_dev->su_dev_flags &
SDF_EMULATED_VPD_UNIT_SERIAL) { SDF_EMULATED_VPD_UNIT_SERIAL) {
buf[3] = 3; buf[3] = 3;
buf[5] = 0x80; buf[5] = 0x80;
...@@ -143,7 +143,7 @@ target_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf) ...@@ -143,7 +143,7 @@ target_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf)
static int static int
target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf) target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf)
{ {
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
u16 len = 0; u16 len = 0;
buf[1] = 0x80; buf[1] = 0x80;
...@@ -152,7 +152,7 @@ target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf) ...@@ -152,7 +152,7 @@ target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf)
u32 unit_serial_len; u32 unit_serial_len;
unit_serial_len = unit_serial_len =
strlen(&DEV_T10_WWN(dev)->unit_serial[0]); strlen(&dev->se_sub_dev->t10_wwn.unit_serial[0]);
unit_serial_len++; /* For NULL Terminator */ unit_serial_len++; /* For NULL Terminator */
if (((len + 4) + unit_serial_len) > cmd->data_length) { if (((len + 4) + unit_serial_len) > cmd->data_length) {
...@@ -162,7 +162,7 @@ target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf) ...@@ -162,7 +162,7 @@ target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf)
return 0; return 0;
} }
len += sprintf((unsigned char *)&buf[4], "%s", len += sprintf((unsigned char *)&buf[4], "%s",
&DEV_T10_WWN(dev)->unit_serial[0]); &dev->se_sub_dev->t10_wwn.unit_serial[0]);
len++; /* Extra Byte for NULL Terminator */ len++; /* Extra Byte for NULL Terminator */
buf[3] = len; buf[3] = len;
} }
...@@ -176,15 +176,15 @@ target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf) ...@@ -176,15 +176,15 @@ target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf)
static int static int
target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
{ {
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_lun *lun = SE_LUN(cmd); struct se_lun *lun = cmd->se_lun;
struct se_port *port = NULL; struct se_port *port = NULL;
struct se_portal_group *tpg = NULL; struct se_portal_group *tpg = NULL;
struct t10_alua_lu_gp_member *lu_gp_mem; struct t10_alua_lu_gp_member *lu_gp_mem;
struct t10_alua_tg_pt_gp *tg_pt_gp; struct t10_alua_tg_pt_gp *tg_pt_gp;
struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem; struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem;
unsigned char binary, binary_new; unsigned char binary, binary_new;
unsigned char *prod = &DEV_T10_WWN(dev)->model[0]; unsigned char *prod = &dev->se_sub_dev->t10_wwn.model[0];
u32 prod_len; u32 prod_len;
u32 unit_serial_len, off = 0; u32 unit_serial_len, off = 0;
int i; int i;
...@@ -238,11 +238,11 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) ...@@ -238,11 +238,11 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
* VENDOR_SPECIFIC_IDENTIFIER_EXTENTION * VENDOR_SPECIFIC_IDENTIFIER_EXTENTION
*/ */
binary = transport_asciihex_to_binaryhex( binary = transport_asciihex_to_binaryhex(
&DEV_T10_WWN(dev)->unit_serial[0]); &dev->se_sub_dev->t10_wwn.unit_serial[0]);
buf[off++] |= (binary & 0xf0) >> 4; buf[off++] |= (binary & 0xf0) >> 4;
for (i = 0; i < 24; i += 2) { for (i = 0; i < 24; i += 2) {
binary_new = transport_asciihex_to_binaryhex( binary_new = transport_asciihex_to_binaryhex(
&DEV_T10_WWN(dev)->unit_serial[i+2]); &dev->se_sub_dev->t10_wwn.unit_serial[i+2]);
buf[off] = (binary & 0x0f) << 4; buf[off] = (binary & 0x0f) << 4;
buf[off++] |= (binary_new & 0xf0) >> 4; buf[off++] |= (binary_new & 0xf0) >> 4;
binary = binary_new; binary = binary_new;
...@@ -263,7 +263,7 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) ...@@ -263,7 +263,7 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
if (dev->se_sub_dev->su_dev_flags & if (dev->se_sub_dev->su_dev_flags &
SDF_EMULATED_VPD_UNIT_SERIAL) { SDF_EMULATED_VPD_UNIT_SERIAL) {
unit_serial_len = unit_serial_len =
strlen(&DEV_T10_WWN(dev)->unit_serial[0]); strlen(&dev->se_sub_dev->t10_wwn.unit_serial[0]);
unit_serial_len++; /* For NULL Terminator */ unit_serial_len++; /* For NULL Terminator */
if ((len + (id_len + 4) + if ((len + (id_len + 4) +
...@@ -274,7 +274,7 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) ...@@ -274,7 +274,7 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
} }
id_len += sprintf((unsigned char *)&buf[off+12], id_len += sprintf((unsigned char *)&buf[off+12],
"%s:%s", prod, "%s:%s", prod,
&DEV_T10_WWN(dev)->unit_serial[0]); &dev->se_sub_dev->t10_wwn.unit_serial[0]);
} }
buf[off] = 0x2; /* ASCII */ buf[off] = 0x2; /* ASCII */
buf[off+1] = 0x1; /* T10 Vendor ID */ buf[off+1] = 0x1; /* T10 Vendor ID */
...@@ -312,7 +312,7 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) ...@@ -312,7 +312,7 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
goto check_tpgi; goto check_tpgi;
} }
buf[off] = buf[off] =
(TPG_TFO(tpg)->get_fabric_proto_ident(tpg) << 4); (tpg->se_tpg_tfo->get_fabric_proto_ident(tpg) << 4);
buf[off++] |= 0x1; /* CODE SET == Binary */ buf[off++] |= 0x1; /* CODE SET == Binary */
buf[off] = 0x80; /* Set PIV=1 */ buf[off] = 0x80; /* Set PIV=1 */
/* Set ASSOICATION == target port: 01b */ /* Set ASSOICATION == target port: 01b */
...@@ -335,7 +335,7 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) ...@@ -335,7 +335,7 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
* section 7.5.1 Table 362 * section 7.5.1 Table 362
*/ */
check_tpgi: check_tpgi:
if (T10_ALUA(dev->se_sub_dev)->alua_type != if (dev->se_sub_dev->t10_alua.alua_type !=
SPC3_ALUA_EMULATED) SPC3_ALUA_EMULATED)
goto check_scsi_name; goto check_scsi_name;
...@@ -357,7 +357,7 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) ...@@ -357,7 +357,7 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
spin_unlock(&tg_pt_gp_mem->tg_pt_gp_mem_lock); spin_unlock(&tg_pt_gp_mem->tg_pt_gp_mem_lock);
buf[off] = buf[off] =
(TPG_TFO(tpg)->get_fabric_proto_ident(tpg) << 4); (tpg->se_tpg_tfo->get_fabric_proto_ident(tpg) << 4);
buf[off++] |= 0x1; /* CODE SET == Binary */ buf[off++] |= 0x1; /* CODE SET == Binary */
buf[off] = 0x80; /* Set PIV=1 */ buf[off] = 0x80; /* Set PIV=1 */
/* Set ASSOICATION == target port: 01b */ /* Set ASSOICATION == target port: 01b */
...@@ -409,7 +409,7 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) ...@@ -409,7 +409,7 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
* section 7.5.1 Table 362 * section 7.5.1 Table 362
*/ */
check_scsi_name: check_scsi_name:
scsi_name_len = strlen(TPG_TFO(tpg)->tpg_get_wwn(tpg)); scsi_name_len = strlen(tpg->se_tpg_tfo->tpg_get_wwn(tpg));
/* UTF-8 ",t,0x<16-bit TPGT>" + NULL Terminator */ /* UTF-8 ",t,0x<16-bit TPGT>" + NULL Terminator */
scsi_name_len += 10; scsi_name_len += 10;
/* Check for 4-byte padding */ /* Check for 4-byte padding */
...@@ -424,7 +424,7 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) ...@@ -424,7 +424,7 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
goto set_len; goto set_len;
} }
buf[off] = buf[off] =
(TPG_TFO(tpg)->get_fabric_proto_ident(tpg) << 4); (tpg->se_tpg_tfo->get_fabric_proto_ident(tpg) << 4);
buf[off++] |= 0x3; /* CODE SET == UTF-8 */ buf[off++] |= 0x3; /* CODE SET == UTF-8 */
buf[off] = 0x80; /* Set PIV=1 */ buf[off] = 0x80; /* Set PIV=1 */
/* Set ASSOICATION == target port: 01b */ /* Set ASSOICATION == target port: 01b */
...@@ -438,9 +438,9 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) ...@@ -438,9 +438,9 @@ target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
* Target Port, this means "<iSCSI name>,t,0x<TPGT> in * Target Port, this means "<iSCSI name>,t,0x<TPGT> in
* UTF-8 encoding. * UTF-8 encoding.
*/ */
tpgt = TPG_TFO(tpg)->tpg_get_tag(tpg); tpgt = tpg->se_tpg_tfo->tpg_get_tag(tpg);
scsi_name_len = sprintf(&buf[off], "%s,t,0x%04x", scsi_name_len = sprintf(&buf[off], "%s,t,0x%04x",
TPG_TFO(tpg)->tpg_get_wwn(tpg), tpgt); tpg->se_tpg_tfo->tpg_get_wwn(tpg), tpgt);
scsi_name_len += 1 /* Include NULL terminator */; scsi_name_len += 1 /* Include NULL terminator */;
/* /*
* The null-terminated, null-padded (see 4.4.2) SCSI * The null-terminated, null-padded (see 4.4.2) SCSI
...@@ -477,7 +477,7 @@ target_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf) ...@@ -477,7 +477,7 @@ target_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf)
buf[5] = 0x07; buf[5] = 0x07;
/* If WriteCache emulation is enabled, set V_SUP */ /* If WriteCache emulation is enabled, set V_SUP */
if (DEV_ATTRIB(SE_DEV(cmd))->emulate_write_cache > 0) if (cmd->se_lun->lun_se_dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0)
buf[6] = 0x01; buf[6] = 0x01;
return 0; return 0;
} }
...@@ -486,7 +486,7 @@ target_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf) ...@@ -486,7 +486,7 @@ target_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf)
static int static int
target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf) target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf)
{ {
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
int have_tp = 0; int have_tp = 0;
/* /*
...@@ -494,14 +494,14 @@ target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf) ...@@ -494,14 +494,14 @@ target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf)
* emulate_tpu=1 or emulate_tpws=1 we will be expect a * emulate_tpu=1 or emulate_tpws=1 we will be expect a
* different page length for Thin Provisioning. * different page length for Thin Provisioning.
*/ */
if (DEV_ATTRIB(dev)->emulate_tpu || DEV_ATTRIB(dev)->emulate_tpws) if (dev->se_sub_dev->se_dev_attrib.emulate_tpu || dev->se_sub_dev->se_dev_attrib.emulate_tpws)
have_tp = 1; have_tp = 1;
if (cmd->data_length < (0x10 + 4)) { if (cmd->data_length < (0x10 + 4)) {
printk(KERN_INFO "Received data_length: %u" printk(KERN_INFO "Received data_length: %u"
" too small for EVPD 0xb0\n", " too small for EVPD 0xb0\n",
cmd->data_length); cmd->data_length);
return -1; return -EINVAL;
} }
if (have_tp && cmd->data_length < (0x3c + 4)) { if (have_tp && cmd->data_length < (0x3c + 4)) {
...@@ -523,12 +523,12 @@ target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf) ...@@ -523,12 +523,12 @@ target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf)
/* /*
* Set MAXIMUM TRANSFER LENGTH * Set MAXIMUM TRANSFER LENGTH
*/ */
put_unaligned_be32(DEV_ATTRIB(dev)->max_sectors, &buf[8]); put_unaligned_be32(dev->se_sub_dev->se_dev_attrib.max_sectors, &buf[8]);
/* /*
* Set OPTIMAL TRANSFER LENGTH * Set OPTIMAL TRANSFER LENGTH
*/ */
put_unaligned_be32(DEV_ATTRIB(dev)->optimal_sectors, &buf[12]); put_unaligned_be32(dev->se_sub_dev->se_dev_attrib.optimal_sectors, &buf[12]);
/* /*
* Exit now if we don't support TP or the initiator sent a too * Exit now if we don't support TP or the initiator sent a too
...@@ -540,25 +540,25 @@ target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf) ...@@ -540,25 +540,25 @@ target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf)
/* /*
* Set MAXIMUM UNMAP LBA COUNT * Set MAXIMUM UNMAP LBA COUNT
*/ */
put_unaligned_be32(DEV_ATTRIB(dev)->max_unmap_lba_count, &buf[20]); put_unaligned_be32(dev->se_sub_dev->se_dev_attrib.max_unmap_lba_count, &buf[20]);
/* /*
* Set MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT * Set MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT
*/ */
put_unaligned_be32(DEV_ATTRIB(dev)->max_unmap_block_desc_count, put_unaligned_be32(dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count,
&buf[24]); &buf[24]);
/* /*
* Set OPTIMAL UNMAP GRANULARITY * Set OPTIMAL UNMAP GRANULARITY
*/ */
put_unaligned_be32(DEV_ATTRIB(dev)->unmap_granularity, &buf[28]); put_unaligned_be32(dev->se_sub_dev->se_dev_attrib.unmap_granularity, &buf[28]);
/* /*
* UNMAP GRANULARITY ALIGNMENT * UNMAP GRANULARITY ALIGNMENT
*/ */
put_unaligned_be32(DEV_ATTRIB(dev)->unmap_granularity_alignment, put_unaligned_be32(dev->se_sub_dev->se_dev_attrib.unmap_granularity_alignment,
&buf[32]); &buf[32]);
if (DEV_ATTRIB(dev)->unmap_granularity_alignment != 0) if (dev->se_sub_dev->se_dev_attrib.unmap_granularity_alignment != 0)
buf[32] |= 0x80; /* Set the UGAVALID bit */ buf[32] |= 0x80; /* Set the UGAVALID bit */
return 0; return 0;
...@@ -568,7 +568,7 @@ target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf) ...@@ -568,7 +568,7 @@ target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf)
static int static int
target_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf) target_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf)
{ {
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
/* /*
* From sbc3r22 section 6.5.4 Thin Provisioning VPD page: * From sbc3r22 section 6.5.4 Thin Provisioning VPD page:
...@@ -602,7 +602,7 @@ target_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf) ...@@ -602,7 +602,7 @@ target_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf)
* the UNMAP command (see 5.25). A TPU bit set to zero indicates * the UNMAP command (see 5.25). A TPU bit set to zero indicates
* that the device server does not support the UNMAP command. * that the device server does not support the UNMAP command.
*/ */
if (DEV_ATTRIB(dev)->emulate_tpu != 0) if (dev->se_sub_dev->se_dev_attrib.emulate_tpu != 0)
buf[5] = 0x80; buf[5] = 0x80;
/* /*
...@@ -611,7 +611,7 @@ target_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf) ...@@ -611,7 +611,7 @@ target_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf)
* A TPWS bit set to zero indicates that the device server does not * A TPWS bit set to zero indicates that the device server does not
* support the use of the WRITE SAME (16) command to unmap LBAs. * support the use of the WRITE SAME (16) command to unmap LBAs.
*/ */
if (DEV_ATTRIB(dev)->emulate_tpws != 0) if (dev->se_sub_dev->se_dev_attrib.emulate_tpws != 0)
buf[5] |= 0x40; buf[5] |= 0x40;
return 0; return 0;
...@@ -620,7 +620,7 @@ target_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf) ...@@ -620,7 +620,7 @@ target_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf)
static int static int
target_emulate_inquiry(struct se_cmd *cmd) target_emulate_inquiry(struct se_cmd *cmd)
{ {
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
unsigned char *buf = cmd->t_task->t_task_buf; unsigned char *buf = cmd->t_task->t_task_buf;
unsigned char *cdb = cmd->t_task->t_task_cdb; unsigned char *cdb = cmd->t_task->t_task_cdb;
...@@ -637,7 +637,7 @@ target_emulate_inquiry(struct se_cmd *cmd) ...@@ -637,7 +637,7 @@ target_emulate_inquiry(struct se_cmd *cmd)
if (cmd->data_length < 4) { if (cmd->data_length < 4) {
printk(KERN_ERR "SCSI Inquiry payload length: %u" printk(KERN_ERR "SCSI Inquiry payload length: %u"
" too small for EVPD=1\n", cmd->data_length); " too small for EVPD=1\n", cmd->data_length);
return -1; return -EINVAL;
} }
buf[0] = dev->transport->get_device_type(dev); buf[0] = dev->transport->get_device_type(dev);
...@@ -656,7 +656,7 @@ target_emulate_inquiry(struct se_cmd *cmd) ...@@ -656,7 +656,7 @@ target_emulate_inquiry(struct se_cmd *cmd)
return target_emulate_evpd_b2(cmd, buf); return target_emulate_evpd_b2(cmd, buf);
default: default:
printk(KERN_ERR "Unknown VPD Code: 0x%02x\n", cdb[2]); printk(KERN_ERR "Unknown VPD Code: 0x%02x\n", cdb[2]);
return -1; return -EINVAL;
} }
return 0; return 0;
...@@ -665,7 +665,7 @@ target_emulate_inquiry(struct se_cmd *cmd) ...@@ -665,7 +665,7 @@ target_emulate_inquiry(struct se_cmd *cmd)
static int static int
target_emulate_readcapacity(struct se_cmd *cmd) target_emulate_readcapacity(struct se_cmd *cmd)
{ {
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
unsigned char *buf = cmd->t_task->t_task_buf; unsigned char *buf = cmd->t_task->t_task_buf;
unsigned long long blocks_long = dev->transport->get_blocks(dev); unsigned long long blocks_long = dev->transport->get_blocks(dev);
u32 blocks; u32 blocks;
...@@ -679,14 +679,14 @@ target_emulate_readcapacity(struct se_cmd *cmd) ...@@ -679,14 +679,14 @@ target_emulate_readcapacity(struct se_cmd *cmd)
buf[1] = (blocks >> 16) & 0xff; buf[1] = (blocks >> 16) & 0xff;
buf[2] = (blocks >> 8) & 0xff; buf[2] = (blocks >> 8) & 0xff;
buf[3] = blocks & 0xff; buf[3] = blocks & 0xff;
buf[4] = (DEV_ATTRIB(dev)->block_size >> 24) & 0xff; buf[4] = (dev->se_sub_dev->se_dev_attrib.block_size >> 24) & 0xff;
buf[5] = (DEV_ATTRIB(dev)->block_size >> 16) & 0xff; buf[5] = (dev->se_sub_dev->se_dev_attrib.block_size >> 16) & 0xff;
buf[6] = (DEV_ATTRIB(dev)->block_size >> 8) & 0xff; buf[6] = (dev->se_sub_dev->se_dev_attrib.block_size >> 8) & 0xff;
buf[7] = DEV_ATTRIB(dev)->block_size & 0xff; buf[7] = dev->se_sub_dev->se_dev_attrib.block_size & 0xff;
/* /*
* Set max 32-bit blocks to signal SERVICE ACTION READ_CAPACITY_16 * Set max 32-bit blocks to signal SERVICE ACTION READ_CAPACITY_16
*/ */
if (DEV_ATTRIB(dev)->emulate_tpu || DEV_ATTRIB(dev)->emulate_tpws) if (dev->se_sub_dev->se_dev_attrib.emulate_tpu || dev->se_sub_dev->se_dev_attrib.emulate_tpws)
put_unaligned_be32(0xFFFFFFFF, &buf[0]); put_unaligned_be32(0xFFFFFFFF, &buf[0]);
return 0; return 0;
...@@ -695,7 +695,7 @@ target_emulate_readcapacity(struct se_cmd *cmd) ...@@ -695,7 +695,7 @@ target_emulate_readcapacity(struct se_cmd *cmd)
static int static int
target_emulate_readcapacity_16(struct se_cmd *cmd) target_emulate_readcapacity_16(struct se_cmd *cmd)
{ {
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
unsigned char *buf = cmd->t_task->t_task_buf; unsigned char *buf = cmd->t_task->t_task_buf;
unsigned long long blocks = dev->transport->get_blocks(dev); unsigned long long blocks = dev->transport->get_blocks(dev);
...@@ -707,15 +707,15 @@ target_emulate_readcapacity_16(struct se_cmd *cmd) ...@@ -707,15 +707,15 @@ target_emulate_readcapacity_16(struct se_cmd *cmd)
buf[5] = (blocks >> 16) & 0xff; buf[5] = (blocks >> 16) & 0xff;
buf[6] = (blocks >> 8) & 0xff; buf[6] = (blocks >> 8) & 0xff;
buf[7] = blocks & 0xff; buf[7] = blocks & 0xff;
buf[8] = (DEV_ATTRIB(dev)->block_size >> 24) & 0xff; buf[8] = (dev->se_sub_dev->se_dev_attrib.block_size >> 24) & 0xff;
buf[9] = (DEV_ATTRIB(dev)->block_size >> 16) & 0xff; buf[9] = (dev->se_sub_dev->se_dev_attrib.block_size >> 16) & 0xff;
buf[10] = (DEV_ATTRIB(dev)->block_size >> 8) & 0xff; buf[10] = (dev->se_sub_dev->se_dev_attrib.block_size >> 8) & 0xff;
buf[11] = DEV_ATTRIB(dev)->block_size & 0xff; buf[11] = dev->se_sub_dev->se_dev_attrib.block_size & 0xff;
/* /*
* Set Thin Provisioning Enable bit following sbc3r22 in section * Set Thin Provisioning Enable bit following sbc3r22 in section
* READ CAPACITY (16) byte 14 if emulate_tpu or emulate_tpws is enabled. * READ CAPACITY (16) byte 14 if emulate_tpu or emulate_tpws is enabled.
*/ */
if (DEV_ATTRIB(dev)->emulate_tpu || DEV_ATTRIB(dev)->emulate_tpws) if (dev->se_sub_dev->se_dev_attrib.emulate_tpu || dev->se_sub_dev->se_dev_attrib.emulate_tpws)
buf[14] = 0x80; buf[14] = 0x80;
return 0; return 0;
...@@ -765,8 +765,8 @@ target_modesense_control(struct se_device *dev, unsigned char *p) ...@@ -765,8 +765,8 @@ target_modesense_control(struct se_device *dev, unsigned char *p)
* for a BUSY, TASK SET FULL, or RESERVATION CONFLICT status regardless * for a BUSY, TASK SET FULL, or RESERVATION CONFLICT status regardless
* to the number of commands completed with one of those status codes. * to the number of commands completed with one of those status codes.
*/ */
p[4] = (DEV_ATTRIB(dev)->emulate_ua_intlck_ctrl == 2) ? 0x30 : p[4] = (dev->se_sub_dev->se_dev_attrib.emulate_ua_intlck_ctrl == 2) ? 0x30 :
(DEV_ATTRIB(dev)->emulate_ua_intlck_ctrl == 1) ? 0x20 : 0x00; (dev->se_sub_dev->se_dev_attrib.emulate_ua_intlck_ctrl == 1) ? 0x20 : 0x00;
/* /*
* From spc4r17, section 7.4.6 Control mode Page * From spc4r17, section 7.4.6 Control mode Page
* *
...@@ -779,7 +779,7 @@ target_modesense_control(struct se_device *dev, unsigned char *p) ...@@ -779,7 +779,7 @@ target_modesense_control(struct se_device *dev, unsigned char *p)
* which the command was received shall be completed with TASK ABORTED * which the command was received shall be completed with TASK ABORTED
* status (see SAM-4). * status (see SAM-4).
*/ */
p[5] = (DEV_ATTRIB(dev)->emulate_tas) ? 0x40 : 0x00; p[5] = (dev->se_sub_dev->se_dev_attrib.emulate_tas) ? 0x40 : 0x00;
p[8] = 0xff; p[8] = 0xff;
p[9] = 0xff; p[9] = 0xff;
p[11] = 30; p[11] = 30;
...@@ -792,7 +792,7 @@ target_modesense_caching(struct se_device *dev, unsigned char *p) ...@@ -792,7 +792,7 @@ target_modesense_caching(struct se_device *dev, unsigned char *p)
{ {
p[0] = 0x08; p[0] = 0x08;
p[1] = 0x12; p[1] = 0x12;
if (DEV_ATTRIB(dev)->emulate_write_cache > 0) if (dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0)
p[2] = 0x04; /* Write Cache Enable */ p[2] = 0x04; /* Write Cache Enable */
p[12] = 0x20; /* Disabled Read Ahead */ p[12] = 0x20; /* Disabled Read Ahead */
...@@ -830,7 +830,7 @@ target_modesense_dpofua(unsigned char *buf, int type) ...@@ -830,7 +830,7 @@ target_modesense_dpofua(unsigned char *buf, int type)
static int static int
target_emulate_modesense(struct se_cmd *cmd, int ten) target_emulate_modesense(struct se_cmd *cmd, int ten)
{ {
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
char *cdb = cmd->t_task->t_task_cdb; char *cdb = cmd->t_task->t_task_cdb;
unsigned char *rbuf = cmd->t_task->t_task_buf; unsigned char *rbuf = cmd->t_task->t_task_buf;
int type = dev->transport->get_device_type(dev); int type = dev->transport->get_device_type(dev);
...@@ -867,13 +867,13 @@ target_emulate_modesense(struct se_cmd *cmd, int ten) ...@@ -867,13 +867,13 @@ target_emulate_modesense(struct se_cmd *cmd, int ten)
buf[0] = (offset >> 8) & 0xff; buf[0] = (offset >> 8) & 0xff;
buf[1] = offset & 0xff; buf[1] = offset & 0xff;
if ((SE_LUN(cmd)->lun_access & TRANSPORT_LUNFLAGS_READ_ONLY) || if ((cmd->se_lun->lun_access & TRANSPORT_LUNFLAGS_READ_ONLY) ||
(cmd->se_deve && (cmd->se_deve &&
(cmd->se_deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY))) (cmd->se_deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY)))
target_modesense_write_protect(&buf[3], type); target_modesense_write_protect(&buf[3], type);
if ((DEV_ATTRIB(dev)->emulate_write_cache > 0) && if ((dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0) &&
(DEV_ATTRIB(dev)->emulate_fua_write > 0)) (dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0))
target_modesense_dpofua(&buf[3], type); target_modesense_dpofua(&buf[3], type);
if ((offset + 2) > cmd->data_length) if ((offset + 2) > cmd->data_length)
...@@ -883,13 +883,13 @@ target_emulate_modesense(struct se_cmd *cmd, int ten) ...@@ -883,13 +883,13 @@ target_emulate_modesense(struct se_cmd *cmd, int ten)
offset -= 1; offset -= 1;
buf[0] = offset & 0xff; buf[0] = offset & 0xff;
if ((SE_LUN(cmd)->lun_access & TRANSPORT_LUNFLAGS_READ_ONLY) || if ((cmd->se_lun->lun_access & TRANSPORT_LUNFLAGS_READ_ONLY) ||
(cmd->se_deve && (cmd->se_deve &&
(cmd->se_deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY))) (cmd->se_deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY)))
target_modesense_write_protect(&buf[2], type); target_modesense_write_protect(&buf[2], type);
if ((DEV_ATTRIB(dev)->emulate_write_cache > 0) && if ((dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0) &&
(DEV_ATTRIB(dev)->emulate_fua_write > 0)) (dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0))
target_modesense_dpofua(&buf[2], type); target_modesense_dpofua(&buf[2], type);
if ((offset + 1) > cmd->data_length) if ((offset + 1) > cmd->data_length)
...@@ -963,8 +963,8 @@ target_emulate_request_sense(struct se_cmd *cmd) ...@@ -963,8 +963,8 @@ target_emulate_request_sense(struct se_cmd *cmd)
static int static int
target_emulate_unmap(struct se_task *task) target_emulate_unmap(struct se_task *task)
{ {
struct se_cmd *cmd = TASK_CMD(task); struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
unsigned char *buf = cmd->t_task->t_task_buf, *ptr = NULL; unsigned char *buf = cmd->t_task->t_task_buf, *ptr = NULL;
unsigned char *cdb = &cmd->t_task->t_task_cdb[0]; unsigned char *cdb = &cmd->t_task->t_task_cdb[0];
sector_t lba; sector_t lba;
...@@ -991,7 +991,7 @@ target_emulate_unmap(struct se_task *task) ...@@ -991,7 +991,7 @@ target_emulate_unmap(struct se_task *task)
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "blkdev_issue_discard() failed: %d\n", printk(KERN_ERR "blkdev_issue_discard() failed: %d\n",
ret); ret);
return -1; return ret;
} }
ptr += 16; ptr += 16;
...@@ -1010,13 +1010,13 @@ target_emulate_unmap(struct se_task *task) ...@@ -1010,13 +1010,13 @@ target_emulate_unmap(struct se_task *task)
static int static int
target_emulate_write_same(struct se_task *task) target_emulate_write_same(struct se_task *task)
{ {
struct se_cmd *cmd = TASK_CMD(task); struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
sector_t lba = cmd->t_task->t_task_lba; sector_t lba = cmd->t_task->t_task_lba;
unsigned int range; unsigned int range;
int ret; int ret;
range = (cmd->data_length / DEV_ATTRIB(dev)->block_size); range = (cmd->data_length / dev->se_sub_dev->se_dev_attrib.block_size);
printk(KERN_INFO "WRITE_SAME UNMAP: LBA: %llu Range: %u\n", printk(KERN_INFO "WRITE_SAME UNMAP: LBA: %llu Range: %u\n",
(unsigned long long)lba, range); (unsigned long long)lba, range);
...@@ -1024,7 +1024,7 @@ target_emulate_write_same(struct se_task *task) ...@@ -1024,7 +1024,7 @@ target_emulate_write_same(struct se_task *task)
ret = dev->transport->do_discard(dev, lba, range); ret = dev->transport->do_discard(dev, lba, range);
if (ret < 0) { if (ret < 0) {
printk(KERN_INFO "blkdev_issue_discard() failed for WRITE_SAME\n"); printk(KERN_INFO "blkdev_issue_discard() failed for WRITE_SAME\n");
return -1; return ret;
} }
task->task_scsi_status = GOOD; task->task_scsi_status = GOOD;
...@@ -1035,8 +1035,8 @@ target_emulate_write_same(struct se_task *task) ...@@ -1035,8 +1035,8 @@ target_emulate_write_same(struct se_task *task)
int int
transport_emulate_control_cdb(struct se_task *task) transport_emulate_control_cdb(struct se_task *task)
{ {
struct se_cmd *cmd = TASK_CMD(task); struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
unsigned short service_action; unsigned short service_action;
int ret = 0; int ret = 0;
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <linux/parser.h> #include <linux/parser.h>
#include <linux/syscalls.h> #include <linux/syscalls.h>
#include <linux/configfs.h> #include <linux/configfs.h>
#include <linux/spinlock.h>
#include <target/target_core_base.h> #include <target/target_core_base.h>
#include <target/target_core_device.h> #include <target/target_core_device.h>
...@@ -52,6 +53,8 @@ ...@@ -52,6 +53,8 @@
#include "target_core_rd.h" #include "target_core_rd.h"
#include "target_core_stat.h" #include "target_core_stat.h"
extern struct t10_alua_lu_gp *default_lu_gp;
static struct list_head g_tf_list; static struct list_head g_tf_list;
static struct mutex g_tf_lock; static struct mutex g_tf_lock;
...@@ -61,6 +64,13 @@ struct target_core_configfs_attribute { ...@@ -61,6 +64,13 @@ struct target_core_configfs_attribute {
ssize_t (*store)(void *, const char *, size_t); ssize_t (*store)(void *, const char *, size_t);
}; };
static struct config_group target_core_hbagroup;
static struct config_group alua_group;
static struct config_group alua_lu_gps_group;
static DEFINE_SPINLOCK(se_device_lock);
static LIST_HEAD(se_dev_list);
static inline struct se_hba * static inline struct se_hba *
item_to_hba(struct config_item *item) item_to_hba(struct config_item *item)
{ {
...@@ -298,21 +308,21 @@ struct target_fabric_configfs *target_fabric_configfs_init( ...@@ -298,21 +308,21 @@ struct target_fabric_configfs *target_fabric_configfs_init(
if (!(fabric_mod)) { if (!(fabric_mod)) {
printk(KERN_ERR "Missing struct module *fabric_mod pointer\n"); printk(KERN_ERR "Missing struct module *fabric_mod pointer\n");
return NULL; return ERR_PTR(-EINVAL);
} }
if (!(name)) { if (!(name)) {
printk(KERN_ERR "Unable to locate passed fabric name\n"); printk(KERN_ERR "Unable to locate passed fabric name\n");
return NULL; return ERR_PTR(-EINVAL);
} }
if (strlen(name) >= TARGET_FABRIC_NAME_SIZE) { if (strlen(name) >= TARGET_FABRIC_NAME_SIZE) {
printk(KERN_ERR "Passed name: %s exceeds TARGET_FABRIC" printk(KERN_ERR "Passed name: %s exceeds TARGET_FABRIC"
"_NAME_SIZE\n", name); "_NAME_SIZE\n", name);
return NULL; return ERR_PTR(-EINVAL);
} }
tf = kzalloc(sizeof(struct target_fabric_configfs), GFP_KERNEL); tf = kzalloc(sizeof(struct target_fabric_configfs), GFP_KERNEL);
if (!(tf)) if (!(tf))
return NULL; return ERR_PTR(-ENOMEM);
INIT_LIST_HEAD(&tf->tf_list); INIT_LIST_HEAD(&tf->tf_list);
atomic_set(&tf->tf_access_cnt, 0); atomic_set(&tf->tf_access_cnt, 0);
...@@ -591,7 +601,6 @@ void target_fabric_configfs_deregister( ...@@ -591,7 +601,6 @@ void target_fabric_configfs_deregister(
printk("<<<<<<<<<<<<<<<<<<<<<< END FABRIC API >>>>>>>>>>>>>>>>>" printk("<<<<<<<<<<<<<<<<<<<<<< END FABRIC API >>>>>>>>>>>>>>>>>"
">>>>>\n"); ">>>>>\n");
return;
} }
EXPORT_SYMBOL(target_fabric_configfs_deregister); EXPORT_SYMBOL(target_fabric_configfs_deregister);
...@@ -616,7 +625,8 @@ static ssize_t target_core_dev_show_attr_##_name( \ ...@@ -616,7 +625,8 @@ static ssize_t target_core_dev_show_attr_##_name( \
spin_unlock(&se_dev->se_dev_lock); \ spin_unlock(&se_dev->se_dev_lock); \
return -ENODEV; \ return -ENODEV; \
} \ } \
rb = snprintf(page, PAGE_SIZE, "%u\n", (u32)DEV_ATTRIB(dev)->_name); \ rb = snprintf(page, PAGE_SIZE, "%u\n", \
(u32)dev->se_sub_dev->se_dev_attrib._name); \
spin_unlock(&se_dev->se_dev_lock); \ spin_unlock(&se_dev->se_dev_lock); \
\ \
return rb; \ return rb; \
...@@ -1078,7 +1088,7 @@ static ssize_t target_core_dev_pr_show_spc3_res( ...@@ -1078,7 +1088,7 @@ static ssize_t target_core_dev_pr_show_spc3_res(
PR_REG_ISID_ID_LEN); PR_REG_ISID_ID_LEN);
*len += sprintf(page + *len, "SPC-3 Reservation: %s Initiator: %s%s\n", *len += sprintf(page + *len, "SPC-3 Reservation: %s Initiator: %s%s\n",
TPG_TFO(se_nacl->se_tpg)->get_fabric_name(), se_nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
se_nacl->initiatorname, (prf_isid) ? &i_buf[0] : ""); se_nacl->initiatorname, (prf_isid) ? &i_buf[0] : "");
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
...@@ -1100,7 +1110,7 @@ static ssize_t target_core_dev_pr_show_spc2_res( ...@@ -1100,7 +1110,7 @@ static ssize_t target_core_dev_pr_show_spc2_res(
return *len; return *len;
} }
*len += sprintf(page + *len, "SPC-2 Reservation: %s Initiator: %s\n", *len += sprintf(page + *len, "SPC-2 Reservation: %s Initiator: %s\n",
TPG_TFO(se_nacl->se_tpg)->get_fabric_name(), se_nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
se_nacl->initiatorname); se_nacl->initiatorname);
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
...@@ -1116,7 +1126,7 @@ static ssize_t target_core_dev_pr_show_attr_res_holder( ...@@ -1116,7 +1126,7 @@ static ssize_t target_core_dev_pr_show_attr_res_holder(
if (!(su_dev->se_dev_ptr)) if (!(su_dev->se_dev_ptr))
return -ENODEV; return -ENODEV;
switch (T10_RES(su_dev)->res_type) { switch (su_dev->t10_pr.res_type) {
case SPC3_PERSISTENT_RESERVATIONS: case SPC3_PERSISTENT_RESERVATIONS:
target_core_dev_pr_show_spc3_res(su_dev->se_dev_ptr, target_core_dev_pr_show_spc3_res(su_dev->se_dev_ptr,
page, &len); page, &len);
...@@ -1153,7 +1163,7 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_all_tgt_pts( ...@@ -1153,7 +1163,7 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_all_tgt_pts(
if (!(dev)) if (!(dev))
return -ENODEV; return -ENODEV;
if (T10_RES(su_dev)->res_type != SPC3_PERSISTENT_RESERVATIONS) if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS)
return len; return len;
spin_lock(&dev->dev_reservation_lock); spin_lock(&dev->dev_reservation_lock);
...@@ -1190,10 +1200,10 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_generation( ...@@ -1190,10 +1200,10 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_generation(
if (!(su_dev->se_dev_ptr)) if (!(su_dev->se_dev_ptr))
return -ENODEV; return -ENODEV;
if (T10_RES(su_dev)->res_type != SPC3_PERSISTENT_RESERVATIONS) if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS)
return 0; return 0;
return sprintf(page, "0x%08x\n", T10_RES(su_dev)->pr_generation); return sprintf(page, "0x%08x\n", su_dev->t10_pr.pr_generation);
} }
SE_DEV_PR_ATTR_RO(res_pr_generation); SE_DEV_PR_ATTR_RO(res_pr_generation);
...@@ -1217,7 +1227,7 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_holder_tg_port( ...@@ -1217,7 +1227,7 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_holder_tg_port(
if (!(dev)) if (!(dev))
return -ENODEV; return -ENODEV;
if (T10_RES(su_dev)->res_type != SPC3_PERSISTENT_RESERVATIONS) if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS)
return len; return len;
spin_lock(&dev->dev_reservation_lock); spin_lock(&dev->dev_reservation_lock);
...@@ -1230,7 +1240,7 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_holder_tg_port( ...@@ -1230,7 +1240,7 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_holder_tg_port(
se_nacl = pr_reg->pr_reg_nacl; se_nacl = pr_reg->pr_reg_nacl;
se_tpg = se_nacl->se_tpg; se_tpg = se_nacl->se_tpg;
lun = pr_reg->pr_reg_tg_pt_lun; lun = pr_reg->pr_reg_tg_pt_lun;
tfo = TPG_TFO(se_tpg); tfo = se_tpg->se_tpg_tfo;
len += sprintf(page+len, "SPC-3 Reservation: %s" len += sprintf(page+len, "SPC-3 Reservation: %s"
" Target Node Endpoint: %s\n", tfo->get_fabric_name(), " Target Node Endpoint: %s\n", tfo->get_fabric_name(),
...@@ -1264,13 +1274,13 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts( ...@@ -1264,13 +1274,13 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts(
if (!(su_dev->se_dev_ptr)) if (!(su_dev->se_dev_ptr))
return -ENODEV; return -ENODEV;
if (T10_RES(su_dev)->res_type != SPC3_PERSISTENT_RESERVATIONS) if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS)
return len; return len;
len += sprintf(page+len, "SPC-3 PR Registrations:\n"); len += sprintf(page+len, "SPC-3 PR Registrations:\n");
spin_lock(&T10_RES(su_dev)->registration_lock); spin_lock(&su_dev->t10_pr.registration_lock);
list_for_each_entry(pr_reg, &T10_RES(su_dev)->registration_list, list_for_each_entry(pr_reg, &su_dev->t10_pr.registration_list,
pr_reg_list) { pr_reg_list) {
memset(buf, 0, 384); memset(buf, 0, 384);
...@@ -1290,7 +1300,7 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts( ...@@ -1290,7 +1300,7 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts(
len += sprintf(page+len, "%s", buf); len += sprintf(page+len, "%s", buf);
reg_count++; reg_count++;
} }
spin_unlock(&T10_RES(su_dev)->registration_lock); spin_unlock(&su_dev->t10_pr.registration_lock);
if (!(reg_count)) if (!(reg_count))
len += sprintf(page+len, "None\n"); len += sprintf(page+len, "None\n");
...@@ -1315,7 +1325,7 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_type( ...@@ -1315,7 +1325,7 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_type(
if (!(dev)) if (!(dev))
return -ENODEV; return -ENODEV;
if (T10_RES(su_dev)->res_type != SPC3_PERSISTENT_RESERVATIONS) if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS)
return len; return len;
spin_lock(&dev->dev_reservation_lock); spin_lock(&dev->dev_reservation_lock);
...@@ -1346,7 +1356,7 @@ static ssize_t target_core_dev_pr_show_attr_res_type( ...@@ -1346,7 +1356,7 @@ static ssize_t target_core_dev_pr_show_attr_res_type(
if (!(su_dev->se_dev_ptr)) if (!(su_dev->se_dev_ptr))
return -ENODEV; return -ENODEV;
switch (T10_RES(su_dev)->res_type) { switch (su_dev->t10_pr.res_type) {
case SPC3_PERSISTENT_RESERVATIONS: case SPC3_PERSISTENT_RESERVATIONS:
len = sprintf(page, "SPC3_PERSISTENT_RESERVATIONS\n"); len = sprintf(page, "SPC3_PERSISTENT_RESERVATIONS\n");
break; break;
...@@ -1377,11 +1387,11 @@ static ssize_t target_core_dev_pr_show_attr_res_aptpl_active( ...@@ -1377,11 +1387,11 @@ static ssize_t target_core_dev_pr_show_attr_res_aptpl_active(
if (!(su_dev->se_dev_ptr)) if (!(su_dev->se_dev_ptr))
return -ENODEV; return -ENODEV;
if (T10_RES(su_dev)->res_type != SPC3_PERSISTENT_RESERVATIONS) if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS)
return 0; return 0;
return sprintf(page, "APTPL Bit Status: %s\n", return sprintf(page, "APTPL Bit Status: %s\n",
(T10_RES(su_dev)->pr_aptpl_active) ? "Activated" : "Disabled"); (su_dev->t10_pr.pr_aptpl_active) ? "Activated" : "Disabled");
} }
SE_DEV_PR_ATTR_RO(res_aptpl_active); SE_DEV_PR_ATTR_RO(res_aptpl_active);
...@@ -1396,7 +1406,7 @@ static ssize_t target_core_dev_pr_show_attr_res_aptpl_metadata( ...@@ -1396,7 +1406,7 @@ static ssize_t target_core_dev_pr_show_attr_res_aptpl_metadata(
if (!(su_dev->se_dev_ptr)) if (!(su_dev->se_dev_ptr))
return -ENODEV; return -ENODEV;
if (T10_RES(su_dev)->res_type != SPC3_PERSISTENT_RESERVATIONS) if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS)
return 0; return 0;
return sprintf(page, "Ready to process PR APTPL metadata..\n"); return sprintf(page, "Ready to process PR APTPL metadata..\n");
...@@ -1448,7 +1458,7 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata( ...@@ -1448,7 +1458,7 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata(
if (!(dev)) if (!(dev))
return -ENODEV; return -ENODEV;
if (T10_RES(su_dev)->res_type != SPC3_PERSISTENT_RESERVATIONS) if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS)
return 0; return 0;
if (atomic_read(&dev->dev_export_obj.obj_access_count)) { if (atomic_read(&dev->dev_export_obj.obj_access_count)) {
...@@ -1594,7 +1604,7 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata( ...@@ -1594,7 +1604,7 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata(
goto out; goto out;
} }
ret = core_scsi3_alloc_aptpl_registration(T10_RES(su_dev), sa_res_key, ret = core_scsi3_alloc_aptpl_registration(&su_dev->t10_pr, sa_res_key,
i_port, isid, mapped_lun, t_port, tpgt, target_lun, i_port, isid, mapped_lun, t_port, tpgt, target_lun,
res_holder, all_tg_pt, type); res_holder, all_tg_pt, type);
out: out:
...@@ -1842,7 +1852,7 @@ static ssize_t target_core_show_alua_lu_gp(void *p, char *page) ...@@ -1842,7 +1852,7 @@ static ssize_t target_core_show_alua_lu_gp(void *p, char *page)
if (!(dev)) if (!(dev))
return -ENODEV; return -ENODEV;
if (T10_ALUA(su_dev)->alua_type != SPC3_ALUA_EMULATED) if (su_dev->t10_alua.alua_type != SPC3_ALUA_EMULATED)
return len; return len;
lu_gp_mem = dev->dev_alua_lu_gp_mem; lu_gp_mem = dev->dev_alua_lu_gp_mem;
...@@ -1881,7 +1891,7 @@ static ssize_t target_core_store_alua_lu_gp( ...@@ -1881,7 +1891,7 @@ static ssize_t target_core_store_alua_lu_gp(
if (!(dev)) if (!(dev))
return -ENODEV; return -ENODEV;
if (T10_ALUA(su_dev)->alua_type != SPC3_ALUA_EMULATED) { if (su_dev->t10_alua.alua_type != SPC3_ALUA_EMULATED) {
printk(KERN_WARNING "SPC3_ALUA_EMULATED not enabled for %s/%s\n", printk(KERN_WARNING "SPC3_ALUA_EMULATED not enabled for %s/%s\n",
config_item_name(&hba->hba_group.cg_item), config_item_name(&hba->hba_group.cg_item),
config_item_name(&su_dev->se_dev_group.cg_item)); config_item_name(&su_dev->se_dev_group.cg_item));
...@@ -2557,9 +2567,9 @@ static ssize_t target_core_alua_tg_pt_gp_show_attr_members( ...@@ -2557,9 +2567,9 @@ static ssize_t target_core_alua_tg_pt_gp_show_attr_members(
lun = port->sep_lun; lun = port->sep_lun;
cur_len = snprintf(buf, TG_PT_GROUP_NAME_BUF, "%s/%s/tpgt_%hu" cur_len = snprintf(buf, TG_PT_GROUP_NAME_BUF, "%s/%s/tpgt_%hu"
"/%s\n", TPG_TFO(tpg)->get_fabric_name(), "/%s\n", tpg->se_tpg_tfo->get_fabric_name(),
TPG_TFO(tpg)->tpg_get_wwn(tpg), tpg->se_tpg_tfo->tpg_get_wwn(tpg),
TPG_TFO(tpg)->tpg_get_tag(tpg), tpg->se_tpg_tfo->tpg_get_tag(tpg),
config_item_name(&lun->lun_group.cg_item)); config_item_name(&lun->lun_group.cg_item));
cur_len++; /* Extra byte for NULL terminator */ cur_len++; /* Extra byte for NULL terminator */
...@@ -2748,17 +2758,17 @@ static struct config_group *target_core_make_subdev( ...@@ -2748,17 +2758,17 @@ static struct config_group *target_core_make_subdev(
" struct se_subsystem_dev\n"); " struct se_subsystem_dev\n");
goto unlock; goto unlock;
} }
INIT_LIST_HEAD(&se_dev->g_se_dev_list); INIT_LIST_HEAD(&se_dev->se_dev_node);
INIT_LIST_HEAD(&se_dev->t10_wwn.t10_vpd_list); INIT_LIST_HEAD(&se_dev->t10_wwn.t10_vpd_list);
spin_lock_init(&se_dev->t10_wwn.t10_vpd_lock); spin_lock_init(&se_dev->t10_wwn.t10_vpd_lock);
INIT_LIST_HEAD(&se_dev->t10_reservation.registration_list); INIT_LIST_HEAD(&se_dev->t10_pr.registration_list);
INIT_LIST_HEAD(&se_dev->t10_reservation.aptpl_reg_list); INIT_LIST_HEAD(&se_dev->t10_pr.aptpl_reg_list);
spin_lock_init(&se_dev->t10_reservation.registration_lock); spin_lock_init(&se_dev->t10_pr.registration_lock);
spin_lock_init(&se_dev->t10_reservation.aptpl_reg_lock); spin_lock_init(&se_dev->t10_pr.aptpl_reg_lock);
INIT_LIST_HEAD(&se_dev->t10_alua.tg_pt_gps_list); INIT_LIST_HEAD(&se_dev->t10_alua.tg_pt_gps_list);
spin_lock_init(&se_dev->t10_alua.tg_pt_gps_lock); spin_lock_init(&se_dev->t10_alua.tg_pt_gps_lock);
spin_lock_init(&se_dev->se_dev_lock); spin_lock_init(&se_dev->se_dev_lock);
se_dev->t10_reservation.pr_aptpl_buf_len = PR_APTPL_BUF_LEN; se_dev->t10_pr.pr_aptpl_buf_len = PR_APTPL_BUF_LEN;
se_dev->t10_wwn.t10_sub_dev = se_dev; se_dev->t10_wwn.t10_sub_dev = se_dev;
se_dev->t10_alua.t10_sub_dev = se_dev; se_dev->t10_alua.t10_sub_dev = se_dev;
se_dev->se_dev_attrib.da_sub_dev = se_dev; se_dev->se_dev_attrib.da_sub_dev = se_dev;
...@@ -2784,9 +2794,9 @@ static struct config_group *target_core_make_subdev( ...@@ -2784,9 +2794,9 @@ static struct config_group *target_core_make_subdev(
" from allocate_virtdevice()\n"); " from allocate_virtdevice()\n");
goto out; goto out;
} }
spin_lock(&se_global->g_device_lock); spin_lock(&se_device_lock);
list_add_tail(&se_dev->g_se_dev_list, &se_global->g_se_dev_list); list_add_tail(&se_dev->se_dev_node, &se_dev_list);
spin_unlock(&se_global->g_device_lock); spin_unlock(&se_device_lock);
config_group_init_type_name(&se_dev->se_dev_group, name, config_group_init_type_name(&se_dev->se_dev_group, name,
&target_core_dev_cit); &target_core_dev_cit);
...@@ -2814,7 +2824,7 @@ static struct config_group *target_core_make_subdev( ...@@ -2814,7 +2824,7 @@ static struct config_group *target_core_make_subdev(
if (!(tg_pt_gp)) if (!(tg_pt_gp))
goto out; goto out;
tg_pt_gp_cg = &T10_ALUA(se_dev)->alua_tg_pt_gps_group; tg_pt_gp_cg = &se_dev->t10_alua.alua_tg_pt_gps_group;
tg_pt_gp_cg->default_groups = kzalloc(sizeof(struct config_group) * 2, tg_pt_gp_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
GFP_KERNEL); GFP_KERNEL);
if (!(tg_pt_gp_cg->default_groups)) { if (!(tg_pt_gp_cg->default_groups)) {
...@@ -2827,11 +2837,11 @@ static struct config_group *target_core_make_subdev( ...@@ -2827,11 +2837,11 @@ static struct config_group *target_core_make_subdev(
"default_tg_pt_gp", &target_core_alua_tg_pt_gp_cit); "default_tg_pt_gp", &target_core_alua_tg_pt_gp_cit);
tg_pt_gp_cg->default_groups[0] = &tg_pt_gp->tg_pt_gp_group; tg_pt_gp_cg->default_groups[0] = &tg_pt_gp->tg_pt_gp_group;
tg_pt_gp_cg->default_groups[1] = NULL; tg_pt_gp_cg->default_groups[1] = NULL;
T10_ALUA(se_dev)->default_tg_pt_gp = tg_pt_gp; se_dev->t10_alua.default_tg_pt_gp = tg_pt_gp;
/* /*
* Add core/$HBA/$DEV/statistics/ default groups * Add core/$HBA/$DEV/statistics/ default groups
*/ */
dev_stat_grp = &DEV_STAT_GRP(se_dev)->stat_group; dev_stat_grp = &se_dev->dev_stat_grps.stat_group;
dev_stat_grp->default_groups = kzalloc(sizeof(struct config_group) * 4, dev_stat_grp->default_groups = kzalloc(sizeof(struct config_group) * 4,
GFP_KERNEL); GFP_KERNEL);
if (!dev_stat_grp->default_groups) { if (!dev_stat_grp->default_groups) {
...@@ -2846,9 +2856,9 @@ static struct config_group *target_core_make_subdev( ...@@ -2846,9 +2856,9 @@ static struct config_group *target_core_make_subdev(
mutex_unlock(&hba->hba_access_mutex); mutex_unlock(&hba->hba_access_mutex);
return &se_dev->se_dev_group; return &se_dev->se_dev_group;
out: out:
if (T10_ALUA(se_dev)->default_tg_pt_gp) { if (se_dev->t10_alua.default_tg_pt_gp) {
core_alua_free_tg_pt_gp(T10_ALUA(se_dev)->default_tg_pt_gp); core_alua_free_tg_pt_gp(se_dev->t10_alua.default_tg_pt_gp);
T10_ALUA(se_dev)->default_tg_pt_gp = NULL; se_dev->t10_alua.default_tg_pt_gp = NULL;
} }
if (dev_stat_grp) if (dev_stat_grp)
kfree(dev_stat_grp->default_groups); kfree(dev_stat_grp->default_groups);
...@@ -2881,11 +2891,11 @@ static void target_core_drop_subdev( ...@@ -2881,11 +2891,11 @@ static void target_core_drop_subdev(
mutex_lock(&hba->hba_access_mutex); mutex_lock(&hba->hba_access_mutex);
t = hba->transport; t = hba->transport;
spin_lock(&se_global->g_device_lock); spin_lock(&se_device_lock);
list_del(&se_dev->g_se_dev_list); list_del(&se_dev->se_dev_node);
spin_unlock(&se_global->g_device_lock); spin_unlock(&se_device_lock);
dev_stat_grp = &DEV_STAT_GRP(se_dev)->stat_group; dev_stat_grp = &se_dev->dev_stat_grps.stat_group;
for (i = 0; dev_stat_grp->default_groups[i]; i++) { for (i = 0; dev_stat_grp->default_groups[i]; i++) {
df_item = &dev_stat_grp->default_groups[i]->cg_item; df_item = &dev_stat_grp->default_groups[i]->cg_item;
dev_stat_grp->default_groups[i] = NULL; dev_stat_grp->default_groups[i] = NULL;
...@@ -2893,7 +2903,7 @@ static void target_core_drop_subdev( ...@@ -2893,7 +2903,7 @@ static void target_core_drop_subdev(
} }
kfree(dev_stat_grp->default_groups); kfree(dev_stat_grp->default_groups);
tg_pt_gp_cg = &T10_ALUA(se_dev)->alua_tg_pt_gps_group; tg_pt_gp_cg = &se_dev->t10_alua.alua_tg_pt_gps_group;
for (i = 0; tg_pt_gp_cg->default_groups[i]; i++) { for (i = 0; tg_pt_gp_cg->default_groups[i]; i++) {
df_item = &tg_pt_gp_cg->default_groups[i]->cg_item; df_item = &tg_pt_gp_cg->default_groups[i]->cg_item;
tg_pt_gp_cg->default_groups[i] = NULL; tg_pt_gp_cg->default_groups[i] = NULL;
...@@ -2904,7 +2914,7 @@ static void target_core_drop_subdev( ...@@ -2904,7 +2914,7 @@ static void target_core_drop_subdev(
* core_alua_free_tg_pt_gp() is called from ->default_tg_pt_gp * core_alua_free_tg_pt_gp() is called from ->default_tg_pt_gp
* directly from target_core_alua_tg_pt_gp_release(). * directly from target_core_alua_tg_pt_gp_release().
*/ */
T10_ALUA(se_dev)->default_tg_pt_gp = NULL; se_dev->t10_alua.default_tg_pt_gp = NULL;
dev_cg = &se_dev->se_dev_group; dev_cg = &se_dev->se_dev_group;
for (i = 0; dev_cg->default_groups[i]; i++) { for (i = 0; dev_cg->default_groups[i]; i++) {
...@@ -3130,10 +3140,9 @@ static int __init target_core_init_configfs(void) ...@@ -3130,10 +3140,9 @@ static int __init target_core_init_configfs(void)
INIT_LIST_HEAD(&g_tf_list); INIT_LIST_HEAD(&g_tf_list);
mutex_init(&g_tf_lock); mutex_init(&g_tf_lock);
init_scsi_index_table(); ret = init_se_kmem_caches();
ret = init_se_global();
if (ret < 0) if (ret < 0)
return -1; return ret;
/* /*
* Create $CONFIGFS/target/core default group for HBA <-> Storage Object * Create $CONFIGFS/target/core default group for HBA <-> Storage Object
* and ALUA Logical Unit Group and Target Port Group infrastructure. * and ALUA Logical Unit Group and Target Port Group infrastructure.
...@@ -3146,29 +3155,29 @@ static int __init target_core_init_configfs(void) ...@@ -3146,29 +3155,29 @@ static int __init target_core_init_configfs(void)
goto out_global; goto out_global;
} }
config_group_init_type_name(&se_global->target_core_hbagroup, config_group_init_type_name(&target_core_hbagroup,
"core", &target_core_cit); "core", &target_core_cit);
target_cg->default_groups[0] = &se_global->target_core_hbagroup; target_cg->default_groups[0] = &target_core_hbagroup;
target_cg->default_groups[1] = NULL; target_cg->default_groups[1] = NULL;
/* /*
* Create ALUA infrastructure under /sys/kernel/config/target/core/alua/ * Create ALUA infrastructure under /sys/kernel/config/target/core/alua/
*/ */
hba_cg = &se_global->target_core_hbagroup; hba_cg = &target_core_hbagroup;
hba_cg->default_groups = kzalloc(sizeof(struct config_group) * 2, hba_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
GFP_KERNEL); GFP_KERNEL);
if (!(hba_cg->default_groups)) { if (!(hba_cg->default_groups)) {
printk(KERN_ERR "Unable to allocate hba_cg->default_groups\n"); printk(KERN_ERR "Unable to allocate hba_cg->default_groups\n");
goto out_global; goto out_global;
} }
config_group_init_type_name(&se_global->alua_group, config_group_init_type_name(&alua_group,
"alua", &target_core_alua_cit); "alua", &target_core_alua_cit);
hba_cg->default_groups[0] = &se_global->alua_group; hba_cg->default_groups[0] = &alua_group;
hba_cg->default_groups[1] = NULL; hba_cg->default_groups[1] = NULL;
/* /*
* Add ALUA Logical Unit Group and Target Port Group ConfigFS * Add ALUA Logical Unit Group and Target Port Group ConfigFS
* groups under /sys/kernel/config/target/core/alua/ * groups under /sys/kernel/config/target/core/alua/
*/ */
alua_cg = &se_global->alua_group; alua_cg = &alua_group;
alua_cg->default_groups = kzalloc(sizeof(struct config_group) * 2, alua_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
GFP_KERNEL); GFP_KERNEL);
if (!(alua_cg->default_groups)) { if (!(alua_cg->default_groups)) {
...@@ -3176,9 +3185,9 @@ static int __init target_core_init_configfs(void) ...@@ -3176,9 +3185,9 @@ static int __init target_core_init_configfs(void)
goto out_global; goto out_global;
} }
config_group_init_type_name(&se_global->alua_lu_gps_group, config_group_init_type_name(&alua_lu_gps_group,
"lu_gps", &target_core_alua_lu_gps_cit); "lu_gps", &target_core_alua_lu_gps_cit);
alua_cg->default_groups[0] = &se_global->alua_lu_gps_group; alua_cg->default_groups[0] = &alua_lu_gps_group;
alua_cg->default_groups[1] = NULL; alua_cg->default_groups[1] = NULL;
/* /*
* Add core/alua/lu_gps/default_lu_gp * Add core/alua/lu_gps/default_lu_gp
...@@ -3187,7 +3196,7 @@ static int __init target_core_init_configfs(void) ...@@ -3187,7 +3196,7 @@ static int __init target_core_init_configfs(void)
if (IS_ERR(lu_gp)) if (IS_ERR(lu_gp))
goto out_global; goto out_global;
lu_gp_cg = &se_global->alua_lu_gps_group; lu_gp_cg = &alua_lu_gps_group;
lu_gp_cg->default_groups = kzalloc(sizeof(struct config_group) * 2, lu_gp_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
GFP_KERNEL); GFP_KERNEL);
if (!(lu_gp_cg->default_groups)) { if (!(lu_gp_cg->default_groups)) {
...@@ -3199,7 +3208,7 @@ static int __init target_core_init_configfs(void) ...@@ -3199,7 +3208,7 @@ static int __init target_core_init_configfs(void)
&target_core_alua_lu_gp_cit); &target_core_alua_lu_gp_cit);
lu_gp_cg->default_groups[0] = &lu_gp->lu_gp_group; lu_gp_cg->default_groups[0] = &lu_gp->lu_gp_group;
lu_gp_cg->default_groups[1] = NULL; lu_gp_cg->default_groups[1] = NULL;
se_global->default_lu_gp = lu_gp; default_lu_gp = lu_gp;
/* /*
* Register the target_core_mod subsystem with configfs. * Register the target_core_mod subsystem with configfs.
*/ */
...@@ -3229,9 +3238,9 @@ static int __init target_core_init_configfs(void) ...@@ -3229,9 +3238,9 @@ static int __init target_core_init_configfs(void)
core_dev_release_virtual_lun0(); core_dev_release_virtual_lun0();
rd_module_exit(); rd_module_exit();
out_global: out_global:
if (se_global->default_lu_gp) { if (default_lu_gp) {
core_alua_free_lu_gp(se_global->default_lu_gp); core_alua_free_lu_gp(default_lu_gp);
se_global->default_lu_gp = NULL; default_lu_gp = NULL;
} }
if (lu_gp_cg) if (lu_gp_cg)
kfree(lu_gp_cg->default_groups); kfree(lu_gp_cg->default_groups);
...@@ -3240,8 +3249,8 @@ static int __init target_core_init_configfs(void) ...@@ -3240,8 +3249,8 @@ static int __init target_core_init_configfs(void)
if (hba_cg) if (hba_cg)
kfree(hba_cg->default_groups); kfree(hba_cg->default_groups);
kfree(target_cg->default_groups); kfree(target_cg->default_groups);
release_se_global(); release_se_kmem_caches();
return -1; return ret;
} }
static void __exit target_core_exit_configfs(void) static void __exit target_core_exit_configfs(void)
...@@ -3251,10 +3260,9 @@ static void __exit target_core_exit_configfs(void) ...@@ -3251,10 +3260,9 @@ static void __exit target_core_exit_configfs(void)
struct config_item *item; struct config_item *item;
int i; int i;
se_global->in_shutdown = 1;
subsys = target_core_subsystem[0]; subsys = target_core_subsystem[0];
lu_gp_cg = &se_global->alua_lu_gps_group; lu_gp_cg = &alua_lu_gps_group;
for (i = 0; lu_gp_cg->default_groups[i]; i++) { for (i = 0; lu_gp_cg->default_groups[i]; i++) {
item = &lu_gp_cg->default_groups[i]->cg_item; item = &lu_gp_cg->default_groups[i]->cg_item;
lu_gp_cg->default_groups[i] = NULL; lu_gp_cg->default_groups[i] = NULL;
...@@ -3263,7 +3271,7 @@ static void __exit target_core_exit_configfs(void) ...@@ -3263,7 +3271,7 @@ static void __exit target_core_exit_configfs(void)
kfree(lu_gp_cg->default_groups); kfree(lu_gp_cg->default_groups);
lu_gp_cg->default_groups = NULL; lu_gp_cg->default_groups = NULL;
alua_cg = &se_global->alua_group; alua_cg = &alua_group;
for (i = 0; alua_cg->default_groups[i]; i++) { for (i = 0; alua_cg->default_groups[i]; i++) {
item = &alua_cg->default_groups[i]->cg_item; item = &alua_cg->default_groups[i]->cg_item;
alua_cg->default_groups[i] = NULL; alua_cg->default_groups[i] = NULL;
...@@ -3272,7 +3280,7 @@ static void __exit target_core_exit_configfs(void) ...@@ -3272,7 +3280,7 @@ static void __exit target_core_exit_configfs(void)
kfree(alua_cg->default_groups); kfree(alua_cg->default_groups);
alua_cg->default_groups = NULL; alua_cg->default_groups = NULL;
hba_cg = &se_global->target_core_hbagroup; hba_cg = &target_core_hbagroup;
for (i = 0; hba_cg->default_groups[i]; i++) { for (i = 0; hba_cg->default_groups[i]; i++) {
item = &hba_cg->default_groups[i]->cg_item; item = &hba_cg->default_groups[i]->cg_item;
hba_cg->default_groups[i] = NULL; hba_cg->default_groups[i] = NULL;
...@@ -3287,17 +3295,15 @@ static void __exit target_core_exit_configfs(void) ...@@ -3287,17 +3295,15 @@ static void __exit target_core_exit_configfs(void)
configfs_unregister_subsystem(subsys); configfs_unregister_subsystem(subsys);
kfree(subsys->su_group.default_groups); kfree(subsys->su_group.default_groups);
core_alua_free_lu_gp(se_global->default_lu_gp); core_alua_free_lu_gp(default_lu_gp);
se_global->default_lu_gp = NULL; default_lu_gp = NULL;
printk(KERN_INFO "TARGET_CORE[0]: Released ConfigFS Fabric" printk(KERN_INFO "TARGET_CORE[0]: Released ConfigFS Fabric"
" Infrastructure\n"); " Infrastructure\n");
core_dev_release_virtual_lun0(); core_dev_release_virtual_lun0();
rd_module_exit(); rd_module_exit();
release_se_global(); release_se_kmem_caches();
return;
} }
MODULE_DESCRIPTION("Target_Core_Mod/ConfigFS"); MODULE_DESCRIPTION("Target_Core_Mod/ConfigFS");
......
/******************************************************************************* /*******************************************************************************
* Filename: target_core_device.c (based on iscsi_target_device.c) * Filename: target_core_device.c (based on iscsi_target_device.c)
* *
* This file contains the iSCSI Virtual Device and Disk Transport * This file contains the TCM Virtual Device and Disk Transport
* agnostic related functions. * agnostic related functions.
* *
* Copyright (c) 2003, 2004, 2005 PyX Technologies, Inc. * Copyright (c) 2003, 2004, 2005 PyX Technologies, Inc.
...@@ -54,25 +54,30 @@ ...@@ -54,25 +54,30 @@
static void se_dev_start(struct se_device *dev); static void se_dev_start(struct se_device *dev);
static void se_dev_stop(struct se_device *dev); static void se_dev_stop(struct se_device *dev);
static struct se_hba *lun0_hba;
static struct se_subsystem_dev *lun0_su_dev;
/* not static, needed by tpg.c */
struct se_device *g_lun0_dev;
int transport_get_lun_for_cmd( int transport_get_lun_for_cmd(
struct se_cmd *se_cmd, struct se_cmd *se_cmd,
u32 unpacked_lun) u32 unpacked_lun)
{ {
struct se_dev_entry *deve; struct se_dev_entry *deve;
struct se_lun *se_lun = NULL; struct se_lun *se_lun = NULL;
struct se_session *se_sess = SE_SESS(se_cmd); struct se_session *se_sess = se_cmd->se_sess;
unsigned long flags; unsigned long flags;
int read_only = 0; int read_only = 0;
if (unpacked_lun >= TRANSPORT_MAX_LUNS_PER_TPG) { if (unpacked_lun >= TRANSPORT_MAX_LUNS_PER_TPG) {
se_cmd->scsi_sense_reason = TCM_NON_EXISTENT_LUN; se_cmd->scsi_sense_reason = TCM_NON_EXISTENT_LUN;
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
return -1; return -ENODEV;
} }
spin_lock_irq(&SE_NODE_ACL(se_sess)->device_list_lock); spin_lock_irq(&se_sess->se_node_acl->device_list_lock);
deve = se_cmd->se_deve = deve = se_cmd->se_deve =
&SE_NODE_ACL(se_sess)->device_list[unpacked_lun]; &se_sess->se_node_acl->device_list[unpacked_lun];
if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) { if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) {
if (se_cmd) { if (se_cmd) {
deve->total_cmds++; deve->total_cmds++;
...@@ -95,11 +100,11 @@ int transport_get_lun_for_cmd( ...@@ -95,11 +100,11 @@ int transport_get_lun_for_cmd(
se_lun = se_cmd->se_lun = deve->se_lun; se_lun = se_cmd->se_lun = deve->se_lun;
se_cmd->pr_res_key = deve->pr_res_key; se_cmd->pr_res_key = deve->pr_res_key;
se_cmd->orig_fe_lun = unpacked_lun; se_cmd->orig_fe_lun = unpacked_lun;
se_cmd->se_orig_obj_ptr = SE_LUN(se_cmd)->lun_se_dev; se_cmd->se_orig_obj_ptr = se_cmd->se_lun->lun_se_dev;
se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD; se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD;
} }
out: out:
spin_unlock_irq(&SE_NODE_ACL(se_sess)->device_list_lock); spin_unlock_irq(&se_sess->se_node_acl->device_list_lock);
if (!se_lun) { if (!se_lun) {
if (read_only) { if (read_only) {
...@@ -107,9 +112,9 @@ int transport_get_lun_for_cmd( ...@@ -107,9 +112,9 @@ int transport_get_lun_for_cmd(
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
printk("TARGET_CORE[%s]: Detected WRITE_PROTECTED LUN" printk("TARGET_CORE[%s]: Detected WRITE_PROTECTED LUN"
" Access for 0x%08x\n", " Access for 0x%08x\n",
CMD_TFO(se_cmd)->get_fabric_name(), se_cmd->se_tfo->get_fabric_name(),
unpacked_lun); unpacked_lun);
return -1; return -EACCES;
} else { } else {
/* /*
* Use the se_portal_group->tpg_virt_lun0 to allow for * Use the se_portal_group->tpg_virt_lun0 to allow for
...@@ -121,9 +126,9 @@ int transport_get_lun_for_cmd( ...@@ -121,9 +126,9 @@ int transport_get_lun_for_cmd(
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
printk("TARGET_CORE[%s]: Detected NON_EXISTENT_LUN" printk("TARGET_CORE[%s]: Detected NON_EXISTENT_LUN"
" Access for 0x%08x\n", " Access for 0x%08x\n",
CMD_TFO(se_cmd)->get_fabric_name(), se_cmd->se_tfo->get_fabric_name(),
unpacked_lun); unpacked_lun);
return -1; return -ENODEV;
} }
/* /*
* Force WRITE PROTECT for virtual LUN 0 * Force WRITE PROTECT for virtual LUN 0
...@@ -132,15 +137,15 @@ int transport_get_lun_for_cmd( ...@@ -132,15 +137,15 @@ int transport_get_lun_for_cmd(
(se_cmd->data_direction != DMA_NONE)) { (se_cmd->data_direction != DMA_NONE)) {
se_cmd->scsi_sense_reason = TCM_WRITE_PROTECTED; se_cmd->scsi_sense_reason = TCM_WRITE_PROTECTED;
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
return -1; return -EACCES;
} }
#if 0 #if 0
printk("TARGET_CORE[%s]: Using virtual LUN0! :-)\n", printk("TARGET_CORE[%s]: Using virtual LUN0! :-)\n",
CMD_TFO(se_cmd)->get_fabric_name()); se_cmd->se_tfo->get_fabric_name());
#endif #endif
se_lun = se_cmd->se_lun = &se_sess->se_tpg->tpg_virt_lun0; se_lun = se_cmd->se_lun = &se_sess->se_tpg->tpg_virt_lun0;
se_cmd->orig_fe_lun = 0; se_cmd->orig_fe_lun = 0;
se_cmd->se_orig_obj_ptr = SE_LUN(se_cmd)->lun_se_dev; se_cmd->se_orig_obj_ptr = se_cmd->se_lun->lun_se_dev;
se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD; se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD;
} }
} }
...@@ -151,7 +156,7 @@ int transport_get_lun_for_cmd( ...@@ -151,7 +156,7 @@ int transport_get_lun_for_cmd(
if (se_dev_check_online(se_lun->lun_se_dev) != 0) { if (se_dev_check_online(se_lun->lun_se_dev) != 0) {
se_cmd->scsi_sense_reason = TCM_NON_EXISTENT_LUN; se_cmd->scsi_sense_reason = TCM_NON_EXISTENT_LUN;
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
return -1; return -ENODEV;
} }
{ {
...@@ -171,10 +176,10 @@ int transport_get_lun_for_cmd( ...@@ -171,10 +176,10 @@ int transport_get_lun_for_cmd(
*/ */
spin_lock_irqsave(&se_lun->lun_cmd_lock, flags); spin_lock_irqsave(&se_lun->lun_cmd_lock, flags);
list_add_tail(&se_cmd->se_lun_list, &se_lun->lun_cmd_list); list_add_tail(&se_cmd->se_lun_list, &se_lun->lun_cmd_list);
atomic_set(&T_TASK(se_cmd)->transport_lun_active, 1); atomic_set(&se_cmd->t_task->transport_lun_active, 1);
#if 0 #if 0
printk(KERN_INFO "Adding ITT: 0x%08x to LUN LIST[%d]\n", printk(KERN_INFO "Adding ITT: 0x%08x to LUN LIST[%d]\n",
CMD_TFO(se_cmd)->get_task_tag(se_cmd), se_lun->unpacked_lun); se_cmd->se_tfo->get_task_tag(se_cmd), se_lun->unpacked_lun);
#endif #endif
spin_unlock_irqrestore(&se_lun->lun_cmd_lock, flags); spin_unlock_irqrestore(&se_lun->lun_cmd_lock, flags);
...@@ -189,35 +194,35 @@ int transport_get_lun_for_tmr( ...@@ -189,35 +194,35 @@ int transport_get_lun_for_tmr(
struct se_device *dev = NULL; struct se_device *dev = NULL;
struct se_dev_entry *deve; struct se_dev_entry *deve;
struct se_lun *se_lun = NULL; struct se_lun *se_lun = NULL;
struct se_session *se_sess = SE_SESS(se_cmd); struct se_session *se_sess = se_cmd->se_sess;
struct se_tmr_req *se_tmr = se_cmd->se_tmr_req; struct se_tmr_req *se_tmr = se_cmd->se_tmr_req;
if (unpacked_lun >= TRANSPORT_MAX_LUNS_PER_TPG) { if (unpacked_lun >= TRANSPORT_MAX_LUNS_PER_TPG) {
se_cmd->scsi_sense_reason = TCM_NON_EXISTENT_LUN; se_cmd->scsi_sense_reason = TCM_NON_EXISTENT_LUN;
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
return -1; return -ENODEV;
} }
spin_lock_irq(&SE_NODE_ACL(se_sess)->device_list_lock); spin_lock_irq(&se_sess->se_node_acl->device_list_lock);
deve = se_cmd->se_deve = deve = se_cmd->se_deve =
&SE_NODE_ACL(se_sess)->device_list[unpacked_lun]; &se_sess->se_node_acl->device_list[unpacked_lun];
if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) { if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) {
se_lun = se_cmd->se_lun = se_tmr->tmr_lun = deve->se_lun; se_lun = se_cmd->se_lun = se_tmr->tmr_lun = deve->se_lun;
dev = se_lun->lun_se_dev; dev = se_lun->lun_se_dev;
se_cmd->pr_res_key = deve->pr_res_key; se_cmd->pr_res_key = deve->pr_res_key;
se_cmd->orig_fe_lun = unpacked_lun; se_cmd->orig_fe_lun = unpacked_lun;
se_cmd->se_orig_obj_ptr = SE_LUN(se_cmd)->lun_se_dev; se_cmd->se_orig_obj_ptr = se_cmd->se_lun->lun_se_dev;
/* se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD; */ /* se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD; */
} }
spin_unlock_irq(&SE_NODE_ACL(se_sess)->device_list_lock); spin_unlock_irq(&se_sess->se_node_acl->device_list_lock);
if (!se_lun) { if (!se_lun) {
printk(KERN_INFO "TARGET_CORE[%s]: Detected NON_EXISTENT_LUN" printk(KERN_INFO "TARGET_CORE[%s]: Detected NON_EXISTENT_LUN"
" Access for 0x%08x\n", " Access for 0x%08x\n",
CMD_TFO(se_cmd)->get_fabric_name(), se_cmd->se_tfo->get_fabric_name(),
unpacked_lun); unpacked_lun);
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
return -1; return -ENODEV;
} }
/* /*
* Determine if the struct se_lun is online. * Determine if the struct se_lun is online.
...@@ -225,7 +230,7 @@ int transport_get_lun_for_tmr( ...@@ -225,7 +230,7 @@ int transport_get_lun_for_tmr(
/* #warning FIXME: Check for LUN_RESET + UNIT Attention */ /* #warning FIXME: Check for LUN_RESET + UNIT Attention */
if (se_dev_check_online(se_lun->lun_se_dev) != 0) { if (se_dev_check_online(se_lun->lun_se_dev) != 0) {
se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
return -1; return -ENODEV;
} }
se_tmr->tmr_dev = dev; se_tmr->tmr_dev = dev;
...@@ -263,14 +268,14 @@ struct se_dev_entry *core_get_se_deve_from_rtpi( ...@@ -263,14 +268,14 @@ struct se_dev_entry *core_get_se_deve_from_rtpi(
if (!(lun)) { if (!(lun)) {
printk(KERN_ERR "%s device entries device pointer is" printk(KERN_ERR "%s device entries device pointer is"
" NULL, but Initiator has access.\n", " NULL, but Initiator has access.\n",
TPG_TFO(tpg)->get_fabric_name()); tpg->se_tpg_tfo->get_fabric_name());
continue; continue;
} }
port = lun->lun_sep; port = lun->lun_sep;
if (!(port)) { if (!(port)) {
printk(KERN_ERR "%s device entries device pointer is" printk(KERN_ERR "%s device entries device pointer is"
" NULL, but Initiator has access.\n", " NULL, but Initiator has access.\n",
TPG_TFO(tpg)->get_fabric_name()); tpg->se_tpg_tfo->get_fabric_name());
continue; continue;
} }
if (port->sep_rtpi != rtpi) if (port->sep_rtpi != rtpi)
...@@ -308,7 +313,7 @@ int core_free_device_list_for_node( ...@@ -308,7 +313,7 @@ int core_free_device_list_for_node(
if (!deve->se_lun) { if (!deve->se_lun) {
printk(KERN_ERR "%s device entries device pointer is" printk(KERN_ERR "%s device entries device pointer is"
" NULL, but Initiator has access.\n", " NULL, but Initiator has access.\n",
TPG_TFO(tpg)->get_fabric_name()); tpg->se_tpg_tfo->get_fabric_name());
continue; continue;
} }
lun = deve->se_lun; lun = deve->se_lun;
...@@ -334,8 +339,6 @@ void core_dec_lacl_count(struct se_node_acl *se_nacl, struct se_cmd *se_cmd) ...@@ -334,8 +339,6 @@ void core_dec_lacl_count(struct se_node_acl *se_nacl, struct se_cmd *se_cmd)
deve = &se_nacl->device_list[se_cmd->orig_fe_lun]; deve = &se_nacl->device_list[se_cmd->orig_fe_lun];
deve->deve_cmds--; deve->deve_cmds--;
spin_unlock_irq(&se_nacl->device_list_lock); spin_unlock_irq(&se_nacl->device_list_lock);
return;
} }
void core_update_device_list_access( void core_update_device_list_access(
...@@ -355,8 +358,6 @@ void core_update_device_list_access( ...@@ -355,8 +358,6 @@ void core_update_device_list_access(
deve->lun_flags |= TRANSPORT_LUNFLAGS_READ_ONLY; deve->lun_flags |= TRANSPORT_LUNFLAGS_READ_ONLY;
} }
spin_unlock_irq(&nacl->device_list_lock); spin_unlock_irq(&nacl->device_list_lock);
return;
} }
/* core_update_device_list_for_node(): /* core_update_device_list_for_node():
...@@ -408,14 +409,14 @@ int core_update_device_list_for_node( ...@@ -408,14 +409,14 @@ int core_update_device_list_for_node(
" already set for demo mode -> explict" " already set for demo mode -> explict"
" LUN ACL transition\n"); " LUN ACL transition\n");
spin_unlock_irq(&nacl->device_list_lock); spin_unlock_irq(&nacl->device_list_lock);
return -1; return -EINVAL;
} }
if (deve->se_lun != lun) { if (deve->se_lun != lun) {
printk(KERN_ERR "struct se_dev_entry->se_lun does" printk(KERN_ERR "struct se_dev_entry->se_lun does"
" match passed struct se_lun for demo mode" " match passed struct se_lun for demo mode"
" -> explict LUN ACL transition\n"); " -> explict LUN ACL transition\n");
spin_unlock_irq(&nacl->device_list_lock); spin_unlock_irq(&nacl->device_list_lock);
return -1; return -EINVAL;
} }
deve->se_lun_acl = lun_acl; deve->se_lun_acl = lun_acl;
trans = 1; trans = 1;
...@@ -503,8 +504,6 @@ void core_clear_lun_from_tpg(struct se_lun *lun, struct se_portal_group *tpg) ...@@ -503,8 +504,6 @@ void core_clear_lun_from_tpg(struct se_lun *lun, struct se_portal_group *tpg)
spin_lock_bh(&tpg->acl_node_lock); spin_lock_bh(&tpg->acl_node_lock);
} }
spin_unlock_bh(&tpg->acl_node_lock); spin_unlock_bh(&tpg->acl_node_lock);
return;
} }
static struct se_port *core_alloc_port(struct se_device *dev) static struct se_port *core_alloc_port(struct se_device *dev)
...@@ -514,7 +513,7 @@ static struct se_port *core_alloc_port(struct se_device *dev) ...@@ -514,7 +513,7 @@ static struct se_port *core_alloc_port(struct se_device *dev)
port = kzalloc(sizeof(struct se_port), GFP_KERNEL); port = kzalloc(sizeof(struct se_port), GFP_KERNEL);
if (!(port)) { if (!(port)) {
printk(KERN_ERR "Unable to allocate struct se_port\n"); printk(KERN_ERR "Unable to allocate struct se_port\n");
return NULL; return ERR_PTR(-ENOMEM);
} }
INIT_LIST_HEAD(&port->sep_alua_list); INIT_LIST_HEAD(&port->sep_alua_list);
INIT_LIST_HEAD(&port->sep_list); INIT_LIST_HEAD(&port->sep_list);
...@@ -527,7 +526,7 @@ static struct se_port *core_alloc_port(struct se_device *dev) ...@@ -527,7 +526,7 @@ static struct se_port *core_alloc_port(struct se_device *dev)
printk(KERN_WARNING "Reached dev->dev_port_count ==" printk(KERN_WARNING "Reached dev->dev_port_count =="
" 0x0000ffff\n"); " 0x0000ffff\n");
spin_unlock(&dev->se_port_lock); spin_unlock(&dev->se_port_lock);
return NULL; return ERR_PTR(-ENOSPC);
} }
again: again:
/* /*
...@@ -565,7 +564,7 @@ static void core_export_port( ...@@ -565,7 +564,7 @@ static void core_export_port(
struct se_port *port, struct se_port *port,
struct se_lun *lun) struct se_lun *lun)
{ {
struct se_subsystem_dev *su_dev = SU_DEV(dev); struct se_subsystem_dev *su_dev = dev->se_sub_dev;
struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem = NULL; struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem = NULL;
spin_lock(&dev->se_port_lock); spin_lock(&dev->se_port_lock);
...@@ -578,7 +577,7 @@ static void core_export_port( ...@@ -578,7 +577,7 @@ static void core_export_port(
list_add_tail(&port->sep_list, &dev->dev_sep_list); list_add_tail(&port->sep_list, &dev->dev_sep_list);
spin_unlock(&dev->se_port_lock); spin_unlock(&dev->se_port_lock);
if (T10_ALUA(su_dev)->alua_type == SPC3_ALUA_EMULATED) { if (su_dev->t10_alua.alua_type == SPC3_ALUA_EMULATED) {
tg_pt_gp_mem = core_alua_allocate_tg_pt_gp_mem(port); tg_pt_gp_mem = core_alua_allocate_tg_pt_gp_mem(port);
if (IS_ERR(tg_pt_gp_mem) || !tg_pt_gp_mem) { if (IS_ERR(tg_pt_gp_mem) || !tg_pt_gp_mem) {
printk(KERN_ERR "Unable to allocate t10_alua_tg_pt" printk(KERN_ERR "Unable to allocate t10_alua_tg_pt"
...@@ -587,11 +586,11 @@ static void core_export_port( ...@@ -587,11 +586,11 @@ static void core_export_port(
} }
spin_lock(&tg_pt_gp_mem->tg_pt_gp_mem_lock); spin_lock(&tg_pt_gp_mem->tg_pt_gp_mem_lock);
__core_alua_attach_tg_pt_gp_mem(tg_pt_gp_mem, __core_alua_attach_tg_pt_gp_mem(tg_pt_gp_mem,
T10_ALUA(su_dev)->default_tg_pt_gp); su_dev->t10_alua.default_tg_pt_gp);
spin_unlock(&tg_pt_gp_mem->tg_pt_gp_mem_lock); spin_unlock(&tg_pt_gp_mem->tg_pt_gp_mem_lock);
printk(KERN_INFO "%s/%s: Adding to default ALUA Target Port" printk(KERN_INFO "%s/%s: Adding to default ALUA Target Port"
" Group: alua/default_tg_pt_gp\n", " Group: alua/default_tg_pt_gp\n",
TRANSPORT(dev)->name, TPG_TFO(tpg)->get_fabric_name()); dev->transport->name, tpg->se_tpg_tfo->get_fabric_name());
} }
dev->dev_port_count++; dev->dev_port_count++;
...@@ -618,8 +617,6 @@ static void core_release_port(struct se_device *dev, struct se_port *port) ...@@ -618,8 +617,6 @@ static void core_release_port(struct se_device *dev, struct se_port *port)
list_del(&port->sep_list); list_del(&port->sep_list);
dev->dev_port_count--; dev->dev_port_count--;
kfree(port); kfree(port);
return;
} }
int core_dev_export( int core_dev_export(
...@@ -630,8 +627,8 @@ int core_dev_export( ...@@ -630,8 +627,8 @@ int core_dev_export(
struct se_port *port; struct se_port *port;
port = core_alloc_port(dev); port = core_alloc_port(dev);
if (!(port)) if (IS_ERR(port))
return -1; return PTR_ERR(port);
lun->lun_se_dev = dev; lun->lun_se_dev = dev;
se_dev_start(dev); se_dev_start(dev);
...@@ -668,12 +665,12 @@ int transport_core_report_lun_response(struct se_cmd *se_cmd) ...@@ -668,12 +665,12 @@ int transport_core_report_lun_response(struct se_cmd *se_cmd)
{ {
struct se_dev_entry *deve; struct se_dev_entry *deve;
struct se_lun *se_lun; struct se_lun *se_lun;
struct se_session *se_sess = SE_SESS(se_cmd); struct se_session *se_sess = se_cmd->se_sess;
struct se_task *se_task; struct se_task *se_task;
unsigned char *buf = (unsigned char *)T_TASK(se_cmd)->t_task_buf; unsigned char *buf = se_cmd->t_task->t_task_buf;
u32 cdb_offset = 0, lun_count = 0, offset = 8, i; u32 cdb_offset = 0, lun_count = 0, offset = 8, i;
list_for_each_entry(se_task, &T_TASK(se_cmd)->t_task_list, t_list) list_for_each_entry(se_task, &se_cmd->t_task->t_task_list, t_list)
break; break;
if (!(se_task)) { if (!(se_task)) {
...@@ -692,9 +689,9 @@ int transport_core_report_lun_response(struct se_cmd *se_cmd) ...@@ -692,9 +689,9 @@ int transport_core_report_lun_response(struct se_cmd *se_cmd)
goto done; goto done;
} }
spin_lock_irq(&SE_NODE_ACL(se_sess)->device_list_lock); spin_lock_irq(&se_sess->se_node_acl->device_list_lock);
for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) { for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) {
deve = &SE_NODE_ACL(se_sess)->device_list[i]; deve = &se_sess->se_node_acl->device_list[i];
if (!(deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS)) if (!(deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS))
continue; continue;
se_lun = deve->se_lun; se_lun = deve->se_lun;
...@@ -711,7 +708,7 @@ int transport_core_report_lun_response(struct se_cmd *se_cmd) ...@@ -711,7 +708,7 @@ int transport_core_report_lun_response(struct se_cmd *se_cmd)
offset += 8; offset += 8;
cdb_offset += 8; cdb_offset += 8;
} }
spin_unlock_irq(&SE_NODE_ACL(se_sess)->device_list_lock); spin_unlock_irq(&se_sess->se_node_acl->device_list_lock);
/* /*
* See SPC3 r07, page 159. * See SPC3 r07, page 159.
...@@ -755,26 +752,20 @@ void se_release_device_for_hba(struct se_device *dev) ...@@ -755,26 +752,20 @@ void se_release_device_for_hba(struct se_device *dev)
core_scsi3_free_all_registrations(dev); core_scsi3_free_all_registrations(dev);
se_release_vpd_for_dev(dev); se_release_vpd_for_dev(dev);
kfree(dev->dev_status_queue_obj);
kfree(dev->dev_queue_obj);
kfree(dev); kfree(dev);
return;
} }
void se_release_vpd_for_dev(struct se_device *dev) void se_release_vpd_for_dev(struct se_device *dev)
{ {
struct t10_vpd *vpd, *vpd_tmp; struct t10_vpd *vpd, *vpd_tmp;
spin_lock(&DEV_T10_WWN(dev)->t10_vpd_lock); spin_lock(&dev->se_sub_dev->t10_wwn.t10_vpd_lock);
list_for_each_entry_safe(vpd, vpd_tmp, list_for_each_entry_safe(vpd, vpd_tmp,
&DEV_T10_WWN(dev)->t10_vpd_list, vpd_list) { &dev->se_sub_dev->t10_wwn.t10_vpd_list, vpd_list) {
list_del(&vpd->vpd_list); list_del(&vpd->vpd_list);
kfree(vpd); kfree(vpd);
} }
spin_unlock(&DEV_T10_WWN(dev)->t10_vpd_lock); spin_unlock(&dev->se_sub_dev->t10_wwn.t10_vpd_lock);
return;
} }
/* se_free_virtual_device(): /* se_free_virtual_device():
...@@ -860,48 +851,48 @@ void se_dev_set_default_attribs( ...@@ -860,48 +851,48 @@ void se_dev_set_default_attribs(
{ {
struct queue_limits *limits = &dev_limits->limits; struct queue_limits *limits = &dev_limits->limits;
DEV_ATTRIB(dev)->emulate_dpo = DA_EMULATE_DPO; dev->se_sub_dev->se_dev_attrib.emulate_dpo = DA_EMULATE_DPO;
DEV_ATTRIB(dev)->emulate_fua_write = DA_EMULATE_FUA_WRITE; dev->se_sub_dev->se_dev_attrib.emulate_fua_write = DA_EMULATE_FUA_WRITE;
DEV_ATTRIB(dev)->emulate_fua_read = DA_EMULATE_FUA_READ; dev->se_sub_dev->se_dev_attrib.emulate_fua_read = DA_EMULATE_FUA_READ;
DEV_ATTRIB(dev)->emulate_write_cache = DA_EMULATE_WRITE_CACHE; dev->se_sub_dev->se_dev_attrib.emulate_write_cache = DA_EMULATE_WRITE_CACHE;
DEV_ATTRIB(dev)->emulate_ua_intlck_ctrl = DA_EMULATE_UA_INTLLCK_CTRL; dev->se_sub_dev->se_dev_attrib.emulate_ua_intlck_ctrl = DA_EMULATE_UA_INTLLCK_CTRL;
DEV_ATTRIB(dev)->emulate_tas = DA_EMULATE_TAS; dev->se_sub_dev->se_dev_attrib.emulate_tas = DA_EMULATE_TAS;
DEV_ATTRIB(dev)->emulate_tpu = DA_EMULATE_TPU; dev->se_sub_dev->se_dev_attrib.emulate_tpu = DA_EMULATE_TPU;
DEV_ATTRIB(dev)->emulate_tpws = DA_EMULATE_TPWS; dev->se_sub_dev->se_dev_attrib.emulate_tpws = DA_EMULATE_TPWS;
DEV_ATTRIB(dev)->emulate_reservations = DA_EMULATE_RESERVATIONS; dev->se_sub_dev->se_dev_attrib.emulate_reservations = DA_EMULATE_RESERVATIONS;
DEV_ATTRIB(dev)->emulate_alua = DA_EMULATE_ALUA; dev->se_sub_dev->se_dev_attrib.emulate_alua = DA_EMULATE_ALUA;
DEV_ATTRIB(dev)->enforce_pr_isids = DA_ENFORCE_PR_ISIDS; dev->se_sub_dev->se_dev_attrib.enforce_pr_isids = DA_ENFORCE_PR_ISIDS;
/* /*
* The TPU=1 and TPWS=1 settings will be set in TCM/IBLOCK * The TPU=1 and TPWS=1 settings will be set in TCM/IBLOCK
* iblock_create_virtdevice() from struct queue_limits values * iblock_create_virtdevice() from struct queue_limits values
* if blk_queue_discard()==1 * if blk_queue_discard()==1
*/ */
DEV_ATTRIB(dev)->max_unmap_lba_count = DA_MAX_UNMAP_LBA_COUNT; dev->se_sub_dev->se_dev_attrib.max_unmap_lba_count = DA_MAX_UNMAP_LBA_COUNT;
DEV_ATTRIB(dev)->max_unmap_block_desc_count = dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count =
DA_MAX_UNMAP_BLOCK_DESC_COUNT; DA_MAX_UNMAP_BLOCK_DESC_COUNT;
DEV_ATTRIB(dev)->unmap_granularity = DA_UNMAP_GRANULARITY_DEFAULT; dev->se_sub_dev->se_dev_attrib.unmap_granularity = DA_UNMAP_GRANULARITY_DEFAULT;
DEV_ATTRIB(dev)->unmap_granularity_alignment = dev->se_sub_dev->se_dev_attrib.unmap_granularity_alignment =
DA_UNMAP_GRANULARITY_ALIGNMENT_DEFAULT; DA_UNMAP_GRANULARITY_ALIGNMENT_DEFAULT;
/* /*
* block_size is based on subsystem plugin dependent requirements. * block_size is based on subsystem plugin dependent requirements.
*/ */
DEV_ATTRIB(dev)->hw_block_size = limits->logical_block_size; dev->se_sub_dev->se_dev_attrib.hw_block_size = limits->logical_block_size;
DEV_ATTRIB(dev)->block_size = limits->logical_block_size; dev->se_sub_dev->se_dev_attrib.block_size = limits->logical_block_size;
/* /*
* max_sectors is based on subsystem plugin dependent requirements. * max_sectors is based on subsystem plugin dependent requirements.
*/ */
DEV_ATTRIB(dev)->hw_max_sectors = limits->max_hw_sectors; dev->se_sub_dev->se_dev_attrib.hw_max_sectors = limits->max_hw_sectors;
DEV_ATTRIB(dev)->max_sectors = limits->max_sectors; dev->se_sub_dev->se_dev_attrib.max_sectors = limits->max_sectors;
/* /*
* Set optimal_sectors from max_sectors, which can be lowered via * Set optimal_sectors from max_sectors, which can be lowered via
* configfs. * configfs.
*/ */
DEV_ATTRIB(dev)->optimal_sectors = limits->max_sectors; dev->se_sub_dev->se_dev_attrib.optimal_sectors = limits->max_sectors;
/* /*
* queue_depth is based on subsystem plugin dependent requirements. * queue_depth is based on subsystem plugin dependent requirements.
*/ */
DEV_ATTRIB(dev)->hw_queue_depth = dev_limits->hw_queue_depth; dev->se_sub_dev->se_dev_attrib.hw_queue_depth = dev_limits->hw_queue_depth;
DEV_ATTRIB(dev)->queue_depth = dev_limits->queue_depth; dev->se_sub_dev->se_dev_attrib.queue_depth = dev_limits->queue_depth;
} }
int se_dev_set_task_timeout(struct se_device *dev, u32 task_timeout) int se_dev_set_task_timeout(struct se_device *dev, u32 task_timeout)
...@@ -909,9 +900,9 @@ int se_dev_set_task_timeout(struct se_device *dev, u32 task_timeout) ...@@ -909,9 +900,9 @@ int se_dev_set_task_timeout(struct se_device *dev, u32 task_timeout)
if (task_timeout > DA_TASK_TIMEOUT_MAX) { if (task_timeout > DA_TASK_TIMEOUT_MAX) {
printk(KERN_ERR "dev[%p]: Passed task_timeout: %u larger then" printk(KERN_ERR "dev[%p]: Passed task_timeout: %u larger then"
" DA_TASK_TIMEOUT_MAX\n", dev, task_timeout); " DA_TASK_TIMEOUT_MAX\n", dev, task_timeout);
return -1; return -EINVAL;
} else { } else {
DEV_ATTRIB(dev)->task_timeout = task_timeout; dev->se_sub_dev->se_dev_attrib.task_timeout = task_timeout;
printk(KERN_INFO "dev[%p]: Set SE Device task_timeout: %u\n", printk(KERN_INFO "dev[%p]: Set SE Device task_timeout: %u\n",
dev, task_timeout); dev, task_timeout);
} }
...@@ -923,9 +914,9 @@ int se_dev_set_max_unmap_lba_count( ...@@ -923,9 +914,9 @@ int se_dev_set_max_unmap_lba_count(
struct se_device *dev, struct se_device *dev,
u32 max_unmap_lba_count) u32 max_unmap_lba_count)
{ {
DEV_ATTRIB(dev)->max_unmap_lba_count = max_unmap_lba_count; dev->se_sub_dev->se_dev_attrib.max_unmap_lba_count = max_unmap_lba_count;
printk(KERN_INFO "dev[%p]: Set max_unmap_lba_count: %u\n", printk(KERN_INFO "dev[%p]: Set max_unmap_lba_count: %u\n",
dev, DEV_ATTRIB(dev)->max_unmap_lba_count); dev, dev->se_sub_dev->se_dev_attrib.max_unmap_lba_count);
return 0; return 0;
} }
...@@ -933,9 +924,10 @@ int se_dev_set_max_unmap_block_desc_count( ...@@ -933,9 +924,10 @@ int se_dev_set_max_unmap_block_desc_count(
struct se_device *dev, struct se_device *dev,
u32 max_unmap_block_desc_count) u32 max_unmap_block_desc_count)
{ {
DEV_ATTRIB(dev)->max_unmap_block_desc_count = max_unmap_block_desc_count; dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count =
max_unmap_block_desc_count;
printk(KERN_INFO "dev[%p]: Set max_unmap_block_desc_count: %u\n", printk(KERN_INFO "dev[%p]: Set max_unmap_block_desc_count: %u\n",
dev, DEV_ATTRIB(dev)->max_unmap_block_desc_count); dev, dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count);
return 0; return 0;
} }
...@@ -943,9 +935,9 @@ int se_dev_set_unmap_granularity( ...@@ -943,9 +935,9 @@ int se_dev_set_unmap_granularity(
struct se_device *dev, struct se_device *dev,
u32 unmap_granularity) u32 unmap_granularity)
{ {
DEV_ATTRIB(dev)->unmap_granularity = unmap_granularity; dev->se_sub_dev->se_dev_attrib.unmap_granularity = unmap_granularity;
printk(KERN_INFO "dev[%p]: Set unmap_granularity: %u\n", printk(KERN_INFO "dev[%p]: Set unmap_granularity: %u\n",
dev, DEV_ATTRIB(dev)->unmap_granularity); dev, dev->se_sub_dev->se_dev_attrib.unmap_granularity);
return 0; return 0;
} }
...@@ -953,9 +945,9 @@ int se_dev_set_unmap_granularity_alignment( ...@@ -953,9 +945,9 @@ int se_dev_set_unmap_granularity_alignment(
struct se_device *dev, struct se_device *dev,
u32 unmap_granularity_alignment) u32 unmap_granularity_alignment)
{ {
DEV_ATTRIB(dev)->unmap_granularity_alignment = unmap_granularity_alignment; dev->se_sub_dev->se_dev_attrib.unmap_granularity_alignment = unmap_granularity_alignment;
printk(KERN_INFO "dev[%p]: Set unmap_granularity_alignment: %u\n", printk(KERN_INFO "dev[%p]: Set unmap_granularity_alignment: %u\n",
dev, DEV_ATTRIB(dev)->unmap_granularity_alignment); dev, dev->se_sub_dev->se_dev_attrib.unmap_granularity_alignment);
return 0; return 0;
} }
...@@ -963,19 +955,19 @@ int se_dev_set_emulate_dpo(struct se_device *dev, int flag) ...@@ -963,19 +955,19 @@ int se_dev_set_emulate_dpo(struct se_device *dev, int flag)
{ {
if ((flag != 0) && (flag != 1)) { if ((flag != 0) && (flag != 1)) {
printk(KERN_ERR "Illegal value %d\n", flag); printk(KERN_ERR "Illegal value %d\n", flag);
return -1; return -EINVAL;
} }
if (TRANSPORT(dev)->dpo_emulated == NULL) { if (dev->transport->dpo_emulated == NULL) {
printk(KERN_ERR "TRANSPORT(dev)->dpo_emulated is NULL\n"); printk(KERN_ERR "dev->transport->dpo_emulated is NULL\n");
return -1; return -EINVAL;
} }
if (TRANSPORT(dev)->dpo_emulated(dev) == 0) { if (dev->transport->dpo_emulated(dev) == 0) {
printk(KERN_ERR "TRANSPORT(dev)->dpo_emulated not supported\n"); printk(KERN_ERR "dev->transport->dpo_emulated not supported\n");
return -1; return -EINVAL;
} }
DEV_ATTRIB(dev)->emulate_dpo = flag; dev->se_sub_dev->se_dev_attrib.emulate_dpo = flag;
printk(KERN_INFO "dev[%p]: SE Device Page Out (DPO) Emulation" printk(KERN_INFO "dev[%p]: SE Device Page Out (DPO) Emulation"
" bit: %d\n", dev, DEV_ATTRIB(dev)->emulate_dpo); " bit: %d\n", dev, dev->se_sub_dev->se_dev_attrib.emulate_dpo);
return 0; return 0;
} }
...@@ -983,19 +975,19 @@ int se_dev_set_emulate_fua_write(struct se_device *dev, int flag) ...@@ -983,19 +975,19 @@ int se_dev_set_emulate_fua_write(struct se_device *dev, int flag)
{ {
if ((flag != 0) && (flag != 1)) { if ((flag != 0) && (flag != 1)) {
printk(KERN_ERR "Illegal value %d\n", flag); printk(KERN_ERR "Illegal value %d\n", flag);
return -1; return -EINVAL;
} }
if (TRANSPORT(dev)->fua_write_emulated == NULL) { if (dev->transport->fua_write_emulated == NULL) {
printk(KERN_ERR "TRANSPORT(dev)->fua_write_emulated is NULL\n"); printk(KERN_ERR "dev->transport->fua_write_emulated is NULL\n");
return -1; return -EINVAL;
} }
if (TRANSPORT(dev)->fua_write_emulated(dev) == 0) { if (dev->transport->fua_write_emulated(dev) == 0) {
printk(KERN_ERR "TRANSPORT(dev)->fua_write_emulated not supported\n"); printk(KERN_ERR "dev->transport->fua_write_emulated not supported\n");
return -1; return -EINVAL;
} }
DEV_ATTRIB(dev)->emulate_fua_write = flag; dev->se_sub_dev->se_dev_attrib.emulate_fua_write = flag;
printk(KERN_INFO "dev[%p]: SE Device Forced Unit Access WRITEs: %d\n", printk(KERN_INFO "dev[%p]: SE Device Forced Unit Access WRITEs: %d\n",
dev, DEV_ATTRIB(dev)->emulate_fua_write); dev, dev->se_sub_dev->se_dev_attrib.emulate_fua_write);
return 0; return 0;
} }
...@@ -1003,19 +995,19 @@ int se_dev_set_emulate_fua_read(struct se_device *dev, int flag) ...@@ -1003,19 +995,19 @@ int se_dev_set_emulate_fua_read(struct se_device *dev, int flag)
{ {
if ((flag != 0) && (flag != 1)) { if ((flag != 0) && (flag != 1)) {
printk(KERN_ERR "Illegal value %d\n", flag); printk(KERN_ERR "Illegal value %d\n", flag);
return -1; return -EINVAL;
} }
if (TRANSPORT(dev)->fua_read_emulated == NULL) { if (dev->transport->fua_read_emulated == NULL) {
printk(KERN_ERR "TRANSPORT(dev)->fua_read_emulated is NULL\n"); printk(KERN_ERR "dev->transport->fua_read_emulated is NULL\n");
return -1; return -EINVAL;
} }
if (TRANSPORT(dev)->fua_read_emulated(dev) == 0) { if (dev->transport->fua_read_emulated(dev) == 0) {
printk(KERN_ERR "TRANSPORT(dev)->fua_read_emulated not supported\n"); printk(KERN_ERR "dev->transport->fua_read_emulated not supported\n");
return -1; return -EINVAL;
} }
DEV_ATTRIB(dev)->emulate_fua_read = flag; dev->se_sub_dev->se_dev_attrib.emulate_fua_read = flag;
printk(KERN_INFO "dev[%p]: SE Device Forced Unit Access READs: %d\n", printk(KERN_INFO "dev[%p]: SE Device Forced Unit Access READs: %d\n",
dev, DEV_ATTRIB(dev)->emulate_fua_read); dev, dev->se_sub_dev->se_dev_attrib.emulate_fua_read);
return 0; return 0;
} }
...@@ -1023,19 +1015,19 @@ int se_dev_set_emulate_write_cache(struct se_device *dev, int flag) ...@@ -1023,19 +1015,19 @@ int se_dev_set_emulate_write_cache(struct se_device *dev, int flag)
{ {
if ((flag != 0) && (flag != 1)) { if ((flag != 0) && (flag != 1)) {
printk(KERN_ERR "Illegal value %d\n", flag); printk(KERN_ERR "Illegal value %d\n", flag);
return -1; return -EINVAL;
} }
if (TRANSPORT(dev)->write_cache_emulated == NULL) { if (dev->transport->write_cache_emulated == NULL) {
printk(KERN_ERR "TRANSPORT(dev)->write_cache_emulated is NULL\n"); printk(KERN_ERR "dev->transport->write_cache_emulated is NULL\n");
return -1; return -EINVAL;
} }
if (TRANSPORT(dev)->write_cache_emulated(dev) == 0) { if (dev->transport->write_cache_emulated(dev) == 0) {
printk(KERN_ERR "TRANSPORT(dev)->write_cache_emulated not supported\n"); printk(KERN_ERR "dev->transport->write_cache_emulated not supported\n");
return -1; return -EINVAL;
} }
DEV_ATTRIB(dev)->emulate_write_cache = flag; dev->se_sub_dev->se_dev_attrib.emulate_write_cache = flag;
printk(KERN_INFO "dev[%p]: SE Device WRITE_CACHE_EMULATION flag: %d\n", printk(KERN_INFO "dev[%p]: SE Device WRITE_CACHE_EMULATION flag: %d\n",
dev, DEV_ATTRIB(dev)->emulate_write_cache); dev, dev->se_sub_dev->se_dev_attrib.emulate_write_cache);
return 0; return 0;
} }
...@@ -1043,7 +1035,7 @@ int se_dev_set_emulate_ua_intlck_ctrl(struct se_device *dev, int flag) ...@@ -1043,7 +1035,7 @@ int se_dev_set_emulate_ua_intlck_ctrl(struct se_device *dev, int flag)
{ {
if ((flag != 0) && (flag != 1) && (flag != 2)) { if ((flag != 0) && (flag != 1) && (flag != 2)) {
printk(KERN_ERR "Illegal value %d\n", flag); printk(KERN_ERR "Illegal value %d\n", flag);
return -1; return -EINVAL;
} }
if (atomic_read(&dev->dev_export_obj.obj_access_count)) { if (atomic_read(&dev->dev_export_obj.obj_access_count)) {
...@@ -1051,11 +1043,11 @@ int se_dev_set_emulate_ua_intlck_ctrl(struct se_device *dev, int flag) ...@@ -1051,11 +1043,11 @@ int se_dev_set_emulate_ua_intlck_ctrl(struct se_device *dev, int flag)
" UA_INTRLCK_CTRL while dev_export_obj: %d count" " UA_INTRLCK_CTRL while dev_export_obj: %d count"
" exists\n", dev, " exists\n", dev,
atomic_read(&dev->dev_export_obj.obj_access_count)); atomic_read(&dev->dev_export_obj.obj_access_count));
return -1; return -EINVAL;
} }
DEV_ATTRIB(dev)->emulate_ua_intlck_ctrl = flag; dev->se_sub_dev->se_dev_attrib.emulate_ua_intlck_ctrl = flag;
printk(KERN_INFO "dev[%p]: SE Device UA_INTRLCK_CTRL flag: %d\n", printk(KERN_INFO "dev[%p]: SE Device UA_INTRLCK_CTRL flag: %d\n",
dev, DEV_ATTRIB(dev)->emulate_ua_intlck_ctrl); dev, dev->se_sub_dev->se_dev_attrib.emulate_ua_intlck_ctrl);
return 0; return 0;
} }
...@@ -1064,18 +1056,18 @@ int se_dev_set_emulate_tas(struct se_device *dev, int flag) ...@@ -1064,18 +1056,18 @@ int se_dev_set_emulate_tas(struct se_device *dev, int flag)
{ {
if ((flag != 0) && (flag != 1)) { if ((flag != 0) && (flag != 1)) {
printk(KERN_ERR "Illegal value %d\n", flag); printk(KERN_ERR "Illegal value %d\n", flag);
return -1; return -EINVAL;
} }
if (atomic_read(&dev->dev_export_obj.obj_access_count)) { if (atomic_read(&dev->dev_export_obj.obj_access_count)) {
printk(KERN_ERR "dev[%p]: Unable to change SE Device TAS while" printk(KERN_ERR "dev[%p]: Unable to change SE Device TAS while"
" dev_export_obj: %d count exists\n", dev, " dev_export_obj: %d count exists\n", dev,
atomic_read(&dev->dev_export_obj.obj_access_count)); atomic_read(&dev->dev_export_obj.obj_access_count));
return -1; return -EINVAL;
} }
DEV_ATTRIB(dev)->emulate_tas = flag; dev->se_sub_dev->se_dev_attrib.emulate_tas = flag;
printk(KERN_INFO "dev[%p]: SE Device TASK_ABORTED status bit: %s\n", printk(KERN_INFO "dev[%p]: SE Device TASK_ABORTED status bit: %s\n",
dev, (DEV_ATTRIB(dev)->emulate_tas) ? "Enabled" : "Disabled"); dev, (dev->se_sub_dev->se_dev_attrib.emulate_tas) ? "Enabled" : "Disabled");
return 0; return 0;
} }
...@@ -1084,18 +1076,18 @@ int se_dev_set_emulate_tpu(struct se_device *dev, int flag) ...@@ -1084,18 +1076,18 @@ int se_dev_set_emulate_tpu(struct se_device *dev, int flag)
{ {
if ((flag != 0) && (flag != 1)) { if ((flag != 0) && (flag != 1)) {
printk(KERN_ERR "Illegal value %d\n", flag); printk(KERN_ERR "Illegal value %d\n", flag);
return -1; return -EINVAL;
} }
/* /*
* We expect this value to be non-zero when generic Block Layer * We expect this value to be non-zero when generic Block Layer
* Discard supported is detected iblock_create_virtdevice(). * Discard supported is detected iblock_create_virtdevice().
*/ */
if (!(DEV_ATTRIB(dev)->max_unmap_block_desc_count)) { if (!(dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count)) {
printk(KERN_ERR "Generic Block Discard not supported\n"); printk(KERN_ERR "Generic Block Discard not supported\n");
return -ENOSYS; return -ENOSYS;
} }
DEV_ATTRIB(dev)->emulate_tpu = flag; dev->se_sub_dev->se_dev_attrib.emulate_tpu = flag;
printk(KERN_INFO "dev[%p]: SE Device Thin Provisioning UNMAP bit: %d\n", printk(KERN_INFO "dev[%p]: SE Device Thin Provisioning UNMAP bit: %d\n",
dev, flag); dev, flag);
return 0; return 0;
...@@ -1105,18 +1097,18 @@ int se_dev_set_emulate_tpws(struct se_device *dev, int flag) ...@@ -1105,18 +1097,18 @@ int se_dev_set_emulate_tpws(struct se_device *dev, int flag)
{ {
if ((flag != 0) && (flag != 1)) { if ((flag != 0) && (flag != 1)) {
printk(KERN_ERR "Illegal value %d\n", flag); printk(KERN_ERR "Illegal value %d\n", flag);
return -1; return -EINVAL;
} }
/* /*
* We expect this value to be non-zero when generic Block Layer * We expect this value to be non-zero when generic Block Layer
* Discard supported is detected iblock_create_virtdevice(). * Discard supported is detected iblock_create_virtdevice().
*/ */
if (!(DEV_ATTRIB(dev)->max_unmap_block_desc_count)) { if (!(dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count)) {
printk(KERN_ERR "Generic Block Discard not supported\n"); printk(KERN_ERR "Generic Block Discard not supported\n");
return -ENOSYS; return -ENOSYS;
} }
DEV_ATTRIB(dev)->emulate_tpws = flag; dev->se_sub_dev->se_dev_attrib.emulate_tpws = flag;
printk(KERN_INFO "dev[%p]: SE Device Thin Provisioning WRITE_SAME: %d\n", printk(KERN_INFO "dev[%p]: SE Device Thin Provisioning WRITE_SAME: %d\n",
dev, flag); dev, flag);
return 0; return 0;
...@@ -1126,11 +1118,11 @@ int se_dev_set_enforce_pr_isids(struct se_device *dev, int flag) ...@@ -1126,11 +1118,11 @@ int se_dev_set_enforce_pr_isids(struct se_device *dev, int flag)
{ {
if ((flag != 0) && (flag != 1)) { if ((flag != 0) && (flag != 1)) {
printk(KERN_ERR "Illegal value %d\n", flag); printk(KERN_ERR "Illegal value %d\n", flag);
return -1; return -EINVAL;
} }
DEV_ATTRIB(dev)->enforce_pr_isids = flag; dev->se_sub_dev->se_dev_attrib.enforce_pr_isids = flag;
printk(KERN_INFO "dev[%p]: SE Device enforce_pr_isids bit: %s\n", dev, printk(KERN_INFO "dev[%p]: SE Device enforce_pr_isids bit: %s\n", dev,
(DEV_ATTRIB(dev)->enforce_pr_isids) ? "Enabled" : "Disabled"); (dev->se_sub_dev->se_dev_attrib.enforce_pr_isids) ? "Enabled" : "Disabled");
return 0; return 0;
} }
...@@ -1145,35 +1137,35 @@ int se_dev_set_queue_depth(struct se_device *dev, u32 queue_depth) ...@@ -1145,35 +1137,35 @@ int se_dev_set_queue_depth(struct se_device *dev, u32 queue_depth)
printk(KERN_ERR "dev[%p]: Unable to change SE Device TCQ while" printk(KERN_ERR "dev[%p]: Unable to change SE Device TCQ while"
" dev_export_obj: %d count exists\n", dev, " dev_export_obj: %d count exists\n", dev,
atomic_read(&dev->dev_export_obj.obj_access_count)); atomic_read(&dev->dev_export_obj.obj_access_count));
return -1; return -EINVAL;
} }
if (!(queue_depth)) { if (!(queue_depth)) {
printk(KERN_ERR "dev[%p]: Illegal ZERO value for queue" printk(KERN_ERR "dev[%p]: Illegal ZERO value for queue"
"_depth\n", dev); "_depth\n", dev);
return -1; return -EINVAL;
} }
if (TRANSPORT(dev)->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) { if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) {
if (queue_depth > DEV_ATTRIB(dev)->hw_queue_depth) { if (queue_depth > dev->se_sub_dev->se_dev_attrib.hw_queue_depth) {
printk(KERN_ERR "dev[%p]: Passed queue_depth: %u" printk(KERN_ERR "dev[%p]: Passed queue_depth: %u"
" exceeds TCM/SE_Device TCQ: %u\n", " exceeds TCM/SE_Device TCQ: %u\n",
dev, queue_depth, dev, queue_depth,
DEV_ATTRIB(dev)->hw_queue_depth); dev->se_sub_dev->se_dev_attrib.hw_queue_depth);
return -1; return -EINVAL;
} }
} else { } else {
if (queue_depth > DEV_ATTRIB(dev)->queue_depth) { if (queue_depth > dev->se_sub_dev->se_dev_attrib.queue_depth) {
if (queue_depth > DEV_ATTRIB(dev)->hw_queue_depth) { if (queue_depth > dev->se_sub_dev->se_dev_attrib.hw_queue_depth) {
printk(KERN_ERR "dev[%p]: Passed queue_depth:" printk(KERN_ERR "dev[%p]: Passed queue_depth:"
" %u exceeds TCM/SE_Device MAX" " %u exceeds TCM/SE_Device MAX"
" TCQ: %u\n", dev, queue_depth, " TCQ: %u\n", dev, queue_depth,
DEV_ATTRIB(dev)->hw_queue_depth); dev->se_sub_dev->se_dev_attrib.hw_queue_depth);
return -1; return -EINVAL;
} }
} }
} }
DEV_ATTRIB(dev)->queue_depth = dev->queue_depth = queue_depth; dev->se_sub_dev->se_dev_attrib.queue_depth = dev->queue_depth = queue_depth;
if (queue_depth > orig_queue_depth) if (queue_depth > orig_queue_depth)
atomic_add(queue_depth - orig_queue_depth, &dev->depth_left); atomic_add(queue_depth - orig_queue_depth, &dev->depth_left);
else if (queue_depth < orig_queue_depth) else if (queue_depth < orig_queue_depth)
...@@ -1192,46 +1184,46 @@ int se_dev_set_max_sectors(struct se_device *dev, u32 max_sectors) ...@@ -1192,46 +1184,46 @@ int se_dev_set_max_sectors(struct se_device *dev, u32 max_sectors)
printk(KERN_ERR "dev[%p]: Unable to change SE Device" printk(KERN_ERR "dev[%p]: Unable to change SE Device"
" max_sectors while dev_export_obj: %d count exists\n", " max_sectors while dev_export_obj: %d count exists\n",
dev, atomic_read(&dev->dev_export_obj.obj_access_count)); dev, atomic_read(&dev->dev_export_obj.obj_access_count));
return -1; return -EINVAL;
} }
if (!(max_sectors)) { if (!(max_sectors)) {
printk(KERN_ERR "dev[%p]: Illegal ZERO value for" printk(KERN_ERR "dev[%p]: Illegal ZERO value for"
" max_sectors\n", dev); " max_sectors\n", dev);
return -1; return -EINVAL;
} }
if (max_sectors < DA_STATUS_MAX_SECTORS_MIN) { if (max_sectors < DA_STATUS_MAX_SECTORS_MIN) {
printk(KERN_ERR "dev[%p]: Passed max_sectors: %u less than" printk(KERN_ERR "dev[%p]: Passed max_sectors: %u less than"
" DA_STATUS_MAX_SECTORS_MIN: %u\n", dev, max_sectors, " DA_STATUS_MAX_SECTORS_MIN: %u\n", dev, max_sectors,
DA_STATUS_MAX_SECTORS_MIN); DA_STATUS_MAX_SECTORS_MIN);
return -1; return -EINVAL;
} }
if (TRANSPORT(dev)->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) { if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) {
if (max_sectors > DEV_ATTRIB(dev)->hw_max_sectors) { if (max_sectors > dev->se_sub_dev->se_dev_attrib.hw_max_sectors) {
printk(KERN_ERR "dev[%p]: Passed max_sectors: %u" printk(KERN_ERR "dev[%p]: Passed max_sectors: %u"
" greater than TCM/SE_Device max_sectors:" " greater than TCM/SE_Device max_sectors:"
" %u\n", dev, max_sectors, " %u\n", dev, max_sectors,
DEV_ATTRIB(dev)->hw_max_sectors); dev->se_sub_dev->se_dev_attrib.hw_max_sectors);
return -1; return -EINVAL;
} }
} else { } else {
if (!(force) && (max_sectors > if (!(force) && (max_sectors >
DEV_ATTRIB(dev)->hw_max_sectors)) { dev->se_sub_dev->se_dev_attrib.hw_max_sectors)) {
printk(KERN_ERR "dev[%p]: Passed max_sectors: %u" printk(KERN_ERR "dev[%p]: Passed max_sectors: %u"
" greater than TCM/SE_Device max_sectors" " greater than TCM/SE_Device max_sectors"
": %u, use force=1 to override.\n", dev, ": %u, use force=1 to override.\n", dev,
max_sectors, DEV_ATTRIB(dev)->hw_max_sectors); max_sectors, dev->se_sub_dev->se_dev_attrib.hw_max_sectors);
return -1; return -EINVAL;
} }
if (max_sectors > DA_STATUS_MAX_SECTORS_MAX) { if (max_sectors > DA_STATUS_MAX_SECTORS_MAX) {
printk(KERN_ERR "dev[%p]: Passed max_sectors: %u" printk(KERN_ERR "dev[%p]: Passed max_sectors: %u"
" greater than DA_STATUS_MAX_SECTORS_MAX:" " greater than DA_STATUS_MAX_SECTORS_MAX:"
" %u\n", dev, max_sectors, " %u\n", dev, max_sectors,
DA_STATUS_MAX_SECTORS_MAX); DA_STATUS_MAX_SECTORS_MAX);
return -1; return -EINVAL;
} }
} }
DEV_ATTRIB(dev)->max_sectors = max_sectors; dev->se_sub_dev->se_dev_attrib.max_sectors = max_sectors;
printk("dev[%p]: SE Device max_sectors changed to %u\n", printk("dev[%p]: SE Device max_sectors changed to %u\n",
dev, max_sectors); dev, max_sectors);
return 0; return 0;
...@@ -1245,19 +1237,19 @@ int se_dev_set_optimal_sectors(struct se_device *dev, u32 optimal_sectors) ...@@ -1245,19 +1237,19 @@ int se_dev_set_optimal_sectors(struct se_device *dev, u32 optimal_sectors)
dev, atomic_read(&dev->dev_export_obj.obj_access_count)); dev, atomic_read(&dev->dev_export_obj.obj_access_count));
return -EINVAL; return -EINVAL;
} }
if (TRANSPORT(dev)->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) { if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) {
printk(KERN_ERR "dev[%p]: Passed optimal_sectors cannot be" printk(KERN_ERR "dev[%p]: Passed optimal_sectors cannot be"
" changed for TCM/pSCSI\n", dev); " changed for TCM/pSCSI\n", dev);
return -EINVAL; return -EINVAL;
} }
if (optimal_sectors > DEV_ATTRIB(dev)->max_sectors) { if (optimal_sectors > dev->se_sub_dev->se_dev_attrib.max_sectors) {
printk(KERN_ERR "dev[%p]: Passed optimal_sectors %u cannot be" printk(KERN_ERR "dev[%p]: Passed optimal_sectors %u cannot be"
" greater than max_sectors: %u\n", dev, " greater than max_sectors: %u\n", dev,
optimal_sectors, DEV_ATTRIB(dev)->max_sectors); optimal_sectors, dev->se_sub_dev->se_dev_attrib.max_sectors);
return -EINVAL; return -EINVAL;
} }
DEV_ATTRIB(dev)->optimal_sectors = optimal_sectors; dev->se_sub_dev->se_dev_attrib.optimal_sectors = optimal_sectors;
printk(KERN_INFO "dev[%p]: SE Device optimal_sectors changed to %u\n", printk(KERN_INFO "dev[%p]: SE Device optimal_sectors changed to %u\n",
dev, optimal_sectors); dev, optimal_sectors);
return 0; return 0;
...@@ -1269,7 +1261,7 @@ int se_dev_set_block_size(struct se_device *dev, u32 block_size) ...@@ -1269,7 +1261,7 @@ int se_dev_set_block_size(struct se_device *dev, u32 block_size)
printk(KERN_ERR "dev[%p]: Unable to change SE Device block_size" printk(KERN_ERR "dev[%p]: Unable to change SE Device block_size"
" while dev_export_obj: %d count exists\n", dev, " while dev_export_obj: %d count exists\n", dev,
atomic_read(&dev->dev_export_obj.obj_access_count)); atomic_read(&dev->dev_export_obj.obj_access_count));
return -1; return -EINVAL;
} }
if ((block_size != 512) && if ((block_size != 512) &&
...@@ -1279,17 +1271,17 @@ int se_dev_set_block_size(struct se_device *dev, u32 block_size) ...@@ -1279,17 +1271,17 @@ int se_dev_set_block_size(struct se_device *dev, u32 block_size)
printk(KERN_ERR "dev[%p]: Illegal value for block_device: %u" printk(KERN_ERR "dev[%p]: Illegal value for block_device: %u"
" for SE device, must be 512, 1024, 2048 or 4096\n", " for SE device, must be 512, 1024, 2048 or 4096\n",
dev, block_size); dev, block_size);
return -1; return -EINVAL;
} }
if (TRANSPORT(dev)->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) { if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) {
printk(KERN_ERR "dev[%p]: Not allowed to change block_size for" printk(KERN_ERR "dev[%p]: Not allowed to change block_size for"
" Physical Device, use for Linux/SCSI to change" " Physical Device, use for Linux/SCSI to change"
" block_size for underlying hardware\n", dev); " block_size for underlying hardware\n", dev);
return -1; return -EINVAL;
} }
DEV_ATTRIB(dev)->block_size = block_size; dev->se_sub_dev->se_dev_attrib.block_size = block_size;
printk(KERN_INFO "dev[%p]: SE Device block_size changed to %u\n", printk(KERN_INFO "dev[%p]: SE Device block_size changed to %u\n",
dev, block_size); dev, block_size);
return 0; return 0;
...@@ -1323,14 +1315,14 @@ struct se_lun *core_dev_add_lun( ...@@ -1323,14 +1315,14 @@ struct se_lun *core_dev_add_lun(
return NULL; return NULL;
printk(KERN_INFO "%s_TPG[%u]_LUN[%u] - Activated %s Logical Unit from" printk(KERN_INFO "%s_TPG[%u]_LUN[%u] - Activated %s Logical Unit from"
" CORE HBA: %u\n", TPG_TFO(tpg)->get_fabric_name(), " CORE HBA: %u\n", tpg->se_tpg_tfo->get_fabric_name(),
TPG_TFO(tpg)->tpg_get_tag(tpg), lun_p->unpacked_lun, tpg->se_tpg_tfo->tpg_get_tag(tpg), lun_p->unpacked_lun,
TPG_TFO(tpg)->get_fabric_name(), hba->hba_id); tpg->se_tpg_tfo->get_fabric_name(), hba->hba_id);
/* /*
* Update LUN maps for dynamically added initiators when * Update LUN maps for dynamically added initiators when
* generate_node_acl is enabled. * generate_node_acl is enabled.
*/ */
if (TPG_TFO(tpg)->tpg_check_demo_mode(tpg)) { if (tpg->se_tpg_tfo->tpg_check_demo_mode(tpg)) {
struct se_node_acl *acl; struct se_node_acl *acl;
spin_lock_bh(&tpg->acl_node_lock); spin_lock_bh(&tpg->acl_node_lock);
list_for_each_entry(acl, &tpg->acl_node_list, acl_list) { list_for_each_entry(acl, &tpg->acl_node_list, acl_list) {
...@@ -1364,9 +1356,9 @@ int core_dev_del_lun( ...@@ -1364,9 +1356,9 @@ int core_dev_del_lun(
core_tpg_post_dellun(tpg, lun); core_tpg_post_dellun(tpg, lun);
printk(KERN_INFO "%s_TPG[%u]_LUN[%u] - Deactivated %s Logical Unit from" printk(KERN_INFO "%s_TPG[%u]_LUN[%u] - Deactivated %s Logical Unit from"
" device object\n", TPG_TFO(tpg)->get_fabric_name(), " device object\n", tpg->se_tpg_tfo->get_fabric_name(),
TPG_TFO(tpg)->tpg_get_tag(tpg), unpacked_lun, tpg->se_tpg_tfo->tpg_get_tag(tpg), unpacked_lun,
TPG_TFO(tpg)->get_fabric_name()); tpg->se_tpg_tfo->get_fabric_name());
return 0; return 0;
} }
...@@ -1379,9 +1371,9 @@ struct se_lun *core_get_lun_from_tpg(struct se_portal_group *tpg, u32 unpacked_l ...@@ -1379,9 +1371,9 @@ struct se_lun *core_get_lun_from_tpg(struct se_portal_group *tpg, u32 unpacked_l
if (unpacked_lun > (TRANSPORT_MAX_LUNS_PER_TPG-1)) { if (unpacked_lun > (TRANSPORT_MAX_LUNS_PER_TPG-1)) {
printk(KERN_ERR "%s LUN: %u exceeds TRANSPORT_MAX_LUNS" printk(KERN_ERR "%s LUN: %u exceeds TRANSPORT_MAX_LUNS"
"_PER_TPG-1: %u for Target Portal Group: %hu\n", "_PER_TPG-1: %u for Target Portal Group: %hu\n",
TPG_TFO(tpg)->get_fabric_name(), unpacked_lun, tpg->se_tpg_tfo->get_fabric_name(), unpacked_lun,
TRANSPORT_MAX_LUNS_PER_TPG-1, TRANSPORT_MAX_LUNS_PER_TPG-1,
TPG_TFO(tpg)->tpg_get_tag(tpg)); tpg->se_tpg_tfo->tpg_get_tag(tpg));
spin_unlock(&tpg->tpg_lun_lock); spin_unlock(&tpg->tpg_lun_lock);
return NULL; return NULL;
} }
...@@ -1390,8 +1382,8 @@ struct se_lun *core_get_lun_from_tpg(struct se_portal_group *tpg, u32 unpacked_l ...@@ -1390,8 +1382,8 @@ struct se_lun *core_get_lun_from_tpg(struct se_portal_group *tpg, u32 unpacked_l
if (lun->lun_status != TRANSPORT_LUN_STATUS_FREE) { if (lun->lun_status != TRANSPORT_LUN_STATUS_FREE) {
printk(KERN_ERR "%s Logical Unit Number: %u is not free on" printk(KERN_ERR "%s Logical Unit Number: %u is not free on"
" Target Portal Group: %hu, ignoring request.\n", " Target Portal Group: %hu, ignoring request.\n",
TPG_TFO(tpg)->get_fabric_name(), unpacked_lun, tpg->se_tpg_tfo->get_fabric_name(), unpacked_lun,
TPG_TFO(tpg)->tpg_get_tag(tpg)); tpg->se_tpg_tfo->tpg_get_tag(tpg));
spin_unlock(&tpg->tpg_lun_lock); spin_unlock(&tpg->tpg_lun_lock);
return NULL; return NULL;
} }
...@@ -1412,9 +1404,9 @@ static struct se_lun *core_dev_get_lun(struct se_portal_group *tpg, u32 unpacked ...@@ -1412,9 +1404,9 @@ static struct se_lun *core_dev_get_lun(struct se_portal_group *tpg, u32 unpacked
if (unpacked_lun > (TRANSPORT_MAX_LUNS_PER_TPG-1)) { if (unpacked_lun > (TRANSPORT_MAX_LUNS_PER_TPG-1)) {
printk(KERN_ERR "%s LUN: %u exceeds TRANSPORT_MAX_LUNS_PER" printk(KERN_ERR "%s LUN: %u exceeds TRANSPORT_MAX_LUNS_PER"
"_TPG-1: %u for Target Portal Group: %hu\n", "_TPG-1: %u for Target Portal Group: %hu\n",
TPG_TFO(tpg)->get_fabric_name(), unpacked_lun, tpg->se_tpg_tfo->get_fabric_name(), unpacked_lun,
TRANSPORT_MAX_LUNS_PER_TPG-1, TRANSPORT_MAX_LUNS_PER_TPG-1,
TPG_TFO(tpg)->tpg_get_tag(tpg)); tpg->se_tpg_tfo->tpg_get_tag(tpg));
spin_unlock(&tpg->tpg_lun_lock); spin_unlock(&tpg->tpg_lun_lock);
return NULL; return NULL;
} }
...@@ -1423,8 +1415,8 @@ static struct se_lun *core_dev_get_lun(struct se_portal_group *tpg, u32 unpacked ...@@ -1423,8 +1415,8 @@ static struct se_lun *core_dev_get_lun(struct se_portal_group *tpg, u32 unpacked
if (lun->lun_status != TRANSPORT_LUN_STATUS_ACTIVE) { if (lun->lun_status != TRANSPORT_LUN_STATUS_ACTIVE) {
printk(KERN_ERR "%s Logical Unit Number: %u is not active on" printk(KERN_ERR "%s Logical Unit Number: %u is not active on"
" Target Portal Group: %hu, ignoring request.\n", " Target Portal Group: %hu, ignoring request.\n",
TPG_TFO(tpg)->get_fabric_name(), unpacked_lun, tpg->se_tpg_tfo->get_fabric_name(), unpacked_lun,
TPG_TFO(tpg)->tpg_get_tag(tpg)); tpg->se_tpg_tfo->tpg_get_tag(tpg));
spin_unlock(&tpg->tpg_lun_lock); spin_unlock(&tpg->tpg_lun_lock);
return NULL; return NULL;
} }
...@@ -1444,7 +1436,7 @@ struct se_lun_acl *core_dev_init_initiator_node_lun_acl( ...@@ -1444,7 +1436,7 @@ struct se_lun_acl *core_dev_init_initiator_node_lun_acl(
if (strlen(initiatorname) >= TRANSPORT_IQN_LEN) { if (strlen(initiatorname) >= TRANSPORT_IQN_LEN) {
printk(KERN_ERR "%s InitiatorName exceeds maximum size.\n", printk(KERN_ERR "%s InitiatorName exceeds maximum size.\n",
TPG_TFO(tpg)->get_fabric_name()); tpg->se_tpg_tfo->get_fabric_name());
*ret = -EOVERFLOW; *ret = -EOVERFLOW;
return NULL; return NULL;
} }
...@@ -1481,8 +1473,8 @@ int core_dev_add_initiator_node_lun_acl( ...@@ -1481,8 +1473,8 @@ int core_dev_add_initiator_node_lun_acl(
if (!(lun)) { if (!(lun)) {
printk(KERN_ERR "%s Logical Unit Number: %u is not active on" printk(KERN_ERR "%s Logical Unit Number: %u is not active on"
" Target Portal Group: %hu, ignoring request.\n", " Target Portal Group: %hu, ignoring request.\n",
TPG_TFO(tpg)->get_fabric_name(), unpacked_lun, tpg->se_tpg_tfo->get_fabric_name(), unpacked_lun,
TPG_TFO(tpg)->tpg_get_tag(tpg)); tpg->se_tpg_tfo->tpg_get_tag(tpg));
return -EINVAL; return -EINVAL;
} }
...@@ -1507,8 +1499,8 @@ int core_dev_add_initiator_node_lun_acl( ...@@ -1507,8 +1499,8 @@ int core_dev_add_initiator_node_lun_acl(
spin_unlock(&lun->lun_acl_lock); spin_unlock(&lun->lun_acl_lock);
printk(KERN_INFO "%s_TPG[%hu]_LUN[%u->%u] - Added %s ACL for " printk(KERN_INFO "%s_TPG[%hu]_LUN[%u->%u] - Added %s ACL for "
" InitiatorNode: %s\n", TPG_TFO(tpg)->get_fabric_name(), " InitiatorNode: %s\n", tpg->se_tpg_tfo->get_fabric_name(),
TPG_TFO(tpg)->tpg_get_tag(tpg), unpacked_lun, lacl->mapped_lun, tpg->se_tpg_tfo->tpg_get_tag(tpg), unpacked_lun, lacl->mapped_lun,
(lun_access & TRANSPORT_LUNFLAGS_READ_WRITE) ? "RW" : "RO", (lun_access & TRANSPORT_LUNFLAGS_READ_WRITE) ? "RW" : "RO",
lacl->initiatorname); lacl->initiatorname);
/* /*
...@@ -1547,8 +1539,8 @@ int core_dev_del_initiator_node_lun_acl( ...@@ -1547,8 +1539,8 @@ int core_dev_del_initiator_node_lun_acl(
printk(KERN_INFO "%s_TPG[%hu]_LUN[%u] - Removed ACL for" printk(KERN_INFO "%s_TPG[%hu]_LUN[%u] - Removed ACL for"
" InitiatorNode: %s Mapped LUN: %u\n", " InitiatorNode: %s Mapped LUN: %u\n",
TPG_TFO(tpg)->get_fabric_name(), tpg->se_tpg_tfo->get_fabric_name(),
TPG_TFO(tpg)->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);
return 0; return 0;
...@@ -1559,9 +1551,9 @@ void core_dev_free_initiator_node_lun_acl( ...@@ -1559,9 +1551,9 @@ void core_dev_free_initiator_node_lun_acl(
struct se_lun_acl *lacl) struct se_lun_acl *lacl)
{ {
printk("%s_TPG[%hu] - Freeing ACL for %s InitiatorNode: %s" printk("%s_TPG[%hu] - Freeing ACL for %s InitiatorNode: %s"
" Mapped LUN: %u\n", TPG_TFO(tpg)->get_fabric_name(), " Mapped LUN: %u\n", tpg->se_tpg_tfo->get_fabric_name(),
TPG_TFO(tpg)->tpg_get_tag(tpg), tpg->se_tpg_tfo->tpg_get_tag(tpg),
TPG_TFO(tpg)->get_fabric_name(), tpg->se_tpg_tfo->get_fabric_name(),
lacl->initiatorname, lacl->mapped_lun); lacl->initiatorname, lacl->mapped_lun);
kfree(lacl); kfree(lacl);
...@@ -1580,7 +1572,7 @@ int core_dev_setup_virtual_lun0(void) ...@@ -1580,7 +1572,7 @@ int core_dev_setup_virtual_lun0(void)
if (IS_ERR(hba)) if (IS_ERR(hba))
return PTR_ERR(hba); return PTR_ERR(hba);
se_global->g_lun0_hba = hba; lun0_hba = hba;
t = hba->transport; t = hba->transport;
se_dev = kzalloc(sizeof(struct se_subsystem_dev), GFP_KERNEL); se_dev = kzalloc(sizeof(struct se_subsystem_dev), GFP_KERNEL);
...@@ -1590,17 +1582,17 @@ int core_dev_setup_virtual_lun0(void) ...@@ -1590,17 +1582,17 @@ int core_dev_setup_virtual_lun0(void)
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
INIT_LIST_HEAD(&se_dev->g_se_dev_list); INIT_LIST_HEAD(&se_dev->se_dev_node);
INIT_LIST_HEAD(&se_dev->t10_wwn.t10_vpd_list); INIT_LIST_HEAD(&se_dev->t10_wwn.t10_vpd_list);
spin_lock_init(&se_dev->t10_wwn.t10_vpd_lock); spin_lock_init(&se_dev->t10_wwn.t10_vpd_lock);
INIT_LIST_HEAD(&se_dev->t10_reservation.registration_list); INIT_LIST_HEAD(&se_dev->t10_pr.registration_list);
INIT_LIST_HEAD(&se_dev->t10_reservation.aptpl_reg_list); INIT_LIST_HEAD(&se_dev->t10_pr.aptpl_reg_list);
spin_lock_init(&se_dev->t10_reservation.registration_lock); spin_lock_init(&se_dev->t10_pr.registration_lock);
spin_lock_init(&se_dev->t10_reservation.aptpl_reg_lock); spin_lock_init(&se_dev->t10_pr.aptpl_reg_lock);
INIT_LIST_HEAD(&se_dev->t10_alua.tg_pt_gps_list); INIT_LIST_HEAD(&se_dev->t10_alua.tg_pt_gps_list);
spin_lock_init(&se_dev->t10_alua.tg_pt_gps_lock); spin_lock_init(&se_dev->t10_alua.tg_pt_gps_lock);
spin_lock_init(&se_dev->se_dev_lock); spin_lock_init(&se_dev->se_dev_lock);
se_dev->t10_reservation.pr_aptpl_buf_len = PR_APTPL_BUF_LEN; se_dev->t10_pr.pr_aptpl_buf_len = PR_APTPL_BUF_LEN;
se_dev->t10_wwn.t10_sub_dev = se_dev; se_dev->t10_wwn.t10_sub_dev = se_dev;
se_dev->t10_alua.t10_sub_dev = se_dev; se_dev->t10_alua.t10_sub_dev = se_dev;
se_dev->se_dev_attrib.da_sub_dev = se_dev; se_dev->se_dev_attrib.da_sub_dev = se_dev;
...@@ -1613,27 +1605,27 @@ int core_dev_setup_virtual_lun0(void) ...@@ -1613,27 +1605,27 @@ int core_dev_setup_virtual_lun0(void)
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
se_global->g_lun0_su_dev = se_dev; lun0_su_dev = se_dev;
memset(buf, 0, 16); memset(buf, 0, 16);
sprintf(buf, "rd_pages=8"); sprintf(buf, "rd_pages=8");
t->set_configfs_dev_params(hba, se_dev, buf, sizeof(buf)); t->set_configfs_dev_params(hba, se_dev, buf, sizeof(buf));
dev = t->create_virtdevice(hba, se_dev, se_dev->se_dev_su_ptr); dev = t->create_virtdevice(hba, se_dev, se_dev->se_dev_su_ptr);
if (!(dev) || IS_ERR(dev)) { if (IS_ERR(dev)) {
ret = -ENOMEM; ret = PTR_ERR(dev);
goto out; goto out;
} }
se_dev->se_dev_ptr = dev; se_dev->se_dev_ptr = dev;
se_global->g_lun0_dev = dev; g_lun0_dev = dev;
return 0; return 0;
out: out:
se_global->g_lun0_su_dev = NULL; lun0_su_dev = NULL;
kfree(se_dev); kfree(se_dev);
if (se_global->g_lun0_hba) { if (lun0_hba) {
core_delete_hba(se_global->g_lun0_hba); core_delete_hba(lun0_hba);
se_global->g_lun0_hba = NULL; lun0_hba = NULL;
} }
return ret; return ret;
} }
...@@ -1641,14 +1633,14 @@ int core_dev_setup_virtual_lun0(void) ...@@ -1641,14 +1633,14 @@ int core_dev_setup_virtual_lun0(void)
void core_dev_release_virtual_lun0(void) void core_dev_release_virtual_lun0(void)
{ {
struct se_hba *hba = se_global->g_lun0_hba; struct se_hba *hba = lun0_hba;
struct se_subsystem_dev *su_dev = se_global->g_lun0_su_dev; struct se_subsystem_dev *su_dev = lun0_su_dev;
if (!(hba)) if (!(hba))
return; return;
if (se_global->g_lun0_dev) if (g_lun0_dev)
se_free_virtual_device(se_global->g_lun0_dev, hba); se_free_virtual_device(g_lun0_dev, hba);
kfree(su_dev); kfree(su_dev);
core_delete_hba(hba); core_delete_hba(hba);
......
...@@ -118,7 +118,7 @@ static int target_fabric_mappedlun_link( ...@@ -118,7 +118,7 @@ static int target_fabric_mappedlun_link(
lun_access = deve->lun_flags; lun_access = deve->lun_flags;
else else
lun_access = lun_access =
(TPG_TFO(se_tpg)->tpg_check_prod_mode_write_protect( (se_tpg->se_tpg_tfo->tpg_check_prod_mode_write_protect(
se_tpg)) ? TRANSPORT_LUNFLAGS_READ_ONLY : se_tpg)) ? TRANSPORT_LUNFLAGS_READ_ONLY :
TRANSPORT_LUNFLAGS_READ_WRITE; TRANSPORT_LUNFLAGS_READ_WRITE;
spin_unlock_irq(&lacl->se_lun_nacl->device_list_lock); spin_unlock_irq(&lacl->se_lun_nacl->device_list_lock);
...@@ -204,7 +204,7 @@ static ssize_t target_fabric_mappedlun_store_write_protect( ...@@ -204,7 +204,7 @@ static ssize_t target_fabric_mappedlun_store_write_protect(
printk(KERN_INFO "%s_ConfigFS: Changed Initiator ACL: %s" printk(KERN_INFO "%s_ConfigFS: Changed Initiator ACL: %s"
" Mapped LUN: %u Write Protect bit to %s\n", " Mapped LUN: %u Write Protect bit to %s\n",
TPG_TFO(se_tpg)->get_fabric_name(), se_tpg->se_tpg_tfo->get_fabric_name(),
lacl->initiatorname, lacl->mapped_lun, (op) ? "ON" : "OFF"); lacl->initiatorname, lacl->mapped_lun, (op) ? "ON" : "OFF");
return count; return count;
...@@ -379,7 +379,7 @@ static struct config_group *target_fabric_make_mappedlun( ...@@ -379,7 +379,7 @@ static struct config_group *target_fabric_make_mappedlun(
lacl_cg->default_groups[0] = &lacl->ml_stat_grps.stat_group; lacl_cg->default_groups[0] = &lacl->ml_stat_grps.stat_group;
lacl_cg->default_groups[1] = NULL; lacl_cg->default_groups[1] = NULL;
ml_stat_grp = &ML_STAT_GRPS(lacl)->stat_group; ml_stat_grp = &lacl->ml_stat_grps.stat_group;
ml_stat_grp->default_groups = kzalloc(sizeof(struct config_group) * 3, ml_stat_grp->default_groups = kzalloc(sizeof(struct config_group) * 3,
GFP_KERNEL); GFP_KERNEL);
if (!ml_stat_grp->default_groups) { if (!ml_stat_grp->default_groups) {
...@@ -408,7 +408,7 @@ static void target_fabric_drop_mappedlun( ...@@ -408,7 +408,7 @@ static void target_fabric_drop_mappedlun(
struct config_group *lacl_cg = NULL, *ml_stat_grp = NULL; struct config_group *lacl_cg = NULL, *ml_stat_grp = NULL;
int i; int i;
ml_stat_grp = &ML_STAT_GRPS(lacl)->stat_group; ml_stat_grp = &lacl->ml_stat_grps.stat_group;
for (i = 0; ml_stat_grp->default_groups[i]; i++) { for (i = 0; ml_stat_grp->default_groups[i]; i++) {
df_item = &ml_stat_grp->default_groups[i]->cg_item; df_item = &ml_stat_grp->default_groups[i]->cg_item;
ml_stat_grp->default_groups[i] = NULL; ml_stat_grp->default_groups[i] = NULL;
...@@ -914,7 +914,7 @@ static struct config_group *target_fabric_make_lun( ...@@ -914,7 +914,7 @@ static struct config_group *target_fabric_make_lun(
lun_cg->default_groups[0] = &lun->port_stat_grps.stat_group; lun_cg->default_groups[0] = &lun->port_stat_grps.stat_group;
lun_cg->default_groups[1] = NULL; lun_cg->default_groups[1] = NULL;
port_stat_grp = &PORT_STAT_GRP(lun)->stat_group; port_stat_grp = &lun->port_stat_grps.stat_group;
port_stat_grp->default_groups = kzalloc(sizeof(struct config_group) * 3, port_stat_grp->default_groups = kzalloc(sizeof(struct config_group) * 3,
GFP_KERNEL); GFP_KERNEL);
if (!port_stat_grp->default_groups) { if (!port_stat_grp->default_groups) {
...@@ -941,7 +941,7 @@ static void target_fabric_drop_lun( ...@@ -941,7 +941,7 @@ static void target_fabric_drop_lun(
struct config_group *lun_cg, *port_stat_grp; struct config_group *lun_cg, *port_stat_grp;
int i; int i;
port_stat_grp = &PORT_STAT_GRP(lun)->stat_group; port_stat_grp = &lun->port_stat_grps.stat_group;
for (i = 0; port_stat_grp->default_groups[i]; i++) { for (i = 0; port_stat_grp->default_groups[i]; i++) {
df_item = &port_stat_grp->default_groups[i]->cg_item; df_item = &port_stat_grp->default_groups[i]->cg_item;
port_stat_grp->default_groups[i] = NULL; port_stat_grp->default_groups[i] = NULL;
......
...@@ -67,22 +67,19 @@ static int fd_attach_hba(struct se_hba *hba, u32 host_id) ...@@ -67,22 +67,19 @@ static int fd_attach_hba(struct se_hba *hba, u32 host_id)
fd_host = kzalloc(sizeof(struct fd_host), GFP_KERNEL); fd_host = kzalloc(sizeof(struct fd_host), GFP_KERNEL);
if (!(fd_host)) { if (!(fd_host)) {
printk(KERN_ERR "Unable to allocate memory for struct fd_host\n"); printk(KERN_ERR "Unable to allocate memory for struct fd_host\n");
return -1; return -ENOMEM;
} }
fd_host->fd_host_id = host_id; fd_host->fd_host_id = host_id;
atomic_set(&hba->left_queue_depth, FD_HBA_QUEUE_DEPTH); hba->hba_ptr = fd_host;
atomic_set(&hba->max_queue_depth, FD_HBA_QUEUE_DEPTH);
hba->hba_ptr = (void *) fd_host;
printk(KERN_INFO "CORE_HBA[%d] - TCM FILEIO HBA Driver %s on Generic" printk(KERN_INFO "CORE_HBA[%d] - TCM FILEIO HBA Driver %s on Generic"
" Target Core Stack %s\n", hba->hba_id, FD_VERSION, " Target Core Stack %s\n", hba->hba_id, FD_VERSION,
TARGET_CORE_MOD_VERSION); TARGET_CORE_MOD_VERSION);
printk(KERN_INFO "CORE_HBA[%d] - Attached FILEIO HBA: %u to Generic" printk(KERN_INFO "CORE_HBA[%d] - Attached FILEIO HBA: %u to Generic"
" Target Core with TCQ Depth: %d MaxSectors: %u\n", " MaxSectors: %u\n",
hba->hba_id, fd_host->fd_host_id, hba->hba_id, fd_host->fd_host_id, FD_MAX_SECTORS);
atomic_read(&hba->max_queue_depth), FD_MAX_SECTORS);
return 0; return 0;
} }
...@@ -282,7 +279,7 @@ fd_alloc_task(struct se_cmd *cmd) ...@@ -282,7 +279,7 @@ fd_alloc_task(struct se_cmd *cmd)
return NULL; return NULL;
} }
fd_req->fd_dev = SE_DEV(cmd)->dev_ptr; fd_req->fd_dev = cmd->se_lun->lun_se_dev->dev_ptr;
return &fd_req->fd_task; return &fd_req->fd_task;
} }
...@@ -294,13 +291,14 @@ static int fd_do_readv(struct se_task *task) ...@@ -294,13 +291,14 @@ static int fd_do_readv(struct se_task *task)
struct scatterlist *sg = task->task_sg; struct scatterlist *sg = task->task_sg;
struct iovec *iov; struct iovec *iov;
mm_segment_t old_fs; mm_segment_t old_fs;
loff_t pos = (task->task_lba * DEV_ATTRIB(task->se_dev)->block_size); loff_t pos = (task->task_lba *
task->se_dev->se_sub_dev->se_dev_attrib.block_size);
int ret = 0, i; int ret = 0, i;
iov = kzalloc(sizeof(struct iovec) * task->task_sg_num, GFP_KERNEL); iov = kzalloc(sizeof(struct iovec) * task->task_sg_num, GFP_KERNEL);
if (!(iov)) { if (!(iov)) {
printk(KERN_ERR "Unable to allocate fd_do_readv iov[]\n"); printk(KERN_ERR "Unable to allocate fd_do_readv iov[]\n");
return -1; return -ENOMEM;
} }
for (i = 0; i < task->task_sg_num; i++) { for (i = 0; i < task->task_sg_num; i++) {
...@@ -324,13 +322,13 @@ static int fd_do_readv(struct se_task *task) ...@@ -324,13 +322,13 @@ static int fd_do_readv(struct se_task *task)
printk(KERN_ERR "vfs_readv() returned %d," printk(KERN_ERR "vfs_readv() returned %d,"
" expecting %d for S_ISBLK\n", ret, " expecting %d for S_ISBLK\n", ret,
(int)task->task_size); (int)task->task_size);
return -1; return (ret < 0 ? ret : -EINVAL);
} }
} else { } else {
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "vfs_readv() returned %d for non" printk(KERN_ERR "vfs_readv() returned %d for non"
" S_ISBLK\n", ret); " S_ISBLK\n", ret);
return -1; return ret;
} }
} }
...@@ -344,13 +342,14 @@ static int fd_do_writev(struct se_task *task) ...@@ -344,13 +342,14 @@ static int fd_do_writev(struct se_task *task)
struct scatterlist *sg = task->task_sg; struct scatterlist *sg = task->task_sg;
struct iovec *iov; struct iovec *iov;
mm_segment_t old_fs; mm_segment_t old_fs;
loff_t pos = (task->task_lba * DEV_ATTRIB(task->se_dev)->block_size); loff_t pos = (task->task_lba *
task->se_dev->se_sub_dev->se_dev_attrib.block_size);
int ret, i = 0; int ret, i = 0;
iov = kzalloc(sizeof(struct iovec) * task->task_sg_num, GFP_KERNEL); iov = kzalloc(sizeof(struct iovec) * task->task_sg_num, GFP_KERNEL);
if (!(iov)) { if (!(iov)) {
printk(KERN_ERR "Unable to allocate fd_do_writev iov[]\n"); printk(KERN_ERR "Unable to allocate fd_do_writev iov[]\n");
return -1; return -ENOMEM;
} }
for (i = 0; i < task->task_sg_num; i++) { for (i = 0; i < task->task_sg_num; i++) {
...@@ -367,7 +366,7 @@ static int fd_do_writev(struct se_task *task) ...@@ -367,7 +366,7 @@ static int fd_do_writev(struct se_task *task)
if (ret < 0 || ret != task->task_size) { if (ret < 0 || ret != task->task_size) {
printk(KERN_ERR "vfs_writev() returned %d\n", ret); printk(KERN_ERR "vfs_writev() returned %d\n", ret);
return -1; return (ret < 0 ? ret : -EINVAL);
} }
return 1; return 1;
...@@ -375,7 +374,7 @@ static int fd_do_writev(struct se_task *task) ...@@ -375,7 +374,7 @@ static int fd_do_writev(struct se_task *task)
static void fd_emulate_sync_cache(struct se_task *task) static void fd_emulate_sync_cache(struct se_task *task)
{ {
struct se_cmd *cmd = TASK_CMD(task); struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_dev; struct se_device *dev = cmd->se_dev;
struct fd_dev *fd_dev = dev->dev_ptr; struct fd_dev *fd_dev = dev->dev_ptr;
int immed = (cmd->t_task->t_task_cdb[1] & 0x2); int immed = (cmd->t_task->t_task_cdb[1] & 0x2);
...@@ -396,7 +395,7 @@ static void fd_emulate_sync_cache(struct se_task *task) ...@@ -396,7 +395,7 @@ static void fd_emulate_sync_cache(struct se_task *task)
start = 0; start = 0;
end = LLONG_MAX; end = LLONG_MAX;
} else { } else {
start = cmd->t_task->t_task_lba * DEV_ATTRIB(dev)->block_size; start = cmd->t_task->t_task_lba * dev->se_sub_dev->se_dev_attrib.block_size;
if (cmd->data_length) if (cmd->data_length)
end = start + cmd->data_length; end = start + cmd->data_length;
else else
...@@ -446,7 +445,7 @@ static void fd_emulate_write_fua(struct se_cmd *cmd, struct se_task *task) ...@@ -446,7 +445,7 @@ static void fd_emulate_write_fua(struct se_cmd *cmd, struct se_task *task)
{ {
struct se_device *dev = cmd->se_dev; struct se_device *dev = cmd->se_dev;
struct fd_dev *fd_dev = dev->dev_ptr; struct fd_dev *fd_dev = dev->dev_ptr;
loff_t start = task->task_lba * DEV_ATTRIB(dev)->block_size; loff_t start = task->task_lba * dev->se_sub_dev->se_dev_attrib.block_size;
loff_t end = start + task->task_size; loff_t end = start + task->task_size;
int ret; int ret;
...@@ -474,9 +473,9 @@ static int fd_do_task(struct se_task *task) ...@@ -474,9 +473,9 @@ static int fd_do_task(struct se_task *task)
ret = fd_do_writev(task); ret = fd_do_writev(task);
if (ret > 0 && if (ret > 0 &&
DEV_ATTRIB(dev)->emulate_write_cache > 0 && dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0 &&
DEV_ATTRIB(dev)->emulate_fua_write > 0 && dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0 &&
T_TASK(cmd)->t_tasks_fua) { cmd->t_task->t_tasks_fua) {
/* /*
* We might need to be a bit smarter here * We might need to be a bit smarter here
* and return some sense data to let the initiator * and return some sense data to let the initiator
...@@ -599,7 +598,7 @@ static ssize_t fd_check_configfs_dev_params(struct se_hba *hba, struct se_subsys ...@@ -599,7 +598,7 @@ static ssize_t fd_check_configfs_dev_params(struct se_hba *hba, struct se_subsys
if (!(fd_dev->fbd_flags & FBDF_HAS_PATH)) { if (!(fd_dev->fbd_flags & FBDF_HAS_PATH)) {
printk(KERN_ERR "Missing fd_dev_name=\n"); printk(KERN_ERR "Missing fd_dev_name=\n");
return -1; return -EINVAL;
} }
return 0; return 0;
...@@ -654,7 +653,7 @@ static sector_t fd_get_blocks(struct se_device *dev) ...@@ -654,7 +653,7 @@ static sector_t fd_get_blocks(struct se_device *dev)
{ {
struct fd_dev *fd_dev = dev->dev_ptr; struct fd_dev *fd_dev = dev->dev_ptr;
unsigned long long blocks_long = div_u64(fd_dev->fd_dev_size, unsigned long long blocks_long = div_u64(fd_dev->fd_dev_size,
DEV_ATTRIB(dev)->block_size); dev->se_sub_dev->se_dev_attrib.block_size);
return blocks_long; return blocks_long;
} }
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#define FD_VERSION "4.0" #define FD_VERSION "4.0"
#define FD_MAX_DEV_NAME 256 #define FD_MAX_DEV_NAME 256
/* Maximum queuedepth for the FILEIO HBA */
#define FD_HBA_QUEUE_DEPTH 256
#define FD_DEVICE_QUEUE_DEPTH 32 #define FD_DEVICE_QUEUE_DEPTH 32
#define FD_MAX_DEVICE_QUEUE_DEPTH 128 #define FD_MAX_DEVICE_QUEUE_DEPTH 128
#define FD_BLOCKSIZE 512 #define FD_BLOCKSIZE 512
......
/******************************************************************************* /*******************************************************************************
* Filename: target_core_hba.c * Filename: target_core_hba.c
* *
* This file copntains the iSCSI HBA Transport related functions. * This file contains the TCM HBA Transport related functions.
* *
* Copyright (c) 2003, 2004, 2005 PyX Technologies, Inc. * Copyright (c) 2003, 2004, 2005 PyX Technologies, Inc.
* Copyright (c) 2005, 2006, 2007 SBE, Inc. * Copyright (c) 2005, 2006, 2007 SBE, Inc.
...@@ -45,6 +45,11 @@ ...@@ -45,6 +45,11 @@
static LIST_HEAD(subsystem_list); static LIST_HEAD(subsystem_list);
static DEFINE_MUTEX(subsystem_mutex); static DEFINE_MUTEX(subsystem_mutex);
static u32 hba_id_counter;
static DEFINE_SPINLOCK(hba_lock);
static LIST_HEAD(hba_list);
int transport_subsystem_register(struct se_subsystem_api *sub_api) int transport_subsystem_register(struct se_subsystem_api *sub_api)
{ {
struct se_subsystem_api *s; struct se_subsystem_api *s;
...@@ -110,15 +115,11 @@ core_alloc_hba(const char *plugin_name, u32 plugin_dep_id, u32 hba_flags) ...@@ -110,15 +115,11 @@ core_alloc_hba(const char *plugin_name, u32 plugin_dep_id, u32 hba_flags)
INIT_LIST_HEAD(&hba->hba_dev_list); INIT_LIST_HEAD(&hba->hba_dev_list);
spin_lock_init(&hba->device_lock); spin_lock_init(&hba->device_lock);
spin_lock_init(&hba->hba_queue_lock);
mutex_init(&hba->hba_access_mutex); mutex_init(&hba->hba_access_mutex);
hba->hba_index = scsi_get_new_index(SCSI_INST_INDEX); hba->hba_index = scsi_get_new_index(SCSI_INST_INDEX);
hba->hba_flags |= hba_flags; hba->hba_flags |= hba_flags;
atomic_set(&hba->max_queue_depth, 0);
atomic_set(&hba->left_queue_depth, 0);
hba->transport = core_get_backend(plugin_name); hba->transport = core_get_backend(plugin_name);
if (!hba->transport) { if (!hba->transport) {
ret = -EINVAL; ret = -EINVAL;
...@@ -129,10 +130,10 @@ core_alloc_hba(const char *plugin_name, u32 plugin_dep_id, u32 hba_flags) ...@@ -129,10 +130,10 @@ core_alloc_hba(const char *plugin_name, u32 plugin_dep_id, u32 hba_flags)
if (ret < 0) if (ret < 0)
goto out_module_put; goto out_module_put;
spin_lock(&se_global->hba_lock); spin_lock(&hba_lock);
hba->hba_id = se_global->g_hba_id_counter++; hba->hba_id = hba_id_counter++;
list_add_tail(&hba->hba_list, &se_global->g_hba_list); list_add_tail(&hba->hba_node, &hba_list);
spin_unlock(&se_global->hba_lock); spin_unlock(&hba_lock);
printk(KERN_INFO "CORE_HBA[%d] - Attached HBA to Generic Target" printk(KERN_INFO "CORE_HBA[%d] - Attached HBA to Generic Target"
" Core\n", hba->hba_id); " Core\n", hba->hba_id);
...@@ -156,9 +157,9 @@ core_delete_hba(struct se_hba *hba) ...@@ -156,9 +157,9 @@ core_delete_hba(struct se_hba *hba)
hba->transport->detach_hba(hba); hba->transport->detach_hba(hba);
spin_lock(&se_global->hba_lock); spin_lock(&hba_lock);
list_del(&hba->hba_list); list_del(&hba->hba_node);
spin_unlock(&se_global->hba_lock); spin_unlock(&hba_lock);
printk(KERN_INFO "CORE_HBA[%d] - Detached HBA from Generic Target" printk(KERN_INFO "CORE_HBA[%d] - Detached HBA from Generic Target"
" Core\n", hba->hba_id); " Core\n", hba->hba_id);
......
...@@ -74,17 +74,14 @@ static int iblock_attach_hba(struct se_hba *hba, u32 host_id) ...@@ -74,17 +74,14 @@ static int iblock_attach_hba(struct se_hba *hba, u32 host_id)
ib_host->iblock_host_id = host_id; ib_host->iblock_host_id = host_id;
atomic_set(&hba->left_queue_depth, IBLOCK_HBA_QUEUE_DEPTH);
atomic_set(&hba->max_queue_depth, IBLOCK_HBA_QUEUE_DEPTH);
hba->hba_ptr = (void *) ib_host; hba->hba_ptr = (void *) ib_host;
printk(KERN_INFO "CORE_HBA[%d] - TCM iBlock HBA Driver %s on" printk(KERN_INFO "CORE_HBA[%d] - TCM iBlock HBA Driver %s on"
" Generic Target Core Stack %s\n", hba->hba_id, " Generic Target Core Stack %s\n", hba->hba_id,
IBLOCK_VERSION, TARGET_CORE_MOD_VERSION); IBLOCK_VERSION, TARGET_CORE_MOD_VERSION);
printk(KERN_INFO "CORE_HBA[%d] - Attached iBlock HBA: %u to Generic" printk(KERN_INFO "CORE_HBA[%d] - Attached iBlock HBA: %u to Generic\n",
" Target Core TCQ Depth: %d\n", hba->hba_id, hba->hba_id, ib_host->iblock_host_id);
ib_host->iblock_host_id, atomic_read(&hba->max_queue_depth));
return 0; return 0;
} }
...@@ -188,15 +185,15 @@ static struct se_device *iblock_create_virtdevice( ...@@ -188,15 +185,15 @@ static struct se_device *iblock_create_virtdevice(
* in ATA and we need to set TPE=1 * in ATA and we need to set TPE=1
*/ */
if (blk_queue_discard(q)) { if (blk_queue_discard(q)) {
DEV_ATTRIB(dev)->max_unmap_lba_count = dev->se_sub_dev->se_dev_attrib.max_unmap_lba_count =
q->limits.max_discard_sectors; q->limits.max_discard_sectors;
/* /*
* Currently hardcoded to 1 in Linux/SCSI code.. * Currently hardcoded to 1 in Linux/SCSI code..
*/ */
DEV_ATTRIB(dev)->max_unmap_block_desc_count = 1; dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count = 1;
DEV_ATTRIB(dev)->unmap_granularity = dev->se_sub_dev->se_dev_attrib.unmap_granularity =
q->limits.discard_granularity; q->limits.discard_granularity;
DEV_ATTRIB(dev)->unmap_granularity_alignment = dev->se_sub_dev->se_dev_attrib.unmap_granularity_alignment =
q->limits.discard_alignment; q->limits.discard_alignment;
printk(KERN_INFO "IBLOCK: BLOCK Discard support available," printk(KERN_INFO "IBLOCK: BLOCK Discard support available,"
...@@ -243,7 +240,7 @@ iblock_alloc_task(struct se_cmd *cmd) ...@@ -243,7 +240,7 @@ iblock_alloc_task(struct se_cmd *cmd)
return NULL; return NULL;
} }
ib_req->ib_dev = SE_DEV(cmd)->dev_ptr; ib_req->ib_dev = cmd->se_lun->lun_se_dev->dev_ptr;
atomic_set(&ib_req->ib_bio_cnt, 0); atomic_set(&ib_req->ib_bio_cnt, 0);
return &ib_req->ib_task; return &ib_req->ib_task;
} }
...@@ -257,12 +254,12 @@ static unsigned long long iblock_emulate_read_cap_with_block_size( ...@@ -257,12 +254,12 @@ static unsigned long long iblock_emulate_read_cap_with_block_size(
bdev_logical_block_size(bd)) - 1); bdev_logical_block_size(bd)) - 1);
u32 block_size = bdev_logical_block_size(bd); u32 block_size = bdev_logical_block_size(bd);
if (block_size == DEV_ATTRIB(dev)->block_size) if (block_size == dev->se_sub_dev->se_dev_attrib.block_size)
return blocks_long; return blocks_long;
switch (block_size) { switch (block_size) {
case 4096: case 4096:
switch (DEV_ATTRIB(dev)->block_size) { switch (dev->se_sub_dev->se_dev_attrib.block_size) {
case 2048: case 2048:
blocks_long <<= 1; blocks_long <<= 1;
break; break;
...@@ -276,7 +273,7 @@ static unsigned long long iblock_emulate_read_cap_with_block_size( ...@@ -276,7 +273,7 @@ static unsigned long long iblock_emulate_read_cap_with_block_size(
} }
break; break;
case 2048: case 2048:
switch (DEV_ATTRIB(dev)->block_size) { switch (dev->se_sub_dev->se_dev_attrib.block_size) {
case 4096: case 4096:
blocks_long >>= 1; blocks_long >>= 1;
break; break;
...@@ -291,7 +288,7 @@ static unsigned long long iblock_emulate_read_cap_with_block_size( ...@@ -291,7 +288,7 @@ static unsigned long long iblock_emulate_read_cap_with_block_size(
} }
break; break;
case 1024: case 1024:
switch (DEV_ATTRIB(dev)->block_size) { switch (dev->se_sub_dev->se_dev_attrib.block_size) {
case 4096: case 4096:
blocks_long >>= 2; blocks_long >>= 2;
break; break;
...@@ -306,7 +303,7 @@ static unsigned long long iblock_emulate_read_cap_with_block_size( ...@@ -306,7 +303,7 @@ static unsigned long long iblock_emulate_read_cap_with_block_size(
} }
break; break;
case 512: case 512:
switch (DEV_ATTRIB(dev)->block_size) { switch (dev->se_sub_dev->se_dev_attrib.block_size) {
case 4096: case 4096:
blocks_long >>= 3; blocks_long >>= 3;
break; break;
...@@ -332,9 +329,9 @@ static unsigned long long iblock_emulate_read_cap_with_block_size( ...@@ -332,9 +329,9 @@ static unsigned long long iblock_emulate_read_cap_with_block_size(
*/ */
static void iblock_emulate_sync_cache(struct se_task *task) static void iblock_emulate_sync_cache(struct se_task *task)
{ {
struct se_cmd *cmd = TASK_CMD(task); struct se_cmd *cmd = task->task_se_cmd;
struct iblock_dev *ib_dev = cmd->se_dev->dev_ptr; struct iblock_dev *ib_dev = cmd->se_dev->dev_ptr;
int immed = (T_TASK(cmd)->t_task_cdb[1] & 0x2); int immed = (cmd->t_task->t_task_cdb[1] & 0x2);
sector_t error_sector; sector_t error_sector;
int ret; int ret;
...@@ -401,9 +398,9 @@ static int iblock_do_task(struct se_task *task) ...@@ -401,9 +398,9 @@ static int iblock_do_task(struct se_task *task)
* Force data to disk if we pretend to not have a volatile * Force data to disk if we pretend to not have a volatile
* write cache, or the initiator set the Force Unit Access bit. * write cache, or the initiator set the Force Unit Access bit.
*/ */
if (DEV_ATTRIB(dev)->emulate_write_cache == 0 || if (dev->se_sub_dev->se_dev_attrib.emulate_write_cache == 0 ||
(DEV_ATTRIB(dev)->emulate_fua_write > 0 && (dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0 &&
T_TASK(task->task_se_cmd)->t_tasks_fua)) task->task_se_cmd->t_task->t_tasks_fua))
rw = WRITE_FUA; rw = WRITE_FUA;
else else
rw = WRITE; rw = WRITE;
...@@ -527,7 +524,7 @@ static ssize_t iblock_check_configfs_dev_params( ...@@ -527,7 +524,7 @@ static ssize_t iblock_check_configfs_dev_params(
if (!(ibd->ibd_flags & IBDF_HAS_UDEV_PATH)) { if (!(ibd->ibd_flags & IBDF_HAS_UDEV_PATH)) {
printk(KERN_ERR "Missing udev_path= parameters for IBLOCK\n"); printk(KERN_ERR "Missing udev_path= parameters for IBLOCK\n");
return -1; return -EINVAL;
} }
return 0; return 0;
...@@ -611,7 +608,7 @@ static struct bio *iblock_get_bio( ...@@ -611,7 +608,7 @@ static struct bio *iblock_get_bio(
static int iblock_map_task_SG(struct se_task *task) static int iblock_map_task_SG(struct se_task *task)
{ {
struct se_cmd *cmd = task->task_se_cmd; struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
struct iblock_dev *ib_dev = task->se_dev->dev_ptr; struct iblock_dev *ib_dev = task->se_dev->dev_ptr;
struct iblock_req *ib_req = IBLOCK_REQ(task); struct iblock_req *ib_req = IBLOCK_REQ(task);
struct bio *bio = NULL, *hbio = NULL, *tbio = NULL; struct bio *bio = NULL, *hbio = NULL, *tbio = NULL;
...@@ -623,17 +620,17 @@ static int iblock_map_task_SG(struct se_task *task) ...@@ -623,17 +620,17 @@ static int iblock_map_task_SG(struct se_task *task)
* Do starting conversion up from non 512-byte blocksize with * Do starting conversion up from non 512-byte blocksize with
* struct se_task SCSI blocksize into Linux/Block 512 units for BIO. * struct se_task SCSI blocksize into Linux/Block 512 units for BIO.
*/ */
if (DEV_ATTRIB(dev)->block_size == 4096) if (dev->se_sub_dev->se_dev_attrib.block_size == 4096)
block_lba = (task->task_lba << 3); block_lba = (task->task_lba << 3);
else if (DEV_ATTRIB(dev)->block_size == 2048) else if (dev->se_sub_dev->se_dev_attrib.block_size == 2048)
block_lba = (task->task_lba << 2); block_lba = (task->task_lba << 2);
else if (DEV_ATTRIB(dev)->block_size == 1024) else if (dev->se_sub_dev->se_dev_attrib.block_size == 1024)
block_lba = (task->task_lba << 1); block_lba = (task->task_lba << 1);
else if (DEV_ATTRIB(dev)->block_size == 512) else if (dev->se_sub_dev->se_dev_attrib.block_size == 512)
block_lba = task->task_lba; block_lba = task->task_lba;
else { else {
printk(KERN_ERR "Unsupported SCSI -> BLOCK LBA conversion:" printk(KERN_ERR "Unsupported SCSI -> BLOCK LBA conversion:"
" %u\n", DEV_ATTRIB(dev)->block_size); " %u\n", dev->se_sub_dev->se_dev_attrib.block_size);
return PYX_TRANSPORT_LU_COMM_FAILURE; return PYX_TRANSPORT_LU_COMM_FAILURE;
} }
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#define IBLOCK_VERSION "4.0" #define IBLOCK_VERSION "4.0"
#define IBLOCK_HBA_QUEUE_DEPTH 512
#define IBLOCK_DEVICE_QUEUE_DEPTH 32 #define IBLOCK_DEVICE_QUEUE_DEPTH 32
#define IBLOCK_MAX_DEVICE_QUEUE_DEPTH 128 #define IBLOCK_MAX_DEVICE_QUEUE_DEPTH 128
#define IBLOCK_MAX_CDBS 16 #define IBLOCK_MAX_CDBS 16
......
...@@ -105,13 +105,13 @@ static int core_scsi2_reservation_check(struct se_cmd *cmd, u32 *pr_reg_type) ...@@ -105,13 +105,13 @@ static int core_scsi2_reservation_check(struct se_cmd *cmd, u32 *pr_reg_type)
} }
if (dev->dev_reserved_node_acl != sess->se_node_acl) { if (dev->dev_reserved_node_acl != sess->se_node_acl) {
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
return -1; return -EINVAL;
} }
if (!(dev->dev_flags & DF_SPC2_RESERVATIONS_WITH_ISID)) { if (!(dev->dev_flags & DF_SPC2_RESERVATIONS_WITH_ISID)) {
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
return 0; return 0;
} }
ret = (dev->dev_res_bin_isid == sess->sess_bin_isid) ? 0 : -1; ret = (dev->dev_res_bin_isid == sess->sess_bin_isid) ? 0 : -EINVAL;
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
return ret; return ret;
...@@ -143,8 +143,8 @@ static int core_scsi2_reservation_release(struct se_cmd *cmd) ...@@ -143,8 +143,8 @@ static int core_scsi2_reservation_release(struct se_cmd *cmd)
dev->dev_flags &= ~DF_SPC2_RESERVATIONS_WITH_ISID; dev->dev_flags &= ~DF_SPC2_RESERVATIONS_WITH_ISID;
} }
printk(KERN_INFO "SCSI-2 Released reservation for %s LUN: %u ->" printk(KERN_INFO "SCSI-2 Released reservation for %s LUN: %u ->"
" MAPPED LUN: %u for %s\n", TPG_TFO(tpg)->get_fabric_name(), " MAPPED LUN: %u for %s\n", tpg->se_tpg_tfo->get_fabric_name(),
SE_LUN(cmd)->unpacked_lun, cmd->se_deve->mapped_lun, cmd->se_lun->unpacked_lun, cmd->se_deve->mapped_lun,
sess->se_node_acl->initiatorname); sess->se_node_acl->initiatorname);
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
...@@ -157,8 +157,8 @@ static int core_scsi2_reservation_reserve(struct se_cmd *cmd) ...@@ -157,8 +157,8 @@ static int core_scsi2_reservation_reserve(struct se_cmd *cmd)
struct se_session *sess = cmd->se_sess; struct se_session *sess = cmd->se_sess;
struct se_portal_group *tpg = sess->se_tpg; struct se_portal_group *tpg = sess->se_tpg;
if ((T_TASK(cmd)->t_task_cdb[1] & 0x01) && if ((cmd->t_task->t_task_cdb[1] & 0x01) &&
(T_TASK(cmd)->t_task_cdb[1] & 0x02)) { (cmd->t_task->t_task_cdb[1] & 0x02)) {
printk(KERN_ERR "LongIO and Obselete Bits set, returning" printk(KERN_ERR "LongIO and Obselete Bits set, returning"
" ILLEGAL_REQUEST\n"); " ILLEGAL_REQUEST\n");
return PYX_TRANSPORT_ILLEGAL_REQUEST; return PYX_TRANSPORT_ILLEGAL_REQUEST;
...@@ -174,12 +174,12 @@ static int core_scsi2_reservation_reserve(struct se_cmd *cmd) ...@@ -174,12 +174,12 @@ static int core_scsi2_reservation_reserve(struct se_cmd *cmd)
if (dev->dev_reserved_node_acl && if (dev->dev_reserved_node_acl &&
(dev->dev_reserved_node_acl != sess->se_node_acl)) { (dev->dev_reserved_node_acl != sess->se_node_acl)) {
printk(KERN_ERR "SCSI-2 RESERVATION CONFLIFT for %s fabric\n", printk(KERN_ERR "SCSI-2 RESERVATION CONFLIFT for %s fabric\n",
TPG_TFO(tpg)->get_fabric_name()); tpg->se_tpg_tfo->get_fabric_name());
printk(KERN_ERR "Original reserver LUN: %u %s\n", printk(KERN_ERR "Original reserver LUN: %u %s\n",
SE_LUN(cmd)->unpacked_lun, cmd->se_lun->unpacked_lun,
dev->dev_reserved_node_acl->initiatorname); dev->dev_reserved_node_acl->initiatorname);
printk(KERN_ERR "Current attempt - LUN: %u -> MAPPED LUN: %u" printk(KERN_ERR "Current attempt - LUN: %u -> MAPPED LUN: %u"
" from %s \n", SE_LUN(cmd)->unpacked_lun, " from %s \n", cmd->se_lun->unpacked_lun,
cmd->se_deve->mapped_lun, cmd->se_deve->mapped_lun,
sess->se_node_acl->initiatorname); sess->se_node_acl->initiatorname);
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
...@@ -193,8 +193,8 @@ static int core_scsi2_reservation_reserve(struct se_cmd *cmd) ...@@ -193,8 +193,8 @@ static int core_scsi2_reservation_reserve(struct se_cmd *cmd)
dev->dev_flags |= DF_SPC2_RESERVATIONS_WITH_ISID; dev->dev_flags |= DF_SPC2_RESERVATIONS_WITH_ISID;
} }
printk(KERN_INFO "SCSI-2 Reserved %s LUN: %u -> MAPPED LUN: %u" printk(KERN_INFO "SCSI-2 Reserved %s LUN: %u -> MAPPED LUN: %u"
" for %s\n", TPG_TFO(tpg)->get_fabric_name(), " for %s\n", tpg->se_tpg_tfo->get_fabric_name(),
SE_LUN(cmd)->unpacked_lun, cmd->se_deve->mapped_lun, cmd->se_lun->unpacked_lun, cmd->se_deve->mapped_lun,
sess->se_node_acl->initiatorname); sess->se_node_acl->initiatorname);
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
...@@ -215,9 +215,9 @@ int core_scsi2_emulate_crh(struct se_cmd *cmd) ...@@ -215,9 +215,9 @@ int core_scsi2_emulate_crh(struct se_cmd *cmd)
struct se_session *se_sess = cmd->se_sess; struct se_session *se_sess = cmd->se_sess;
struct se_subsystem_dev *su_dev = cmd->se_dev->se_sub_dev; struct se_subsystem_dev *su_dev = cmd->se_dev->se_sub_dev;
struct t10_pr_registration *pr_reg; struct t10_pr_registration *pr_reg;
struct t10_reservation_template *pr_tmpl = &su_dev->t10_reservation; struct t10_reservation *pr_tmpl = &su_dev->t10_pr;
unsigned char *cdb = &T_TASK(cmd)->t_task_cdb[0]; unsigned char *cdb = &cmd->t_task->t_task_cdb[0];
int crh = (T10_RES(su_dev)->res_type == SPC3_PERSISTENT_RESERVATIONS); int crh = (su_dev->t10_pr.res_type == SPC3_PERSISTENT_RESERVATIONS);
int conflict = 0; int conflict = 0;
if (!(se_sess)) if (!(se_sess))
...@@ -307,7 +307,7 @@ static int core_scsi3_pr_seq_non_holder( ...@@ -307,7 +307,7 @@ static int core_scsi3_pr_seq_non_holder(
u32 pr_reg_type) u32 pr_reg_type)
{ {
struct se_dev_entry *se_deve; struct se_dev_entry *se_deve;
struct se_session *se_sess = SE_SESS(cmd); struct se_session *se_sess = cmd->se_sess;
int other_cdb = 0, ignore_reg; int other_cdb = 0, ignore_reg;
int registered_nexus = 0, ret = 1; /* Conflict by default */ int registered_nexus = 0, ret = 1; /* Conflict by default */
int all_reg = 0, reg_only = 0; /* ALL_REG, REG_ONLY */ int all_reg = 0, reg_only = 0; /* ALL_REG, REG_ONLY */
...@@ -362,7 +362,7 @@ static int core_scsi3_pr_seq_non_holder( ...@@ -362,7 +362,7 @@ static int core_scsi3_pr_seq_non_holder(
registered_nexus = 1; registered_nexus = 1;
break; break;
default: default:
return -1; return -EINVAL;
} }
/* /*
* Referenced from spc4r17 table 45 for *NON* PR holder access * Referenced from spc4r17 table 45 for *NON* PR holder access
...@@ -414,7 +414,7 @@ static int core_scsi3_pr_seq_non_holder( ...@@ -414,7 +414,7 @@ static int core_scsi3_pr_seq_non_holder(
default: default:
printk(KERN_ERR "Unknown PERSISTENT_RESERVE_OUT service" printk(KERN_ERR "Unknown PERSISTENT_RESERVE_OUT service"
" action: 0x%02x\n", cdb[1] & 0x1f); " action: 0x%02x\n", cdb[1] & 0x1f);
return -1; return -EINVAL;
} }
break; break;
case RELEASE: case RELEASE:
...@@ -461,7 +461,7 @@ static int core_scsi3_pr_seq_non_holder( ...@@ -461,7 +461,7 @@ static int core_scsi3_pr_seq_non_holder(
default: default:
printk(KERN_ERR "Unknown MI Service Action: 0x%02x\n", printk(KERN_ERR "Unknown MI Service Action: 0x%02x\n",
(cdb[1] & 0x1f)); (cdb[1] & 0x1f));
return -1; return -EINVAL;
} }
break; break;
case ACCESS_CONTROL_IN: case ACCESS_CONTROL_IN:
...@@ -549,7 +549,7 @@ static int core_scsi3_pr_seq_non_holder( ...@@ -549,7 +549,7 @@ static int core_scsi3_pr_seq_non_holder(
static u32 core_scsi3_pr_generation(struct se_device *dev) static u32 core_scsi3_pr_generation(struct se_device *dev)
{ {
struct se_subsystem_dev *su_dev = SU_DEV(dev); struct se_subsystem_dev *su_dev = dev->se_sub_dev;
u32 prg; u32 prg;
/* /*
* PRGeneration field shall contain the value of a 32-bit wrapping * PRGeneration field shall contain the value of a 32-bit wrapping
...@@ -561,7 +561,7 @@ static u32 core_scsi3_pr_generation(struct se_device *dev) ...@@ -561,7 +561,7 @@ static u32 core_scsi3_pr_generation(struct se_device *dev)
* See spc4r17 section 6.3.12 READ_KEYS service action * See spc4r17 section 6.3.12 READ_KEYS service action
*/ */
spin_lock(&dev->dev_reservation_lock); spin_lock(&dev->dev_reservation_lock);
prg = T10_RES(su_dev)->pr_generation++; prg = su_dev->t10_pr.pr_generation++;
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
return prg; return prg;
...@@ -592,14 +592,14 @@ static int core_scsi3_pr_reservation_check( ...@@ -592,14 +592,14 @@ static int core_scsi3_pr_reservation_check(
cmd->pr_res_key = dev->dev_pr_res_holder->pr_res_key; cmd->pr_res_key = dev->dev_pr_res_holder->pr_res_key;
if (dev->dev_pr_res_holder->pr_reg_nacl != sess->se_node_acl) { if (dev->dev_pr_res_holder->pr_reg_nacl != sess->se_node_acl) {
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
return -1; return -EINVAL;
} }
if (!(dev->dev_pr_res_holder->isid_present_at_reg)) { if (!(dev->dev_pr_res_holder->isid_present_at_reg)) {
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
return 0; return 0;
} }
ret = (dev->dev_pr_res_holder->pr_reg_bin_isid == ret = (dev->dev_pr_res_holder->pr_reg_bin_isid ==
sess->sess_bin_isid) ? 0 : -1; sess->sess_bin_isid) ? 0 : -EINVAL;
/* /*
* Use bit in *pr_reg_type to notify ISID mismatch in * Use bit in *pr_reg_type to notify ISID mismatch in
* core_scsi3_pr_seq_non_holder(). * core_scsi3_pr_seq_non_holder().
...@@ -620,7 +620,7 @@ static struct t10_pr_registration *__core_scsi3_do_alloc_registration( ...@@ -620,7 +620,7 @@ static struct t10_pr_registration *__core_scsi3_do_alloc_registration(
int all_tg_pt, int all_tg_pt,
int aptpl) int aptpl)
{ {
struct se_subsystem_dev *su_dev = SU_DEV(dev); struct se_subsystem_dev *su_dev = dev->se_sub_dev;
struct t10_pr_registration *pr_reg; struct t10_pr_registration *pr_reg;
pr_reg = kmem_cache_zalloc(t10_pr_reg_cache, GFP_ATOMIC); pr_reg = kmem_cache_zalloc(t10_pr_reg_cache, GFP_ATOMIC);
...@@ -629,7 +629,7 @@ static struct t10_pr_registration *__core_scsi3_do_alloc_registration( ...@@ -629,7 +629,7 @@ static struct t10_pr_registration *__core_scsi3_do_alloc_registration(
return NULL; return NULL;
} }
pr_reg->pr_aptpl_buf = kzalloc(T10_RES(su_dev)->pr_aptpl_buf_len, pr_reg->pr_aptpl_buf = kzalloc(su_dev->t10_pr.pr_aptpl_buf_len,
GFP_ATOMIC); GFP_ATOMIC);
if (!(pr_reg->pr_aptpl_buf)) { if (!(pr_reg->pr_aptpl_buf)) {
printk(KERN_ERR "Unable to allocate pr_reg->pr_aptpl_buf\n"); printk(KERN_ERR "Unable to allocate pr_reg->pr_aptpl_buf\n");
...@@ -803,7 +803,7 @@ static struct t10_pr_registration *__core_scsi3_alloc_registration( ...@@ -803,7 +803,7 @@ static struct t10_pr_registration *__core_scsi3_alloc_registration(
} }
int core_scsi3_alloc_aptpl_registration( int core_scsi3_alloc_aptpl_registration(
struct t10_reservation_template *pr_tmpl, struct t10_reservation *pr_tmpl,
u64 sa_res_key, u64 sa_res_key,
unsigned char *i_port, unsigned char *i_port,
unsigned char *isid, unsigned char *isid,
...@@ -819,13 +819,13 @@ int core_scsi3_alloc_aptpl_registration( ...@@ -819,13 +819,13 @@ int core_scsi3_alloc_aptpl_registration(
if (!(i_port) || !(t_port) || !(sa_res_key)) { if (!(i_port) || !(t_port) || !(sa_res_key)) {
printk(KERN_ERR "Illegal parameters for APTPL registration\n"); printk(KERN_ERR "Illegal parameters for APTPL registration\n");
return -1; return -EINVAL;
} }
pr_reg = kmem_cache_zalloc(t10_pr_reg_cache, GFP_KERNEL); pr_reg = kmem_cache_zalloc(t10_pr_reg_cache, GFP_KERNEL);
if (!(pr_reg)) { if (!(pr_reg)) {
printk(KERN_ERR "Unable to allocate struct t10_pr_registration\n"); printk(KERN_ERR "Unable to allocate struct t10_pr_registration\n");
return -1; return -ENOMEM;
} }
pr_reg->pr_aptpl_buf = kzalloc(pr_tmpl->pr_aptpl_buf_len, GFP_KERNEL); pr_reg->pr_aptpl_buf = kzalloc(pr_tmpl->pr_aptpl_buf_len, GFP_KERNEL);
...@@ -893,11 +893,11 @@ static void core_scsi3_aptpl_reserve( ...@@ -893,11 +893,11 @@ static void core_scsi3_aptpl_reserve(
printk(KERN_INFO "SPC-3 PR [%s] Service Action: APTPL RESERVE created" printk(KERN_INFO "SPC-3 PR [%s] Service Action: APTPL RESERVE created"
" new reservation holder TYPE: %s ALL_TG_PT: %d\n", " new reservation holder TYPE: %s ALL_TG_PT: %d\n",
TPG_TFO(tpg)->get_fabric_name(), tpg->se_tpg_tfo->get_fabric_name(),
core_scsi3_pr_dump_type(pr_reg->pr_res_type), core_scsi3_pr_dump_type(pr_reg->pr_res_type),
(pr_reg->pr_reg_all_tg_pt) ? 1 : 0); (pr_reg->pr_reg_all_tg_pt) ? 1 : 0);
printk(KERN_INFO "SPC-3 PR [%s] RESERVE Node: %s%s\n", printk(KERN_INFO "SPC-3 PR [%s] RESERVE Node: %s%s\n",
TPG_TFO(tpg)->get_fabric_name(), node_acl->initiatorname, tpg->se_tpg_tfo->get_fabric_name(), node_acl->initiatorname,
(prf_isid) ? &i_buf[0] : ""); (prf_isid) ? &i_buf[0] : "");
} }
...@@ -913,7 +913,7 @@ static int __core_scsi3_check_aptpl_registration( ...@@ -913,7 +913,7 @@ static int __core_scsi3_check_aptpl_registration(
struct se_dev_entry *deve) struct se_dev_entry *deve)
{ {
struct t10_pr_registration *pr_reg, *pr_reg_tmp; struct t10_pr_registration *pr_reg, *pr_reg_tmp;
struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr;
unsigned char i_port[PR_APTPL_MAX_IPORT_LEN]; unsigned char i_port[PR_APTPL_MAX_IPORT_LEN];
unsigned char t_port[PR_APTPL_MAX_TPORT_LEN]; unsigned char t_port[PR_APTPL_MAX_TPORT_LEN];
u16 tpgt; u16 tpgt;
...@@ -925,8 +925,8 @@ static int __core_scsi3_check_aptpl_registration( ...@@ -925,8 +925,8 @@ static int __core_scsi3_check_aptpl_registration(
*/ */
snprintf(i_port, PR_APTPL_MAX_IPORT_LEN, "%s", nacl->initiatorname); snprintf(i_port, PR_APTPL_MAX_IPORT_LEN, "%s", nacl->initiatorname);
snprintf(t_port, PR_APTPL_MAX_TPORT_LEN, "%s", snprintf(t_port, PR_APTPL_MAX_TPORT_LEN, "%s",
TPG_TFO(tpg)->tpg_get_wwn(tpg)); tpg->se_tpg_tfo->tpg_get_wwn(tpg));
tpgt = TPG_TFO(tpg)->tpg_get_tag(tpg); tpgt = tpg->se_tpg_tfo->tpg_get_tag(tpg);
/* /*
* Look for the matching registrations+reservation from those * Look for the matching registrations+reservation from those
* created from APTPL metadata. Note that multiple registrations * created from APTPL metadata. Note that multiple registrations
...@@ -980,11 +980,11 @@ int core_scsi3_check_aptpl_registration( ...@@ -980,11 +980,11 @@ int core_scsi3_check_aptpl_registration(
struct se_lun *lun, struct se_lun *lun,
struct se_lun_acl *lun_acl) struct se_lun_acl *lun_acl)
{ {
struct se_subsystem_dev *su_dev = SU_DEV(dev); struct se_subsystem_dev *su_dev = dev->se_sub_dev;
struct se_node_acl *nacl = lun_acl->se_lun_nacl; struct se_node_acl *nacl = lun_acl->se_lun_nacl;
struct se_dev_entry *deve = &nacl->device_list[lun_acl->mapped_lun]; struct se_dev_entry *deve = &nacl->device_list[lun_acl->mapped_lun];
if (T10_RES(su_dev)->res_type != SPC3_PERSISTENT_RESERVATIONS) if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS)
return 0; return 0;
return __core_scsi3_check_aptpl_registration(dev, tpg, lun, return __core_scsi3_check_aptpl_registration(dev, tpg, lun,
...@@ -1017,7 +1017,7 @@ static void __core_scsi3_dump_registration( ...@@ -1017,7 +1017,7 @@ static void __core_scsi3_dump_registration(
printk(KERN_INFO "SPC-3 PR [%s] for %s TCM Subsystem %s Object Target" printk(KERN_INFO "SPC-3 PR [%s] for %s TCM Subsystem %s Object Target"
" Port(s)\n", tfo->get_fabric_name(), " Port(s)\n", tfo->get_fabric_name(),
(pr_reg->pr_reg_all_tg_pt) ? "ALL" : "SINGLE", (pr_reg->pr_reg_all_tg_pt) ? "ALL" : "SINGLE",
TRANSPORT(dev)->name); dev->transport->name);
printk(KERN_INFO "SPC-3 PR [%s] SA Res Key: 0x%016Lx PRgeneration:" printk(KERN_INFO "SPC-3 PR [%s] SA Res Key: 0x%016Lx PRgeneration:"
" 0x%08x APTPL: %d\n", tfo->get_fabric_name(), " 0x%08x APTPL: %d\n", tfo->get_fabric_name(),
pr_reg->pr_res_key, pr_reg->pr_res_generation, pr_reg->pr_res_key, pr_reg->pr_res_generation,
...@@ -1035,10 +1035,10 @@ static void __core_scsi3_add_registration( ...@@ -1035,10 +1035,10 @@ static void __core_scsi3_add_registration(
int register_type, int register_type,
int register_move) int register_move)
{ {
struct se_subsystem_dev *su_dev = SU_DEV(dev); struct se_subsystem_dev *su_dev = dev->se_sub_dev;
struct target_core_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo; struct target_core_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo;
struct t10_pr_registration *pr_reg_tmp, *pr_reg_tmp_safe; struct t10_pr_registration *pr_reg_tmp, *pr_reg_tmp_safe;
struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr;
/* /*
* Increment PRgeneration counter for struct se_device upon a successful * Increment PRgeneration counter for struct se_device upon a successful
...@@ -1050,7 +1050,7 @@ static void __core_scsi3_add_registration( ...@@ -1050,7 +1050,7 @@ static void __core_scsi3_add_registration(
* for the REGISTER. * for the REGISTER.
*/ */
pr_reg->pr_res_generation = (register_move) ? pr_reg->pr_res_generation = (register_move) ?
T10_RES(su_dev)->pr_generation++ : su_dev->t10_pr.pr_generation++ :
core_scsi3_pr_generation(dev); core_scsi3_pr_generation(dev);
spin_lock(&pr_tmpl->registration_lock); spin_lock(&pr_tmpl->registration_lock);
...@@ -1107,7 +1107,7 @@ static int core_scsi3_alloc_registration( ...@@ -1107,7 +1107,7 @@ static int core_scsi3_alloc_registration(
pr_reg = __core_scsi3_alloc_registration(dev, nacl, deve, isid, pr_reg = __core_scsi3_alloc_registration(dev, nacl, deve, isid,
sa_res_key, all_tg_pt, aptpl); sa_res_key, all_tg_pt, aptpl);
if (!(pr_reg)) if (!(pr_reg))
return -1; return -EPERM;
__core_scsi3_add_registration(dev, nacl, pr_reg, __core_scsi3_add_registration(dev, nacl, pr_reg,
register_type, register_move); register_type, register_move);
...@@ -1119,7 +1119,7 @@ static struct t10_pr_registration *__core_scsi3_locate_pr_reg( ...@@ -1119,7 +1119,7 @@ static struct t10_pr_registration *__core_scsi3_locate_pr_reg(
struct se_node_acl *nacl, struct se_node_acl *nacl,
unsigned char *isid) unsigned char *isid)
{ {
struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr;
struct t10_pr_registration *pr_reg, *pr_reg_tmp; struct t10_pr_registration *pr_reg, *pr_reg_tmp;
struct se_portal_group *tpg; struct se_portal_group *tpg;
...@@ -1143,8 +1143,8 @@ static struct t10_pr_registration *__core_scsi3_locate_pr_reg( ...@@ -1143,8 +1143,8 @@ static struct t10_pr_registration *__core_scsi3_locate_pr_reg(
* SCSI Intiatior TransportID w/ ISIDs is enforced * SCSI Intiatior TransportID w/ ISIDs is enforced
* for fabric modules (iSCSI) requiring them. * for fabric modules (iSCSI) requiring them.
*/ */
if (TPG_TFO(tpg)->sess_get_initiator_sid != NULL) { if (tpg->se_tpg_tfo->sess_get_initiator_sid != NULL) {
if (DEV_ATTRIB(dev)->enforce_pr_isids) if (dev->se_sub_dev->se_dev_attrib.enforce_pr_isids)
continue; continue;
} }
atomic_inc(&pr_reg->pr_res_holders); atomic_inc(&pr_reg->pr_res_holders);
...@@ -1180,9 +1180,9 @@ static struct t10_pr_registration *core_scsi3_locate_pr_reg( ...@@ -1180,9 +1180,9 @@ static struct t10_pr_registration *core_scsi3_locate_pr_reg(
struct se_portal_group *tpg = nacl->se_tpg; struct se_portal_group *tpg = nacl->se_tpg;
unsigned char buf[PR_REG_ISID_LEN], *isid_ptr = NULL; unsigned char buf[PR_REG_ISID_LEN], *isid_ptr = NULL;
if (TPG_TFO(tpg)->sess_get_initiator_sid != NULL) { if (tpg->se_tpg_tfo->sess_get_initiator_sid != NULL) {
memset(&buf[0], 0, PR_REG_ISID_LEN); memset(&buf[0], 0, PR_REG_ISID_LEN);
TPG_TFO(tpg)->sess_get_initiator_sid(sess, &buf[0], tpg->se_tpg_tfo->sess_get_initiator_sid(sess, &buf[0],
PR_REG_ISID_LEN); PR_REG_ISID_LEN);
isid_ptr = &buf[0]; isid_ptr = &buf[0];
} }
...@@ -1240,7 +1240,7 @@ static int core_scsi3_check_implict_release( ...@@ -1240,7 +1240,7 @@ static int core_scsi3_check_implict_release(
" UNREGISTER while existing reservation with matching" " UNREGISTER while existing reservation with matching"
" key 0x%016Lx is present from another SCSI Initiator" " key 0x%016Lx is present from another SCSI Initiator"
" Port\n", pr_reg->pr_res_key); " Port\n", pr_reg->pr_res_key);
ret = -1; ret = -EPERM;
} }
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
...@@ -1248,7 +1248,7 @@ static int core_scsi3_check_implict_release( ...@@ -1248,7 +1248,7 @@ static int core_scsi3_check_implict_release(
} }
/* /*
* Called with struct t10_reservation_template->registration_lock held. * Called with struct t10_reservation->registration_lock held.
*/ */
static void __core_scsi3_free_registration( static void __core_scsi3_free_registration(
struct se_device *dev, struct se_device *dev,
...@@ -1258,7 +1258,7 @@ static void __core_scsi3_free_registration( ...@@ -1258,7 +1258,7 @@ static void __core_scsi3_free_registration(
{ {
struct target_core_fabric_ops *tfo = struct target_core_fabric_ops *tfo =
pr_reg->pr_reg_nacl->se_tpg->se_tpg_tfo; pr_reg->pr_reg_nacl->se_tpg->se_tpg_tfo;
struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr;
char i_buf[PR_REG_ISID_ID_LEN]; char i_buf[PR_REG_ISID_ID_LEN];
int prf_isid; int prf_isid;
...@@ -1296,7 +1296,7 @@ static void __core_scsi3_free_registration( ...@@ -1296,7 +1296,7 @@ static void __core_scsi3_free_registration(
printk(KERN_INFO "SPC-3 PR [%s] for %s TCM Subsystem %s Object Target" printk(KERN_INFO "SPC-3 PR [%s] for %s TCM Subsystem %s Object Target"
" Port(s)\n", tfo->get_fabric_name(), " Port(s)\n", tfo->get_fabric_name(),
(pr_reg->pr_reg_all_tg_pt) ? "ALL" : "SINGLE", (pr_reg->pr_reg_all_tg_pt) ? "ALL" : "SINGLE",
TRANSPORT(dev)->name); dev->transport->name);
printk(KERN_INFO "SPC-3 PR [%s] SA Res Key: 0x%016Lx PRgeneration:" printk(KERN_INFO "SPC-3 PR [%s] SA Res Key: 0x%016Lx PRgeneration:"
" 0x%08x\n", tfo->get_fabric_name(), pr_reg->pr_res_key, " 0x%08x\n", tfo->get_fabric_name(), pr_reg->pr_res_key,
pr_reg->pr_res_generation); pr_reg->pr_res_generation);
...@@ -1319,7 +1319,7 @@ void core_scsi3_free_pr_reg_from_nacl( ...@@ -1319,7 +1319,7 @@ void core_scsi3_free_pr_reg_from_nacl(
struct se_device *dev, struct se_device *dev,
struct se_node_acl *nacl) struct se_node_acl *nacl)
{ {
struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr;
struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_res_holder; struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_res_holder;
/* /*
* If the passed se_node_acl matches the reservation holder, * If the passed se_node_acl matches the reservation holder,
...@@ -1349,7 +1349,7 @@ void core_scsi3_free_pr_reg_from_nacl( ...@@ -1349,7 +1349,7 @@ void core_scsi3_free_pr_reg_from_nacl(
void core_scsi3_free_all_registrations( void core_scsi3_free_all_registrations(
struct se_device *dev) struct se_device *dev)
{ {
struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr;
struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_res_holder; struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_res_holder;
spin_lock(&dev->dev_reservation_lock); spin_lock(&dev->dev_reservation_lock);
...@@ -1381,13 +1381,13 @@ void core_scsi3_free_all_registrations( ...@@ -1381,13 +1381,13 @@ void core_scsi3_free_all_registrations(
static int core_scsi3_tpg_depend_item(struct se_portal_group *tpg) static int core_scsi3_tpg_depend_item(struct se_portal_group *tpg)
{ {
return configfs_depend_item(TPG_TFO(tpg)->tf_subsys, return configfs_depend_item(tpg->se_tpg_tfo->tf_subsys,
&tpg->tpg_group.cg_item); &tpg->tpg_group.cg_item);
} }
static void core_scsi3_tpg_undepend_item(struct se_portal_group *tpg) static void core_scsi3_tpg_undepend_item(struct se_portal_group *tpg)
{ {
configfs_undepend_item(TPG_TFO(tpg)->tf_subsys, configfs_undepend_item(tpg->se_tpg_tfo->tf_subsys,
&tpg->tpg_group.cg_item); &tpg->tpg_group.cg_item);
atomic_dec(&tpg->tpg_pr_ref_count); atomic_dec(&tpg->tpg_pr_ref_count);
...@@ -1401,7 +1401,7 @@ static int core_scsi3_nodeacl_depend_item(struct se_node_acl *nacl) ...@@ -1401,7 +1401,7 @@ static int core_scsi3_nodeacl_depend_item(struct se_node_acl *nacl)
if (nacl->dynamic_node_acl) if (nacl->dynamic_node_acl)
return 0; return 0;
return configfs_depend_item(TPG_TFO(tpg)->tf_subsys, return configfs_depend_item(tpg->se_tpg_tfo->tf_subsys,
&nacl->acl_group.cg_item); &nacl->acl_group.cg_item);
} }
...@@ -1415,7 +1415,7 @@ static void core_scsi3_nodeacl_undepend_item(struct se_node_acl *nacl) ...@@ -1415,7 +1415,7 @@ static void core_scsi3_nodeacl_undepend_item(struct se_node_acl *nacl)
return; return;
} }
configfs_undepend_item(TPG_TFO(tpg)->tf_subsys, configfs_undepend_item(tpg->se_tpg_tfo->tf_subsys,
&nacl->acl_group.cg_item); &nacl->acl_group.cg_item);
atomic_dec(&nacl->acl_pr_ref_count); atomic_dec(&nacl->acl_pr_ref_count);
...@@ -1436,7 +1436,7 @@ static int core_scsi3_lunacl_depend_item(struct se_dev_entry *se_deve) ...@@ -1436,7 +1436,7 @@ static int core_scsi3_lunacl_depend_item(struct se_dev_entry *se_deve)
nacl = lun_acl->se_lun_nacl; nacl = lun_acl->se_lun_nacl;
tpg = nacl->se_tpg; tpg = nacl->se_tpg;
return configfs_depend_item(TPG_TFO(tpg)->tf_subsys, return configfs_depend_item(tpg->se_tpg_tfo->tf_subsys,
&lun_acl->se_lun_group.cg_item); &lun_acl->se_lun_group.cg_item);
} }
...@@ -1456,7 +1456,7 @@ static void core_scsi3_lunacl_undepend_item(struct se_dev_entry *se_deve) ...@@ -1456,7 +1456,7 @@ static void core_scsi3_lunacl_undepend_item(struct se_dev_entry *se_deve)
nacl = lun_acl->se_lun_nacl; nacl = lun_acl->se_lun_nacl;
tpg = nacl->se_tpg; tpg = nacl->se_tpg;
configfs_undepend_item(TPG_TFO(tpg)->tf_subsys, configfs_undepend_item(tpg->se_tpg_tfo->tf_subsys,
&lun_acl->se_lun_group.cg_item); &lun_acl->se_lun_group.cg_item);
atomic_dec(&se_deve->pr_ref_count); atomic_dec(&se_deve->pr_ref_count);
...@@ -1471,10 +1471,10 @@ static int core_scsi3_decode_spec_i_port( ...@@ -1471,10 +1471,10 @@ static int core_scsi3_decode_spec_i_port(
int all_tg_pt, int all_tg_pt,
int aptpl) int aptpl)
{ {
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_port *tmp_port; struct se_port *tmp_port;
struct se_portal_group *dest_tpg = NULL, *tmp_tpg; struct se_portal_group *dest_tpg = NULL, *tmp_tpg;
struct se_session *se_sess = SE_SESS(cmd); struct se_session *se_sess = cmd->se_sess;
struct se_node_acl *dest_node_acl = NULL; struct se_node_acl *dest_node_acl = NULL;
struct se_dev_entry *dest_se_deve = NULL, *local_se_deve; struct se_dev_entry *dest_se_deve = NULL, *local_se_deve;
struct t10_pr_registration *dest_pr_reg, *local_pr_reg, *pr_reg_e; struct t10_pr_registration *dest_pr_reg, *local_pr_reg, *pr_reg_e;
...@@ -1482,7 +1482,7 @@ static int core_scsi3_decode_spec_i_port( ...@@ -1482,7 +1482,7 @@ static int core_scsi3_decode_spec_i_port(
struct list_head tid_dest_list; struct list_head tid_dest_list;
struct pr_transport_id_holder *tidh_new, *tidh, *tidh_tmp; struct pr_transport_id_holder *tidh_new, *tidh, *tidh_tmp;
struct target_core_fabric_ops *tmp_tf_ops; struct target_core_fabric_ops *tmp_tf_ops;
unsigned char *buf = (unsigned char *)T_TASK(cmd)->t_task_buf; unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf;
unsigned char *ptr, *i_str = NULL, proto_ident, tmp_proto_ident; unsigned char *ptr, *i_str = NULL, proto_ident, tmp_proto_ident;
char *iport_ptr = NULL, dest_iport[64], i_buf[PR_REG_ISID_ID_LEN]; char *iport_ptr = NULL, dest_iport[64], i_buf[PR_REG_ISID_ID_LEN];
u32 tpdl, tid_len = 0; u32 tpdl, tid_len = 0;
...@@ -1509,7 +1509,7 @@ static int core_scsi3_decode_spec_i_port( ...@@ -1509,7 +1509,7 @@ static int core_scsi3_decode_spec_i_port(
tidh_new->dest_node_acl = se_sess->se_node_acl; tidh_new->dest_node_acl = se_sess->se_node_acl;
tidh_new->dest_se_deve = local_se_deve; tidh_new->dest_se_deve = local_se_deve;
local_pr_reg = __core_scsi3_alloc_registration(SE_DEV(cmd), local_pr_reg = __core_scsi3_alloc_registration(cmd->se_lun->lun_se_dev,
se_sess->se_node_acl, local_se_deve, l_isid, se_sess->se_node_acl, local_se_deve, l_isid,
sa_res_key, all_tg_pt, aptpl); sa_res_key, all_tg_pt, aptpl);
if (!(local_pr_reg)) { if (!(local_pr_reg)) {
...@@ -1557,7 +1557,7 @@ static int core_scsi3_decode_spec_i_port( ...@@ -1557,7 +1557,7 @@ static int core_scsi3_decode_spec_i_port(
tmp_tpg = tmp_port->sep_tpg; tmp_tpg = tmp_port->sep_tpg;
if (!(tmp_tpg)) if (!(tmp_tpg))
continue; continue;
tmp_tf_ops = TPG_TFO(tmp_tpg); tmp_tf_ops = tmp_tpg->se_tpg_tfo;
if (!(tmp_tf_ops)) if (!(tmp_tf_ops))
continue; continue;
if (!(tmp_tf_ops->get_fabric_proto_ident) || if (!(tmp_tf_ops->get_fabric_proto_ident) ||
...@@ -1625,7 +1625,7 @@ static int core_scsi3_decode_spec_i_port( ...@@ -1625,7 +1625,7 @@ static int core_scsi3_decode_spec_i_port(
dest_tpg = tmp_tpg; dest_tpg = tmp_tpg;
printk(KERN_INFO "SPC-3 PR SPEC_I_PT: Located %s Node:" printk(KERN_INFO "SPC-3 PR SPEC_I_PT: Located %s Node:"
" %s Port RTPI: %hu\n", " %s Port RTPI: %hu\n",
TPG_TFO(dest_tpg)->get_fabric_name(), dest_tpg->se_tpg_tfo->get_fabric_name(),
dest_node_acl->initiatorname, dest_rtpi); dest_node_acl->initiatorname, dest_rtpi);
spin_lock(&dev->se_port_lock); spin_lock(&dev->se_port_lock);
...@@ -1642,7 +1642,7 @@ static int core_scsi3_decode_spec_i_port( ...@@ -1642,7 +1642,7 @@ static int core_scsi3_decode_spec_i_port(
#if 0 #if 0
printk("SPC-3 PR SPEC_I_PT: Got %s data_length: %u tpdl: %u" printk("SPC-3 PR SPEC_I_PT: Got %s data_length: %u tpdl: %u"
" tid_len: %d for %s + %s\n", " tid_len: %d for %s + %s\n",
TPG_TFO(dest_tpg)->get_fabric_name(), cmd->data_length, dest_tpg->se_tpg_tfo->get_fabric_name(), cmd->data_length,
tpdl, tid_len, i_str, iport_ptr); tpdl, tid_len, i_str, iport_ptr);
#endif #endif
if (tid_len > tpdl) { if (tid_len > tpdl) {
...@@ -1663,7 +1663,7 @@ static int core_scsi3_decode_spec_i_port( ...@@ -1663,7 +1663,7 @@ static int core_scsi3_decode_spec_i_port(
if (!(dest_se_deve)) { if (!(dest_se_deve)) {
printk(KERN_ERR "Unable to locate %s dest_se_deve" printk(KERN_ERR "Unable to locate %s dest_se_deve"
" from destination RTPI: %hu\n", " from destination RTPI: %hu\n",
TPG_TFO(dest_tpg)->get_fabric_name(), dest_tpg->se_tpg_tfo->get_fabric_name(),
dest_rtpi); dest_rtpi);
core_scsi3_nodeacl_undepend_item(dest_node_acl); core_scsi3_nodeacl_undepend_item(dest_node_acl);
...@@ -1686,7 +1686,7 @@ static int core_scsi3_decode_spec_i_port( ...@@ -1686,7 +1686,7 @@ static int core_scsi3_decode_spec_i_port(
#if 0 #if 0
printk(KERN_INFO "SPC-3 PR SPEC_I_PT: Located %s Node: %s" printk(KERN_INFO "SPC-3 PR SPEC_I_PT: Located %s Node: %s"
" dest_se_deve mapped_lun: %u\n", " dest_se_deve mapped_lun: %u\n",
TPG_TFO(dest_tpg)->get_fabric_name(), dest_tpg->se_tpg_tfo->get_fabric_name(),
dest_node_acl->initiatorname, dest_se_deve->mapped_lun); dest_node_acl->initiatorname, dest_se_deve->mapped_lun);
#endif #endif
/* /*
...@@ -1741,7 +1741,7 @@ static int core_scsi3_decode_spec_i_port( ...@@ -1741,7 +1741,7 @@ static int core_scsi3_decode_spec_i_port(
* and then call __core_scsi3_add_registration() in the * and then call __core_scsi3_add_registration() in the
* 2nd loop which will never fail. * 2nd loop which will never fail.
*/ */
dest_pr_reg = __core_scsi3_alloc_registration(SE_DEV(cmd), dest_pr_reg = __core_scsi3_alloc_registration(cmd->se_lun->lun_se_dev,
dest_node_acl, dest_se_deve, iport_ptr, dest_node_acl, dest_se_deve, iport_ptr,
sa_res_key, all_tg_pt, aptpl); sa_res_key, all_tg_pt, aptpl);
if (!(dest_pr_reg)) { if (!(dest_pr_reg)) {
...@@ -1787,12 +1787,12 @@ static int core_scsi3_decode_spec_i_port( ...@@ -1787,12 +1787,12 @@ static int core_scsi3_decode_spec_i_port(
prf_isid = core_pr_dump_initiator_port(dest_pr_reg, &i_buf[0], prf_isid = core_pr_dump_initiator_port(dest_pr_reg, &i_buf[0],
PR_REG_ISID_ID_LEN); PR_REG_ISID_ID_LEN);
__core_scsi3_add_registration(SE_DEV(cmd), dest_node_acl, __core_scsi3_add_registration(cmd->se_lun->lun_se_dev, dest_node_acl,
dest_pr_reg, 0, 0); dest_pr_reg, 0, 0);
printk(KERN_INFO "SPC-3 PR [%s] SPEC_I_PT: Successfully" printk(KERN_INFO "SPC-3 PR [%s] SPEC_I_PT: Successfully"
" registered Transport ID for Node: %s%s Mapped LUN:" " registered Transport ID for Node: %s%s Mapped LUN:"
" %u\n", TPG_TFO(dest_tpg)->get_fabric_name(), " %u\n", dest_tpg->se_tpg_tfo->get_fabric_name(),
dest_node_acl->initiatorname, (prf_isid) ? dest_node_acl->initiatorname, (prf_isid) ?
&i_buf[0] : "", dest_se_deve->mapped_lun); &i_buf[0] : "", dest_se_deve->mapped_lun);
...@@ -1855,7 +1855,7 @@ static int __core_scsi3_update_aptpl_buf( ...@@ -1855,7 +1855,7 @@ static int __core_scsi3_update_aptpl_buf(
{ {
struct se_lun *lun; struct se_lun *lun;
struct se_portal_group *tpg; struct se_portal_group *tpg;
struct se_subsystem_dev *su_dev = SU_DEV(dev); struct se_subsystem_dev *su_dev = dev->se_sub_dev;
struct t10_pr_registration *pr_reg; struct t10_pr_registration *pr_reg;
unsigned char tmp[512], isid_buf[32]; unsigned char tmp[512], isid_buf[32];
ssize_t len = 0; ssize_t len = 0;
...@@ -1873,8 +1873,8 @@ static int __core_scsi3_update_aptpl_buf( ...@@ -1873,8 +1873,8 @@ static int __core_scsi3_update_aptpl_buf(
/* /*
* Walk the registration list.. * Walk the registration list..
*/ */
spin_lock(&T10_RES(su_dev)->registration_lock); spin_lock(&su_dev->t10_pr.registration_lock);
list_for_each_entry(pr_reg, &T10_RES(su_dev)->registration_list, list_for_each_entry(pr_reg, &su_dev->t10_pr.registration_list,
pr_reg_list) { pr_reg_list) {
tmp[0] = '\0'; tmp[0] = '\0';
...@@ -1900,7 +1900,7 @@ static int __core_scsi3_update_aptpl_buf( ...@@ -1900,7 +1900,7 @@ static int __core_scsi3_update_aptpl_buf(
"res_holder=1\nres_type=%02x\n" "res_holder=1\nres_type=%02x\n"
"res_scope=%02x\nres_all_tg_pt=%d\n" "res_scope=%02x\nres_all_tg_pt=%d\n"
"mapped_lun=%u\n", reg_count, "mapped_lun=%u\n", reg_count,
TPG_TFO(tpg)->get_fabric_name(), tpg->se_tpg_tfo->get_fabric_name(),
pr_reg->pr_reg_nacl->initiatorname, isid_buf, pr_reg->pr_reg_nacl->initiatorname, isid_buf,
pr_reg->pr_res_key, pr_reg->pr_res_type, pr_reg->pr_res_key, pr_reg->pr_res_type,
pr_reg->pr_res_scope, pr_reg->pr_reg_all_tg_pt, pr_reg->pr_res_scope, pr_reg->pr_reg_all_tg_pt,
...@@ -1910,7 +1910,7 @@ static int __core_scsi3_update_aptpl_buf( ...@@ -1910,7 +1910,7 @@ static int __core_scsi3_update_aptpl_buf(
"initiator_fabric=%s\ninitiator_node=%s\n%s" "initiator_fabric=%s\ninitiator_node=%s\n%s"
"sa_res_key=%llu\nres_holder=0\n" "sa_res_key=%llu\nres_holder=0\n"
"res_all_tg_pt=%d\nmapped_lun=%u\n", "res_all_tg_pt=%d\nmapped_lun=%u\n",
reg_count, TPG_TFO(tpg)->get_fabric_name(), reg_count, tpg->se_tpg_tfo->get_fabric_name(),
pr_reg->pr_reg_nacl->initiatorname, isid_buf, pr_reg->pr_reg_nacl->initiatorname, isid_buf,
pr_reg->pr_res_key, pr_reg->pr_reg_all_tg_pt, pr_reg->pr_res_key, pr_reg->pr_reg_all_tg_pt,
pr_reg->pr_res_mapped_lun); pr_reg->pr_res_mapped_lun);
...@@ -1919,8 +1919,8 @@ static int __core_scsi3_update_aptpl_buf( ...@@ -1919,8 +1919,8 @@ static int __core_scsi3_update_aptpl_buf(
if ((len + strlen(tmp) >= pr_aptpl_buf_len)) { if ((len + strlen(tmp) >= pr_aptpl_buf_len)) {
printk(KERN_ERR "Unable to update renaming" printk(KERN_ERR "Unable to update renaming"
" APTPL metadata\n"); " APTPL metadata\n");
spin_unlock(&T10_RES(su_dev)->registration_lock); spin_unlock(&su_dev->t10_pr.registration_lock);
return -1; return -EMSGSIZE;
} }
len += sprintf(buf+len, "%s", tmp); len += sprintf(buf+len, "%s", tmp);
...@@ -1929,21 +1929,21 @@ static int __core_scsi3_update_aptpl_buf( ...@@ -1929,21 +1929,21 @@ static int __core_scsi3_update_aptpl_buf(
*/ */
snprintf(tmp, 512, "target_fabric=%s\ntarget_node=%s\n" snprintf(tmp, 512, "target_fabric=%s\ntarget_node=%s\n"
"tpgt=%hu\nport_rtpi=%hu\ntarget_lun=%u\nPR_REG_END:" "tpgt=%hu\nport_rtpi=%hu\ntarget_lun=%u\nPR_REG_END:"
" %d\n", TPG_TFO(tpg)->get_fabric_name(), " %d\n", tpg->se_tpg_tfo->get_fabric_name(),
TPG_TFO(tpg)->tpg_get_wwn(tpg), tpg->se_tpg_tfo->tpg_get_wwn(tpg),
TPG_TFO(tpg)->tpg_get_tag(tpg), tpg->se_tpg_tfo->tpg_get_tag(tpg),
lun->lun_sep->sep_rtpi, lun->unpacked_lun, reg_count); lun->lun_sep->sep_rtpi, lun->unpacked_lun, reg_count);
if ((len + strlen(tmp) >= pr_aptpl_buf_len)) { if ((len + strlen(tmp) >= pr_aptpl_buf_len)) {
printk(KERN_ERR "Unable to update renaming" printk(KERN_ERR "Unable to update renaming"
" APTPL metadata\n"); " APTPL metadata\n");
spin_unlock(&T10_RES(su_dev)->registration_lock); spin_unlock(&su_dev->t10_pr.registration_lock);
return -1; return -EMSGSIZE;
} }
len += sprintf(buf+len, "%s", tmp); len += sprintf(buf+len, "%s", tmp);
reg_count++; reg_count++;
} }
spin_unlock(&T10_RES(su_dev)->registration_lock); spin_unlock(&su_dev->t10_pr.registration_lock);
if (!(reg_count)) if (!(reg_count))
len += sprintf(buf+len, "No Registrations or Reservations"); len += sprintf(buf+len, "No Registrations or Reservations");
...@@ -1975,7 +1975,7 @@ static int __core_scsi3_write_aptpl_to_file( ...@@ -1975,7 +1975,7 @@ static int __core_scsi3_write_aptpl_to_file(
unsigned char *buf, unsigned char *buf,
u32 pr_aptpl_buf_len) u32 pr_aptpl_buf_len)
{ {
struct t10_wwn *wwn = &SU_DEV(dev)->t10_wwn; struct t10_wwn *wwn = &dev->se_sub_dev->t10_wwn;
struct file *file; struct file *file;
struct iovec iov[1]; struct iovec iov[1];
mm_segment_t old_fs; mm_segment_t old_fs;
...@@ -1989,7 +1989,7 @@ static int __core_scsi3_write_aptpl_to_file( ...@@ -1989,7 +1989,7 @@ static int __core_scsi3_write_aptpl_to_file(
if (strlen(&wwn->unit_serial[0]) >= 512) { if (strlen(&wwn->unit_serial[0]) >= 512) {
printk(KERN_ERR "WWN value for struct se_device does not fit" printk(KERN_ERR "WWN value for struct se_device does not fit"
" into path buffer\n"); " into path buffer\n");
return -1; return -EMSGSIZE;
} }
snprintf(path, 512, "/var/target/pr/aptpl_%s", &wwn->unit_serial[0]); snprintf(path, 512, "/var/target/pr/aptpl_%s", &wwn->unit_serial[0]);
...@@ -1997,7 +1997,7 @@ static int __core_scsi3_write_aptpl_to_file( ...@@ -1997,7 +1997,7 @@ static int __core_scsi3_write_aptpl_to_file(
if (IS_ERR(file) || !file || !file->f_dentry) { if (IS_ERR(file) || !file || !file->f_dentry) {
printk(KERN_ERR "filp_open(%s) for APTPL metadata" printk(KERN_ERR "filp_open(%s) for APTPL metadata"
" failed\n", path); " failed\n", path);
return -1; return (PTR_ERR(file) < 0 ? PTR_ERR(file) : -ENOENT);
} }
iov[0].iov_base = &buf[0]; iov[0].iov_base = &buf[0];
...@@ -2014,7 +2014,7 @@ static int __core_scsi3_write_aptpl_to_file( ...@@ -2014,7 +2014,7 @@ static int __core_scsi3_write_aptpl_to_file(
if (ret < 0) { if (ret < 0) {
printk("Error writing APTPL metadata file: %s\n", path); printk("Error writing APTPL metadata file: %s\n", path);
filp_close(file, NULL); filp_close(file, NULL);
return -1; return -EIO;
} }
filp_close(file, NULL); filp_close(file, NULL);
...@@ -2049,14 +2049,14 @@ static int core_scsi3_update_and_write_aptpl( ...@@ -2049,14 +2049,14 @@ static int core_scsi3_update_and_write_aptpl(
ret = core_scsi3_update_aptpl_buf(dev, buf, pr_aptpl_buf_len, ret = core_scsi3_update_aptpl_buf(dev, buf, pr_aptpl_buf_len,
clear_aptpl_metadata); clear_aptpl_metadata);
if (ret != 0) if (ret != 0)
return -1; return ret;
/* /*
* __core_scsi3_write_aptpl_to_file() will call strlen() * __core_scsi3_write_aptpl_to_file() will call strlen()
* on the passed buf to determine pr_aptpl_buf_len. * on the passed buf to determine pr_aptpl_buf_len.
*/ */
ret = __core_scsi3_write_aptpl_to_file(dev, buf, 0); ret = __core_scsi3_write_aptpl_to_file(dev, buf, 0);
if (ret != 0) if (ret != 0)
return -1; return ret;
return ret; return ret;
} }
...@@ -2070,13 +2070,13 @@ static int core_scsi3_emulate_pro_register( ...@@ -2070,13 +2070,13 @@ static int core_scsi3_emulate_pro_register(
int spec_i_pt, int spec_i_pt,
int ignore_key) int ignore_key)
{ {
struct se_session *se_sess = SE_SESS(cmd); struct se_session *se_sess = cmd->se_sess;
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_dev_entry *se_deve; struct se_dev_entry *se_deve;
struct se_lun *se_lun = SE_LUN(cmd); struct se_lun *se_lun = cmd->se_lun;
struct se_portal_group *se_tpg; struct se_portal_group *se_tpg;
struct t10_pr_registration *pr_reg, *pr_reg_p, *pr_reg_tmp, *pr_reg_e; struct t10_pr_registration *pr_reg, *pr_reg_p, *pr_reg_tmp, *pr_reg_e;
struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr;
/* Used for APTPL metadata w/ UNREGISTER */ /* Used for APTPL metadata w/ UNREGISTER */
unsigned char *pr_aptpl_buf = NULL; unsigned char *pr_aptpl_buf = NULL;
unsigned char isid_buf[PR_REG_ISID_LEN], *isid_ptr = NULL; unsigned char isid_buf[PR_REG_ISID_LEN], *isid_ptr = NULL;
...@@ -2089,9 +2089,9 @@ static int core_scsi3_emulate_pro_register( ...@@ -2089,9 +2089,9 @@ static int core_scsi3_emulate_pro_register(
se_tpg = se_sess->se_tpg; se_tpg = se_sess->se_tpg;
se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun];
if (TPG_TFO(se_tpg)->sess_get_initiator_sid != NULL) { if (se_tpg->se_tpg_tfo->sess_get_initiator_sid) {
memset(&isid_buf[0], 0, PR_REG_ISID_LEN); memset(&isid_buf[0], 0, PR_REG_ISID_LEN);
TPG_TFO(se_tpg)->sess_get_initiator_sid(se_sess, &isid_buf[0], se_tpg->se_tpg_tfo->sess_get_initiator_sid(se_sess, &isid_buf[0],
PR_REG_ISID_LEN); PR_REG_ISID_LEN);
isid_ptr = &isid_buf[0]; isid_ptr = &isid_buf[0];
} }
...@@ -2117,7 +2117,7 @@ static int core_scsi3_emulate_pro_register( ...@@ -2117,7 +2117,7 @@ static int core_scsi3_emulate_pro_register(
* Port Endpoint that the PRO was received from on the * Port Endpoint that the PRO was received from on the
* Logical Unit of the SCSI device server. * Logical Unit of the SCSI device server.
*/ */
ret = core_scsi3_alloc_registration(SE_DEV(cmd), ret = core_scsi3_alloc_registration(cmd->se_lun->lun_se_dev,
se_sess->se_node_acl, se_deve, isid_ptr, se_sess->se_node_acl, se_deve, isid_ptr,
sa_res_key, all_tg_pt, aptpl, sa_res_key, all_tg_pt, aptpl,
ignore_key, 0); ignore_key, 0);
...@@ -2145,7 +2145,7 @@ static int core_scsi3_emulate_pro_register( ...@@ -2145,7 +2145,7 @@ static int core_scsi3_emulate_pro_register(
*/ */
if (!(aptpl)) { if (!(aptpl)) {
pr_tmpl->pr_aptpl_active = 0; pr_tmpl->pr_aptpl_active = 0;
core_scsi3_update_and_write_aptpl(SE_DEV(cmd), NULL, 0); core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev, NULL, 0);
printk("SPC-3 PR: Set APTPL Bit Deactivated for" printk("SPC-3 PR: Set APTPL Bit Deactivated for"
" REGISTER\n"); " REGISTER\n");
return 0; return 0;
...@@ -2155,10 +2155,10 @@ static int core_scsi3_emulate_pro_register( ...@@ -2155,10 +2155,10 @@ static int core_scsi3_emulate_pro_register(
* update the APTPL metadata information using its * update the APTPL metadata information using its
* preallocated *pr_reg->pr_aptpl_buf. * preallocated *pr_reg->pr_aptpl_buf.
*/ */
pr_reg = core_scsi3_locate_pr_reg(SE_DEV(cmd), pr_reg = core_scsi3_locate_pr_reg(cmd->se_lun->lun_se_dev,
se_sess->se_node_acl, se_sess); se_sess->se_node_acl, se_sess);
ret = core_scsi3_update_and_write_aptpl(SE_DEV(cmd), ret = core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev,
&pr_reg->pr_aptpl_buf[0], &pr_reg->pr_aptpl_buf[0],
pr_tmpl->pr_aptpl_buf_len); pr_tmpl->pr_aptpl_buf_len);
if (!(ret)) { if (!(ret)) {
...@@ -2223,7 +2223,7 @@ static int core_scsi3_emulate_pro_register( ...@@ -2223,7 +2223,7 @@ static int core_scsi3_emulate_pro_register(
*/ */
if (!(sa_res_key)) { if (!(sa_res_key)) {
pr_holder = core_scsi3_check_implict_release( pr_holder = core_scsi3_check_implict_release(
SE_DEV(cmd), pr_reg); cmd->se_lun->lun_se_dev, pr_reg);
if (pr_holder < 0) { if (pr_holder < 0) {
kfree(pr_aptpl_buf); kfree(pr_aptpl_buf);
core_scsi3_put_pr_reg(pr_reg); core_scsi3_put_pr_reg(pr_reg);
...@@ -2260,7 +2260,7 @@ static int core_scsi3_emulate_pro_register( ...@@ -2260,7 +2260,7 @@ static int core_scsi3_emulate_pro_register(
/* /*
* Release the calling I_T Nexus registration now.. * Release the calling I_T Nexus registration now..
*/ */
__core_scsi3_free_registration(SE_DEV(cmd), pr_reg, __core_scsi3_free_registration(cmd->se_lun->lun_se_dev, pr_reg,
NULL, 1); NULL, 1);
/* /*
* From spc4r17, section 5.7.11.3 Unregistering * From spc4r17, section 5.7.11.3 Unregistering
...@@ -2315,11 +2315,11 @@ static int core_scsi3_emulate_pro_register( ...@@ -2315,11 +2315,11 @@ static int core_scsi3_emulate_pro_register(
* READ_KEYS service action. * READ_KEYS service action.
*/ */
pr_reg->pr_res_generation = core_scsi3_pr_generation( pr_reg->pr_res_generation = core_scsi3_pr_generation(
SE_DEV(cmd)); cmd->se_lun->lun_se_dev);
pr_reg->pr_res_key = sa_res_key; pr_reg->pr_res_key = sa_res_key;
printk("SPC-3 PR [%s] REGISTER%s: Changed Reservation" printk("SPC-3 PR [%s] REGISTER%s: Changed Reservation"
" Key for %s to: 0x%016Lx PRgeneration:" " Key for %s to: 0x%016Lx PRgeneration:"
" 0x%08x\n", CMD_TFO(cmd)->get_fabric_name(), " 0x%08x\n", cmd->se_tfo->get_fabric_name(),
(ignore_key) ? "_AND_IGNORE_EXISTING_KEY" : "", (ignore_key) ? "_AND_IGNORE_EXISTING_KEY" : "",
pr_reg->pr_reg_nacl->initiatorname, pr_reg->pr_reg_nacl->initiatorname,
pr_reg->pr_res_key, pr_reg->pr_res_generation); pr_reg->pr_res_key, pr_reg->pr_res_generation);
...@@ -2378,12 +2378,12 @@ static int core_scsi3_pro_reserve( ...@@ -2378,12 +2378,12 @@ static int core_scsi3_pro_reserve(
int scope, int scope,
u64 res_key) u64 res_key)
{ {
struct se_session *se_sess = SE_SESS(cmd); struct se_session *se_sess = cmd->se_sess;
struct se_dev_entry *se_deve; struct se_dev_entry *se_deve;
struct se_lun *se_lun = SE_LUN(cmd); struct se_lun *se_lun = cmd->se_lun;
struct se_portal_group *se_tpg; struct se_portal_group *se_tpg;
struct t10_pr_registration *pr_reg, *pr_res_holder; struct t10_pr_registration *pr_reg, *pr_res_holder;
struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr;
char i_buf[PR_REG_ISID_ID_LEN]; char i_buf[PR_REG_ISID_ID_LEN];
int ret, prf_isid; int ret, prf_isid;
...@@ -2398,7 +2398,7 @@ static int core_scsi3_pro_reserve( ...@@ -2398,7 +2398,7 @@ static int core_scsi3_pro_reserve(
/* /*
* Locate the existing *pr_reg via struct se_node_acl pointers * Locate the existing *pr_reg via struct se_node_acl pointers
*/ */
pr_reg = core_scsi3_locate_pr_reg(SE_DEV(cmd), se_sess->se_node_acl, pr_reg = core_scsi3_locate_pr_reg(cmd->se_lun->lun_se_dev, se_sess->se_node_acl,
se_sess); se_sess);
if (!(pr_reg)) { if (!(pr_reg)) {
printk(KERN_ERR "SPC-3 PR: Unable to locate" printk(KERN_ERR "SPC-3 PR: Unable to locate"
...@@ -2459,9 +2459,9 @@ static int core_scsi3_pro_reserve( ...@@ -2459,9 +2459,9 @@ static int core_scsi3_pro_reserve(
printk(KERN_ERR "SPC-3 PR: Attempted RESERVE from" printk(KERN_ERR "SPC-3 PR: Attempted RESERVE from"
" [%s]: %s while reservation already held by" " [%s]: %s while reservation already held by"
" [%s]: %s, returning RESERVATION_CONFLICT\n", " [%s]: %s, returning RESERVATION_CONFLICT\n",
CMD_TFO(cmd)->get_fabric_name(), cmd->se_tfo->get_fabric_name(),
se_sess->se_node_acl->initiatorname, se_sess->se_node_acl->initiatorname,
TPG_TFO(pr_res_nacl->se_tpg)->get_fabric_name(), pr_res_nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
pr_res_holder->pr_reg_nacl->initiatorname); pr_res_holder->pr_reg_nacl->initiatorname);
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
...@@ -2482,9 +2482,9 @@ static int core_scsi3_pro_reserve( ...@@ -2482,9 +2482,9 @@ static int core_scsi3_pro_reserve(
" [%s]: %s trying to change TYPE and/or SCOPE," " [%s]: %s trying to change TYPE and/or SCOPE,"
" while reservation already held by [%s]: %s," " while reservation already held by [%s]: %s,"
" returning RESERVATION_CONFLICT\n", " returning RESERVATION_CONFLICT\n",
CMD_TFO(cmd)->get_fabric_name(), cmd->se_tfo->get_fabric_name(),
se_sess->se_node_acl->initiatorname, se_sess->se_node_acl->initiatorname,
TPG_TFO(pr_res_nacl->se_tpg)->get_fabric_name(), pr_res_nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
pr_res_holder->pr_reg_nacl->initiatorname); pr_res_holder->pr_reg_nacl->initiatorname);
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
...@@ -2518,16 +2518,16 @@ static int core_scsi3_pro_reserve( ...@@ -2518,16 +2518,16 @@ static int core_scsi3_pro_reserve(
printk(KERN_INFO "SPC-3 PR [%s] Service Action: RESERVE created new" printk(KERN_INFO "SPC-3 PR [%s] Service Action: RESERVE created new"
" reservation holder TYPE: %s ALL_TG_PT: %d\n", " reservation holder TYPE: %s ALL_TG_PT: %d\n",
CMD_TFO(cmd)->get_fabric_name(), core_scsi3_pr_dump_type(type), cmd->se_tfo->get_fabric_name(), core_scsi3_pr_dump_type(type),
(pr_reg->pr_reg_all_tg_pt) ? 1 : 0); (pr_reg->pr_reg_all_tg_pt) ? 1 : 0);
printk(KERN_INFO "SPC-3 PR [%s] RESERVE Node: %s%s\n", printk(KERN_INFO "SPC-3 PR [%s] RESERVE Node: %s%s\n",
CMD_TFO(cmd)->get_fabric_name(), cmd->se_tfo->get_fabric_name(),
se_sess->se_node_acl->initiatorname, se_sess->se_node_acl->initiatorname,
(prf_isid) ? &i_buf[0] : ""); (prf_isid) ? &i_buf[0] : "");
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
if (pr_tmpl->pr_aptpl_active) { if (pr_tmpl->pr_aptpl_active) {
ret = core_scsi3_update_and_write_aptpl(SE_DEV(cmd), ret = core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev,
&pr_reg->pr_aptpl_buf[0], &pr_reg->pr_aptpl_buf[0],
pr_tmpl->pr_aptpl_buf_len); pr_tmpl->pr_aptpl_buf_len);
if (!(ret)) if (!(ret))
...@@ -2608,10 +2608,10 @@ static int core_scsi3_emulate_pro_release( ...@@ -2608,10 +2608,10 @@ static int core_scsi3_emulate_pro_release(
u64 res_key) u64 res_key)
{ {
struct se_device *dev = cmd->se_dev; struct se_device *dev = cmd->se_dev;
struct se_session *se_sess = SE_SESS(cmd); struct se_session *se_sess = cmd->se_sess;
struct se_lun *se_lun = SE_LUN(cmd); struct se_lun *se_lun = cmd->se_lun;
struct t10_pr_registration *pr_reg, *pr_reg_p, *pr_res_holder; struct t10_pr_registration *pr_reg, *pr_reg_p, *pr_res_holder;
struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr;
int ret, all_reg = 0; int ret, all_reg = 0;
if (!(se_sess) || !(se_lun)) { if (!(se_sess) || !(se_lun)) {
...@@ -2698,9 +2698,9 @@ static int core_scsi3_emulate_pro_release( ...@@ -2698,9 +2698,9 @@ static int core_scsi3_emulate_pro_release(
" reservation from [%s]: %s with different TYPE " " reservation from [%s]: %s with different TYPE "
"and/or SCOPE while reservation already held by" "and/or SCOPE while reservation already held by"
" [%s]: %s, returning RESERVATION_CONFLICT\n", " [%s]: %s, returning RESERVATION_CONFLICT\n",
CMD_TFO(cmd)->get_fabric_name(), cmd->se_tfo->get_fabric_name(),
se_sess->se_node_acl->initiatorname, se_sess->se_node_acl->initiatorname,
TPG_TFO(pr_res_nacl->se_tpg)->get_fabric_name(), pr_res_nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
pr_res_holder->pr_reg_nacl->initiatorname); pr_res_holder->pr_reg_nacl->initiatorname);
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
...@@ -2758,7 +2758,7 @@ static int core_scsi3_emulate_pro_release( ...@@ -2758,7 +2758,7 @@ static int core_scsi3_emulate_pro_release(
write_aptpl: write_aptpl:
if (pr_tmpl->pr_aptpl_active) { if (pr_tmpl->pr_aptpl_active) {
ret = core_scsi3_update_and_write_aptpl(SE_DEV(cmd), ret = core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev,
&pr_reg->pr_aptpl_buf[0], &pr_reg->pr_aptpl_buf[0],
pr_tmpl->pr_aptpl_buf_len); pr_tmpl->pr_aptpl_buf_len);
if (!(ret)) if (!(ret))
...@@ -2775,15 +2775,15 @@ static int core_scsi3_emulate_pro_clear( ...@@ -2775,15 +2775,15 @@ static int core_scsi3_emulate_pro_clear(
{ {
struct se_device *dev = cmd->se_dev; struct se_device *dev = cmd->se_dev;
struct se_node_acl *pr_reg_nacl; struct se_node_acl *pr_reg_nacl;
struct se_session *se_sess = SE_SESS(cmd); struct se_session *se_sess = cmd->se_sess;
struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr;
struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_reg_n, *pr_res_holder; struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_reg_n, *pr_res_holder;
u32 pr_res_mapped_lun = 0; u32 pr_res_mapped_lun = 0;
int calling_it_nexus = 0; int calling_it_nexus = 0;
/* /*
* Locate the existing *pr_reg via struct se_node_acl pointers * Locate the existing *pr_reg via struct se_node_acl pointers
*/ */
pr_reg_n = core_scsi3_locate_pr_reg(SE_DEV(cmd), pr_reg_n = core_scsi3_locate_pr_reg(cmd->se_lun->lun_se_dev,
se_sess->se_node_acl, se_sess); se_sess->se_node_acl, se_sess);
if (!(pr_reg_n)) { if (!(pr_reg_n)) {
printk(KERN_ERR "SPC-3 PR: Unable to locate" printk(KERN_ERR "SPC-3 PR: Unable to locate"
...@@ -2846,10 +2846,10 @@ static int core_scsi3_emulate_pro_clear( ...@@ -2846,10 +2846,10 @@ static int core_scsi3_emulate_pro_clear(
spin_unlock(&pr_tmpl->registration_lock); spin_unlock(&pr_tmpl->registration_lock);
printk(KERN_INFO "SPC-3 PR [%s] Service Action: CLEAR complete\n", printk(KERN_INFO "SPC-3 PR [%s] Service Action: CLEAR complete\n",
CMD_TFO(cmd)->get_fabric_name()); cmd->se_tfo->get_fabric_name());
if (pr_tmpl->pr_aptpl_active) { if (pr_tmpl->pr_aptpl_active) {
core_scsi3_update_and_write_aptpl(SE_DEV(cmd), NULL, 0); core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev, NULL, 0);
printk(KERN_INFO "SPC-3 PR: Updated APTPL metadata" printk(KERN_INFO "SPC-3 PR: Updated APTPL metadata"
" for CLEAR\n"); " for CLEAR\n");
} }
...@@ -2954,13 +2954,13 @@ static int core_scsi3_pro_preempt( ...@@ -2954,13 +2954,13 @@ static int core_scsi3_pro_preempt(
u64 sa_res_key, u64 sa_res_key,
int abort) int abort)
{ {
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_dev_entry *se_deve; struct se_dev_entry *se_deve;
struct se_node_acl *pr_reg_nacl; struct se_node_acl *pr_reg_nacl;
struct se_session *se_sess = SE_SESS(cmd); struct se_session *se_sess = cmd->se_sess;
struct list_head preempt_and_abort_list; struct list_head preempt_and_abort_list;
struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_reg_n, *pr_res_holder; struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_reg_n, *pr_res_holder;
struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr;
u32 pr_res_mapped_lun = 0; u32 pr_res_mapped_lun = 0;
int all_reg = 0, calling_it_nexus = 0, released_regs = 0; int all_reg = 0, calling_it_nexus = 0, released_regs = 0;
int prh_type = 0, prh_scope = 0, ret; int prh_type = 0, prh_scope = 0, ret;
...@@ -2969,7 +2969,7 @@ static int core_scsi3_pro_preempt( ...@@ -2969,7 +2969,7 @@ static int core_scsi3_pro_preempt(
return PYX_TRANSPORT_LU_COMM_FAILURE; return PYX_TRANSPORT_LU_COMM_FAILURE;
se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun];
pr_reg_n = core_scsi3_locate_pr_reg(SE_DEV(cmd), se_sess->se_node_acl, pr_reg_n = core_scsi3_locate_pr_reg(cmd->se_lun->lun_se_dev, se_sess->se_node_acl,
se_sess); se_sess);
if (!(pr_reg_n)) { if (!(pr_reg_n)) {
printk(KERN_ERR "SPC-3 PR: Unable to locate" printk(KERN_ERR "SPC-3 PR: Unable to locate"
...@@ -3111,7 +3111,7 @@ static int core_scsi3_pro_preempt( ...@@ -3111,7 +3111,7 @@ static int core_scsi3_pro_preempt(
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
if (pr_tmpl->pr_aptpl_active) { if (pr_tmpl->pr_aptpl_active) {
ret = core_scsi3_update_and_write_aptpl(SE_DEV(cmd), ret = core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev,
&pr_reg_n->pr_aptpl_buf[0], &pr_reg_n->pr_aptpl_buf[0],
pr_tmpl->pr_aptpl_buf_len); pr_tmpl->pr_aptpl_buf_len);
if (!(ret)) if (!(ret))
...@@ -3121,7 +3121,7 @@ static int core_scsi3_pro_preempt( ...@@ -3121,7 +3121,7 @@ static int core_scsi3_pro_preempt(
} }
core_scsi3_put_pr_reg(pr_reg_n); core_scsi3_put_pr_reg(pr_reg_n);
core_scsi3_pr_generation(SE_DEV(cmd)); core_scsi3_pr_generation(cmd->se_lun->lun_se_dev);
return 0; return 0;
} }
/* /*
...@@ -3247,7 +3247,7 @@ static int core_scsi3_pro_preempt( ...@@ -3247,7 +3247,7 @@ static int core_scsi3_pro_preempt(
} }
if (pr_tmpl->pr_aptpl_active) { if (pr_tmpl->pr_aptpl_active) {
ret = core_scsi3_update_and_write_aptpl(SE_DEV(cmd), ret = core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev,
&pr_reg_n->pr_aptpl_buf[0], &pr_reg_n->pr_aptpl_buf[0],
pr_tmpl->pr_aptpl_buf_len); pr_tmpl->pr_aptpl_buf_len);
if (!(ret)) if (!(ret))
...@@ -3256,7 +3256,7 @@ static int core_scsi3_pro_preempt( ...@@ -3256,7 +3256,7 @@ static int core_scsi3_pro_preempt(
} }
core_scsi3_put_pr_reg(pr_reg_n); core_scsi3_put_pr_reg(pr_reg_n);
core_scsi3_pr_generation(SE_DEV(cmd)); core_scsi3_pr_generation(cmd->se_lun->lun_se_dev);
return 0; return 0;
} }
...@@ -3297,17 +3297,17 @@ static int core_scsi3_emulate_pro_register_and_move( ...@@ -3297,17 +3297,17 @@ static int core_scsi3_emulate_pro_register_and_move(
int aptpl, int aptpl,
int unreg) int unreg)
{ {
struct se_session *se_sess = SE_SESS(cmd); struct se_session *se_sess = cmd->se_sess;
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_dev_entry *se_deve, *dest_se_deve = NULL; struct se_dev_entry *se_deve, *dest_se_deve = NULL;
struct se_lun *se_lun = SE_LUN(cmd); struct se_lun *se_lun = cmd->se_lun;
struct se_node_acl *pr_res_nacl, *pr_reg_nacl, *dest_node_acl = NULL; struct se_node_acl *pr_res_nacl, *pr_reg_nacl, *dest_node_acl = NULL;
struct se_port *se_port; struct se_port *se_port;
struct se_portal_group *se_tpg, *dest_se_tpg = NULL; struct se_portal_group *se_tpg, *dest_se_tpg = NULL;
struct target_core_fabric_ops *dest_tf_ops = NULL, *tf_ops; struct target_core_fabric_ops *dest_tf_ops = NULL, *tf_ops;
struct t10_pr_registration *pr_reg, *pr_res_holder, *dest_pr_reg; struct t10_pr_registration *pr_reg, *pr_res_holder, *dest_pr_reg;
struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr;
unsigned char *buf = (unsigned char *)T_TASK(cmd)->t_task_buf; unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf;
unsigned char *initiator_str; unsigned char *initiator_str;
char *iport_ptr = NULL, dest_iport[64], i_buf[PR_REG_ISID_ID_LEN]; char *iport_ptr = NULL, dest_iport[64], i_buf[PR_REG_ISID_ID_LEN];
u32 tid_len, tmp_tid_len; u32 tid_len, tmp_tid_len;
...@@ -3322,7 +3322,7 @@ static int core_scsi3_emulate_pro_register_and_move( ...@@ -3322,7 +3322,7 @@ static int core_scsi3_emulate_pro_register_and_move(
memset(dest_iport, 0, 64); memset(dest_iport, 0, 64);
memset(i_buf, 0, PR_REG_ISID_ID_LEN); memset(i_buf, 0, PR_REG_ISID_ID_LEN);
se_tpg = se_sess->se_tpg; se_tpg = se_sess->se_tpg;
tf_ops = TPG_TFO(se_tpg); tf_ops = se_tpg->se_tpg_tfo;
se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun];
/* /*
* Follow logic from spc4r17 Section 5.7.8, Table 50 -- * Follow logic from spc4r17 Section 5.7.8, Table 50 --
...@@ -3330,7 +3330,7 @@ static int core_scsi3_emulate_pro_register_and_move( ...@@ -3330,7 +3330,7 @@ static int core_scsi3_emulate_pro_register_and_move(
* *
* Locate the existing *pr_reg via struct se_node_acl pointers * Locate the existing *pr_reg via struct se_node_acl pointers
*/ */
pr_reg = core_scsi3_locate_pr_reg(SE_DEV(cmd), se_sess->se_node_acl, pr_reg = core_scsi3_locate_pr_reg(cmd->se_lun->lun_se_dev, se_sess->se_node_acl,
se_sess); se_sess);
if (!(pr_reg)) { if (!(pr_reg)) {
printk(KERN_ERR "SPC-3 PR: Unable to locate PR_REGISTERED" printk(KERN_ERR "SPC-3 PR: Unable to locate PR_REGISTERED"
...@@ -3384,7 +3384,7 @@ static int core_scsi3_emulate_pro_register_and_move( ...@@ -3384,7 +3384,7 @@ static int core_scsi3_emulate_pro_register_and_move(
dest_se_tpg = se_port->sep_tpg; dest_se_tpg = se_port->sep_tpg;
if (!(dest_se_tpg)) if (!(dest_se_tpg))
continue; continue;
dest_tf_ops = TPG_TFO(dest_se_tpg); dest_tf_ops = dest_se_tpg->se_tpg_tfo;
if (!(dest_tf_ops)) if (!(dest_tf_ops))
continue; continue;
...@@ -3612,7 +3612,7 @@ static int core_scsi3_emulate_pro_register_and_move( ...@@ -3612,7 +3612,7 @@ static int core_scsi3_emulate_pro_register_and_move(
dest_pr_reg = __core_scsi3_locate_pr_reg(dev, dest_node_acl, dest_pr_reg = __core_scsi3_locate_pr_reg(dev, dest_node_acl,
iport_ptr); iport_ptr);
if (!(dest_pr_reg)) { if (!(dest_pr_reg)) {
ret = core_scsi3_alloc_registration(SE_DEV(cmd), ret = core_scsi3_alloc_registration(cmd->se_lun->lun_se_dev,
dest_node_acl, dest_se_deve, iport_ptr, dest_node_acl, dest_se_deve, iport_ptr,
sa_res_key, 0, aptpl, 2, 1); sa_res_key, 0, aptpl, 2, 1);
if (ret != 0) { if (ret != 0) {
...@@ -3683,12 +3683,12 @@ static int core_scsi3_emulate_pro_register_and_move( ...@@ -3683,12 +3683,12 @@ static int core_scsi3_emulate_pro_register_and_move(
*/ */
if (!(aptpl)) { if (!(aptpl)) {
pr_tmpl->pr_aptpl_active = 0; pr_tmpl->pr_aptpl_active = 0;
core_scsi3_update_and_write_aptpl(SE_DEV(cmd), NULL, 0); core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev, NULL, 0);
printk("SPC-3 PR: Set APTPL Bit Deactivated for" printk("SPC-3 PR: Set APTPL Bit Deactivated for"
" REGISTER_AND_MOVE\n"); " REGISTER_AND_MOVE\n");
} else { } else {
pr_tmpl->pr_aptpl_active = 1; pr_tmpl->pr_aptpl_active = 1;
ret = core_scsi3_update_and_write_aptpl(SE_DEV(cmd), ret = core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev,
&dest_pr_reg->pr_aptpl_buf[0], &dest_pr_reg->pr_aptpl_buf[0],
pr_tmpl->pr_aptpl_buf_len); pr_tmpl->pr_aptpl_buf_len);
if (!(ret)) if (!(ret))
...@@ -3723,7 +3723,7 @@ static unsigned long long core_scsi3_extract_reservation_key(unsigned char *cdb) ...@@ -3723,7 +3723,7 @@ static unsigned long long core_scsi3_extract_reservation_key(unsigned char *cdb)
*/ */
static int core_scsi3_emulate_pr_out(struct se_cmd *cmd, unsigned char *cdb) static int core_scsi3_emulate_pr_out(struct se_cmd *cmd, unsigned char *cdb)
{ {
unsigned char *buf = (unsigned char *)T_TASK(cmd)->t_task_buf; unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf;
u64 res_key, sa_res_key; u64 res_key, sa_res_key;
int sa, scope, type, aptpl; int sa, scope, type, aptpl;
int spec_i_pt = 0, all_tg_pt = 0, unreg = 0; int spec_i_pt = 0, all_tg_pt = 0, unreg = 0;
...@@ -3731,7 +3731,7 @@ static int core_scsi3_emulate_pr_out(struct se_cmd *cmd, unsigned char *cdb) ...@@ -3731,7 +3731,7 @@ static int core_scsi3_emulate_pr_out(struct se_cmd *cmd, unsigned char *cdb)
* FIXME: A NULL struct se_session pointer means an this is not coming from * FIXME: A NULL struct se_session pointer means an this is not coming from
* a $FABRIC_MOD's nexus, but from internal passthrough ops. * a $FABRIC_MOD's nexus, but from internal passthrough ops.
*/ */
if (!(SE_SESS(cmd))) if (!(cmd->se_sess))
return PYX_TRANSPORT_LU_COMM_FAILURE; return PYX_TRANSPORT_LU_COMM_FAILURE;
if (cmd->data_length < 24) { if (cmd->data_length < 24) {
...@@ -3827,10 +3827,10 @@ static int core_scsi3_emulate_pr_out(struct se_cmd *cmd, unsigned char *cdb) ...@@ -3827,10 +3827,10 @@ static int core_scsi3_emulate_pr_out(struct se_cmd *cmd, unsigned char *cdb)
*/ */
static int core_scsi3_pri_read_keys(struct se_cmd *cmd) static int core_scsi3_pri_read_keys(struct se_cmd *cmd)
{ {
struct se_device *se_dev = SE_DEV(cmd); struct se_device *se_dev = cmd->se_lun->lun_se_dev;
struct se_subsystem_dev *su_dev = SU_DEV(se_dev); struct se_subsystem_dev *su_dev = se_dev->se_sub_dev;
struct t10_pr_registration *pr_reg; struct t10_pr_registration *pr_reg;
unsigned char *buf = (unsigned char *)T_TASK(cmd)->t_task_buf; unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf;
u32 add_len = 0, off = 8; u32 add_len = 0, off = 8;
if (cmd->data_length < 8) { if (cmd->data_length < 8) {
...@@ -3839,13 +3839,13 @@ static int core_scsi3_pri_read_keys(struct se_cmd *cmd) ...@@ -3839,13 +3839,13 @@ static int core_scsi3_pri_read_keys(struct se_cmd *cmd)
return PYX_TRANSPORT_INVALID_CDB_FIELD; return PYX_TRANSPORT_INVALID_CDB_FIELD;
} }
buf[0] = ((T10_RES(su_dev)->pr_generation >> 24) & 0xff); buf[0] = ((su_dev->t10_pr.pr_generation >> 24) & 0xff);
buf[1] = ((T10_RES(su_dev)->pr_generation >> 16) & 0xff); buf[1] = ((su_dev->t10_pr.pr_generation >> 16) & 0xff);
buf[2] = ((T10_RES(su_dev)->pr_generation >> 8) & 0xff); buf[2] = ((su_dev->t10_pr.pr_generation >> 8) & 0xff);
buf[3] = (T10_RES(su_dev)->pr_generation & 0xff); buf[3] = (su_dev->t10_pr.pr_generation & 0xff);
spin_lock(&T10_RES(su_dev)->registration_lock); spin_lock(&su_dev->t10_pr.registration_lock);
list_for_each_entry(pr_reg, &T10_RES(su_dev)->registration_list, list_for_each_entry(pr_reg, &su_dev->t10_pr.registration_list,
pr_reg_list) { pr_reg_list) {
/* /*
* Check for overflow of 8byte PRI READ_KEYS payload and * Check for overflow of 8byte PRI READ_KEYS payload and
...@@ -3865,7 +3865,7 @@ static int core_scsi3_pri_read_keys(struct se_cmd *cmd) ...@@ -3865,7 +3865,7 @@ static int core_scsi3_pri_read_keys(struct se_cmd *cmd)
add_len += 8; add_len += 8;
} }
spin_unlock(&T10_RES(su_dev)->registration_lock); spin_unlock(&su_dev->t10_pr.registration_lock);
buf[4] = ((add_len >> 24) & 0xff); buf[4] = ((add_len >> 24) & 0xff);
buf[5] = ((add_len >> 16) & 0xff); buf[5] = ((add_len >> 16) & 0xff);
...@@ -3882,10 +3882,10 @@ static int core_scsi3_pri_read_keys(struct se_cmd *cmd) ...@@ -3882,10 +3882,10 @@ static int core_scsi3_pri_read_keys(struct se_cmd *cmd)
*/ */
static int core_scsi3_pri_read_reservation(struct se_cmd *cmd) static int core_scsi3_pri_read_reservation(struct se_cmd *cmd)
{ {
struct se_device *se_dev = SE_DEV(cmd); struct se_device *se_dev = cmd->se_lun->lun_se_dev;
struct se_subsystem_dev *su_dev = SU_DEV(se_dev); struct se_subsystem_dev *su_dev = se_dev->se_sub_dev;
struct t10_pr_registration *pr_reg; struct t10_pr_registration *pr_reg;
unsigned char *buf = (unsigned char *)T_TASK(cmd)->t_task_buf; unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf;
u64 pr_res_key; u64 pr_res_key;
u32 add_len = 16; /* Hardcoded to 16 when a reservation is held. */ u32 add_len = 16; /* Hardcoded to 16 when a reservation is held. */
...@@ -3895,10 +3895,10 @@ static int core_scsi3_pri_read_reservation(struct se_cmd *cmd) ...@@ -3895,10 +3895,10 @@ static int core_scsi3_pri_read_reservation(struct se_cmd *cmd)
return PYX_TRANSPORT_INVALID_CDB_FIELD; return PYX_TRANSPORT_INVALID_CDB_FIELD;
} }
buf[0] = ((T10_RES(su_dev)->pr_generation >> 24) & 0xff); buf[0] = ((su_dev->t10_pr.pr_generation >> 24) & 0xff);
buf[1] = ((T10_RES(su_dev)->pr_generation >> 16) & 0xff); buf[1] = ((su_dev->t10_pr.pr_generation >> 16) & 0xff);
buf[2] = ((T10_RES(su_dev)->pr_generation >> 8) & 0xff); buf[2] = ((su_dev->t10_pr.pr_generation >> 8) & 0xff);
buf[3] = (T10_RES(su_dev)->pr_generation & 0xff); buf[3] = (su_dev->t10_pr.pr_generation & 0xff);
spin_lock(&se_dev->dev_reservation_lock); spin_lock(&se_dev->dev_reservation_lock);
pr_reg = se_dev->dev_pr_res_holder; pr_reg = se_dev->dev_pr_res_holder;
...@@ -3963,9 +3963,9 @@ static int core_scsi3_pri_read_reservation(struct se_cmd *cmd) ...@@ -3963,9 +3963,9 @@ static int core_scsi3_pri_read_reservation(struct se_cmd *cmd)
*/ */
static int core_scsi3_pri_report_capabilities(struct se_cmd *cmd) static int core_scsi3_pri_report_capabilities(struct se_cmd *cmd)
{ {
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr;
unsigned char *buf = (unsigned char *)T_TASK(cmd)->t_task_buf; unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf;
u16 add_len = 8; /* Hardcoded to 8. */ u16 add_len = 8; /* Hardcoded to 8. */
if (cmd->data_length < 6) { if (cmd->data_length < 6) {
...@@ -4014,13 +4014,13 @@ static int core_scsi3_pri_report_capabilities(struct se_cmd *cmd) ...@@ -4014,13 +4014,13 @@ static int core_scsi3_pri_report_capabilities(struct se_cmd *cmd)
*/ */
static int core_scsi3_pri_read_full_status(struct se_cmd *cmd) static int core_scsi3_pri_read_full_status(struct se_cmd *cmd)
{ {
struct se_device *se_dev = SE_DEV(cmd); struct se_device *se_dev = cmd->se_lun->lun_se_dev;
struct se_node_acl *se_nacl; struct se_node_acl *se_nacl;
struct se_subsystem_dev *su_dev = SU_DEV(se_dev); struct se_subsystem_dev *su_dev = se_dev->se_sub_dev;
struct se_portal_group *se_tpg; struct se_portal_group *se_tpg;
struct t10_pr_registration *pr_reg, *pr_reg_tmp; struct t10_pr_registration *pr_reg, *pr_reg_tmp;
struct t10_reservation_template *pr_tmpl = &SU_DEV(se_dev)->t10_reservation; struct t10_reservation *pr_tmpl = &se_dev->se_sub_dev->t10_pr;
unsigned char *buf = (unsigned char *)T_TASK(cmd)->t_task_buf; unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf;
u32 add_desc_len = 0, add_len = 0, desc_len, exp_desc_len; u32 add_desc_len = 0, add_len = 0, desc_len, exp_desc_len;
u32 off = 8; /* off into first Full Status descriptor */ u32 off = 8; /* off into first Full Status descriptor */
int format_code = 0; int format_code = 0;
...@@ -4031,10 +4031,10 @@ static int core_scsi3_pri_read_full_status(struct se_cmd *cmd) ...@@ -4031,10 +4031,10 @@ static int core_scsi3_pri_read_full_status(struct se_cmd *cmd)
return PYX_TRANSPORT_INVALID_CDB_FIELD; return PYX_TRANSPORT_INVALID_CDB_FIELD;
} }
buf[0] = ((T10_RES(su_dev)->pr_generation >> 24) & 0xff); buf[0] = ((su_dev->t10_pr.pr_generation >> 24) & 0xff);
buf[1] = ((T10_RES(su_dev)->pr_generation >> 16) & 0xff); buf[1] = ((su_dev->t10_pr.pr_generation >> 16) & 0xff);
buf[2] = ((T10_RES(su_dev)->pr_generation >> 8) & 0xff); buf[2] = ((su_dev->t10_pr.pr_generation >> 8) & 0xff);
buf[3] = (T10_RES(su_dev)->pr_generation & 0xff); buf[3] = (su_dev->t10_pr.pr_generation & 0xff);
spin_lock(&pr_tmpl->registration_lock); spin_lock(&pr_tmpl->registration_lock);
list_for_each_entry_safe(pr_reg, pr_reg_tmp, list_for_each_entry_safe(pr_reg, pr_reg_tmp,
...@@ -4051,7 +4051,7 @@ static int core_scsi3_pri_read_full_status(struct se_cmd *cmd) ...@@ -4051,7 +4051,7 @@ static int core_scsi3_pri_read_full_status(struct se_cmd *cmd)
* Determine expected length of $FABRIC_MOD specific * Determine expected length of $FABRIC_MOD specific
* TransportID full status descriptor.. * TransportID full status descriptor..
*/ */
exp_desc_len = TPG_TFO(se_tpg)->tpg_get_pr_transport_id_len( exp_desc_len = se_tpg->se_tpg_tfo->tpg_get_pr_transport_id_len(
se_tpg, se_nacl, pr_reg, &format_code); se_tpg, se_nacl, pr_reg, &format_code);
if ((exp_desc_len + add_len) > cmd->data_length) { if ((exp_desc_len + add_len) > cmd->data_length) {
...@@ -4116,7 +4116,7 @@ static int core_scsi3_pri_read_full_status(struct se_cmd *cmd) ...@@ -4116,7 +4116,7 @@ static int core_scsi3_pri_read_full_status(struct se_cmd *cmd)
/* /*
* Now, have the $FABRIC_MOD fill in the protocol identifier * Now, have the $FABRIC_MOD fill in the protocol identifier
*/ */
desc_len = TPG_TFO(se_tpg)->tpg_get_pr_transport_id(se_tpg, desc_len = se_tpg->se_tpg_tfo->tpg_get_pr_transport_id(se_tpg,
se_nacl, pr_reg, &format_code, &buf[off+4]); se_nacl, pr_reg, &format_code, &buf[off+4]);
spin_lock(&pr_tmpl->registration_lock); spin_lock(&pr_tmpl->registration_lock);
...@@ -4174,7 +4174,7 @@ static int core_scsi3_emulate_pr_in(struct se_cmd *cmd, unsigned char *cdb) ...@@ -4174,7 +4174,7 @@ static int core_scsi3_emulate_pr_in(struct se_cmd *cmd, unsigned char *cdb)
int core_scsi3_emulate_pr(struct se_cmd *cmd) int core_scsi3_emulate_pr(struct se_cmd *cmd)
{ {
unsigned char *cdb = &T_TASK(cmd)->t_task_cdb[0]; unsigned char *cdb = &cmd->t_task->t_task_cdb[0];
struct se_device *dev = cmd->se_dev; struct se_device *dev = cmd->se_dev;
/* /*
* Following spc2r20 5.5.1 Reservations overview: * Following spc2r20 5.5.1 Reservations overview:
...@@ -4213,39 +4213,39 @@ static int core_pt_seq_non_holder( ...@@ -4213,39 +4213,39 @@ static int core_pt_seq_non_holder(
int core_setup_reservations(struct se_device *dev, int force_pt) int core_setup_reservations(struct se_device *dev, int force_pt)
{ {
struct se_subsystem_dev *su_dev = dev->se_sub_dev; struct se_subsystem_dev *su_dev = dev->se_sub_dev;
struct t10_reservation_template *rest = &su_dev->t10_reservation; struct t10_reservation *rest = &su_dev->t10_pr;
/* /*
* If this device is from Target_Core_Mod/pSCSI, use the reservations * If this device is from Target_Core_Mod/pSCSI, use the reservations
* of the Underlying SCSI hardware. In Linux/SCSI terms, this can * of the Underlying SCSI hardware. In Linux/SCSI terms, this can
* cause a problem because libata and some SATA RAID HBAs appear * cause a problem because libata and some SATA RAID HBAs appear
* under Linux/SCSI, but to emulate reservations themselves. * under Linux/SCSI, but to emulate reservations themselves.
*/ */
if (((TRANSPORT(dev)->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) && if (((dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) &&
!(DEV_ATTRIB(dev)->emulate_reservations)) || force_pt) { !(dev->se_sub_dev->se_dev_attrib.emulate_reservations)) || force_pt) {
rest->res_type = SPC_PASSTHROUGH; rest->res_type = SPC_PASSTHROUGH;
rest->pr_ops.t10_reservation_check = &core_pt_reservation_check; rest->pr_ops.t10_reservation_check = &core_pt_reservation_check;
rest->pr_ops.t10_seq_non_holder = &core_pt_seq_non_holder; rest->pr_ops.t10_seq_non_holder = &core_pt_seq_non_holder;
printk(KERN_INFO "%s: Using SPC_PASSTHROUGH, no reservation" printk(KERN_INFO "%s: Using SPC_PASSTHROUGH, no reservation"
" emulation\n", TRANSPORT(dev)->name); " emulation\n", dev->transport->name);
return 0; return 0;
} }
/* /*
* If SPC-3 or above is reported by real or emulated struct se_device, * If SPC-3 or above is reported by real or emulated struct se_device,
* use emulated Persistent Reservations. * use emulated Persistent Reservations.
*/ */
if (TRANSPORT(dev)->get_device_rev(dev) >= SCSI_3) { if (dev->transport->get_device_rev(dev) >= SCSI_3) {
rest->res_type = SPC3_PERSISTENT_RESERVATIONS; rest->res_type = SPC3_PERSISTENT_RESERVATIONS;
rest->pr_ops.t10_reservation_check = &core_scsi3_pr_reservation_check; rest->pr_ops.t10_reservation_check = &core_scsi3_pr_reservation_check;
rest->pr_ops.t10_seq_non_holder = &core_scsi3_pr_seq_non_holder; rest->pr_ops.t10_seq_non_holder = &core_scsi3_pr_seq_non_holder;
printk(KERN_INFO "%s: Using SPC3_PERSISTENT_RESERVATIONS" printk(KERN_INFO "%s: Using SPC3_PERSISTENT_RESERVATIONS"
" emulation\n", TRANSPORT(dev)->name); " emulation\n", dev->transport->name);
} else { } else {
rest->res_type = SPC2_RESERVATIONS; rest->res_type = SPC2_RESERVATIONS;
rest->pr_ops.t10_reservation_check = &core_scsi2_reservation_check; rest->pr_ops.t10_reservation_check = &core_scsi2_reservation_check;
rest->pr_ops.t10_seq_non_holder = rest->pr_ops.t10_seq_non_holder =
&core_scsi2_reservation_seq_non_holder; &core_scsi2_reservation_seq_non_holder;
printk(KERN_INFO "%s: Using SPC2_RESERVATIONS emulation\n", printk(KERN_INFO "%s: Using SPC2_RESERVATIONS emulation\n",
TRANSPORT(dev)->name); dev->transport->name);
} }
return 0; return 0;
......
...@@ -49,7 +49,7 @@ extern int core_pr_dump_initiator_port(struct t10_pr_registration *, ...@@ -49,7 +49,7 @@ extern int core_pr_dump_initiator_port(struct t10_pr_registration *,
char *, u32); char *, u32);
extern int core_scsi2_emulate_crh(struct se_cmd *); extern int core_scsi2_emulate_crh(struct se_cmd *);
extern int core_scsi3_alloc_aptpl_registration( extern int core_scsi3_alloc_aptpl_registration(
struct t10_reservation_template *, u64, struct t10_reservation *, u64,
unsigned char *, unsigned char *, u32, unsigned char *, unsigned char *, u32,
unsigned char *, u16, u32, int, int, u8); unsigned char *, u16, u32, int, int, u8);
extern int core_scsi3_check_aptpl_registration(struct se_device *, extern int core_scsi3_check_aptpl_registration(struct se_device *,
......
...@@ -55,24 +55,6 @@ static struct se_subsystem_api pscsi_template; ...@@ -55,24 +55,6 @@ static struct se_subsystem_api pscsi_template;
static void pscsi_req_done(struct request *, int); static void pscsi_req_done(struct request *, int);
/* pscsi_get_sh():
*
*
*/
static struct Scsi_Host *pscsi_get_sh(u32 host_no)
{
struct Scsi_Host *sh = NULL;
sh = scsi_host_lookup(host_no);
if (IS_ERR(sh)) {
printk(KERN_ERR "Unable to locate SCSI HBA with Host ID:"
" %u\n", host_no);
return NULL;
}
return sh;
}
/* pscsi_attach_hba(): /* pscsi_attach_hba():
* *
* pscsi_get_sh() used scsi_host_lookup() to locate struct Scsi_Host. * pscsi_get_sh() used scsi_host_lookup() to locate struct Scsi_Host.
...@@ -80,28 +62,23 @@ static struct Scsi_Host *pscsi_get_sh(u32 host_no) ...@@ -80,28 +62,23 @@ static struct Scsi_Host *pscsi_get_sh(u32 host_no)
*/ */
static int pscsi_attach_hba(struct se_hba *hba, u32 host_id) static int pscsi_attach_hba(struct se_hba *hba, u32 host_id)
{ {
int hba_depth;
struct pscsi_hba_virt *phv; struct pscsi_hba_virt *phv;
phv = kzalloc(sizeof(struct pscsi_hba_virt), GFP_KERNEL); phv = kzalloc(sizeof(struct pscsi_hba_virt), GFP_KERNEL);
if (!(phv)) { if (!(phv)) {
printk(KERN_ERR "Unable to allocate struct pscsi_hba_virt\n"); printk(KERN_ERR "Unable to allocate struct pscsi_hba_virt\n");
return -1; return -ENOMEM;
} }
phv->phv_host_id = host_id; phv->phv_host_id = host_id;
phv->phv_mode = PHV_VIRUTAL_HOST_ID; phv->phv_mode = PHV_VIRUTAL_HOST_ID;
hba_depth = PSCSI_VIRTUAL_HBA_DEPTH;
atomic_set(&hba->left_queue_depth, hba_depth);
atomic_set(&hba->max_queue_depth, hba_depth);
hba->hba_ptr = (void *)phv; hba->hba_ptr = (void *)phv;
printk(KERN_INFO "CORE_HBA[%d] - TCM SCSI HBA Driver %s on" printk(KERN_INFO "CORE_HBA[%d] - TCM SCSI HBA Driver %s on"
" Generic Target Core Stack %s\n", hba->hba_id, " Generic Target Core Stack %s\n", hba->hba_id,
PSCSI_VERSION, TARGET_CORE_MOD_VERSION); PSCSI_VERSION, TARGET_CORE_MOD_VERSION);
printk(KERN_INFO "CORE_HBA[%d] - Attached SCSI HBA to Generic" printk(KERN_INFO "CORE_HBA[%d] - Attached SCSI HBA to Generic\n",
" Target Core with TCQ Depth: %d\n", hba->hba_id, hba->hba_id);
atomic_read(&hba->max_queue_depth));
return 0; return 0;
} }
...@@ -130,7 +107,6 @@ static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag) ...@@ -130,7 +107,6 @@ static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag)
{ {
struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)hba->hba_ptr; struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)hba->hba_ptr;
struct Scsi_Host *sh = phv->phv_lld_host; struct Scsi_Host *sh = phv->phv_lld_host;
int hba_depth = PSCSI_VIRTUAL_HBA_DEPTH;
/* /*
* Release the struct Scsi_Host * Release the struct Scsi_Host
*/ */
...@@ -140,8 +116,6 @@ static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag) ...@@ -140,8 +116,6 @@ static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag)
phv->phv_lld_host = NULL; phv->phv_lld_host = NULL;
phv->phv_mode = PHV_VIRUTAL_HOST_ID; phv->phv_mode = PHV_VIRUTAL_HOST_ID;
atomic_set(&hba->left_queue_depth, hba_depth);
atomic_set(&hba->max_queue_depth, hba_depth);
printk(KERN_INFO "CORE_HBA[%d] - Disabled pSCSI HBA Passthrough" printk(KERN_INFO "CORE_HBA[%d] - Disabled pSCSI HBA Passthrough"
" %s\n", hba->hba_id, (sh->hostt->name) ? " %s\n", hba->hba_id, (sh->hostt->name) ?
...@@ -154,22 +128,12 @@ static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag) ...@@ -154,22 +128,12 @@ static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag)
* Otherwise, locate struct Scsi_Host from the original passed * Otherwise, locate struct Scsi_Host from the original passed
* pSCSI Host ID and enable for phba mode * pSCSI Host ID and enable for phba mode
*/ */
sh = pscsi_get_sh(phv->phv_host_id); sh = scsi_host_lookup(phv->phv_host_id);
if (!(sh)) { if (IS_ERR(sh)) {
printk(KERN_ERR "pSCSI: Unable to locate SCSI Host for" printk(KERN_ERR "pSCSI: Unable to locate SCSI Host for"
" phv_host_id: %d\n", phv->phv_host_id); " phv_host_id: %d\n", phv->phv_host_id);
return -1; return PTR_ERR(sh);
} }
/*
* Usually the SCSI LLD will use the hostt->can_queue value to define
* its HBA TCQ depth. Some other drivers (like 2.6 megaraid) don't set
* this at all and set sh->can_queue at runtime.
*/
hba_depth = (sh->hostt->can_queue > sh->can_queue) ?
sh->hostt->can_queue : sh->can_queue;
atomic_set(&hba->left_queue_depth, hba_depth);
atomic_set(&hba->max_queue_depth, hba_depth);
phv->phv_lld_host = sh; phv->phv_lld_host = sh;
phv->phv_mode = PHV_LLD_SCSI_HOST_NO; phv->phv_mode = PHV_LLD_SCSI_HOST_NO;
...@@ -236,7 +200,7 @@ pscsi_get_inquiry_vpd_serial(struct scsi_device *sdev, struct t10_wwn *wwn) ...@@ -236,7 +200,7 @@ pscsi_get_inquiry_vpd_serial(struct scsi_device *sdev, struct t10_wwn *wwn)
buf = kzalloc(INQUIRY_VPD_SERIAL_LEN, GFP_KERNEL); buf = kzalloc(INQUIRY_VPD_SERIAL_LEN, GFP_KERNEL);
if (!buf) if (!buf)
return -1; return -ENOMEM;
memset(cdb, 0, MAX_COMMAND_SIZE); memset(cdb, 0, MAX_COMMAND_SIZE);
cdb[0] = INQUIRY; cdb[0] = INQUIRY;
...@@ -259,7 +223,7 @@ pscsi_get_inquiry_vpd_serial(struct scsi_device *sdev, struct t10_wwn *wwn) ...@@ -259,7 +223,7 @@ pscsi_get_inquiry_vpd_serial(struct scsi_device *sdev, struct t10_wwn *wwn)
out_free: out_free:
kfree(buf); kfree(buf);
return -1; return -EPERM;
} }
static void static void
...@@ -601,11 +565,11 @@ static struct se_device *pscsi_create_virtdevice( ...@@ -601,11 +565,11 @@ static struct se_device *pscsi_create_virtdevice(
hba->hba_flags |= HBA_FLAGS_PSCSI_MODE; hba->hba_flags |= HBA_FLAGS_PSCSI_MODE;
sh = phv->phv_lld_host; sh = phv->phv_lld_host;
} else { } else {
sh = pscsi_get_sh(pdv->pdv_host_id); sh = scsi_host_lookup(pdv->pdv_host_id);
if (!(sh)) { if (IS_ERR(sh)) {
printk(KERN_ERR "pSCSI: Unable to locate" printk(KERN_ERR "pSCSI: Unable to locate"
" pdv_host_id: %d\n", pdv->pdv_host_id); " pdv_host_id: %d\n", pdv->pdv_host_id);
return ERR_PTR(-ENODEV); return (struct se_device *) sh;
} }
} }
} else { } else {
...@@ -728,13 +692,12 @@ static int pscsi_transport_complete(struct se_task *task) ...@@ -728,13 +692,12 @@ static int pscsi_transport_complete(struct se_task *task)
*/ */
if (((cdb[0] == MODE_SENSE) || (cdb[0] == MODE_SENSE_10)) && if (((cdb[0] == MODE_SENSE) || (cdb[0] == MODE_SENSE_10)) &&
(status_byte(result) << 1) == SAM_STAT_GOOD) { (status_byte(result) << 1) == SAM_STAT_GOOD) {
if (!TASK_CMD(task)->se_deve) if (!task->task_se_cmd->se_deve)
goto after_mode_sense; goto after_mode_sense;
if (TASK_CMD(task)->se_deve->lun_flags & if (task->task_se_cmd->se_deve->lun_flags &
TRANSPORT_LUNFLAGS_READ_ONLY) { TRANSPORT_LUNFLAGS_READ_ONLY) {
unsigned char *buf = (unsigned char *) unsigned char *buf = task->task_se_cmd->t_task->t_task_buf;
T_TASK(task->task_se_cmd)->t_task_buf;
if (cdb[0] == MODE_SENSE_10) { if (cdb[0] == MODE_SENSE_10) {
if (!(buf[3] & 0x80)) if (!(buf[3] & 0x80))
...@@ -800,7 +763,7 @@ static struct se_task * ...@@ -800,7 +763,7 @@ static struct se_task *
pscsi_alloc_task(struct se_cmd *cmd) pscsi_alloc_task(struct se_cmd *cmd)
{ {
struct pscsi_plugin_task *pt; struct pscsi_plugin_task *pt;
unsigned char *cdb = T_TASK(cmd)->t_task_cdb; unsigned char *cdb = cmd->t_task->t_task_cdb;
pt = kzalloc(sizeof(struct pscsi_plugin_task), GFP_KERNEL); pt = kzalloc(sizeof(struct pscsi_plugin_task), GFP_KERNEL);
if (!pt) { if (!pt) {
...@@ -813,7 +776,7 @@ pscsi_alloc_task(struct se_cmd *cmd) ...@@ -813,7 +776,7 @@ pscsi_alloc_task(struct se_cmd *cmd)
* allocate the extended CDB buffer for per struct se_task context * allocate the extended CDB buffer for per struct se_task context
* pt->pscsi_cdb now. * pt->pscsi_cdb now.
*/ */
if (T_TASK(cmd)->t_task_cdb != T_TASK(cmd)->__t_task_cdb) { if (cmd->t_task->t_task_cdb != cmd->t_task->__t_task_cdb) {
pt->pscsi_cdb = kzalloc(scsi_command_size(cdb), GFP_KERNEL); pt->pscsi_cdb = kzalloc(scsi_command_size(cdb), GFP_KERNEL);
if (!(pt->pscsi_cdb)) { if (!(pt->pscsi_cdb)) {
...@@ -926,7 +889,7 @@ static void pscsi_free_task(struct se_task *task) ...@@ -926,7 +889,7 @@ static void pscsi_free_task(struct se_task *task)
* Release the extended CDB allocation from pscsi_alloc_task() * Release the extended CDB allocation from pscsi_alloc_task()
* if one exists. * if one exists.
*/ */
if (T_TASK(cmd)->t_task_cdb != T_TASK(cmd)->__t_task_cdb) if (cmd->t_task->t_task_cdb != cmd->t_task->__t_task_cdb)
kfree(pt->pscsi_cdb); kfree(pt->pscsi_cdb);
/* /*
* We do not release the bio(s) here associated with this task, as * We do not release the bio(s) here associated with this task, as
...@@ -1030,7 +993,7 @@ static ssize_t pscsi_check_configfs_dev_params( ...@@ -1030,7 +993,7 @@ static ssize_t pscsi_check_configfs_dev_params(
!(pdv->pdv_flags & PDF_HAS_LUN_ID)) { !(pdv->pdv_flags & PDF_HAS_LUN_ID)) {
printk(KERN_ERR "Missing scsi_channel_id=, scsi_target_id= and" printk(KERN_ERR "Missing scsi_channel_id=, scsi_target_id= and"
" scsi_lun_id= parameters\n"); " scsi_lun_id= parameters\n");
return -1; return -EINVAL;
} }
return 0; return 0;
...@@ -1291,7 +1254,7 @@ static int pscsi_map_task_SG(struct se_task *task) ...@@ -1291,7 +1254,7 @@ static int pscsi_map_task_SG(struct se_task *task)
*/ */
static int pscsi_map_task_non_SG(struct se_task *task) static int pscsi_map_task_non_SG(struct se_task *task)
{ {
struct se_cmd *cmd = TASK_CMD(task); struct se_cmd *cmd = task->task_se_cmd;
struct pscsi_plugin_task *pt = PSCSI_TASK(task); struct pscsi_plugin_task *pt = PSCSI_TASK(task);
struct pscsi_dev_virt *pdv = task->se_dev->dev_ptr; struct pscsi_dev_virt *pdv = task->se_dev->dev_ptr;
int ret = 0; int ret = 0;
...@@ -1303,7 +1266,7 @@ static int pscsi_map_task_non_SG(struct se_task *task) ...@@ -1303,7 +1266,7 @@ static int pscsi_map_task_non_SG(struct se_task *task)
return 0; return 0;
ret = blk_rq_map_kern(pdv->pdv_sd->request_queue, ret = blk_rq_map_kern(pdv->pdv_sd->request_queue,
pt->pscsi_req, T_TASK(cmd)->t_task_buf, pt->pscsi_req, cmd->t_task->t_task_buf,
task->task_size, GFP_KERNEL); task->task_size, GFP_KERNEL);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "PSCSI: blk_rq_map_kern() failed: %d\n", ret); printk(KERN_ERR "PSCSI: blk_rq_map_kern() failed: %d\n", ret);
...@@ -1400,13 +1363,11 @@ static inline void pscsi_process_SAM_status( ...@@ -1400,13 +1363,11 @@ static inline void pscsi_process_SAM_status(
pt->pscsi_result); pt->pscsi_result);
task->task_scsi_status = SAM_STAT_CHECK_CONDITION; task->task_scsi_status = SAM_STAT_CHECK_CONDITION;
task->task_error_status = PYX_TRANSPORT_UNKNOWN_SAM_OPCODE; task->task_error_status = PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
TASK_CMD(task)->transport_error_status = task->task_se_cmd->transport_error_status =
PYX_TRANSPORT_UNKNOWN_SAM_OPCODE; PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
transport_complete_task(task, 0); transport_complete_task(task, 0);
break; break;
} }
return;
} }
static void pscsi_req_done(struct request *req, int uptodate) static void pscsi_req_done(struct request *req, int uptodate)
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#define TARGET_CORE_PSCSI_H #define TARGET_CORE_PSCSI_H
#define PSCSI_VERSION "v4.0" #define PSCSI_VERSION "v4.0"
#define PSCSI_VIRTUAL_HBA_DEPTH 2048
/* used in pscsi_find_alloc_len() */ /* used in pscsi_find_alloc_len() */
#ifndef INQUIRY_DATA_SIZE #ifndef INQUIRY_DATA_SIZE
......
...@@ -66,17 +66,14 @@ static int rd_attach_hba(struct se_hba *hba, u32 host_id) ...@@ -66,17 +66,14 @@ static int rd_attach_hba(struct se_hba *hba, u32 host_id)
rd_host->rd_host_id = host_id; rd_host->rd_host_id = host_id;
atomic_set(&hba->left_queue_depth, RD_HBA_QUEUE_DEPTH);
atomic_set(&hba->max_queue_depth, RD_HBA_QUEUE_DEPTH);
hba->hba_ptr = (void *) rd_host; hba->hba_ptr = (void *) rd_host;
printk(KERN_INFO "CORE_HBA[%d] - TCM Ramdisk HBA Driver %s on" printk(KERN_INFO "CORE_HBA[%d] - TCM Ramdisk HBA Driver %s on"
" Generic Target Core Stack %s\n", hba->hba_id, " Generic Target Core Stack %s\n", hba->hba_id,
RD_HBA_VERSION, TARGET_CORE_MOD_VERSION); RD_HBA_VERSION, TARGET_CORE_MOD_VERSION);
printk(KERN_INFO "CORE_HBA[%d] - Attached Ramdisk HBA: %u to Generic" printk(KERN_INFO "CORE_HBA[%d] - Attached Ramdisk HBA: %u to Generic"
" Target Core TCQ Depth: %d MaxSectors: %u\n", hba->hba_id, " MaxSectors: %u\n", hba->hba_id,
rd_host->rd_host_id, atomic_read(&hba->max_queue_depth), rd_host->rd_host_id, RD_MAX_SECTORS);
RD_MAX_SECTORS);
return 0; return 0;
} }
...@@ -339,7 +336,7 @@ rd_alloc_task(struct se_cmd *cmd) ...@@ -339,7 +336,7 @@ rd_alloc_task(struct se_cmd *cmd)
printk(KERN_ERR "Unable to allocate struct rd_request\n"); printk(KERN_ERR "Unable to allocate struct rd_request\n");
return NULL; return NULL;
} }
rd_req->rd_dev = SE_DEV(cmd)->dev_ptr; rd_req->rd_dev = cmd->se_lun->lun_se_dev->dev_ptr;
return &rd_req->rd_task; return &rd_req->rd_task;
} }
...@@ -383,7 +380,7 @@ static int rd_MEMCPY_read(struct rd_request *req) ...@@ -383,7 +380,7 @@ static int rd_MEMCPY_read(struct rd_request *req)
table = rd_get_sg_table(dev, req->rd_page); table = rd_get_sg_table(dev, req->rd_page);
if (!(table)) if (!(table))
return -1; return -EINVAL;
table_sg_end = (table->page_end_offset - req->rd_page); table_sg_end = (table->page_end_offset - req->rd_page);
sg_d = task->task_sg; sg_d = task->task_sg;
...@@ -481,7 +478,7 @@ static int rd_MEMCPY_read(struct rd_request *req) ...@@ -481,7 +478,7 @@ static int rd_MEMCPY_read(struct rd_request *req)
#endif #endif
table = rd_get_sg_table(dev, req->rd_page); table = rd_get_sg_table(dev, req->rd_page);
if (!(table)) if (!(table))
return -1; return -EINVAL;
sg_s = &table->sg_table[j = 0]; sg_s = &table->sg_table[j = 0];
} }
...@@ -506,7 +503,7 @@ static int rd_MEMCPY_write(struct rd_request *req) ...@@ -506,7 +503,7 @@ static int rd_MEMCPY_write(struct rd_request *req)
table = rd_get_sg_table(dev, req->rd_page); table = rd_get_sg_table(dev, req->rd_page);
if (!(table)) if (!(table))
return -1; return -EINVAL;
table_sg_end = (table->page_end_offset - req->rd_page); table_sg_end = (table->page_end_offset - req->rd_page);
sg_d = &table->sg_table[req->rd_page - table->page_start_offset]; sg_d = &table->sg_table[req->rd_page - table->page_start_offset];
...@@ -604,7 +601,7 @@ static int rd_MEMCPY_write(struct rd_request *req) ...@@ -604,7 +601,7 @@ static int rd_MEMCPY_write(struct rd_request *req)
#endif #endif
table = rd_get_sg_table(dev, req->rd_page); table = rd_get_sg_table(dev, req->rd_page);
if (!(table)) if (!(table))
return -1; return -EINVAL;
sg_d = &table->sg_table[j = 0]; sg_d = &table->sg_table[j = 0];
} }
...@@ -623,11 +620,11 @@ static int rd_MEMCPY_do_task(struct se_task *task) ...@@ -623,11 +620,11 @@ static int rd_MEMCPY_do_task(struct se_task *task)
unsigned long long lba; unsigned long long lba;
int ret; int ret;
req->rd_page = (task->task_lba * DEV_ATTRIB(dev)->block_size) / PAGE_SIZE; req->rd_page = (task->task_lba * dev->se_sub_dev->se_dev_attrib.block_size) / PAGE_SIZE;
lba = task->task_lba; lba = task->task_lba;
req->rd_offset = (do_div(lba, req->rd_offset = (do_div(lba,
(PAGE_SIZE / DEV_ATTRIB(dev)->block_size))) * (PAGE_SIZE / dev->se_sub_dev->se_dev_attrib.block_size))) *
DEV_ATTRIB(dev)->block_size; dev->se_sub_dev->se_dev_attrib.block_size;
req->rd_size = task->task_size; req->rd_size = task->task_size;
if (task->task_data_direction == DMA_FROM_DEVICE) if (task->task_data_direction == DMA_FROM_DEVICE)
...@@ -664,7 +661,7 @@ static int rd_DIRECT_with_offset( ...@@ -664,7 +661,7 @@ static int rd_DIRECT_with_offset(
table = rd_get_sg_table(dev, req->rd_page); table = rd_get_sg_table(dev, req->rd_page);
if (!(table)) if (!(table))
return -1; return -EINVAL;
table_sg_end = (table->page_end_offset - req->rd_page); table_sg_end = (table->page_end_offset - req->rd_page);
sg_s = &table->sg_table[req->rd_page - table->page_start_offset]; sg_s = &table->sg_table[req->rd_page - table->page_start_offset];
...@@ -678,7 +675,7 @@ static int rd_DIRECT_with_offset( ...@@ -678,7 +675,7 @@ static int rd_DIRECT_with_offset(
se_mem = kmem_cache_zalloc(se_mem_cache, GFP_KERNEL); se_mem = kmem_cache_zalloc(se_mem_cache, GFP_KERNEL);
if (!(se_mem)) { if (!(se_mem)) {
printk(KERN_ERR "Unable to allocate struct se_mem\n"); printk(KERN_ERR "Unable to allocate struct se_mem\n");
return -1; return -ENOMEM;
} }
INIT_LIST_HEAD(&se_mem->se_list); INIT_LIST_HEAD(&se_mem->se_list);
...@@ -734,13 +731,13 @@ static int rd_DIRECT_with_offset( ...@@ -734,13 +731,13 @@ static int rd_DIRECT_with_offset(
#endif #endif
table = rd_get_sg_table(dev, req->rd_page); table = rd_get_sg_table(dev, req->rd_page);
if (!(table)) if (!(table))
return -1; return -EINVAL;
sg_s = &table->sg_table[j = 0]; sg_s = &table->sg_table[j = 0];
} }
out: out:
T_TASK(task->task_se_cmd)->t_tasks_se_num += *se_mem_cnt; task->task_se_cmd->t_task->t_tasks_se_num += *se_mem_cnt;
#ifdef DEBUG_RAMDISK_DR #ifdef DEBUG_RAMDISK_DR
printk(KERN_INFO "RD_DR - Allocated %u struct se_mem segments for task\n", printk(KERN_INFO "RD_DR - Allocated %u struct se_mem segments for task\n",
*se_mem_cnt); *se_mem_cnt);
...@@ -767,7 +764,7 @@ static int rd_DIRECT_without_offset( ...@@ -767,7 +764,7 @@ static int rd_DIRECT_without_offset(
table = rd_get_sg_table(dev, req->rd_page); table = rd_get_sg_table(dev, req->rd_page);
if (!(table)) if (!(table))
return -1; return -EINVAL;
sg_s = &table->sg_table[req->rd_page - table->page_start_offset]; sg_s = &table->sg_table[req->rd_page - table->page_start_offset];
#ifdef DEBUG_RAMDISK_DR #ifdef DEBUG_RAMDISK_DR
...@@ -780,7 +777,7 @@ static int rd_DIRECT_without_offset( ...@@ -780,7 +777,7 @@ static int rd_DIRECT_without_offset(
se_mem = kmem_cache_zalloc(se_mem_cache, GFP_KERNEL); se_mem = kmem_cache_zalloc(se_mem_cache, GFP_KERNEL);
if (!(se_mem)) { if (!(se_mem)) {
printk(KERN_ERR "Unable to allocate struct se_mem\n"); printk(KERN_ERR "Unable to allocate struct se_mem\n");
return -1; return -ENOMEM;
} }
INIT_LIST_HEAD(&se_mem->se_list); INIT_LIST_HEAD(&se_mem->se_list);
...@@ -816,13 +813,13 @@ static int rd_DIRECT_without_offset( ...@@ -816,13 +813,13 @@ static int rd_DIRECT_without_offset(
#endif #endif
table = rd_get_sg_table(dev, req->rd_page); table = rd_get_sg_table(dev, req->rd_page);
if (!(table)) if (!(table))
return -1; return -EINVAL;
sg_s = &table->sg_table[j = 0]; sg_s = &table->sg_table[j = 0];
} }
out: out:
T_TASK(task->task_se_cmd)->t_tasks_se_num += *se_mem_cnt; task->task_se_cmd->t_task->t_tasks_se_num += *se_mem_cnt;
#ifdef DEBUG_RAMDISK_DR #ifdef DEBUG_RAMDISK_DR
printk(KERN_INFO "RD_DR - Allocated %u struct se_mem segments for task\n", printk(KERN_INFO "RD_DR - Allocated %u struct se_mem segments for task\n",
*se_mem_cnt); *se_mem_cnt);
...@@ -848,13 +845,11 @@ static int rd_DIRECT_do_se_mem_map( ...@@ -848,13 +845,11 @@ static int rd_DIRECT_do_se_mem_map(
u32 task_offset = *task_offset_in; u32 task_offset = *task_offset_in;
unsigned long long lba; unsigned long long lba;
int ret; int ret;
int block_size = task->se_dev->se_sub_dev->se_dev_attrib.block_size;
req->rd_page = ((task->task_lba * DEV_ATTRIB(task->se_dev)->block_size) /
PAGE_SIZE);
lba = task->task_lba; lba = task->task_lba;
req->rd_offset = (do_div(lba, req->rd_page = ((task->task_lba * block_size) / PAGE_SIZE);
(PAGE_SIZE / DEV_ATTRIB(task->se_dev)->block_size))) * req->rd_offset = (do_div(lba, (PAGE_SIZE / block_size))) * block_size;
DEV_ATTRIB(task->se_dev)->block_size;
req->rd_size = task->task_size; req->rd_size = task->task_size;
if (req->rd_offset) if (req->rd_offset)
...@@ -867,7 +862,7 @@ static int rd_DIRECT_do_se_mem_map( ...@@ -867,7 +862,7 @@ static int rd_DIRECT_do_se_mem_map(
if (ret < 0) if (ret < 0)
return ret; return ret;
if (CMD_TFO(cmd)->task_sg_chaining == 0) if (cmd->se_tfo->task_sg_chaining == 0)
return 0; return 0;
/* /*
* Currently prevent writers from multiple HW fabrics doing * Currently prevent writers from multiple HW fabrics doing
...@@ -876,7 +871,7 @@ static int rd_DIRECT_do_se_mem_map( ...@@ -876,7 +871,7 @@ static int rd_DIRECT_do_se_mem_map(
if (cmd->data_direction == DMA_TO_DEVICE) { if (cmd->data_direction == DMA_TO_DEVICE) {
printk(KERN_ERR "DMA_TO_DEVICE not supported for" printk(KERN_ERR "DMA_TO_DEVICE not supported for"
" RAMDISK_DR with task_sg_chaining=1\n"); " RAMDISK_DR with task_sg_chaining=1\n");
return -1; return -ENOSYS;
} }
/* /*
* Special case for if task_sg_chaining is enabled, then * Special case for if task_sg_chaining is enabled, then
...@@ -884,14 +879,15 @@ static int rd_DIRECT_do_se_mem_map( ...@@ -884,14 +879,15 @@ static int rd_DIRECT_do_se_mem_map(
* transport_do_task_sg_chain() for creating chainged SGLs * transport_do_task_sg_chain() for creating chainged SGLs
* across multiple struct se_task->task_sg[]. * across multiple struct se_task->task_sg[].
*/ */
if (!(transport_calc_sg_num(task, ret = transport_init_task_sg(task,
list_entry(T_TASK(cmd)->t_mem_list->next, list_entry(cmd->t_task->t_mem_list->next,
struct se_mem, se_list), struct se_mem, se_list),
task_offset))) task_offset);
return -1; if (ret <= 0)
return ret;
return transport_map_mem_to_sg(task, se_mem_list, task->task_sg, return transport_map_mem_to_sg(task, se_mem_list, task->task_sg,
list_entry(T_TASK(cmd)->t_mem_list->next, list_entry(cmd->t_task->t_mem_list->next,
struct se_mem, se_list), struct se_mem, se_list),
out_se_mem, se_mem_cnt, task_offset_in); out_se_mem, se_mem_cnt, task_offset_in);
} }
...@@ -975,7 +971,7 @@ static ssize_t rd_check_configfs_dev_params(struct se_hba *hba, struct se_subsys ...@@ -975,7 +971,7 @@ static ssize_t rd_check_configfs_dev_params(struct se_hba *hba, struct se_subsys
if (!(rd_dev->rd_flags & RDF_HAS_PAGE_COUNT)) { if (!(rd_dev->rd_flags & RDF_HAS_PAGE_COUNT)) {
printk(KERN_INFO "Missing rd_pages= parameter\n"); printk(KERN_INFO "Missing rd_pages= parameter\n");
return -1; return -EINVAL;
} }
return 0; return 0;
...@@ -1021,7 +1017,7 @@ static sector_t rd_get_blocks(struct se_device *dev) ...@@ -1021,7 +1017,7 @@ static sector_t rd_get_blocks(struct se_device *dev)
{ {
struct rd_dev *rd_dev = dev->dev_ptr; struct rd_dev *rd_dev = dev->dev_ptr;
unsigned long long blocks_long = ((rd_dev->rd_page_count * PAGE_SIZE) / unsigned long long blocks_long = ((rd_dev->rd_page_count * PAGE_SIZE) /
DEV_ATTRIB(dev)->block_size) - 1; dev->se_sub_dev->se_dev_attrib.block_size) - 1;
return blocks_long; return blocks_long;
} }
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
/* Largest piece of memory kmalloc can allocate */ /* Largest piece of memory kmalloc can allocate */
#define RD_MAX_ALLOCATION_SIZE 65536 #define RD_MAX_ALLOCATION_SIZE 65536
/* Maximum queuedepth for the Ramdisk HBA */
#define RD_HBA_QUEUE_DEPTH 256
#define RD_DEVICE_QUEUE_DEPTH 32 #define RD_DEVICE_QUEUE_DEPTH 32
#define RD_MAX_DEVICE_QUEUE_DEPTH 128 #define RD_MAX_DEVICE_QUEUE_DEPTH 128
#define RD_BLOCKSIZE 512 #define RD_BLOCKSIZE 512
......
...@@ -402,8 +402,8 @@ static ssize_t target_stat_scsi_lu_show_attr_lu_name( ...@@ -402,8 +402,8 @@ static ssize_t target_stat_scsi_lu_show_attr_lu_name(
return -ENODEV; return -ENODEV;
/* scsiLuWwnName */ /* scsiLuWwnName */
return snprintf(page, PAGE_SIZE, "%s\n", return snprintf(page, PAGE_SIZE, "%s\n",
(strlen(DEV_T10_WWN(dev)->unit_serial)) ? (strlen(dev->se_sub_dev->t10_wwn.unit_serial)) ?
(char *)&DEV_T10_WWN(dev)->unit_serial[0] : "None"); dev->se_sub_dev->t10_wwn.unit_serial : "None");
} }
DEV_STAT_SCSI_LU_ATTR_RO(lu_name); DEV_STAT_SCSI_LU_ATTR_RO(lu_name);
...@@ -413,17 +413,17 @@ static ssize_t target_stat_scsi_lu_show_attr_vend( ...@@ -413,17 +413,17 @@ static ssize_t target_stat_scsi_lu_show_attr_vend(
struct se_subsystem_dev *se_subdev = container_of(sgrps, struct se_subsystem_dev *se_subdev = container_of(sgrps,
struct se_subsystem_dev, dev_stat_grps); struct se_subsystem_dev, dev_stat_grps);
struct se_device *dev = se_subdev->se_dev_ptr; struct se_device *dev = se_subdev->se_dev_ptr;
int j; int i;
char str[28]; char str[sizeof(dev->se_sub_dev->t10_wwn.vendor)+1];
if (!dev) if (!dev)
return -ENODEV; return -ENODEV;
/* scsiLuVendorId */ /* scsiLuVendorId */
memcpy(&str[0], (void *)DEV_T10_WWN(dev), 28); for (i = 0; i < sizeof(dev->se_sub_dev->t10_wwn.vendor); i++)
for (j = 0; j < 8; j++) str[i] = ISPRINT(dev->se_sub_dev->t10_wwn.vendor[i]) ?
str[j] = ISPRINT(DEV_T10_WWN(dev)->vendor[j]) ? dev->se_sub_dev->t10_wwn.vendor[i] : ' ';
DEV_T10_WWN(dev)->vendor[j] : 0x20; str[i] = '\0';
str[8] = 0;
return snprintf(page, PAGE_SIZE, "%s\n", str); return snprintf(page, PAGE_SIZE, "%s\n", str);
} }
DEV_STAT_SCSI_LU_ATTR_RO(vend); DEV_STAT_SCSI_LU_ATTR_RO(vend);
...@@ -434,18 +434,17 @@ static ssize_t target_stat_scsi_lu_show_attr_prod( ...@@ -434,18 +434,17 @@ static ssize_t target_stat_scsi_lu_show_attr_prod(
struct se_subsystem_dev *se_subdev = container_of(sgrps, struct se_subsystem_dev *se_subdev = container_of(sgrps,
struct se_subsystem_dev, dev_stat_grps); struct se_subsystem_dev, dev_stat_grps);
struct se_device *dev = se_subdev->se_dev_ptr; struct se_device *dev = se_subdev->se_dev_ptr;
int j; int i;
char str[28]; char str[sizeof(dev->se_sub_dev->t10_wwn.model)+1];
if (!dev) if (!dev)
return -ENODEV; return -ENODEV;
/* scsiLuProductId */ /* scsiLuProductId */
memcpy(&str[0], (void *)DEV_T10_WWN(dev), 28); for (i = 0; i < sizeof(dev->se_sub_dev->t10_wwn.vendor); i++)
for (j = 0; j < 16; j++) str[i] = ISPRINT(dev->se_sub_dev->t10_wwn.model[i]) ?
str[j] = ISPRINT(DEV_T10_WWN(dev)->model[j]) ? dev->se_sub_dev->t10_wwn.model[i] : ' ';
DEV_T10_WWN(dev)->model[j] : 0x20; str[i] = '\0';
str[16] = 0;
return snprintf(page, PAGE_SIZE, "%s\n", str); return snprintf(page, PAGE_SIZE, "%s\n", str);
} }
DEV_STAT_SCSI_LU_ATTR_RO(prod); DEV_STAT_SCSI_LU_ATTR_RO(prod);
...@@ -456,18 +455,17 @@ static ssize_t target_stat_scsi_lu_show_attr_rev( ...@@ -456,18 +455,17 @@ static ssize_t target_stat_scsi_lu_show_attr_rev(
struct se_subsystem_dev *se_subdev = container_of(sgrps, struct se_subsystem_dev *se_subdev = container_of(sgrps,
struct se_subsystem_dev, dev_stat_grps); struct se_subsystem_dev, dev_stat_grps);
struct se_device *dev = se_subdev->se_dev_ptr; struct se_device *dev = se_subdev->se_dev_ptr;
int j; int i;
char str[28]; char str[sizeof(dev->se_sub_dev->t10_wwn.revision)+1];
if (!dev) if (!dev)
return -ENODEV; return -ENODEV;
/* scsiLuRevisionId */ /* scsiLuRevisionId */
memcpy(&str[0], (void *)DEV_T10_WWN(dev), 28); for (i = 0; i < sizeof(dev->se_sub_dev->t10_wwn.revision); i++)
for (j = 0; j < 4; j++) str[i] = ISPRINT(dev->se_sub_dev->t10_wwn.revision[i]) ?
str[j] = ISPRINT(DEV_T10_WWN(dev)->revision[j]) ? dev->se_sub_dev->t10_wwn.revision[i] : ' ';
DEV_T10_WWN(dev)->revision[j] : 0x20; str[i] = '\0';
str[4] = 0;
return snprintf(page, PAGE_SIZE, "%s\n", str); return snprintf(page, PAGE_SIZE, "%s\n", str);
} }
DEV_STAT_SCSI_LU_ATTR_RO(rev); DEV_STAT_SCSI_LU_ATTR_RO(rev);
...@@ -484,7 +482,7 @@ static ssize_t target_stat_scsi_lu_show_attr_dev_type( ...@@ -484,7 +482,7 @@ static ssize_t target_stat_scsi_lu_show_attr_dev_type(
/* scsiLuPeripheralType */ /* scsiLuPeripheralType */
return snprintf(page, PAGE_SIZE, "%u\n", return snprintf(page, PAGE_SIZE, "%u\n",
TRANSPORT(dev)->get_device_type(dev)); dev->transport->get_device_type(dev));
} }
DEV_STAT_SCSI_LU_ATTR_RO(dev_type); DEV_STAT_SCSI_LU_ATTR_RO(dev_type);
...@@ -668,18 +666,18 @@ static struct config_item_type target_stat_scsi_lu_cit = { ...@@ -668,18 +666,18 @@ static struct config_item_type target_stat_scsi_lu_cit = {
*/ */
void target_stat_setup_dev_default_groups(struct se_subsystem_dev *se_subdev) void target_stat_setup_dev_default_groups(struct se_subsystem_dev *se_subdev)
{ {
struct config_group *dev_stat_grp = &DEV_STAT_GRP(se_subdev)->stat_group; struct config_group *dev_stat_grp = &se_subdev->dev_stat_grps.stat_group;
config_group_init_type_name(&DEV_STAT_GRP(se_subdev)->scsi_dev_group, config_group_init_type_name(&se_subdev->dev_stat_grps.scsi_dev_group,
"scsi_dev", &target_stat_scsi_dev_cit); "scsi_dev", &target_stat_scsi_dev_cit);
config_group_init_type_name(&DEV_STAT_GRP(se_subdev)->scsi_tgt_dev_group, config_group_init_type_name(&se_subdev->dev_stat_grps.scsi_tgt_dev_group,
"scsi_tgt_dev", &target_stat_scsi_tgt_dev_cit); "scsi_tgt_dev", &target_stat_scsi_tgt_dev_cit);
config_group_init_type_name(&DEV_STAT_GRP(se_subdev)->scsi_lu_group, config_group_init_type_name(&se_subdev->dev_stat_grps.scsi_lu_group,
"scsi_lu", &target_stat_scsi_lu_cit); "scsi_lu", &target_stat_scsi_lu_cit);
dev_stat_grp->default_groups[0] = &DEV_STAT_GRP(se_subdev)->scsi_dev_group; dev_stat_grp->default_groups[0] = &se_subdev->dev_stat_grps.scsi_dev_group;
dev_stat_grp->default_groups[1] = &DEV_STAT_GRP(se_subdev)->scsi_tgt_dev_group; dev_stat_grp->default_groups[1] = &se_subdev->dev_stat_grps.scsi_tgt_dev_group;
dev_stat_grp->default_groups[2] = &DEV_STAT_GRP(se_subdev)->scsi_lu_group; dev_stat_grp->default_groups[2] = &se_subdev->dev_stat_grps.scsi_lu_group;
dev_stat_grp->default_groups[3] = NULL; dev_stat_grp->default_groups[3] = NULL;
} }
...@@ -922,7 +920,7 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_name( ...@@ -922,7 +920,7 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_name(
tpg = sep->sep_tpg; tpg = sep->sep_tpg;
ret = snprintf(page, PAGE_SIZE, "%sPort#%u\n", ret = snprintf(page, PAGE_SIZE, "%sPort#%u\n",
TPG_TFO(tpg)->get_fabric_name(), sep->sep_index); tpg->se_tpg_tfo->get_fabric_name(), sep->sep_index);
spin_unlock(&lun->lun_sep_lock); spin_unlock(&lun->lun_sep_lock);
return ret; return ret;
} }
...@@ -945,8 +943,8 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_port_index( ...@@ -945,8 +943,8 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_port_index(
tpg = sep->sep_tpg; tpg = sep->sep_tpg;
ret = snprintf(page, PAGE_SIZE, "%s%s%d\n", ret = snprintf(page, PAGE_SIZE, "%s%s%d\n",
TPG_TFO(tpg)->tpg_get_wwn(tpg), "+t+", tpg->se_tpg_tfo->tpg_get_wwn(tpg), "+t+",
TPG_TFO(tpg)->tpg_get_tag(tpg)); tpg->se_tpg_tfo->tpg_get_tag(tpg));
spin_unlock(&lun->lun_sep_lock); spin_unlock(&lun->lun_sep_lock);
return ret; return ret;
} }
...@@ -1128,7 +1126,7 @@ static ssize_t target_stat_scsi_transport_show_attr_device( ...@@ -1128,7 +1126,7 @@ static ssize_t target_stat_scsi_transport_show_attr_device(
tpg = sep->sep_tpg; tpg = sep->sep_tpg;
/* scsiTransportType */ /* scsiTransportType */
ret = snprintf(page, PAGE_SIZE, "scsiTransport%s\n", ret = snprintf(page, PAGE_SIZE, "scsiTransport%s\n",
TPG_TFO(tpg)->get_fabric_name()); tpg->se_tpg_tfo->get_fabric_name());
spin_unlock(&lun->lun_sep_lock); spin_unlock(&lun->lun_sep_lock);
return ret; return ret;
} }
...@@ -1150,7 +1148,7 @@ static ssize_t target_stat_scsi_transport_show_attr_indx( ...@@ -1150,7 +1148,7 @@ static ssize_t target_stat_scsi_transport_show_attr_indx(
} }
tpg = sep->sep_tpg; tpg = sep->sep_tpg;
ret = snprintf(page, PAGE_SIZE, "%u\n", ret = snprintf(page, PAGE_SIZE, "%u\n",
TPG_TFO(tpg)->tpg_get_inst_index(tpg)); tpg->se_tpg_tfo->tpg_get_inst_index(tpg));
spin_unlock(&lun->lun_sep_lock); spin_unlock(&lun->lun_sep_lock);
return ret; return ret;
} }
...@@ -1173,10 +1171,10 @@ static ssize_t target_stat_scsi_transport_show_attr_dev_name( ...@@ -1173,10 +1171,10 @@ static ssize_t target_stat_scsi_transport_show_attr_dev_name(
return -ENODEV; return -ENODEV;
} }
tpg = sep->sep_tpg; tpg = sep->sep_tpg;
wwn = DEV_T10_WWN(dev); wwn = &dev->se_sub_dev->t10_wwn;
/* scsiTransportDevName */ /* scsiTransportDevName */
ret = snprintf(page, PAGE_SIZE, "%s+%s\n", ret = snprintf(page, PAGE_SIZE, "%s+%s\n",
TPG_TFO(tpg)->tpg_get_wwn(tpg), tpg->se_tpg_tfo->tpg_get_wwn(tpg),
(strlen(wwn->unit_serial)) ? wwn->unit_serial : (strlen(wwn->unit_serial)) ? wwn->unit_serial :
wwn->vendor); wwn->vendor);
spin_unlock(&lun->lun_sep_lock); spin_unlock(&lun->lun_sep_lock);
...@@ -1212,18 +1210,18 @@ static struct config_item_type target_stat_scsi_transport_cit = { ...@@ -1212,18 +1210,18 @@ static struct config_item_type target_stat_scsi_transport_cit = {
*/ */
void target_stat_setup_port_default_groups(struct se_lun *lun) void target_stat_setup_port_default_groups(struct se_lun *lun)
{ {
struct config_group *port_stat_grp = &PORT_STAT_GRP(lun)->stat_group; struct config_group *port_stat_grp = &lun->port_stat_grps.stat_group;
config_group_init_type_name(&PORT_STAT_GRP(lun)->scsi_port_group, config_group_init_type_name(&lun->port_stat_grps.scsi_port_group,
"scsi_port", &target_stat_scsi_port_cit); "scsi_port", &target_stat_scsi_port_cit);
config_group_init_type_name(&PORT_STAT_GRP(lun)->scsi_tgt_port_group, config_group_init_type_name(&lun->port_stat_grps.scsi_tgt_port_group,
"scsi_tgt_port", &target_stat_scsi_tgt_port_cit); "scsi_tgt_port", &target_stat_scsi_tgt_port_cit);
config_group_init_type_name(&PORT_STAT_GRP(lun)->scsi_transport_group, config_group_init_type_name(&lun->port_stat_grps.scsi_transport_group,
"scsi_transport", &target_stat_scsi_transport_cit); "scsi_transport", &target_stat_scsi_transport_cit);
port_stat_grp->default_groups[0] = &PORT_STAT_GRP(lun)->scsi_port_group; port_stat_grp->default_groups[0] = &lun->port_stat_grps.scsi_port_group;
port_stat_grp->default_groups[1] = &PORT_STAT_GRP(lun)->scsi_tgt_port_group; port_stat_grp->default_groups[1] = &lun->port_stat_grps.scsi_tgt_port_group;
port_stat_grp->default_groups[2] = &PORT_STAT_GRP(lun)->scsi_transport_group; port_stat_grp->default_groups[2] = &lun->port_stat_grps.scsi_transport_group;
port_stat_grp->default_groups[3] = NULL; port_stat_grp->default_groups[3] = NULL;
} }
...@@ -1264,7 +1262,7 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_inst( ...@@ -1264,7 +1262,7 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_inst(
tpg = nacl->se_tpg; tpg = nacl->se_tpg;
/* scsiInstIndex */ /* scsiInstIndex */
ret = snprintf(page, PAGE_SIZE, "%u\n", ret = snprintf(page, PAGE_SIZE, "%u\n",
TPG_TFO(tpg)->tpg_get_inst_index(tpg)); tpg->se_tpg_tfo->tpg_get_inst_index(tpg));
spin_unlock_irq(&nacl->device_list_lock); spin_unlock_irq(&nacl->device_list_lock);
return ret; return ret;
} }
...@@ -1314,7 +1312,7 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_port( ...@@ -1314,7 +1312,7 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_port(
} }
tpg = nacl->se_tpg; tpg = nacl->se_tpg;
/* scsiAuthIntrTgtPortIndex */ /* scsiAuthIntrTgtPortIndex */
ret = snprintf(page, PAGE_SIZE, "%u\n", TPG_TFO(tpg)->tpg_get_tag(tpg)); ret = snprintf(page, PAGE_SIZE, "%u\n", tpg->se_tpg_tfo->tpg_get_tag(tpg));
spin_unlock_irq(&nacl->device_list_lock); spin_unlock_irq(&nacl->device_list_lock);
return ret; return ret;
} }
...@@ -1632,7 +1630,7 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_inst( ...@@ -1632,7 +1630,7 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_inst(
tpg = nacl->se_tpg; tpg = nacl->se_tpg;
/* scsiInstIndex */ /* scsiInstIndex */
ret = snprintf(page, PAGE_SIZE, "%u\n", ret = snprintf(page, PAGE_SIZE, "%u\n",
TPG_TFO(tpg)->tpg_get_inst_index(tpg)); tpg->se_tpg_tfo->tpg_get_inst_index(tpg));
spin_unlock_irq(&nacl->device_list_lock); spin_unlock_irq(&nacl->device_list_lock);
return ret; return ret;
} }
...@@ -1682,7 +1680,7 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_port( ...@@ -1682,7 +1680,7 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_port(
} }
tpg = nacl->se_tpg; tpg = nacl->se_tpg;
/* scsiPortIndex */ /* scsiPortIndex */
ret = snprintf(page, PAGE_SIZE, "%u\n", TPG_TFO(tpg)->tpg_get_tag(tpg)); ret = snprintf(page, PAGE_SIZE, "%u\n", tpg->se_tpg_tfo->tpg_get_tag(tpg));
spin_unlock_irq(&nacl->device_list_lock); spin_unlock_irq(&nacl->device_list_lock);
return ret; return ret;
} }
...@@ -1708,7 +1706,7 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_indx( ...@@ -1708,7 +1706,7 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_indx(
tpg = nacl->se_tpg; tpg = nacl->se_tpg;
/* scsiAttIntrPortIndex */ /* scsiAttIntrPortIndex */
ret = snprintf(page, PAGE_SIZE, "%u\n", ret = snprintf(page, PAGE_SIZE, "%u\n",
TPG_TFO(tpg)->sess_get_index(se_sess)); tpg->se_tpg_tfo->sess_get_index(se_sess));
spin_unlock_irq(&nacl->nacl_sess_lock); spin_unlock_irq(&nacl->nacl_sess_lock);
return ret; return ret;
} }
...@@ -1757,8 +1755,8 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_port_ident( ...@@ -1757,8 +1755,8 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_port_ident(
tpg = nacl->se_tpg; tpg = nacl->se_tpg;
/* scsiAttIntrPortName+scsiAttIntrPortIdentifier */ /* scsiAttIntrPortName+scsiAttIntrPortIdentifier */
memset(buf, 0, 64); memset(buf, 0, 64);
if (TPG_TFO(tpg)->sess_get_initiator_sid != NULL) if (tpg->se_tpg_tfo->sess_get_initiator_sid != NULL)
TPG_TFO(tpg)->sess_get_initiator_sid(se_sess, tpg->se_tpg_tfo->sess_get_initiator_sid(se_sess,
(unsigned char *)&buf[0], 64); (unsigned char *)&buf[0], 64);
ret = snprintf(page, PAGE_SIZE, "%s+i+%s\n", nacl->initiatorname, buf); ret = snprintf(page, PAGE_SIZE, "%s+i+%s\n", nacl->initiatorname, buf);
...@@ -1797,14 +1795,14 @@ static struct config_item_type target_stat_scsi_att_intr_port_cit = { ...@@ -1797,14 +1795,14 @@ static struct config_item_type target_stat_scsi_att_intr_port_cit = {
*/ */
void target_stat_setup_mappedlun_default_groups(struct se_lun_acl *lacl) void target_stat_setup_mappedlun_default_groups(struct se_lun_acl *lacl)
{ {
struct config_group *ml_stat_grp = &ML_STAT_GRPS(lacl)->stat_group; struct config_group *ml_stat_grp = &lacl->ml_stat_grps.stat_group;
config_group_init_type_name(&ML_STAT_GRPS(lacl)->scsi_auth_intr_group, config_group_init_type_name(&lacl->ml_stat_grps.scsi_auth_intr_group,
"scsi_auth_intr", &target_stat_scsi_auth_intr_cit); "scsi_auth_intr", &target_stat_scsi_auth_intr_cit);
config_group_init_type_name(&ML_STAT_GRPS(lacl)->scsi_att_intr_port_group, config_group_init_type_name(&lacl->ml_stat_grps.scsi_att_intr_port_group,
"scsi_att_intr_port", &target_stat_scsi_att_intr_port_cit); "scsi_att_intr_port", &target_stat_scsi_att_intr_port_cit);
ml_stat_grp->default_groups[0] = &ML_STAT_GRPS(lacl)->scsi_auth_intr_group; ml_stat_grp->default_groups[0] = &lacl->ml_stat_grps.scsi_auth_intr_group;
ml_stat_grp->default_groups[1] = &ML_STAT_GRPS(lacl)->scsi_att_intr_port_group; ml_stat_grp->default_groups[1] = &lacl->ml_stat_grps.scsi_att_intr_port_group;
ml_stat_grp->default_groups[2] = NULL; ml_stat_grp->default_groups[2] = NULL;
} }
...@@ -117,7 +117,7 @@ int core_tmr_lun_reset( ...@@ -117,7 +117,7 @@ int core_tmr_lun_reset(
struct se_queue_req *qr, *qr_tmp; struct se_queue_req *qr, *qr_tmp;
struct se_node_acl *tmr_nacl = NULL; struct se_node_acl *tmr_nacl = NULL;
struct se_portal_group *tmr_tpg = NULL; struct se_portal_group *tmr_tpg = NULL;
struct se_queue_obj *qobj = dev->dev_queue_obj; struct se_queue_obj *qobj = &dev->dev_queue_obj;
struct se_tmr_req *tmr_p, *tmr_pp; struct se_tmr_req *tmr_p, *tmr_pp;
struct se_task *task, *task_tmp; struct se_task *task, *task_tmp;
unsigned long flags; unsigned long flags;
...@@ -133,7 +133,7 @@ int core_tmr_lun_reset( ...@@ -133,7 +133,7 @@ int core_tmr_lun_reset(
* which the command was received shall be completed with TASK ABORTED * which the command was received shall be completed with TASK ABORTED
* status (see SAM-4). * status (see SAM-4).
*/ */
tas = DEV_ATTRIB(dev)->emulate_tas; tas = dev->se_sub_dev->se_dev_attrib.emulate_tas;
/* /*
* Determine if this se_tmr is coming from a $FABRIC_MOD * Determine if this se_tmr is coming from a $FABRIC_MOD
* or struct se_device passthrough.. * or struct se_device passthrough..
...@@ -144,13 +144,13 @@ int core_tmr_lun_reset( ...@@ -144,13 +144,13 @@ int core_tmr_lun_reset(
if (tmr_nacl && tmr_tpg) { if (tmr_nacl && tmr_tpg) {
DEBUG_LR("LUN_RESET: TMR caller fabric: %s" DEBUG_LR("LUN_RESET: TMR caller fabric: %s"
" initiator port %s\n", " initiator port %s\n",
TPG_TFO(tmr_tpg)->get_fabric_name(), tmr_tpg->se_tpg_tfo->get_fabric_name(),
tmr_nacl->initiatorname); tmr_nacl->initiatorname);
} }
} }
DEBUG_LR("LUN_RESET: %s starting for [%s], tas: %d\n", DEBUG_LR("LUN_RESET: %s starting for [%s], tas: %d\n",
(preempt_and_abort_list) ? "Preempt" : "TMR", (preempt_and_abort_list) ? "Preempt" : "TMR",
TRANSPORT(dev)->name, tas); dev->transport->name, tas);
/* /*
* Release all pending and outgoing TMRs aside from the received * Release all pending and outgoing TMRs aside from the received
* LUN_RESET tmr.. * LUN_RESET tmr..
...@@ -179,14 +179,14 @@ int core_tmr_lun_reset( ...@@ -179,14 +179,14 @@ int core_tmr_lun_reset(
continue; continue;
spin_unlock(&dev->se_tmr_lock); spin_unlock(&dev->se_tmr_lock);
spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); spin_lock_irqsave(&cmd->t_task->t_state_lock, flags);
if (!(atomic_read(&T_TASK(cmd)->t_transport_active))) { if (!(atomic_read(&cmd->t_task->t_transport_active))) {
spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); spin_unlock_irqrestore(&cmd->t_task->t_state_lock, flags);
spin_lock(&dev->se_tmr_lock); spin_lock(&dev->se_tmr_lock);
continue; continue;
} }
if (cmd->t_state == TRANSPORT_ISTATE_PROCESSING) { if (cmd->t_state == TRANSPORT_ISTATE_PROCESSING) {
spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); spin_unlock_irqrestore(&cmd->t_task->t_state_lock, flags);
spin_lock(&dev->se_tmr_lock); spin_lock(&dev->se_tmr_lock);
continue; continue;
} }
...@@ -194,7 +194,7 @@ int core_tmr_lun_reset( ...@@ -194,7 +194,7 @@ int core_tmr_lun_reset(
" Response: 0x%02x, t_state: %d\n", " Response: 0x%02x, t_state: %d\n",
(preempt_and_abort_list) ? "Preempt" : "", tmr_p, (preempt_and_abort_list) ? "Preempt" : "", tmr_p,
tmr_p->function, tmr_p->response, cmd->t_state); tmr_p->function, tmr_p->response, cmd->t_state);
spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); spin_unlock_irqrestore(&cmd->t_task->t_state_lock, flags);
transport_cmd_finish_abort_tmr(cmd); transport_cmd_finish_abort_tmr(cmd);
spin_lock(&dev->se_tmr_lock); spin_lock(&dev->se_tmr_lock);
...@@ -224,16 +224,16 @@ int core_tmr_lun_reset( ...@@ -224,16 +224,16 @@ int core_tmr_lun_reset(
spin_lock_irqsave(&dev->execute_task_lock, flags); spin_lock_irqsave(&dev->execute_task_lock, flags);
list_for_each_entry_safe(task, task_tmp, &dev->state_task_list, list_for_each_entry_safe(task, task_tmp, &dev->state_task_list,
t_state_list) { t_state_list) {
if (!(TASK_CMD(task))) { if (!task->task_se_cmd) {
printk(KERN_ERR "TASK_CMD(task) is NULL!\n"); printk(KERN_ERR "task->task_se_cmd is NULL!\n");
continue; continue;
} }
cmd = TASK_CMD(task); cmd = task->task_se_cmd;
if (!T_TASK(cmd)) { if (!cmd->t_task) {
printk(KERN_ERR "T_TASK(cmd) is NULL for task: %p cmd:" printk(KERN_ERR "cmd->t_task is NULL for task: %p cmd:"
" %p ITT: 0x%08x\n", task, cmd, " %p ITT: 0x%08x\n", task, cmd,
CMD_TFO(cmd)->get_task_tag(cmd)); cmd->se_tfo->get_task_tag(cmd));
continue; continue;
} }
/* /*
...@@ -254,38 +254,38 @@ int core_tmr_lun_reset( ...@@ -254,38 +254,38 @@ int core_tmr_lun_reset(
atomic_set(&task->task_state_active, 0); atomic_set(&task->task_state_active, 0);
spin_unlock_irqrestore(&dev->execute_task_lock, flags); spin_unlock_irqrestore(&dev->execute_task_lock, flags);
spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); spin_lock_irqsave(&cmd->t_task->t_state_lock, flags);
DEBUG_LR("LUN_RESET: %s cmd: %p task: %p" DEBUG_LR("LUN_RESET: %s cmd: %p task: %p"
" ITT/CmdSN: 0x%08x/0x%08x, i_state: %d, t_state/" " ITT/CmdSN: 0x%08x/0x%08x, i_state: %d, t_state/"
"def_t_state: %d/%d cdb: 0x%02x\n", "def_t_state: %d/%d cdb: 0x%02x\n",
(preempt_and_abort_list) ? "Preempt" : "", cmd, task, (preempt_and_abort_list) ? "Preempt" : "", cmd, task,
CMD_TFO(cmd)->get_task_tag(cmd), 0, cmd->se_tfo->get_task_tag(cmd), 0,
CMD_TFO(cmd)->get_cmd_state(cmd), cmd->t_state, cmd->se_tfo->get_cmd_state(cmd), cmd->t_state,
cmd->deferred_t_state, T_TASK(cmd)->t_task_cdb[0]); cmd->deferred_t_state, cmd->t_task->t_task_cdb[0]);
DEBUG_LR("LUN_RESET: ITT[0x%08x] - pr_res_key: 0x%016Lx" DEBUG_LR("LUN_RESET: ITT[0x%08x] - pr_res_key: 0x%016Lx"
" t_task_cdbs: %d t_task_cdbs_left: %d" " t_task_cdbs: %d t_task_cdbs_left: %d"
" t_task_cdbs_sent: %d -- t_transport_active: %d" " t_task_cdbs_sent: %d -- t_transport_active: %d"
" t_transport_stop: %d t_transport_sent: %d\n", " t_transport_stop: %d t_transport_sent: %d\n",
CMD_TFO(cmd)->get_task_tag(cmd), cmd->pr_res_key, cmd->se_tfo->get_task_tag(cmd), cmd->pr_res_key,
T_TASK(cmd)->t_task_cdbs, cmd->t_task->t_task_cdbs,
atomic_read(&T_TASK(cmd)->t_task_cdbs_left), atomic_read(&cmd->t_task->t_task_cdbs_left),
atomic_read(&T_TASK(cmd)->t_task_cdbs_sent), atomic_read(&cmd->t_task->t_task_cdbs_sent),
atomic_read(&T_TASK(cmd)->t_transport_active), atomic_read(&cmd->t_task->t_transport_active),
atomic_read(&T_TASK(cmd)->t_transport_stop), atomic_read(&cmd->t_task->t_transport_stop),
atomic_read(&T_TASK(cmd)->t_transport_sent)); atomic_read(&cmd->t_task->t_transport_sent));
if (atomic_read(&task->task_active)) { if (atomic_read(&task->task_active)) {
atomic_set(&task->task_stop, 1); atomic_set(&task->task_stop, 1);
spin_unlock_irqrestore( spin_unlock_irqrestore(
&T_TASK(cmd)->t_state_lock, flags); &cmd->t_task->t_state_lock, flags);
DEBUG_LR("LUN_RESET: Waiting for task: %p to shutdown" DEBUG_LR("LUN_RESET: Waiting for task: %p to shutdown"
" for dev: %p\n", task, dev); " for dev: %p\n", task, dev);
wait_for_completion(&task->task_stop_comp); wait_for_completion(&task->task_stop_comp);
DEBUG_LR("LUN_RESET Completed task: %p shutdown for" DEBUG_LR("LUN_RESET Completed task: %p shutdown for"
" dev: %p\n", task, dev); " dev: %p\n", task, dev);
spin_lock_irqsave(&T_TASK(cmd)->t_state_lock, flags); spin_lock_irqsave(&cmd->t_task->t_state_lock, flags);
atomic_dec(&T_TASK(cmd)->t_task_cdbs_left); atomic_dec(&cmd->t_task->t_task_cdbs_left);
atomic_set(&task->task_active, 0); atomic_set(&task->task_active, 0);
atomic_set(&task->task_stop, 0); atomic_set(&task->task_stop, 0);
...@@ -295,24 +295,24 @@ int core_tmr_lun_reset( ...@@ -295,24 +295,24 @@ int core_tmr_lun_reset(
} }
__transport_stop_task_timer(task, &flags); __transport_stop_task_timer(task, &flags);
if (!(atomic_dec_and_test(&T_TASK(cmd)->t_task_cdbs_ex_left))) { if (!(atomic_dec_and_test(&cmd->t_task->t_task_cdbs_ex_left))) {
spin_unlock_irqrestore( spin_unlock_irqrestore(
&T_TASK(cmd)->t_state_lock, flags); &cmd->t_task->t_state_lock, flags);
DEBUG_LR("LUN_RESET: Skipping task: %p, dev: %p for" DEBUG_LR("LUN_RESET: Skipping task: %p, dev: %p for"
" t_task_cdbs_ex_left: %d\n", task, dev, " t_task_cdbs_ex_left: %d\n", task, dev,
atomic_read(&T_TASK(cmd)->t_task_cdbs_ex_left)); atomic_read(&cmd->t_task->t_task_cdbs_ex_left));
spin_lock_irqsave(&dev->execute_task_lock, flags); spin_lock_irqsave(&dev->execute_task_lock, flags);
continue; continue;
} }
fe_count = atomic_read(&T_TASK(cmd)->t_fe_count); fe_count = atomic_read(&cmd->t_task->t_fe_count);
if (atomic_read(&T_TASK(cmd)->t_transport_active)) { if (atomic_read(&cmd->t_task->t_transport_active)) {
DEBUG_LR("LUN_RESET: got t_transport_active = 1 for" DEBUG_LR("LUN_RESET: got t_transport_active = 1 for"
" task: %p, t_fe_count: %d dev: %p\n", task, " task: %p, t_fe_count: %d dev: %p\n", task,
fe_count, dev); fe_count, dev);
atomic_set(&T_TASK(cmd)->t_transport_aborted, 1); atomic_set(&cmd->t_task->t_transport_aborted, 1);
spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, spin_unlock_irqrestore(&cmd->t_task->t_state_lock,
flags); flags);
core_tmr_handle_tas_abort(tmr_nacl, cmd, tas, fe_count); core_tmr_handle_tas_abort(tmr_nacl, cmd, tas, fe_count);
...@@ -321,8 +321,8 @@ int core_tmr_lun_reset( ...@@ -321,8 +321,8 @@ int core_tmr_lun_reset(
} }
DEBUG_LR("LUN_RESET: Got t_transport_active = 0 for task: %p," DEBUG_LR("LUN_RESET: Got t_transport_active = 0 for task: %p,"
" t_fe_count: %d dev: %p\n", task, fe_count, dev); " t_fe_count: %d dev: %p\n", task, fe_count, dev);
atomic_set(&T_TASK(cmd)->t_transport_aborted, 1); atomic_set(&cmd->t_task->t_transport_aborted, 1);
spin_unlock_irqrestore(&T_TASK(cmd)->t_state_lock, flags); spin_unlock_irqrestore(&cmd->t_task->t_state_lock, flags);
core_tmr_handle_tas_abort(tmr_nacl, cmd, tas, fe_count); core_tmr_handle_tas_abort(tmr_nacl, cmd, tas, fe_count);
spin_lock_irqsave(&dev->execute_task_lock, flags); spin_lock_irqsave(&dev->execute_task_lock, flags);
...@@ -365,7 +365,7 @@ int core_tmr_lun_reset( ...@@ -365,7 +365,7 @@ int core_tmr_lun_reset(
if (prout_cmd == cmd) if (prout_cmd == cmd)
continue; continue;
atomic_dec(&T_TASK(cmd)->t_transport_queue_active); atomic_dec(&cmd->t_task->t_transport_queue_active);
atomic_dec(&qobj->queue_cnt); atomic_dec(&qobj->queue_cnt);
list_del(&qr->qr_list); list_del(&qr->qr_list);
spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags); spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags);
...@@ -376,7 +376,7 @@ int core_tmr_lun_reset( ...@@ -376,7 +376,7 @@ int core_tmr_lun_reset(
DEBUG_LR("LUN_RESET: %s from Device Queue: cmd: %p t_state:" DEBUG_LR("LUN_RESET: %s from Device Queue: cmd: %p t_state:"
" %d t_fe_count: %d\n", (preempt_and_abort_list) ? " %d t_fe_count: %d\n", (preempt_and_abort_list) ?
"Preempt" : "", cmd, state, "Preempt" : "", cmd, state,
atomic_read(&T_TASK(cmd)->t_fe_count)); atomic_read(&cmd->t_task->t_fe_count));
/* /*
* Signal that the command has failed via cmd->se_cmd_flags, * Signal that the command has failed via cmd->se_cmd_flags,
* and call TFO->new_cmd_failure() to wakeup any fabric * and call TFO->new_cmd_failure() to wakeup any fabric
...@@ -388,7 +388,7 @@ int core_tmr_lun_reset( ...@@ -388,7 +388,7 @@ int core_tmr_lun_reset(
transport_new_cmd_failure(cmd); transport_new_cmd_failure(cmd);
core_tmr_handle_tas_abort(tmr_nacl, cmd, tas, core_tmr_handle_tas_abort(tmr_nacl, cmd, tas,
atomic_read(&T_TASK(cmd)->t_fe_count)); atomic_read(&cmd->t_task->t_fe_count));
spin_lock_irqsave(&qobj->cmd_queue_lock, flags); spin_lock_irqsave(&qobj->cmd_queue_lock, flags);
} }
spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags); spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags);
...@@ -411,6 +411,6 @@ int core_tmr_lun_reset( ...@@ -411,6 +411,6 @@ int core_tmr_lun_reset(
DEBUG_LR("LUN_RESET: %s for [%s] Complete\n", DEBUG_LR("LUN_RESET: %s for [%s] Complete\n",
(preempt_and_abort_list) ? "Preempt" : "TMR", (preempt_and_abort_list) ? "Preempt" : "TMR",
TRANSPORT(dev)->name); dev->transport->name);
return 0; return 0;
} }
...@@ -44,6 +44,12 @@ ...@@ -44,6 +44,12 @@
#include <target/target_core_fabric_ops.h> #include <target/target_core_fabric_ops.h>
#include "target_core_hba.h" #include "target_core_hba.h"
#include "target_core_stat.h"
extern struct se_device *g_lun0_dev;
static DEFINE_SPINLOCK(tpg_lock);
static LIST_HEAD(tpg_list);
/* core_clear_initiator_node_from_tpg(): /* core_clear_initiator_node_from_tpg():
* *
...@@ -68,7 +74,7 @@ static void core_clear_initiator_node_from_tpg( ...@@ -68,7 +74,7 @@ static void core_clear_initiator_node_from_tpg(
if (!deve->se_lun) { if (!deve->se_lun) {
printk(KERN_ERR "%s device entries device pointer is" printk(KERN_ERR "%s device entries device pointer is"
" NULL, but Initiator has access.\n", " NULL, but Initiator has access.\n",
TPG_TFO(tpg)->get_fabric_name()); tpg->se_tpg_tfo->get_fabric_name());
continue; continue;
} }
...@@ -171,7 +177,7 @@ void core_tpg_add_node_to_devs( ...@@ -171,7 +177,7 @@ void core_tpg_add_node_to_devs(
* By default in LIO-Target $FABRIC_MOD, * By default in LIO-Target $FABRIC_MOD,
* demo_mode_write_protect is ON, or READ_ONLY; * demo_mode_write_protect is ON, or READ_ONLY;
*/ */
if (!(TPG_TFO(tpg)->tpg_check_demo_mode_write_protect(tpg))) { if (!(tpg->se_tpg_tfo->tpg_check_demo_mode_write_protect(tpg))) {
if (dev->dev_flags & DF_READ_ONLY) if (dev->dev_flags & DF_READ_ONLY)
lun_access = TRANSPORT_LUNFLAGS_READ_ONLY; lun_access = TRANSPORT_LUNFLAGS_READ_ONLY;
else else
...@@ -181,7 +187,7 @@ void core_tpg_add_node_to_devs( ...@@ -181,7 +187,7 @@ void core_tpg_add_node_to_devs(
* Allow only optical drives to issue R/W in default RO * Allow only optical drives to issue R/W in default RO
* demo mode. * demo mode.
*/ */
if (TRANSPORT(dev)->get_device_type(dev) == TYPE_DISK) if (dev->transport->get_device_type(dev) == TYPE_DISK)
lun_access = TRANSPORT_LUNFLAGS_READ_ONLY; lun_access = TRANSPORT_LUNFLAGS_READ_ONLY;
else else
lun_access = TRANSPORT_LUNFLAGS_READ_WRITE; lun_access = TRANSPORT_LUNFLAGS_READ_WRITE;
...@@ -189,8 +195,8 @@ void core_tpg_add_node_to_devs( ...@@ -189,8 +195,8 @@ void core_tpg_add_node_to_devs(
printk(KERN_INFO "TARGET_CORE[%s]->TPG[%u]_LUN[%u] - Adding %s" printk(KERN_INFO "TARGET_CORE[%s]->TPG[%u]_LUN[%u] - Adding %s"
" access for LUN in Demo Mode\n", " access for LUN in Demo Mode\n",
TPG_TFO(tpg)->get_fabric_name(), tpg->se_tpg_tfo->get_fabric_name(),
TPG_TFO(tpg)->tpg_get_tag(tpg), lun->unpacked_lun, tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun,
(lun_access == TRANSPORT_LUNFLAGS_READ_WRITE) ? (lun_access == TRANSPORT_LUNFLAGS_READ_WRITE) ?
"READ-WRITE" : "READ-ONLY"); "READ-WRITE" : "READ-ONLY");
...@@ -211,7 +217,7 @@ static int core_set_queue_depth_for_node( ...@@ -211,7 +217,7 @@ static int core_set_queue_depth_for_node(
{ {
if (!acl->queue_depth) { if (!acl->queue_depth) {
printk(KERN_ERR "Queue depth for %s Initiator Node: %s is 0," printk(KERN_ERR "Queue depth for %s Initiator Node: %s is 0,"
"defaulting to 1.\n", TPG_TFO(tpg)->get_fabric_name(), "defaulting to 1.\n", tpg->se_tpg_tfo->get_fabric_name(),
acl->initiatorname); acl->initiatorname);
acl->queue_depth = 1; acl->queue_depth = 1;
} }
...@@ -233,7 +239,7 @@ static int core_create_device_list_for_node(struct se_node_acl *nacl) ...@@ -233,7 +239,7 @@ static int core_create_device_list_for_node(struct se_node_acl *nacl)
if (!(nacl->device_list)) { if (!(nacl->device_list)) {
printk(KERN_ERR "Unable to allocate memory for" printk(KERN_ERR "Unable to allocate memory for"
" struct se_node_acl->device_list\n"); " struct se_node_acl->device_list\n");
return -1; return -ENOMEM;
} }
for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) { for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) {
deve = &nacl->device_list[i]; deve = &nacl->device_list[i];
...@@ -262,10 +268,10 @@ struct se_node_acl *core_tpg_check_initiator_node_acl( ...@@ -262,10 +268,10 @@ struct se_node_acl *core_tpg_check_initiator_node_acl(
if ((acl)) if ((acl))
return acl; return acl;
if (!(TPG_TFO(tpg)->tpg_check_demo_mode(tpg))) if (!(tpg->se_tpg_tfo->tpg_check_demo_mode(tpg)))
return NULL; return NULL;
acl = TPG_TFO(tpg)->tpg_alloc_fabric_acl(tpg); acl = tpg->se_tpg_tfo->tpg_alloc_fabric_acl(tpg);
if (!(acl)) if (!(acl))
return NULL; return NULL;
...@@ -274,23 +280,23 @@ struct se_node_acl *core_tpg_check_initiator_node_acl( ...@@ -274,23 +280,23 @@ struct se_node_acl *core_tpg_check_initiator_node_acl(
spin_lock_init(&acl->device_list_lock); spin_lock_init(&acl->device_list_lock);
spin_lock_init(&acl->nacl_sess_lock); spin_lock_init(&acl->nacl_sess_lock);
atomic_set(&acl->acl_pr_ref_count, 0); atomic_set(&acl->acl_pr_ref_count, 0);
acl->queue_depth = TPG_TFO(tpg)->tpg_get_default_depth(tpg); acl->queue_depth = tpg->se_tpg_tfo->tpg_get_default_depth(tpg);
snprintf(acl->initiatorname, TRANSPORT_IQN_LEN, "%s", initiatorname); snprintf(acl->initiatorname, TRANSPORT_IQN_LEN, "%s", initiatorname);
acl->se_tpg = tpg; acl->se_tpg = tpg;
acl->acl_index = scsi_get_new_index(SCSI_AUTH_INTR_INDEX); acl->acl_index = scsi_get_new_index(SCSI_AUTH_INTR_INDEX);
spin_lock_init(&acl->stats_lock); spin_lock_init(&acl->stats_lock);
acl->dynamic_node_acl = 1; acl->dynamic_node_acl = 1;
TPG_TFO(tpg)->set_default_node_attributes(acl); tpg->se_tpg_tfo->set_default_node_attributes(acl);
if (core_create_device_list_for_node(acl) < 0) { if (core_create_device_list_for_node(acl) < 0) {
TPG_TFO(tpg)->tpg_release_fabric_acl(tpg, acl); tpg->se_tpg_tfo->tpg_release_fabric_acl(tpg, acl);
return NULL; return NULL;
} }
if (core_set_queue_depth_for_node(tpg, acl) < 0) { if (core_set_queue_depth_for_node(tpg, acl) < 0) {
core_free_device_list_for_node(acl, tpg); core_free_device_list_for_node(acl, tpg);
TPG_TFO(tpg)->tpg_release_fabric_acl(tpg, acl); tpg->se_tpg_tfo->tpg_release_fabric_acl(tpg, acl);
return NULL; return NULL;
} }
...@@ -302,9 +308,9 @@ struct se_node_acl *core_tpg_check_initiator_node_acl( ...@@ -302,9 +308,9 @@ struct se_node_acl *core_tpg_check_initiator_node_acl(
spin_unlock_bh(&tpg->acl_node_lock); spin_unlock_bh(&tpg->acl_node_lock);
printk("%s_TPG[%u] - Added DYNAMIC ACL with TCQ Depth: %d for %s" printk("%s_TPG[%u] - Added DYNAMIC ACL with TCQ Depth: %d for %s"
" Initiator Node: %s\n", TPG_TFO(tpg)->get_fabric_name(), " Initiator Node: %s\n", tpg->se_tpg_tfo->get_fabric_name(),
TPG_TFO(tpg)->tpg_get_tag(tpg), acl->queue_depth, tpg->se_tpg_tfo->tpg_get_tag(tpg), acl->queue_depth,
TPG_TFO(tpg)->get_fabric_name(), initiatorname); tpg->se_tpg_tfo->get_fabric_name(), initiatorname);
return acl; return acl;
} }
...@@ -355,8 +361,8 @@ struct se_node_acl *core_tpg_add_initiator_node_acl( ...@@ -355,8 +361,8 @@ struct se_node_acl *core_tpg_add_initiator_node_acl(
if (acl->dynamic_node_acl) { if (acl->dynamic_node_acl) {
acl->dynamic_node_acl = 0; acl->dynamic_node_acl = 0;
printk(KERN_INFO "%s_TPG[%u] - Replacing dynamic ACL" printk(KERN_INFO "%s_TPG[%u] - Replacing dynamic ACL"
" for %s\n", TPG_TFO(tpg)->get_fabric_name(), " for %s\n", tpg->se_tpg_tfo->get_fabric_name(),
TPG_TFO(tpg)->tpg_get_tag(tpg), initiatorname); tpg->se_tpg_tfo->tpg_get_tag(tpg), initiatorname);
spin_unlock_bh(&tpg->acl_node_lock); spin_unlock_bh(&tpg->acl_node_lock);
/* /*
* Release the locally allocated struct se_node_acl * Release the locally allocated struct se_node_acl
...@@ -364,15 +370,15 @@ struct se_node_acl *core_tpg_add_initiator_node_acl( ...@@ -364,15 +370,15 @@ struct se_node_acl *core_tpg_add_initiator_node_acl(
* a pointer to an existing demo mode node ACL. * a pointer to an existing demo mode node ACL.
*/ */
if (se_nacl) if (se_nacl)
TPG_TFO(tpg)->tpg_release_fabric_acl(tpg, tpg->se_tpg_tfo->tpg_release_fabric_acl(tpg,
se_nacl); se_nacl);
goto done; goto done;
} }
printk(KERN_ERR "ACL entry for %s Initiator" printk(KERN_ERR "ACL entry for %s Initiator"
" Node %s already exists for TPG %u, ignoring" " Node %s already exists for TPG %u, ignoring"
" request.\n", TPG_TFO(tpg)->get_fabric_name(), " request.\n", tpg->se_tpg_tfo->get_fabric_name(),
initiatorname, TPG_TFO(tpg)->tpg_get_tag(tpg)); initiatorname, tpg->se_tpg_tfo->tpg_get_tag(tpg));
spin_unlock_bh(&tpg->acl_node_lock); spin_unlock_bh(&tpg->acl_node_lock);
return ERR_PTR(-EEXIST); return ERR_PTR(-EEXIST);
} }
...@@ -400,16 +406,16 @@ struct se_node_acl *core_tpg_add_initiator_node_acl( ...@@ -400,16 +406,16 @@ struct se_node_acl *core_tpg_add_initiator_node_acl(
acl->acl_index = scsi_get_new_index(SCSI_AUTH_INTR_INDEX); acl->acl_index = scsi_get_new_index(SCSI_AUTH_INTR_INDEX);
spin_lock_init(&acl->stats_lock); spin_lock_init(&acl->stats_lock);
TPG_TFO(tpg)->set_default_node_attributes(acl); tpg->se_tpg_tfo->set_default_node_attributes(acl);
if (core_create_device_list_for_node(acl) < 0) { if (core_create_device_list_for_node(acl) < 0) {
TPG_TFO(tpg)->tpg_release_fabric_acl(tpg, acl); tpg->se_tpg_tfo->tpg_release_fabric_acl(tpg, acl);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
if (core_set_queue_depth_for_node(tpg, acl) < 0) { if (core_set_queue_depth_for_node(tpg, acl) < 0) {
core_free_device_list_for_node(acl, tpg); core_free_device_list_for_node(acl, tpg);
TPG_TFO(tpg)->tpg_release_fabric_acl(tpg, acl); tpg->se_tpg_tfo->tpg_release_fabric_acl(tpg, acl);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
...@@ -420,9 +426,9 @@ struct se_node_acl *core_tpg_add_initiator_node_acl( ...@@ -420,9 +426,9 @@ struct se_node_acl *core_tpg_add_initiator_node_acl(
done: done:
printk(KERN_INFO "%s_TPG[%hu] - Added ACL with TCQ Depth: %d for %s" printk(KERN_INFO "%s_TPG[%hu] - Added ACL with TCQ Depth: %d for %s"
" Initiator Node: %s\n", TPG_TFO(tpg)->get_fabric_name(), " Initiator Node: %s\n", tpg->se_tpg_tfo->get_fabric_name(),
TPG_TFO(tpg)->tpg_get_tag(tpg), acl->queue_depth, tpg->se_tpg_tfo->tpg_get_tag(tpg), acl->queue_depth,
TPG_TFO(tpg)->get_fabric_name(), initiatorname); tpg->se_tpg_tfo->get_fabric_name(), initiatorname);
return acl; return acl;
} }
...@@ -457,7 +463,7 @@ int core_tpg_del_initiator_node_acl( ...@@ -457,7 +463,7 @@ int core_tpg_del_initiator_node_acl(
/* /*
* Determine if the session needs to be closed by our context. * Determine if the session needs to be closed by our context.
*/ */
if (!(TPG_TFO(tpg)->shutdown_session(sess))) if (!(tpg->se_tpg_tfo->shutdown_session(sess)))
continue; continue;
spin_unlock_bh(&tpg->session_lock); spin_unlock_bh(&tpg->session_lock);
...@@ -465,7 +471,7 @@ int core_tpg_del_initiator_node_acl( ...@@ -465,7 +471,7 @@ int core_tpg_del_initiator_node_acl(
* If the $FABRIC_MOD session for the Initiator Node ACL exists, * If the $FABRIC_MOD session for the Initiator Node ACL exists,
* forcefully shutdown the $FABRIC_MOD session/nexus. * forcefully shutdown the $FABRIC_MOD session/nexus.
*/ */
TPG_TFO(tpg)->close_session(sess); tpg->se_tpg_tfo->close_session(sess);
spin_lock_bh(&tpg->session_lock); spin_lock_bh(&tpg->session_lock);
} }
...@@ -476,9 +482,9 @@ int core_tpg_del_initiator_node_acl( ...@@ -476,9 +482,9 @@ int core_tpg_del_initiator_node_acl(
core_free_device_list_for_node(acl, tpg); core_free_device_list_for_node(acl, tpg);
printk(KERN_INFO "%s_TPG[%hu] - Deleted ACL with TCQ Depth: %d for %s" printk(KERN_INFO "%s_TPG[%hu] - Deleted ACL with TCQ Depth: %d for %s"
" Initiator Node: %s\n", TPG_TFO(tpg)->get_fabric_name(), " Initiator Node: %s\n", tpg->se_tpg_tfo->get_fabric_name(),
TPG_TFO(tpg)->tpg_get_tag(tpg), acl->queue_depth, tpg->se_tpg_tfo->tpg_get_tag(tpg), acl->queue_depth,
TPG_TFO(tpg)->get_fabric_name(), acl->initiatorname); tpg->se_tpg_tfo->get_fabric_name(), acl->initiatorname);
return 0; return 0;
} }
...@@ -503,8 +509,8 @@ int core_tpg_set_initiator_node_queue_depth( ...@@ -503,8 +509,8 @@ int core_tpg_set_initiator_node_queue_depth(
if (!(acl)) { if (!(acl)) {
printk(KERN_ERR "Access Control List entry for %s Initiator" printk(KERN_ERR "Access Control List entry for %s Initiator"
" Node %s does not exists for TPG %hu, ignoring" " Node %s does not exists for TPG %hu, ignoring"
" request.\n", TPG_TFO(tpg)->get_fabric_name(), " request.\n", tpg->se_tpg_tfo->get_fabric_name(),
initiatorname, TPG_TFO(tpg)->tpg_get_tag(tpg)); initiatorname, tpg->se_tpg_tfo->tpg_get_tag(tpg));
spin_unlock_bh(&tpg->acl_node_lock); spin_unlock_bh(&tpg->acl_node_lock);
return -ENODEV; return -ENODEV;
} }
...@@ -525,7 +531,7 @@ int core_tpg_set_initiator_node_queue_depth( ...@@ -525,7 +531,7 @@ int core_tpg_set_initiator_node_queue_depth(
" operational. To forcefully change the queue" " operational. To forcefully change the queue"
" depth and force session reinstatement" " depth and force session reinstatement"
" use the \"force=1\" parameter.\n", " use the \"force=1\" parameter.\n",
TPG_TFO(tpg)->get_fabric_name(), initiatorname); tpg->se_tpg_tfo->get_fabric_name(), initiatorname);
spin_unlock_bh(&tpg->session_lock); spin_unlock_bh(&tpg->session_lock);
spin_lock_bh(&tpg->acl_node_lock); spin_lock_bh(&tpg->acl_node_lock);
...@@ -537,7 +543,7 @@ int core_tpg_set_initiator_node_queue_depth( ...@@ -537,7 +543,7 @@ int core_tpg_set_initiator_node_queue_depth(
/* /*
* Determine if the session needs to be closed by our context. * Determine if the session needs to be closed by our context.
*/ */
if (!(TPG_TFO(tpg)->shutdown_session(sess))) if (!(tpg->se_tpg_tfo->shutdown_session(sess)))
continue; continue;
init_sess = sess; init_sess = sess;
...@@ -549,7 +555,7 @@ int core_tpg_set_initiator_node_queue_depth( ...@@ -549,7 +555,7 @@ int core_tpg_set_initiator_node_queue_depth(
* Change the value in the Node's struct se_node_acl, and call * Change the value in the Node's struct se_node_acl, and call
* core_set_queue_depth_for_node() to add the requested queue depth. * core_set_queue_depth_for_node() to add the requested queue depth.
* *
* Finally call TPG_TFO(tpg)->close_session() to force session * Finally call tpg->se_tpg_tfo->close_session() to force session
* reinstatement to occur if there is an active session for the * reinstatement to occur if there is an active session for the
* $FABRIC_MOD Initiator Node in question. * $FABRIC_MOD Initiator Node in question.
*/ */
...@@ -561,10 +567,10 @@ int core_tpg_set_initiator_node_queue_depth( ...@@ -561,10 +567,10 @@ int core_tpg_set_initiator_node_queue_depth(
* Force session reinstatement if * Force session reinstatement if
* core_set_queue_depth_for_node() failed, because we assume * core_set_queue_depth_for_node() failed, because we assume
* the $FABRIC_MOD has already the set session reinstatement * the $FABRIC_MOD has already the set session reinstatement
* bit from TPG_TFO(tpg)->shutdown_session() called above. * bit from tpg->se_tpg_tfo->shutdown_session() called above.
*/ */
if (init_sess) if (init_sess)
TPG_TFO(tpg)->close_session(init_sess); tpg->se_tpg_tfo->close_session(init_sess);
spin_lock_bh(&tpg->acl_node_lock); spin_lock_bh(&tpg->acl_node_lock);
if (dynamic_acl) if (dynamic_acl)
...@@ -578,12 +584,12 @@ int core_tpg_set_initiator_node_queue_depth( ...@@ -578,12 +584,12 @@ int core_tpg_set_initiator_node_queue_depth(
* forcefully shutdown the $FABRIC_MOD session/nexus. * forcefully shutdown the $FABRIC_MOD session/nexus.
*/ */
if (init_sess) if (init_sess)
TPG_TFO(tpg)->close_session(init_sess); tpg->se_tpg_tfo->close_session(init_sess);
printk(KERN_INFO "Successfuly changed queue depth to: %d for Initiator" printk(KERN_INFO "Successfuly changed queue depth to: %d for Initiator"
" Node: %s on %s Target Portal Group: %u\n", queue_depth, " Node: %s on %s Target Portal Group: %u\n", queue_depth,
initiatorname, TPG_TFO(tpg)->get_fabric_name(), initiatorname, tpg->se_tpg_tfo->get_fabric_name(),
TPG_TFO(tpg)->tpg_get_tag(tpg)); tpg->se_tpg_tfo->tpg_get_tag(tpg));
spin_lock_bh(&tpg->acl_node_lock); spin_lock_bh(&tpg->acl_node_lock);
if (dynamic_acl) if (dynamic_acl)
...@@ -597,7 +603,7 @@ EXPORT_SYMBOL(core_tpg_set_initiator_node_queue_depth); ...@@ -597,7 +603,7 @@ EXPORT_SYMBOL(core_tpg_set_initiator_node_queue_depth);
static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg) static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg)
{ {
/* Set in core_dev_setup_virtual_lun0() */ /* Set in core_dev_setup_virtual_lun0() */
struct se_device *dev = se_global->g_lun0_dev; struct se_device *dev = g_lun0_dev;
struct se_lun *lun = &se_tpg->tpg_virt_lun0; struct se_lun *lun = &se_tpg->tpg_virt_lun0;
u32 lun_access = TRANSPORT_LUNFLAGS_READ_ONLY; u32 lun_access = TRANSPORT_LUNFLAGS_READ_ONLY;
int ret; int ret;
...@@ -614,7 +620,7 @@ static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg) ...@@ -614,7 +620,7 @@ static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg)
ret = core_tpg_post_addlun(se_tpg, lun, lun_access, dev); ret = core_tpg_post_addlun(se_tpg, lun, lun_access, dev);
if (ret < 0) if (ret < 0)
return -1; return ret;
return 0; return 0;
} }
...@@ -663,7 +669,7 @@ int core_tpg_register( ...@@ -663,7 +669,7 @@ int core_tpg_register(
se_tpg->se_tpg_wwn = se_wwn; se_tpg->se_tpg_wwn = se_wwn;
atomic_set(&se_tpg->tpg_pr_ref_count, 0); atomic_set(&se_tpg->tpg_pr_ref_count, 0);
INIT_LIST_HEAD(&se_tpg->acl_node_list); INIT_LIST_HEAD(&se_tpg->acl_node_list);
INIT_LIST_HEAD(&se_tpg->se_tpg_list); INIT_LIST_HEAD(&se_tpg->se_tpg_node);
INIT_LIST_HEAD(&se_tpg->tpg_sess_list); INIT_LIST_HEAD(&se_tpg->tpg_sess_list);
spin_lock_init(&se_tpg->acl_node_lock); spin_lock_init(&se_tpg->acl_node_lock);
spin_lock_init(&se_tpg->session_lock); spin_lock_init(&se_tpg->session_lock);
...@@ -676,9 +682,9 @@ int core_tpg_register( ...@@ -676,9 +682,9 @@ int core_tpg_register(
} }
} }
spin_lock_bh(&se_global->se_tpg_lock); spin_lock_bh(&tpg_lock);
list_add_tail(&se_tpg->se_tpg_list, &se_global->g_se_tpg_list); list_add_tail(&se_tpg->se_tpg_node, &tpg_list);
spin_unlock_bh(&se_global->se_tpg_lock); spin_unlock_bh(&tpg_lock);
printk(KERN_INFO "TARGET_CORE[%s]: Allocated %s struct se_portal_group for" printk(KERN_INFO "TARGET_CORE[%s]: Allocated %s struct se_portal_group for"
" endpoint: %s, Portal Tag: %u\n", tfo->get_fabric_name(), " endpoint: %s, Portal Tag: %u\n", tfo->get_fabric_name(),
...@@ -697,13 +703,13 @@ int core_tpg_deregister(struct se_portal_group *se_tpg) ...@@ -697,13 +703,13 @@ int core_tpg_deregister(struct se_portal_group *se_tpg)
printk(KERN_INFO "TARGET_CORE[%s]: Deallocating %s struct se_portal_group" printk(KERN_INFO "TARGET_CORE[%s]: Deallocating %s struct se_portal_group"
" for endpoint: %s Portal Tag %u\n", " for endpoint: %s Portal Tag %u\n",
(se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL) ? (se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL) ?
"Normal" : "Discovery", TPG_TFO(se_tpg)->get_fabric_name(), "Normal" : "Discovery", se_tpg->se_tpg_tfo->get_fabric_name(),
TPG_TFO(se_tpg)->tpg_get_wwn(se_tpg), se_tpg->se_tpg_tfo->tpg_get_wwn(se_tpg),
TPG_TFO(se_tpg)->tpg_get_tag(se_tpg)); se_tpg->se_tpg_tfo->tpg_get_tag(se_tpg));
spin_lock_bh(&se_global->se_tpg_lock); spin_lock_bh(&tpg_lock);
list_del(&se_tpg->se_tpg_list); list_del(&se_tpg->se_tpg_node);
spin_unlock_bh(&se_global->se_tpg_lock); spin_unlock_bh(&tpg_lock);
while (atomic_read(&se_tpg->tpg_pr_ref_count) != 0) while (atomic_read(&se_tpg->tpg_pr_ref_count) != 0)
cpu_relax(); cpu_relax();
...@@ -721,7 +727,7 @@ int core_tpg_deregister(struct se_portal_group *se_tpg) ...@@ -721,7 +727,7 @@ int core_tpg_deregister(struct se_portal_group *se_tpg)
core_tpg_wait_for_nacl_pr_ref(nacl); core_tpg_wait_for_nacl_pr_ref(nacl);
core_free_device_list_for_node(nacl, se_tpg); core_free_device_list_for_node(nacl, se_tpg);
TPG_TFO(se_tpg)->tpg_release_fabric_acl(se_tpg, nacl); se_tpg->se_tpg_tfo->tpg_release_fabric_acl(se_tpg, nacl);
spin_lock_bh(&se_tpg->acl_node_lock); spin_lock_bh(&se_tpg->acl_node_lock);
} }
...@@ -745,9 +751,9 @@ struct se_lun *core_tpg_pre_addlun( ...@@ -745,9 +751,9 @@ struct se_lun *core_tpg_pre_addlun(
if (unpacked_lun > (TRANSPORT_MAX_LUNS_PER_TPG-1)) { if (unpacked_lun > (TRANSPORT_MAX_LUNS_PER_TPG-1)) {
printk(KERN_ERR "%s LUN: %u exceeds TRANSPORT_MAX_LUNS_PER_TPG" printk(KERN_ERR "%s LUN: %u exceeds TRANSPORT_MAX_LUNS_PER_TPG"
"-1: %u for Target Portal Group: %u\n", "-1: %u for Target Portal Group: %u\n",
TPG_TFO(tpg)->get_fabric_name(), tpg->se_tpg_tfo->get_fabric_name(),
unpacked_lun, TRANSPORT_MAX_LUNS_PER_TPG-1, unpacked_lun, TRANSPORT_MAX_LUNS_PER_TPG-1,
TPG_TFO(tpg)->tpg_get_tag(tpg)); tpg->se_tpg_tfo->tpg_get_tag(tpg));
return ERR_PTR(-EOVERFLOW); return ERR_PTR(-EOVERFLOW);
} }
...@@ -756,8 +762,8 @@ struct se_lun *core_tpg_pre_addlun( ...@@ -756,8 +762,8 @@ struct se_lun *core_tpg_pre_addlun(
if (lun->lun_status == TRANSPORT_LUN_STATUS_ACTIVE) { if (lun->lun_status == TRANSPORT_LUN_STATUS_ACTIVE) {
printk(KERN_ERR "TPG Logical Unit Number: %u is already active" printk(KERN_ERR "TPG Logical Unit Number: %u is already active"
" on %s Target Portal Group: %u, ignoring request.\n", " on %s Target Portal Group: %u, ignoring request.\n",
unpacked_lun, TPG_TFO(tpg)->get_fabric_name(), unpacked_lun, tpg->se_tpg_tfo->get_fabric_name(),
TPG_TFO(tpg)->tpg_get_tag(tpg)); tpg->se_tpg_tfo->tpg_get_tag(tpg));
spin_unlock(&tpg->tpg_lun_lock); spin_unlock(&tpg->tpg_lun_lock);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
...@@ -772,8 +778,11 @@ int core_tpg_post_addlun( ...@@ -772,8 +778,11 @@ int core_tpg_post_addlun(
u32 lun_access, u32 lun_access,
void *lun_ptr) void *lun_ptr)
{ {
if (core_dev_export(lun_ptr, tpg, lun) < 0) int ret;
return -1;
ret = core_dev_export(lun_ptr, tpg, lun);
if (ret < 0)
return ret;
spin_lock(&tpg->tpg_lun_lock); spin_lock(&tpg->tpg_lun_lock);
lun->lun_access = lun_access; lun->lun_access = lun_access;
...@@ -801,9 +810,9 @@ struct se_lun *core_tpg_pre_dellun( ...@@ -801,9 +810,9 @@ struct se_lun *core_tpg_pre_dellun(
if (unpacked_lun > (TRANSPORT_MAX_LUNS_PER_TPG-1)) { if (unpacked_lun > (TRANSPORT_MAX_LUNS_PER_TPG-1)) {
printk(KERN_ERR "%s LUN: %u exceeds TRANSPORT_MAX_LUNS_PER_TPG" printk(KERN_ERR "%s LUN: %u exceeds TRANSPORT_MAX_LUNS_PER_TPG"
"-1: %u for Target Portal Group: %u\n", "-1: %u for Target Portal Group: %u\n",
TPG_TFO(tpg)->get_fabric_name(), unpacked_lun, tpg->se_tpg_tfo->get_fabric_name(), unpacked_lun,
TRANSPORT_MAX_LUNS_PER_TPG-1, TRANSPORT_MAX_LUNS_PER_TPG-1,
TPG_TFO(tpg)->tpg_get_tag(tpg)); tpg->se_tpg_tfo->tpg_get_tag(tpg));
return ERR_PTR(-EOVERFLOW); return ERR_PTR(-EOVERFLOW);
} }
...@@ -812,8 +821,8 @@ struct se_lun *core_tpg_pre_dellun( ...@@ -812,8 +821,8 @@ struct se_lun *core_tpg_pre_dellun(
if (lun->lun_status != TRANSPORT_LUN_STATUS_ACTIVE) { if (lun->lun_status != TRANSPORT_LUN_STATUS_ACTIVE) {
printk(KERN_ERR "%s Logical Unit Number: %u is not active on" printk(KERN_ERR "%s Logical Unit Number: %u is not active on"
" Target Portal Group: %u, ignoring request.\n", " Target Portal Group: %u, ignoring request.\n",
TPG_TFO(tpg)->get_fabric_name(), unpacked_lun, tpg->se_tpg_tfo->get_fabric_name(), unpacked_lun,
TPG_TFO(tpg)->tpg_get_tag(tpg)); tpg->se_tpg_tfo->tpg_get_tag(tpg));
spin_unlock(&tpg->tpg_lun_lock); spin_unlock(&tpg->tpg_lun_lock);
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -80,10 +80,10 @@ int core_scsi3_ua_check( ...@@ -80,10 +80,10 @@ int core_scsi3_ua_check(
case REQUEST_SENSE: case REQUEST_SENSE:
return 0; return 0;
default: default:
return -1; return -EINVAL;
} }
return -1; return -EINVAL;
} }
int core_scsi3_ua_allocate( int core_scsi3_ua_allocate(
...@@ -98,12 +98,12 @@ int core_scsi3_ua_allocate( ...@@ -98,12 +98,12 @@ int core_scsi3_ua_allocate(
* PASSTHROUGH OPS * PASSTHROUGH OPS
*/ */
if (!(nacl)) if (!(nacl))
return -1; return -EINVAL;
ua = kmem_cache_zalloc(se_ua_cache, GFP_ATOMIC); ua = kmem_cache_zalloc(se_ua_cache, GFP_ATOMIC);
if (!(ua)) { if (!(ua)) {
printk(KERN_ERR "Unable to allocate struct se_ua\n"); printk(KERN_ERR "Unable to allocate struct se_ua\n");
return -1; return -ENOMEM;
} }
INIT_LIST_HEAD(&ua->ua_dev_list); INIT_LIST_HEAD(&ua->ua_dev_list);
INIT_LIST_HEAD(&ua->ua_nacl_list); INIT_LIST_HEAD(&ua->ua_nacl_list);
...@@ -179,7 +179,7 @@ int core_scsi3_ua_allocate( ...@@ -179,7 +179,7 @@ int core_scsi3_ua_allocate(
printk(KERN_INFO "[%s]: Allocated UNIT ATTENTION, mapped LUN: %u, ASC:" printk(KERN_INFO "[%s]: Allocated UNIT ATTENTION, mapped LUN: %u, ASC:"
" 0x%02x, ASCQ: 0x%02x\n", " 0x%02x, ASCQ: 0x%02x\n",
TPG_TFO(nacl->se_tpg)->get_fabric_name(), unpacked_lun, nacl->se_tpg->se_tpg_tfo->get_fabric_name(), unpacked_lun,
asc, ascq); asc, ascq);
atomic_inc(&deve->ua_count); atomic_inc(&deve->ua_count);
...@@ -208,7 +208,7 @@ void core_scsi3_ua_for_check_condition( ...@@ -208,7 +208,7 @@ void core_scsi3_ua_for_check_condition(
u8 *asc, u8 *asc,
u8 *ascq) u8 *ascq)
{ {
struct se_device *dev = SE_DEV(cmd); struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_dev_entry *deve; struct se_dev_entry *deve;
struct se_session *sess = cmd->se_sess; struct se_session *sess = cmd->se_sess;
struct se_node_acl *nacl; struct se_node_acl *nacl;
...@@ -240,7 +240,7 @@ void core_scsi3_ua_for_check_condition( ...@@ -240,7 +240,7 @@ void core_scsi3_ua_for_check_condition(
* highest priority UNIT_ATTENTION and ASC/ASCQ without * highest priority UNIT_ATTENTION and ASC/ASCQ without
* clearing it. * clearing it.
*/ */
if (DEV_ATTRIB(dev)->emulate_ua_intlck_ctrl != 0) { if (dev->se_sub_dev->se_dev_attrib.emulate_ua_intlck_ctrl != 0) {
*asc = ua->ua_asc; *asc = ua->ua_asc;
*ascq = ua->ua_ascq; *ascq = ua->ua_ascq;
break; break;
...@@ -267,10 +267,10 @@ void core_scsi3_ua_for_check_condition( ...@@ -267,10 +267,10 @@ void core_scsi3_ua_for_check_condition(
printk(KERN_INFO "[%s]: %s UNIT ATTENTION condition with" printk(KERN_INFO "[%s]: %s UNIT ATTENTION condition with"
" INTLCK_CTRL: %d, mapped LUN: %u, got CDB: 0x%02x" " INTLCK_CTRL: %d, mapped LUN: %u, got CDB: 0x%02x"
" reported ASC: 0x%02x, ASCQ: 0x%02x\n", " reported ASC: 0x%02x, ASCQ: 0x%02x\n",
TPG_TFO(nacl->se_tpg)->get_fabric_name(), nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
(DEV_ATTRIB(dev)->emulate_ua_intlck_ctrl != 0) ? "Reporting" : (dev->se_sub_dev->se_dev_attrib.emulate_ua_intlck_ctrl != 0) ? "Reporting" :
"Releasing", DEV_ATTRIB(dev)->emulate_ua_intlck_ctrl, "Releasing", dev->se_sub_dev->se_dev_attrib.emulate_ua_intlck_ctrl,
cmd->orig_fe_lun, T_TASK(cmd)->t_task_cdb[0], *asc, *ascq); cmd->orig_fe_lun, cmd->t_task->t_task_cdb[0], *asc, *ascq);
} }
int core_scsi3_ua_clear_for_request_sense( int core_scsi3_ua_clear_for_request_sense(
...@@ -285,17 +285,17 @@ int core_scsi3_ua_clear_for_request_sense( ...@@ -285,17 +285,17 @@ int core_scsi3_ua_clear_for_request_sense(
int head = 1; int head = 1;
if (!(sess)) if (!(sess))
return -1; return -EINVAL;
nacl = sess->se_node_acl; nacl = sess->se_node_acl;
if (!(nacl)) if (!(nacl))
return -1; return -EINVAL;
spin_lock_irq(&nacl->device_list_lock); spin_lock_irq(&nacl->device_list_lock);
deve = &nacl->device_list[cmd->orig_fe_lun]; deve = &nacl->device_list[cmd->orig_fe_lun];
if (!(atomic_read(&deve->ua_count))) { if (!(atomic_read(&deve->ua_count))) {
spin_unlock_irq(&nacl->device_list_lock); spin_unlock_irq(&nacl->device_list_lock);
return -1; return -EPERM;
} }
/* /*
* The highest priority Unit Attentions are placed at the head of the * The highest priority Unit Attentions are placed at the head of the
...@@ -325,8 +325,8 @@ int core_scsi3_ua_clear_for_request_sense( ...@@ -325,8 +325,8 @@ int core_scsi3_ua_clear_for_request_sense(
printk(KERN_INFO "[%s]: Released UNIT ATTENTION condition, mapped" printk(KERN_INFO "[%s]: Released UNIT ATTENTION condition, mapped"
" LUN: %u, got REQUEST_SENSE reported ASC: 0x%02x," " LUN: %u, got REQUEST_SENSE reported ASC: 0x%02x,"
" ASCQ: 0x%02x\n", TPG_TFO(nacl->se_tpg)->get_fabric_name(), " ASCQ: 0x%02x\n", nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
cmd->orig_fe_lun, *asc, *ascq); cmd->orig_fe_lun, *asc, *ascq);
return (head) ? -1 : 0; return (head) ? -EPERM : 0;
} }
...@@ -72,7 +72,7 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller) ...@@ -72,7 +72,7 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
caller, cmd, cmd->cdb); caller, cmd, cmd->cdb);
printk(KERN_INFO "%s: cmd %p lun %d\n", caller, cmd, cmd->lun); printk(KERN_INFO "%s: cmd %p lun %d\n", caller, cmd, cmd->lun);
task = T_TASK(se_cmd); task = se_cmd->t_task;
printk(KERN_INFO "%s: cmd %p task %p se_num %u buf %p len %u se_cmd_flags <0x%x>\n", printk(KERN_INFO "%s: cmd %p task %p se_num %u buf %p len %u se_cmd_flags <0x%x>\n",
caller, cmd, task, task->t_tasks_se_num, caller, cmd, task, task->t_tasks_se_num,
task->t_task_buf, se_cmd->data_length, se_cmd->se_cmd_flags); task->t_task_buf, se_cmd->data_length, se_cmd->se_cmd_flags);
...@@ -262,9 +262,9 @@ int ft_write_pending(struct se_cmd *se_cmd) ...@@ -262,9 +262,9 @@ int ft_write_pending(struct se_cmd *se_cmd)
* TCM/LIO target * TCM/LIO target
*/ */
transport_do_task_sg_chain(se_cmd); transport_do_task_sg_chain(se_cmd);
cmd->sg = T_TASK(se_cmd)->t_tasks_sg_chained; cmd->sg = se_cmd->t_task->t_tasks_sg_chained;
cmd->sg_cnt = cmd->sg_cnt =
T_TASK(se_cmd)->t_tasks_sg_chained_no; se_cmd->t_task->t_tasks_sg_chained_no;
} }
if (cmd->sg && lport->tt.ddp_setup(lport, ep->xid, if (cmd->sg && lport->tt.ddp_setup(lport, ep->xid,
cmd->sg, cmd->sg_cnt)) cmd->sg, cmd->sg_cnt))
...@@ -670,7 +670,6 @@ static void ft_send_cmd(struct ft_cmd *cmd) ...@@ -670,7 +670,6 @@ static void ft_send_cmd(struct ft_cmd *cmd)
err: err:
ft_send_resp_code(cmd, FCP_CMND_FIELDS_INVALID); ft_send_resp_code(cmd, FCP_CMND_FIELDS_INVALID);
return;
} }
/* /*
......
...@@ -582,10 +582,10 @@ int ft_register_configfs(void) ...@@ -582,10 +582,10 @@ int ft_register_configfs(void)
* Register the top level struct config_item_type with TCM core * Register the top level struct config_item_type with TCM core
*/ */
fabric = target_fabric_configfs_init(THIS_MODULE, "fc"); fabric = target_fabric_configfs_init(THIS_MODULE, "fc");
if (!fabric) { if (IS_ERR(fabric)) {
printk(KERN_INFO "%s: target_fabric_configfs_init() failed!\n", printk(KERN_INFO "%s: target_fabric_configfs_init() failed!\n",
__func__); __func__);
return -1; return PTR_ERR(fabric);
} }
fabric->tf_ops = ft_fabric_ops; fabric->tf_ops = ft_fabric_ops;
......
...@@ -90,7 +90,7 @@ int ft_queue_data_in(struct se_cmd *se_cmd) ...@@ -90,7 +90,7 @@ int ft_queue_data_in(struct se_cmd *se_cmd)
lport = ep->lp; lport = ep->lp;
cmd->seq = lport->tt.seq_start_next(cmd->seq); cmd->seq = lport->tt.seq_start_next(cmd->seq);
task = T_TASK(se_cmd); task = se_cmd->t_task;
BUG_ON(!task); BUG_ON(!task);
remaining = se_cmd->data_length; remaining = se_cmd->data_length;
...@@ -236,7 +236,7 @@ void ft_recv_write_data(struct ft_cmd *cmd, struct fc_frame *fp) ...@@ -236,7 +236,7 @@ void ft_recv_write_data(struct ft_cmd *cmd, struct fc_frame *fp)
u32 f_ctl; u32 f_ctl;
void *buf; void *buf;
task = T_TASK(se_cmd); task = se_cmd->t_task;
BUG_ON(!task); BUG_ON(!task);
fh = fc_frame_header_get(fp); fh = fc_frame_header_get(fp);
......
...@@ -205,11 +205,6 @@ typedef enum { ...@@ -205,11 +205,6 @@ typedef enum {
SCSI_INDEX_TYPE_MAX SCSI_INDEX_TYPE_MAX
} scsi_index_t; } scsi_index_t;
struct scsi_index_table {
spinlock_t lock;
u32 scsi_mib_index[SCSI_INDEX_TYPE_MAX];
} ____cacheline_aligned;
struct se_cmd; struct se_cmd;
struct t10_alua { struct t10_alua {
...@@ -235,7 +230,7 @@ struct t10_alua_lu_gp { ...@@ -235,7 +230,7 @@ struct t10_alua_lu_gp {
atomic_t lu_gp_ref_cnt; atomic_t lu_gp_ref_cnt;
spinlock_t lu_gp_lock; spinlock_t lu_gp_lock;
struct config_group lu_gp_group; struct config_group lu_gp_group;
struct list_head lu_gp_list; struct list_head lu_gp_node;
struct list_head lu_gp_mem_list; struct list_head lu_gp_mem_list;
} ____cacheline_aligned; } ____cacheline_aligned;
...@@ -291,10 +286,10 @@ struct t10_vpd { ...@@ -291,10 +286,10 @@ struct t10_vpd {
} ____cacheline_aligned; } ____cacheline_aligned;
struct t10_wwn { struct t10_wwn {
unsigned char vendor[8]; char vendor[8];
unsigned char model[16]; char model[16];
unsigned char revision[4]; char revision[4];
unsigned char unit_serial[INQUIRY_VPD_SERIAL_LEN]; char unit_serial[INQUIRY_VPD_SERIAL_LEN];
spinlock_t t10_vpd_lock; spinlock_t t10_vpd_lock;
struct se_subsystem_dev *t10_sub_dev; struct se_subsystem_dev *t10_sub_dev;
struct config_group t10_wwn_group; struct config_group t10_wwn_group;
...@@ -366,13 +361,13 @@ struct t10_reservation_ops { ...@@ -366,13 +361,13 @@ struct t10_reservation_ops {
int (*t10_pr_clear)(struct se_cmd *); int (*t10_pr_clear)(struct se_cmd *);
}; };
struct t10_reservation_template { struct t10_reservation {
/* Reservation effects all target ports */ /* Reservation effects all target ports */
int pr_all_tg_pt; int pr_all_tg_pt;
/* Activate Persistence across Target Power Loss enabled /* Activate Persistence across Target Power Loss enabled
* for SCSI device */ * for SCSI device */
int pr_aptpl_active; int pr_aptpl_active;
/* Used by struct t10_reservation_template->pr_aptpl_buf_len */ /* Used by struct t10_reservation->pr_aptpl_buf_len */
#define PR_APTPL_BUF_LEN 8192 #define PR_APTPL_BUF_LEN 8192
u32 pr_aptpl_buf_len; u32 pr_aptpl_buf_len;
u32 pr_generation; u32 pr_generation;
...@@ -397,7 +392,7 @@ struct t10_reservation_template { ...@@ -397,7 +392,7 @@ struct t10_reservation_template {
struct se_queue_req { struct se_queue_req {
int state; int state;
void *cmd; struct se_cmd *cmd;
struct list_head qr_list; struct list_head qr_list;
} ____cacheline_aligned; } ____cacheline_aligned;
...@@ -495,9 +490,6 @@ struct se_task { ...@@ -495,9 +490,6 @@ struct se_task {
struct list_head t_state_list; struct list_head t_state_list;
} ____cacheline_aligned; } ____cacheline_aligned;
#define TASK_CMD(task) ((task)->task_se_cmd)
#define TASK_DEV(task) ((task)->se_dev)
struct se_cmd { struct se_cmd {
/* SAM response code being sent to initiator */ /* SAM response code being sent to initiator */
u8 scsi_status; u8 scsi_status;
...@@ -552,9 +544,6 @@ struct se_cmd { ...@@ -552,9 +544,6 @@ struct se_cmd {
void (*transport_complete_callback)(struct se_cmd *); void (*transport_complete_callback)(struct se_cmd *);
} ____cacheline_aligned; } ____cacheline_aligned;
#define T_TASK(cmd) ((cmd)->t_task)
#define CMD_TFO(cmd) ((cmd)->se_tfo)
struct se_tmr_req { struct se_tmr_req {
/* Task Management function to be preformed */ /* Task Management function to be preformed */
u8 function; u8 function;
...@@ -617,9 +606,6 @@ struct se_session { ...@@ -617,9 +606,6 @@ struct se_session {
struct list_head sess_acl_list; struct list_head sess_acl_list;
} ____cacheline_aligned; } ____cacheline_aligned;
#define SE_SESS(cmd) ((cmd)->se_sess)
#define SE_NODE_ACL(sess) ((sess)->se_node_acl)
struct se_device; struct se_device;
struct se_transform_info; struct se_transform_info;
struct scatterlist; struct scatterlist;
...@@ -640,8 +626,6 @@ struct se_lun_acl { ...@@ -640,8 +626,6 @@ struct se_lun_acl {
struct se_ml_stat_grps ml_stat_grps; struct se_ml_stat_grps ml_stat_grps;
} ____cacheline_aligned; } ____cacheline_aligned;
#define ML_STAT_GRPS(lacl) (&(lacl)->ml_stat_grps)
struct se_dev_entry { struct se_dev_entry {
bool def_pr_registered; bool def_pr_registered;
/* See transport_lunflags_table */ /* See transport_lunflags_table */
...@@ -727,10 +711,10 @@ struct se_subsystem_dev { ...@@ -727,10 +711,10 @@ struct se_subsystem_dev {
/* T10 Inquiry and VPD WWN Information */ /* T10 Inquiry and VPD WWN Information */
struct t10_wwn t10_wwn; struct t10_wwn t10_wwn;
/* T10 SPC-2 + SPC-3 Reservations */ /* T10 SPC-2 + SPC-3 Reservations */
struct t10_reservation_template t10_reservation; struct t10_reservation t10_pr;
spinlock_t se_dev_lock; spinlock_t se_dev_lock;
void *se_dev_su_ptr; void *se_dev_su_ptr;
struct list_head g_se_dev_list; struct list_head se_dev_node;
struct config_group se_dev_group; struct config_group se_dev_group;
/* For T10 Reservations */ /* For T10 Reservations */
struct config_group se_dev_pr_group; struct config_group se_dev_pr_group;
...@@ -738,11 +722,6 @@ struct se_subsystem_dev { ...@@ -738,11 +722,6 @@ struct se_subsystem_dev {
struct se_dev_stat_grps dev_stat_grps; struct se_dev_stat_grps dev_stat_grps;
} ____cacheline_aligned; } ____cacheline_aligned;
#define T10_ALUA(su_dev) (&(su_dev)->t10_alua)
#define T10_RES(su_dev) (&(su_dev)->t10_reservation)
#define T10_PR_OPS(su_dev) (&(su_dev)->t10_reservation.pr_ops)
#define DEV_STAT_GRP(dev) (&(dev)->dev_stat_grps)
struct se_device { struct se_device {
/* Set to 1 if thread is NOT sleeping on thread_sem */ /* Set to 1 if thread is NOT sleeping on thread_sem */
u8 thread_active; u8 thread_active;
...@@ -783,8 +762,7 @@ struct se_device { ...@@ -783,8 +762,7 @@ struct se_device {
struct se_obj dev_obj; struct se_obj dev_obj;
struct se_obj dev_access_obj; struct se_obj dev_access_obj;
struct se_obj dev_export_obj; struct se_obj dev_export_obj;
struct se_queue_obj *dev_queue_obj; struct se_queue_obj dev_queue_obj;
struct se_queue_obj *dev_status_queue_obj;
spinlock_t delayed_cmd_lock; spinlock_t delayed_cmd_lock;
spinlock_t ordered_cmd_lock; spinlock_t ordered_cmd_lock;
spinlock_t execute_task_lock; spinlock_t execute_task_lock;
...@@ -824,11 +802,6 @@ struct se_device { ...@@ -824,11 +802,6 @@ struct se_device {
struct list_head g_se_dev_list; struct list_head g_se_dev_list;
} ____cacheline_aligned; } ____cacheline_aligned;
#define SE_DEV(cmd) ((cmd)->se_lun->lun_se_dev)
#define SU_DEV(dev) ((dev)->se_sub_dev)
#define DEV_ATTRIB(dev) (&(dev)->se_sub_dev->se_dev_attrib)
#define DEV_T10_WWN(dev) (&(dev)->se_sub_dev->t10_wwn)
struct se_hba { struct se_hba {
u16 hba_tpgt; u16 hba_tpgt;
u32 hba_id; u32 hba_id;
...@@ -837,24 +810,17 @@ struct se_hba { ...@@ -837,24 +810,17 @@ struct se_hba {
/* Virtual iSCSI devices attached. */ /* Virtual iSCSI devices attached. */
u32 dev_count; u32 dev_count;
u32 hba_index; u32 hba_index;
atomic_t load_balance_queue;
atomic_t left_queue_depth;
/* Maximum queue depth the HBA can handle. */
atomic_t max_queue_depth;
/* Pointer to transport specific host structure. */ /* Pointer to transport specific host structure. */
void *hba_ptr; void *hba_ptr;
/* Linked list for struct se_device */ /* Linked list for struct se_device */
struct list_head hba_dev_list; struct list_head hba_dev_list;
struct list_head hba_list; struct list_head hba_node;
spinlock_t device_lock; spinlock_t device_lock;
spinlock_t hba_queue_lock;
struct config_group hba_group; struct config_group hba_group;
struct mutex hba_access_mutex; struct mutex hba_access_mutex;
struct se_subsystem_api *transport; struct se_subsystem_api *transport;
} ____cacheline_aligned; } ____cacheline_aligned;
#define SE_HBA(dev) ((dev)->se_hba)
struct se_port_stat_grps { struct se_port_stat_grps {
struct config_group stat_group; struct config_group stat_group;
struct config_group scsi_port_group; struct config_group scsi_port_group;
...@@ -881,9 +847,6 @@ struct se_lun { ...@@ -881,9 +847,6 @@ struct se_lun {
struct se_port_stat_grps port_stat_grps; struct se_port_stat_grps port_stat_grps;
} ____cacheline_aligned; } ____cacheline_aligned;
#define SE_LUN(cmd) ((cmd)->se_lun)
#define PORT_STAT_GRP(lun) (&(lun)->port_stat_grps)
struct scsi_port_stats { struct scsi_port_stats {
u64 cmd_pdus; u64 cmd_pdus;
u64 tx_data_octets; u64 tx_data_octets;
...@@ -930,7 +893,7 @@ struct se_portal_group { ...@@ -930,7 +893,7 @@ struct se_portal_group {
spinlock_t tpg_lun_lock; spinlock_t tpg_lun_lock;
/* Pointer to $FABRIC_MOD portal group */ /* Pointer to $FABRIC_MOD portal group */
void *se_tpg_fabric_ptr; void *se_tpg_fabric_ptr;
struct list_head se_tpg_list; struct list_head se_tpg_node;
/* linked list for initiator ACL list */ /* linked list for initiator ACL list */
struct list_head acl_node_list; struct list_head acl_node_list;
struct se_lun *tpg_lun_list; struct se_lun *tpg_lun_list;
...@@ -949,8 +912,6 @@ struct se_portal_group { ...@@ -949,8 +912,6 @@ struct se_portal_group {
struct config_group tpg_param_group; struct config_group tpg_param_group;
} ____cacheline_aligned; } ____cacheline_aligned;
#define TPG_TFO(se_tpg) ((se_tpg)->se_tpg_tfo)
struct se_wwn { struct se_wwn {
struct target_fabric_configfs *wwn_tf; struct target_fabric_configfs *wwn_tf;
struct config_group wwn_group; struct config_group wwn_group;
...@@ -958,28 +919,4 @@ struct se_wwn { ...@@ -958,28 +919,4 @@ struct se_wwn {
struct config_group fabric_stat_group; struct config_group fabric_stat_group;
} ____cacheline_aligned; } ____cacheline_aligned;
struct se_global {
u16 alua_lu_gps_counter;
int g_sub_api_initialized;
u32 in_shutdown;
u32 alua_lu_gps_count;
u32 g_hba_id_counter;
struct config_group target_core_hbagroup;
struct config_group alua_group;
struct config_group alua_lu_gps_group;
struct list_head g_lu_gps_list;
struct list_head g_se_tpg_list;
struct list_head g_hba_list;
struct list_head g_se_dev_list;
struct se_hba *g_lun0_hba;
struct se_subsystem_dev *g_lun0_su_dev;
struct se_device *g_lun0_dev;
struct t10_alua_lu_gp *default_lu_gp;
spinlock_t g_device_lock;
spinlock_t hba_lock;
spinlock_t se_tpg_lock;
spinlock_t lu_gps_lock;
spinlock_t plugin_class_lock;
} ____cacheline_aligned;
#endif /* TARGET_CORE_BASE_H */ #endif /* TARGET_CORE_BASE_H */
...@@ -111,9 +111,8 @@ struct se_subsystem_api; ...@@ -111,9 +111,8 @@ struct se_subsystem_api;
extern struct kmem_cache *se_mem_cache; extern struct kmem_cache *se_mem_cache;
extern int init_se_global(void); extern int init_se_kmem_caches(void);
extern void release_se_global(void); extern void release_se_kmem_caches(void);
extern void init_scsi_index_table(void);
extern u32 scsi_get_new_index(scsi_index_t); extern u32 scsi_get_new_index(scsi_index_t);
extern void transport_init_queue_obj(struct se_queue_obj *); extern void transport_init_queue_obj(struct se_queue_obj *);
extern int transport_subsystem_check_init(void); extern int transport_subsystem_check_init(void);
...@@ -184,7 +183,7 @@ extern void transport_send_task_abort(struct se_cmd *); ...@@ -184,7 +183,7 @@ extern void transport_send_task_abort(struct se_cmd *);
extern void transport_release_cmd_to_pool(struct se_cmd *); extern void transport_release_cmd_to_pool(struct se_cmd *);
extern void transport_generic_free_cmd(struct se_cmd *, int, int, int); extern void transport_generic_free_cmd(struct se_cmd *, int, int, int);
extern void transport_generic_wait_for_cmds(struct se_cmd *, int); extern void transport_generic_wait_for_cmds(struct se_cmd *, int);
extern u32 transport_calc_sg_num(struct se_task *, struct se_mem *, u32); extern int transport_init_task_sg(struct se_task *, struct se_mem *, u32);
extern int transport_map_mem_to_sg(struct se_task *, struct list_head *, extern int transport_map_mem_to_sg(struct se_task *, struct list_head *,
void *, struct se_mem *, void *, struct se_mem *,
struct se_mem **, u32 *, u32 *); struct se_mem **, u32 *, u32 *);
...@@ -352,9 +351,4 @@ struct se_subsystem_api { ...@@ -352,9 +351,4 @@ struct se_subsystem_api {
unsigned char *(*get_sense_buffer)(struct se_task *); unsigned char *(*get_sense_buffer)(struct se_task *);
} ____cacheline_aligned; } ____cacheline_aligned;
#define TRANSPORT(dev) ((dev)->transport)
#define HBA_TRANSPORT(hba) ((hba)->transport)
extern struct se_global *se_global;
#endif /* TARGET_CORE_TRANSPORT_H */ #endif /* TARGET_CORE_TRANSPORT_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment