Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 256882
b: refs/heads/master
c: 5951146
h: refs/heads/master
v: v3
  • Loading branch information
Andy Grover authored and Nicholas Bellinger committed Jul 22, 2011
1 parent 88728d6 commit 9f0f986
Show file tree
Hide file tree
Showing 20 changed files with 762 additions and 942 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f22c119683e73498d8126581a1be75e1b7a339a3
refs/heads/master: 5951146dea1ac8ff2f177477c907084d63913cad
56 changes: 22 additions & 34 deletions trunk/drivers/target/loopback/tcm_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,16 @@ static struct se_cmd *tcm_loop_allocate_core_cmd(
* Signal BIDI usage with T_TASK(cmd)->t_tasks_bidi
*/
if (scsi_bidi_cmnd(sc))
se_cmd->t_task->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
*/
if (transport_get_lun_for_cmd(se_cmd, tl_cmd->sc->device->lun) < 0) {
if (transport_lookup_cmd_lun(se_cmd, tl_cmd->sc->device->lun) < 0) {
kmem_cache_free(tcm_loop_cmd_cache, tl_cmd);
set_host_byte(sc, DID_NO_CONNECT);
return NULL;
}

transport_device_setup_cmd(se_cmd);
return se_cmd;
}

Expand All @@ -143,17 +142,17 @@ static int tcm_loop_new_cmd_map(struct se_cmd *se_cmd)
struct tcm_loop_cmd *tl_cmd = container_of(se_cmd,
struct tcm_loop_cmd, tl_se_cmd);
struct scsi_cmnd *sc = tl_cmd->sc;
void *mem_ptr, *mem_bidi_ptr = NULL;
u32 sg_no_bidi = 0;
struct scatterlist *sgl_bidi = NULL;
u32 sgl_bidi_count = 0;
int ret;
/*
* Allocate the necessary tasks to complete the received CDB+data
*/
ret = transport_generic_allocate_tasks(se_cmd, tl_cmd->sc->cmnd);
if (ret == -1) {
ret = transport_generic_allocate_tasks(se_cmd, sc->cmnd);
if (ret == -ENOMEM) {
/* Out of Resources */
return PYX_TRANSPORT_LU_COMM_FAILURE;
} else if (ret == -2) {
} else if (ret == -EINVAL) {
/*
* Handle case for SAM_STAT_RESERVATION_CONFLICT
*/
Expand All @@ -165,35 +164,24 @@ static int tcm_loop_new_cmd_map(struct se_cmd *se_cmd)
*/
return PYX_TRANSPORT_USE_SENSE_REASON;
}

/*
* Setup the struct scatterlist memory from the received
* struct scsi_cmnd.
* For BIDI commands, pass in the extra READ buffer
* to transport_generic_map_mem_to_cmd() below..
*/
if (scsi_sg_count(sc)) {
se_cmd->se_cmd_flags |= SCF_PASSTHROUGH_SG_TO_MEM;
mem_ptr = (void *)scsi_sglist(sc);
/*
* For BIDI commands, pass in the extra READ buffer
* to transport_generic_map_mem_to_cmd() below..
*/
if (se_cmd->t_task->t_tasks_bidi) {
struct scsi_data_buffer *sdb = scsi_in(sc);
if (se_cmd->t_task.t_tasks_bidi) {
struct scsi_data_buffer *sdb = scsi_in(sc);

mem_bidi_ptr = (void *)sdb->table.sgl;
sg_no_bidi = sdb->table.nents;
}
} else {
/*
* Used for DMA_NONE
*/
mem_ptr = NULL;
sgl_bidi = sdb->table.sgl;
sgl_bidi_count = sdb->table.nents;
}

/*
* Map the SG memory into struct se_mem->page linked list using the same
* physical memory at sg->page_link.
*/
ret = transport_generic_map_mem_to_cmd(se_cmd, mem_ptr,
scsi_sg_count(sc), mem_bidi_ptr, sg_no_bidi);
ret = transport_generic_map_mem_to_cmd(se_cmd, scsi_sglist(sc),
scsi_sg_count(sc), sgl_bidi, sgl_bidi_count);
if (ret < 0)
return PYX_TRANSPORT_LU_COMM_FAILURE;

Expand Down Expand Up @@ -384,14 +372,14 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc)
/*
* Allocate the LUN_RESET TMR
*/
se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd, (void *)tl_tmr,
se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd, tl_tmr,
TMR_LUN_RESET);
if (IS_ERR(se_cmd->se_tmr_req))
goto release;
/*
* Locate the underlying TCM struct se_lun from sc->device->lun
*/
if (transport_get_lun_for_tmr(se_cmd, sc->device->lun) < 0)
if (transport_lookup_tmr_lun(se_cmd, sc->device->lun) < 0)
goto release;
/*
* Queue the TMR to TCM Core and sleep waiting for tcm_loop_queue_tm_rsp()
Expand Down Expand Up @@ -904,7 +892,7 @@ static int tcm_loop_queue_status(struct se_cmd *se_cmd)
((se_cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) ||
(se_cmd->se_cmd_flags & SCF_EMULATED_TASK_SENSE))) {

memcpy((void *)sc->sense_buffer, (void *)se_cmd->sense_buffer,
memcpy(sc->sense_buffer, se_cmd->sense_buffer,
SCSI_SENSE_BUFFERSIZE);
sc->result = SAM_STAT_CHECK_CONDITION;
set_driver_byte(sc, DRIVER_SENSE);
Expand Down Expand Up @@ -1054,7 +1042,7 @@ static int tcm_loop_make_nexus(
* transport_register_session()
*/
__transport_register_session(se_tpg, tl_nexus->se_sess->se_node_acl,
tl_nexus->se_sess, (void *)tl_nexus);
tl_nexus->se_sess, tl_nexus);
tl_tpg->tl_hba->tl_nexus = tl_nexus;
printk(KERN_INFO "TCM_Loop_ConfigFS: Established I_T Nexus to emulated"
" %s Initiator Port: %s\n", tcm_loop_dump_proto_id(tl_hba),
Expand Down Expand Up @@ -1242,7 +1230,7 @@ struct se_portal_group *tcm_loop_make_naa_tpg(
* Register the tl_tpg as a emulated SAS TCM Target Endpoint
*/
ret = core_tpg_register(&tcm_loop_fabric_configfs->tf_ops,
wwn, &tl_tpg->tl_se_tpg, (void *)tl_tpg,
wwn, &tl_tpg->tl_se_tpg, tl_tpg,
TRANSPORT_TPG_TYPE_NORMAL);
if (ret < 0)
return ERR_PTR(-ENOMEM);
Expand Down
8 changes: 4 additions & 4 deletions trunk/drivers/target/target_core_alua.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ struct t10_alua_lu_gp *default_lu_gp;
*/
int core_emulate_report_target_port_groups(struct se_cmd *cmd)
{
struct se_subsystem_dev *su_dev = cmd->se_lun->lun_se_dev->se_sub_dev;
struct se_subsystem_dev *su_dev = cmd->se_dev->se_sub_dev;
struct se_port *port;
struct t10_alua_tg_pt_gp *tg_pt_gp;
struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem;
unsigned char *buf = (unsigned char *)cmd->t_task->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
Target port group descriptor */

Expand Down Expand Up @@ -151,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)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_device *dev = cmd->se_dev;
struct se_subsystem_dev *su_dev = dev->se_sub_dev;
struct se_port *port, *l_port = cmd->se_lun->lun_sep;
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_member *tg_pt_gp_mem, *l_tg_pt_gp_mem;
unsigned char *buf = (unsigned char *)cmd->t_task->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 */
u32 len = 4; /* Skip over RESERVED area in header */
int alua_access_state, primary = 0, rc;
Expand Down
62 changes: 31 additions & 31 deletions trunk/drivers/target/target_core_cdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ static int
target_emulate_inquiry_std(struct se_cmd *cmd)
{
struct se_lun *lun = cmd->se_lun;
struct se_device *dev = cmd->se_lun->lun_se_dev;
unsigned char *buf = cmd->t_task->t_task_buf;
struct se_device *dev = cmd->se_dev;
unsigned char *buf = cmd->t_task.t_task_buf;

/*
* Make sure we at least have 6 bytes of INQUIRY response
Expand Down Expand Up @@ -128,7 +128,7 @@ target_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf)
* Registered Extended LUN WWN has been set via ConfigFS
* during device creation/restart.
*/
if (cmd->se_lun->lun_se_dev->se_sub_dev->su_dev_flags &
if (cmd->se_dev->se_sub_dev->su_dev_flags &
SDF_EMULATED_VPD_UNIT_SERIAL) {
buf[3] = 3;
buf[5] = 0x80;
Expand All @@ -143,7 +143,7 @@ target_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf)
static int
target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_device *dev = cmd->se_dev;
u16 len = 0;

buf[1] = 0x80;
Expand Down Expand Up @@ -176,7 +176,7 @@ target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf)
static int
target_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_device *dev = cmd->se_dev;
struct se_lun *lun = cmd->se_lun;
struct se_port *port = NULL;
struct se_portal_group *tpg = NULL;
Expand Down Expand Up @@ -477,7 +477,7 @@ target_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf)
buf[5] = 0x07;

/* If WriteCache emulation is enabled, set V_SUP */
if (cmd->se_lun->lun_se_dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0)
if (cmd->se_dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0)
buf[6] = 0x01;
return 0;
}
Expand All @@ -486,7 +486,7 @@ target_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf)
static int
target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_device *dev = cmd->se_dev;
int have_tp = 0;

