Skip to content

Commit

Permalink
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…git/nab/target-pending

* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (62 commits)
  target: Fix compile warning w/ missing module.h include
  target: Remove legacy se_task->task_timer and associated logic
  target: Fix incorrect transport_sent usage
  target: re-use the command S/G list for single-task commands
  target: Fix BIDI t_task_cdb handling in transport_generic_new_cmd
  target: remove transport_allocate_tasks
  target: merge transport_new_cmd_obj into transport_generic_new_cmd
  target: remove the task_sg_bidi field se_task and pSCSI BIDI support
  target: transport_subsystem_check_init cleanups
  target: use a workqueue for I/O completions
  target: remove unused TRANSPORT_ states
  target: remove TRANSPORT_DEFERRED_CMD state
  target: remove the TRANSPORT_REMOVE state
  target: move depth_left manipulation out of transport_generic_request_failure
  target: stop task timers earlier
  target: remove TF_TIMER_STOP
  target: factor some duplicate code for stopping a task
  target: fix list walking in transport_free_dev_tasks
  target: use transport_cmd_check_stop_to_fabric consistently
  target: do not pass the queue object to transport_remove_cmd_from_queue
  ...
  • Loading branch information
Linus Torvalds committed Oct 25, 2011
2 parents 1bc6718 + b91bf5b commit 7c1953d
Show file tree
Hide file tree
Showing 36 changed files with 955 additions and 2,086 deletions.
1 change: 0 additions & 1 deletion drivers/target/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ target_core_mod-y := target_core_configfs.o \
target_core_hba.o \
target_core_pr.o \
target_core_alua.o \
target_core_scdb.o \
target_core_tmr.o \
target_core_tpg.o \
target_core_transport.o \
Expand Down
39 changes: 4 additions & 35 deletions drivers/target/iscsi/iscsi_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ static int iscsit_allocate_iovecs(struct iscsi_cmd *cmd)
u32 iov_count = (cmd->se_cmd.t_data_nents == 0) ? 1 :
cmd->se_cmd.t_data_nents;

iov_count += TRANSPORT_IOV_DATA_BUFFER;
iov_count += ISCSI_IOV_DATA_BUFFER;

cmd->iov_data = kzalloc(iov_count * sizeof(struct kvec), GFP_KERNEL);
if (!cmd->iov_data) {
Expand Down Expand Up @@ -3538,16 +3538,8 @@ int iscsi_target_tx_thread(void *arg)
spin_lock_bh(&conn->cmd_lock);
list_del(&cmd->i_list);
spin_unlock_bh(&conn->cmd_lock);
/*
* Determine if a struct se_cmd is assoicated with
* this struct iscsi_cmd.
*/
if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) &&
!(cmd->tmr_req))
iscsit_release_cmd(cmd);
else
transport_generic_free_cmd(&cmd->se_cmd,
1, 0);

iscsit_free_cmd(cmd);
goto get_immediate;
case ISTATE_SEND_NOPIN_WANT_RESPONSE:
spin_unlock_bh(&cmd->istate_lock);
Expand Down Expand Up @@ -3940,43 +3932,20 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn)
{
struct iscsi_cmd *cmd = NULL, *cmd_tmp = NULL;
struct iscsi_session *sess = conn->sess;
struct se_cmd *se_cmd;
/*
* We expect this function to only ever be called from either RX or TX
* thread context via iscsit_close_connection() once the other context
* has been reset -> returned sleeping pre-handler state.
*/
spin_lock_bh(&conn->cmd_lock);
list_for_each_entry_safe(cmd, cmd_tmp, &conn->conn_cmd_list, i_list) {
if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD)) {

list_del(&cmd->i_list);
spin_unlock_bh(&conn->cmd_lock);
iscsit_increment_maxcmdsn(cmd, sess);
se_cmd = &cmd->se_cmd;
/*
* Special cases for active iSCSI TMR, and
* transport_lookup_cmd_lun() failing from
* iscsit_get_lun_for_cmd() in iscsit_handle_scsi_cmd().
*/
if (cmd->tmr_req && se_cmd->transport_wait_for_tasks)
se_cmd->transport_wait_for_tasks(se_cmd, 1, 1);
else if (cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD)
transport_release_cmd(se_cmd);
else
iscsit_release_cmd(cmd);

spin_lock_bh(&conn->cmd_lock);
continue;
}
list_del(&cmd->i_list);
spin_unlock_bh(&conn->cmd_lock);

iscsit_increment_maxcmdsn(cmd, sess);
se_cmd = &cmd->se_cmd;

if (se_cmd->transport_wait_for_tasks)
se_cmd->transport_wait_for_tasks(se_cmd, 1, 1);
iscsit_free_cmd(cmd);

spin_lock_bh(&conn->cmd_lock);
}
Expand Down
34 changes: 3 additions & 31 deletions drivers/target/iscsi/iscsi_target_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* GNU General Public License for more details.
******************************************************************************/

#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/crypto.h>
#include <linux/err.h>
Expand All @@ -27,40 +28,11 @@
#include "iscsi_target_nego.h"
#include "iscsi_target_auth.h"

static unsigned char chap_asciihex_to_binaryhex(unsigned char val[2])
{
unsigned char result = 0;
/*
* MSB
*/
if ((val[0] >= 'a') && (val[0] <= 'f'))
result = ((val[0] - 'a' + 10) & 0xf) << 4;
else
if ((val[0] >= 'A') && (val[0] <= 'F'))
result = ((val[0] - 'A' + 10) & 0xf) << 4;
else /* digit */
result = ((val[0] - '0') & 0xf) << 4;
/*
* LSB
*/
if ((val[1] >= 'a') && (val[1] <= 'f'))
result |= ((val[1] - 'a' + 10) & 0xf);
else
if ((val[1] >= 'A') && (val[1] <= 'F'))
result |= ((val[1] - 'A' + 10) & 0xf);
else /* digit */
result |= ((val[1] - '0') & 0xf);

return result;
}

static int chap_string_to_hex(unsigned char *dst, unsigned char *src, int len)
{
int i, j = 0;
int j = DIV_ROUND_UP(len, 2);

for (i = 0; i < len; i += 2) {
dst[j++] = (unsigned char) chap_asciihex_to_binaryhex(&src[i]);
}
hex2bin(dst, src, j);

dst[j] = '\0';
return j;
Expand Down
4 changes: 3 additions & 1 deletion drivers/target/iscsi/iscsi_target_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
#define TA_PROD_MODE_WRITE_PROTECT 0
#define TA_CACHE_CORE_NPS 0


#define ISCSI_IOV_DATA_BUFFER 5

enum tpg_np_network_transport_table {
ISCSI_TCP = 0,
ISCSI_SCTP_TCP = 1,
Expand Down Expand Up @@ -425,7 +428,6 @@ struct iscsi_cmd {
/* Number of times struct iscsi_cmd is present in immediate queue */
atomic_t immed_queue_count;
atomic_t response_queue_count;
atomic_t transport_sent;
spinlock_t datain_lock;
spinlock_t dataout_timeout_lock;
/* spinlock for protecting struct iscsi_cmd->i_state */
Expand Down
49 changes: 7 additions & 42 deletions drivers/target/iscsi/iscsi_target_erl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,7 @@ void iscsit_free_connection_recovery_entires(struct iscsi_session *sess)
list_del(&cmd->i_list);
cmd->conn = NULL;
spin_unlock(&cr->conn_recovery_cmd_lock);
if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) ||
!(cmd->se_cmd.transport_wait_for_tasks))
iscsit_release_cmd(cmd);
else
cmd->se_cmd.transport_wait_for_tasks(
&cmd->se_cmd, 1, 1);
iscsit_free_cmd(cmd);
spin_lock(&cr->conn_recovery_cmd_lock);
}
spin_unlock(&cr->conn_recovery_cmd_lock);
Expand All @@ -170,12 +165,7 @@ void iscsit_free_connection_recovery_entires(struct iscsi_session *sess)
list_del(&cmd->i_list);
cmd->conn = NULL;
spin_unlock(&cr->conn_recovery_cmd_lock);
if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) ||
!(cmd->se_cmd.transport_wait_for_tasks))
iscsit_release_cmd(cmd);
else
cmd->se_cmd.transport_wait_for_tasks(
&cmd->se_cmd, 1, 1);
iscsit_free_cmd(cmd);
spin_lock(&cr->conn_recovery_cmd_lock);
}
spin_unlock(&cr->conn_recovery_cmd_lock);
Expand Down Expand Up @@ -260,12 +250,7 @@ void iscsit_discard_cr_cmds_by_expstatsn(
iscsit_remove_cmd_from_connection_recovery(cmd, sess);

spin_unlock(&cr->conn_recovery_cmd_lock);
if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) ||
!(cmd->se_cmd.transport_wait_for_tasks))
iscsit_release_cmd(cmd);
else
cmd->se_cmd.transport_wait_for_tasks(
&cmd->se_cmd, 1, 0);
iscsit_free_cmd(cmd);
spin_lock(&cr->conn_recovery_cmd_lock);
}
spin_unlock(&cr->conn_recovery_cmd_lock);
Expand Down Expand Up @@ -319,12 +304,7 @@ int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *conn)
list_del(&cmd->i_list);