/*
Expand Down Expand Up @@ -568,7 +568,7 @@ target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf)
static int
target_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_device *dev = cmd->se_dev;

/*
* From sbc3r22 section 6.5.4 Thin Provisioning VPD page:
Expand Down Expand Up @@ -620,9 +620,9 @@ target_emulate_evpd_b2(struct se_cmd *cmd, unsigned char *buf)
static int
target_emulate_inquiry(struct se_cmd *cmd)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
unsigned char *buf = cmd->t_task->t_task_buf;
unsigned char *cdb = cmd->t_task->t_task_cdb;
struct se_device *dev = cmd->se_dev;
unsigned char *buf = cmd->t_task.t_task_buf;
unsigned char *cdb = cmd->t_task.t_task_cdb;

if (!(cdb[1] & 0x1))
return target_emulate_inquiry_std(cmd);
Expand Down Expand Up @@ -665,8 +665,8 @@ target_emulate_inquiry(struct se_cmd *cmd)
static int
target_emulate_readcapacity(struct se_cmd *cmd)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
unsigned char *buf = cmd->t_task->t_task_buf;
struct se_device *dev = cmd->se_dev;
unsigned char *buf = cmd->t_task.t_task_buf;
unsigned long long blocks_long = dev->transport->get_blocks(dev);
u32 blocks;

Expand Down Expand Up @@ -695,8 +695,8 @@ target_emulate_readcapacity(struct se_cmd *cmd)
static int
target_emulate_readcapacity_16(struct se_cmd *cmd)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
unsigned char *buf = cmd->t_task->t_task_buf;
struct se_device *dev = cmd->se_dev;
unsigned char *buf = cmd->t_task.t_task_buf;
unsigned long long blocks = dev->transport->get_blocks(dev);

buf[0] = (blocks >> 56) & 0xff;
Expand Down Expand Up @@ -830,9 +830,9 @@ target_modesense_dpofua(unsigned char *buf, int type)
static int
target_emulate_modesense(struct se_cmd *cmd, int ten)
{
struct se_device *dev = cmd->se_lun->lun_se_dev;
char *cdb = cmd->t_task->t_task_cdb;
unsigned char *rbuf = cmd->t_task->t_task_buf;
struct se_device *dev = cmd->se_dev;
char *cdb = cmd->t_task.t_task_cdb;
unsigned char *rbuf = cmd->t_task.t_task_buf;
int type = dev->transport->get_device_type(dev);
int offset = (ten) ? 8 : 4;
int length = 0;
Expand Down Expand Up @@ -903,8 +903,8 @@ target_emulate_modesense(struct se_cmd *cmd, int ten)
static int
target_emulate_request_sense(struct se_cmd *cmd)
{
unsigned char *cdb = cmd->t_task->t_task_cdb;
unsigned char *buf = cmd->t_task->t_task_buf;
unsigned char *cdb = cmd->t_task.t_task_cdb;
unsigned char *buf = cmd->t_task.t_task_buf;
u8 ua_asc = 0, ua_ascq = 0;

if (cdb[1] & 0x01) {
Expand Down Expand Up @@ -964,9 +964,9 @@ static int
target_emulate_unmap(struct se_task *task)
{
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_lun->lun_se_dev;
unsigned char *buf = cmd->t_task->t_task_buf, *ptr = NULL;
unsigned char *cdb = &cmd->t_task->t_task_cdb[0];
struct se_device *dev = cmd->se_dev;
unsigned char *buf = cmd->t_task.t_task_buf, *ptr = NULL;
unsigned char *cdb = &cmd->t_task.t_task_cdb[0];
sector_t lba;
unsigned int size = cmd->data_length, range;
int ret, offset;
Expand Down Expand Up @@ -1011,8 +1011,8 @@ static int
target_emulate_write_same(struct se_task *task)
{
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_lun->lun_se_dev;
sector_t lba = cmd->t_task->t_task_lba;
struct se_device *dev = cmd->se_dev;
sector_t lba = cmd->t_task.t_task_lba;
unsigned int range;
int ret;

Expand All @@ -1036,11 +1036,11 @@ int
transport_emulate_control_cdb(struct se_task *task)
{
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_lun->lun_se_dev;
struct se_device *dev = cmd->se_dev;
unsigned short service_action;
int ret = 0;

switch (cmd->t_task->t_task_cdb[0]) {
switch (cmd->t_task.t_task_cdb[0]) {
case INQUIRY:
ret = target_emulate_inquiry(cmd);
break;
Expand All @@ -1054,13 +1054,13 @@ transport_emulate_control_cdb(struct se_task *task)
ret = target_emulate_modesense(cmd, 1);
break;
case SERVICE_ACTION_IN:
switch (cmd->t_task->t_task_cdb[1] & 0x1f) {
switch (cmd->t_task.t_task_cdb[1] & 0x1f) {
case SAI_READ_CAPACITY_16:
ret = target_emulate_readcapacity_16(cmd);
break;
default:
printk(KERN_ERR "Unsupported SA: 0x%02x\n",
cmd->t_task->t_task_cdb[1] & 0x1f);
cmd->t_task.t_task_cdb[1] & 0x1f);
return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
}
break;
Expand All @@ -1085,7 +1085,7 @@ transport_emulate_control_cdb(struct se_task *task)
break;
case VARIABLE_LENGTH_CMD:
service_action =
get_unaligned_be16(&cmd->t_task->t_task_cdb[8]);
get_unaligned_be16(&cmd->t_task.t_task_cdb[8]);
switch (service_action) {
case WRITE_SAME_32:
if (!dev->transport->do_discard) {
Expand Down Expand Up @@ -1124,7 +1124,7 @@ transport_emulate_control_cdb(struct se_task *task)
break;
default:
printk(KERN_ERR "Unsupported SCSI Opcode: 0x%02x for %s\n",
cmd->t_task->t_task_cdb[0], dev->transport->name);
cmd->t_task.t_task_cdb[0], dev->transport->name);
return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
}

Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/target/target_core_configfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2037,7 +2037,7 @@ static ssize_t target_core_dev_show(struct config_item *item,
if (!(tc_attr->show))
return -EINVAL;

return tc_attr->show((void *)se_dev, page);
return tc_attr->show(se_dev, page);
}

static ssize_t target_core_dev_store(struct config_item *item,
Expand All @@ -2053,7 +2053,7 @@ static ssize_t target_core_dev_store(struct config_item *item,
if (!(tc_attr->store))
return -EINVAL;

return tc_attr->store((void *)se_dev, page, count);
return tc_attr->store(se_dev, page, count);
}

static struct configfs_item_operations target_core_dev_item_ops = {
Expand Down
Loading

0 comments on commit 9f0f986

Please sign in to comment.