spin_unlock_bh(&conn->cmd_lock);
if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) ||
!(cmd->se_cmd.transport_wait_for_tasks))
iscsit_release_cmd(cmd);
else
cmd->se_cmd.transport_wait_for_tasks(
&cmd->se_cmd, 1, 1);
iscsit_free_cmd(cmd);
spin_lock_bh(&conn->cmd_lock);
}
spin_unlock_bh(&conn->cmd_lock);
Expand Down Expand Up @@ -377,13 +357,7 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn)

list_del(&cmd->i_list);
spin_unlock_bh(&conn->cmd_lock);

if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) ||
!(cmd->se_cmd.transport_wait_for_tasks))
iscsit_release_cmd(cmd);
else
cmd->se_cmd.transport_wait_for_tasks(
&cmd->se_cmd, 1, 0);
iscsit_free_cmd(cmd);
spin_lock_bh(&conn->cmd_lock);
continue;
}
Expand All @@ -403,13 +377,7 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn)
(cmd->cmd_sn >= conn->sess->exp_cmd_sn)) {
list_del(&cmd->i_list);
spin_unlock_bh(&conn->cmd_lock);

if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) ||
!(cmd->se_cmd.transport_wait_for_tasks))
iscsit_release_cmd(cmd);
else
cmd->se_cmd.transport_wait_for_tasks(
&cmd->se_cmd, 1, 1);
iscsit_free_cmd(cmd);
spin_lock_bh(&conn->cmd_lock);
continue;
}
Expand All @@ -434,10 +402,7 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn)

iscsit_free_all_datain_reqs(cmd);

if ((cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) &&
cmd->se_cmd.transport_wait_for_tasks)
cmd->se_cmd.transport_wait_for_tasks(&cmd->se_cmd,
0, 0);
transport_wait_for_tasks(&cmd->se_cmd);
/*
* Add the struct iscsi_cmd to the connection recovery cmd list
*/
Expand Down
6 changes: 3 additions & 3 deletions drivers/target/iscsi/iscsi_target_tmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ static int iscsit_task_reassign_complete_write(
* so if we have received all DataOUT we can safety ignore Initiator.
*/
if (cmd->cmd_flags & ICF_GOT_LAST_DATAOUT) {
if (!atomic_read(&cmd->transport_sent)) {
if (!atomic_read(&cmd->se_cmd.t_transport_sent)) {
pr_debug("WRITE ITT: 0x%08x: t_state: %d"
" never sent to transport\n",
cmd->init_task_tag, cmd->se_cmd.t_state);
Expand Down Expand Up @@ -314,11 +314,11 @@ static int iscsit_task_reassign_complete_read(
cmd->acked_data_sn = (tmr_req->exp_data_sn - 1);
}

if (!atomic_read(&cmd->transport_sent)) {
if (!atomic_read(&cmd->se_cmd.t_transport_sent)) {
pr_debug("READ ITT: 0x%08x: t_state: %d never sent to"
" transport\n", cmd->init_task_tag,
cmd->se_cmd.t_state);
transport_generic_handle_cdb(se_cmd);
transport_handle_cdb_direct(se_cmd);
return 0;
}

Expand Down
20 changes: 19 additions & 1 deletion drivers/target/iscsi/iscsi_target_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ struct iscsi_cmd *iscsit_allocate_se_cmd_for_tmr(
}

se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd,
(void *)cmd->tmr_req, tcm_function);
(void *)cmd->tmr_req, tcm_function,
GFP_KERNEL);
if (!se_cmd->se_tmr_req)
goto out;

Expand Down Expand Up @@ -839,6 +840,23 @@ void iscsit_release_cmd(struct iscsi_cmd *cmd)
kmem_cache_free(lio_cmd_cache, cmd);
}

void iscsit_free_cmd(struct iscsi_cmd *cmd)
{
/*
* Determine if a struct se_cmd is assoicated with
* this struct iscsi_cmd.
*/
switch (cmd->iscsi_opcode) {
case ISCSI_OP_SCSI_CMD:
case ISCSI_OP_SCSI_TMFUNC:
transport_generic_free_cmd(&cmd->se_cmd, 1);
break;
default:
iscsit_release_cmd(cmd);
break;
}
}

int iscsit_check_session_usage_count(struct iscsi_session *sess)
{
spin_lock_bh(&sess->session_usage_lock);
Expand Down
1 change: 1 addition & 0 deletions drivers/target/iscsi/iscsi_target_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extern struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_c
extern void iscsit_remove_cmd_from_tx_queues(struct iscsi_cmd *, struct iscsi_conn *);
extern void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *);
extern void iscsit_release_cmd(struct iscsi_cmd *);
extern void iscsit_free_cmd(struct iscsi_cmd *);
extern int iscsit_check_session_usage_count(struct iscsi_session *);
extern void iscsit_dec_session_usage_count(struct iscsi_session *);
extern void iscsit_inc_session_usage_count(struct iscsi_session *);
Expand Down
18 changes: 15 additions & 3 deletions drivers/target/loopback/tcm_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static void tcm_loop_check_stop_free(struct se_cmd *se_cmd)
* Release the struct se_cmd, which will make a callback to release
* struct tcm_loop_cmd * in tcm_loop_deallocate_core_cmd()
*/
transport_generic_free_cmd(se_cmd, 0, 0);
transport_generic_free_cmd(se_cmd, 0);
}

static void tcm_loop_release_cmd(struct se_cmd *se_cmd)
Expand Down Expand Up @@ -290,6 +290,15 @@ static int tcm_loop_queuecommand(
*/
tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host);
tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id];
/*
* Ensure that this tl_tpg reference from the incoming sc->device->id
* has already been configured via tcm_loop_make_naa_tpg().
*/
if (!tl_tpg->tl_hba) {
set_host_byte(sc, DID_NO_CONNECT);
sc->scsi_done(sc);
return 0;
}
se_tpg = &tl_tpg->tl_se_tpg;
/*
* Determine the SAM Task Attribute and allocate tl_cmd and
Expand Down Expand Up @@ -366,7 +375,7 @@ 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, tl_tmr,
TMR_LUN_RESET);
TMR_LUN_RESET, GFP_KERNEL);
if (IS_ERR(se_cmd->se_tmr_req))
goto release;
/*
Expand All @@ -388,7 +397,7 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc)
SUCCESS : FAILED;
release:
if (se_cmd)
transport_generic_free_cmd(se_cmd, 1, 0);
transport_generic_free_cmd(se_cmd, 1);
else
kmem_cache_free(tcm_loop_cmd_cache, tl_cmd);
kfree(tl_tmr);
Expand Down Expand Up @@ -1245,6 +1254,9 @@ void tcm_loop_drop_naa_tpg(
*/
core_tpg_deregister(se_tpg);

tl_tpg->tl_hba = NULL;
tl_tpg->tl_tpgt = 0;

pr_debug("TCM_Loop_ConfigFS: Deallocated Emulated %s"
" Target Port %s,t,0x%04x\n", tcm_loop_dump_proto_id(tl_hba),
config_item_name(&wwn->wwn_group.cg_item), tpgt);
Expand Down
Loading

0 comments on commit 7c1953d

Please sign in to comment.