Skip to content

Commit 7c1953d

Browse files
committed
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/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 ...
2 parents 1bc6718 + b91bf5b commit 7c1953d

36 files changed

Lines changed: 955 additions & 2086 deletions

‎drivers/target/Makefile‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ target_core_mod-y := target_core_configfs.o \
66
target_core_hba.o \
77
target_core_pr.o \
88
target_core_alua.o \
9-
target_core_scdb.o \
109
target_core_tmr.o \
1110
target_core_tpg.o \
1211
target_core_transport.o \

‎drivers/target/iscsi/iscsi_target.c‎

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ static int iscsit_allocate_iovecs(struct iscsi_cmd *cmd)
765765
u32 iov_count = (cmd->se_cmd.t_data_nents == 0) ? 1 :
766766
cmd->se_cmd.t_data_nents;
767767

768-
iov_count += TRANSPORT_IOV_DATA_BUFFER;
768+
iov_count += ISCSI_IOV_DATA_BUFFER;
769769

770770
cmd->iov_data = kzalloc(iov_count * sizeof(struct kvec), GFP_KERNEL);
771771
if (!cmd->iov_data) {
@@ -3538,16 +3538,8 @@ int iscsi_target_tx_thread(void *arg)
35383538
spin_lock_bh(&conn->cmd_lock);
35393539
list_del(&cmd->i_list);
35403540
spin_unlock_bh(&conn->cmd_lock);
3541-
/*
3542-
* Determine if a struct se_cmd is assoicated with
3543-
* this struct iscsi_cmd.
3544-
*/
3545-
if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) &&
3546-
!(cmd->tmr_req))
3547-
iscsit_release_cmd(cmd);
3548-
else
3549-
transport_generic_free_cmd(&cmd->se_cmd,
3550-
1, 0);
3541+
3542+
iscsit_free_cmd(cmd);
35513543
goto get_immediate;
35523544
case ISTATE_SEND_NOPIN_WANT_RESPONSE:
35533545
spin_unlock_bh(&cmd->istate_lock);
@@ -3940,43 +3932,20 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn)
39403932
{
39413933
struct iscsi_cmd *cmd = NULL, *cmd_tmp = NULL;
39423934
struct iscsi_session *sess = conn->sess;
3943-
struct se_cmd *se_cmd;
39443935
/*
39453936
* We expect this function to only ever be called from either RX or TX
39463937
* thread context via iscsit_close_connection() once the other context
39473938
* has been reset -> returned sleeping pre-handler state.
39483939
*/
39493940
spin_lock_bh(&conn->cmd_lock);
39503941
list_for_each_entry_safe(cmd, cmd_tmp, &conn->conn_cmd_list, i_list) {
3951-
if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD)) {
39523942

3953-
list_del(&cmd->i_list);
3954-
spin_unlock_bh(&conn->cmd_lock);
3955-
iscsit_increment_maxcmdsn(cmd, sess);
3956-
se_cmd = &cmd->se_cmd;
3957-
/*
3958-
* Special cases for active iSCSI TMR, and
3959-
* transport_lookup_cmd_lun() failing from
3960-
* iscsit_get_lun_for_cmd() in iscsit_handle_scsi_cmd().
3961-
*/
3962-
if (cmd->tmr_req && se_cmd->transport_wait_for_tasks)
3963-
se_cmd->transport_wait_for_tasks(se_cmd, 1, 1);
3964-
else if (cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD)
3965-
transport_release_cmd(se_cmd);
3966-
else
3967-
iscsit_release_cmd(cmd);
3968-
3969-
spin_lock_bh(&conn->cmd_lock);
3970-
continue;
3971-
}
39723943
list_del(&cmd->i_list);
39733944
spin_unlock_bh(&conn->cmd_lock);
39743945

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

3978-
if (se_cmd->transport_wait_for_tasks)
3979-
se_cmd->transport_wait_for_tasks(se_cmd, 1, 1);
3948+
iscsit_free_cmd(cmd);
39803949

39813950
spin_lock_bh(&conn->cmd_lock);
39823951
}

‎drivers/target/iscsi/iscsi_target_auth.c‎

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* GNU General Public License for more details.
1919
******************************************************************************/
2020

21+
#include <linux/kernel.h>
2122
#include <linux/string.h>
2223
#include <linux/crypto.h>
2324
#include <linux/err.h>
@@ -27,40 +28,11 @@
2728
#include "iscsi_target_nego.h"
2829
#include "iscsi_target_auth.h"
2930

30-
static unsigned char chap_asciihex_to_binaryhex(unsigned char val[2])
31-
{
32-
unsigned char result = 0;
33-
/*
34-
* MSB
35-
*/
36-
if ((val[0] >= 'a') && (val[0] <= 'f'))
37-
result = ((val[0] - 'a' + 10) & 0xf) << 4;
38-
else
39-
if ((val[0] >= 'A') && (val[0] <= 'F'))
40-
result = ((val[0] - 'A' + 10) & 0xf) << 4;
41-
else /* digit */
42-
result = ((val[0] - '0') & 0xf) << 4;
43-
/*
44-
* LSB
45-
*/
46-
if ((val[1] >= 'a') && (val[1] <= 'f'))
47-
result |= ((val[1] - 'a' + 10) & 0xf);
48-
else
49-
if ((val[1] >= 'A') && (val[1] <= 'F'))
50-
result |= ((val[1] - 'A' + 10) & 0xf);
51-
else /* digit */
52-
result |= ((val[1] - '0') & 0xf);
53-
54-
return result;
55-
}
56-
5731
static int chap_string_to_hex(unsigned char *dst, unsigned char *src, int len)
5832
{
59-
int i, j = 0;
33+
int j = DIV_ROUND_UP(len, 2);
6034

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

6537
dst[j] = '\0';
6638
return j;

‎drivers/target/iscsi/iscsi_target_core.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
#define TA_PROD_MODE_WRITE_PROTECT 0
5858
#define TA_CACHE_CORE_NPS 0
5959

60+
61+
#define ISCSI_IOV_DATA_BUFFER 5
62+
6063
enum tpg_np_network_transport_table {
6164
ISCSI_TCP = 0,
6265
ISCSI_SCTP_TCP = 1,
@@ -425,7 +428,6 @@ struct iscsi_cmd {
425428
/* Number of times struct iscsi_cmd is present in immediate queue */
426429
atomic_t immed_queue_count;
427430
atomic_t response_queue_count;
428-
atomic_t transport_sent;
429431
spinlock_t datain_lock;
430432
spinlock_t dataout_timeout_lock;
431433
/* spinlock for protecting struct iscsi_cmd->i_state */

‎drivers/target/iscsi/iscsi_target_erl2.c‎

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,7 @@ void iscsit_free_connection_recovery_entires(struct iscsi_session *sess)
143143
list_del(&cmd->i_list);
144144
cmd->conn = NULL;
145145
spin_unlock(&cr->conn_recovery_cmd_lock);
146-
if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) ||
147-
!(cmd->se_cmd.transport_wait_for_tasks))
148-
iscsit_release_cmd(cmd);
149-
else
150-
cmd->se_cmd.transport_wait_for_tasks(
151-
&cmd->se_cmd, 1, 1);
146+
iscsit_free_cmd(cmd);
152147
spin_lock(&cr->conn_recovery_cmd_lock);
153148
}
154149
spin_unlock(&cr->conn_recovery_cmd_lock);
@@ -170,12 +165,7 @@ void iscsit_free_connection_recovery_entires(struct iscsi_session *sess)
170165
list_del(&cmd->i_list);
171166
cmd->conn = NULL;
172167
spin_unlock(&cr->conn_recovery_cmd_lock);
173-
if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) ||
174-
!(cmd->se_cmd.transport_wait_for_tasks))
175-
iscsit_release_cmd(cmd);
176-
else
177-
cmd->se_cmd.transport_wait_for_tasks(
178-
&cmd->se_cmd, 1, 1);
168+
iscsit_free_cmd(cmd);
179169
spin_lock(&cr->conn_recovery_cmd_lock);
180170
}
181171
spin_unlock(&cr->conn_recovery_cmd_lock);
@@ -260,12 +250,7 @@ void iscsit_discard_cr_cmds_by_expstatsn(
260250
iscsit_remove_cmd_from_connection_recovery(cmd, sess);
261251

262252
spin_unlock(&cr->conn_recovery_cmd_lock);
263-
if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) ||
264-
!(cmd->se_cmd.transport_wait_for_tasks))
265-
iscsit_release_cmd(cmd);
266-
else
267-
cmd->se_cmd.transport_wait_for_tasks(
268-
&cmd->se_cmd, 1, 0);
253+
iscsit_free_cmd(cmd);
269254
spin_lock(&cr->conn_recovery_cmd_lock);
270255
}
271256
spin_unlock(&cr->conn_recovery_cmd_lock);
@@ -319,12 +304,7 @@ int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *conn)
319304
list_del(&cmd->i_list);
320305

321306
spin_unlock_bh(&conn->cmd_lock);
322-
if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) ||
323-
!(cmd->se_cmd.transport_wait_for_tasks))
324-
iscsit_release_cmd(cmd);
325-
else
326-
cmd->se_cmd.transport_wait_for_tasks(
327-
&cmd->se_cmd, 1, 1);
307+
iscsit_free_cmd(cmd);
328308
spin_lock_bh(&conn->cmd_lock);
329309
}
330310
spin_unlock_bh(&conn->cmd_lock);
@@ -377,13 +357,7 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn)
377357

378358
list_del(&cmd->i_list);
379359
spin_unlock_bh(&conn->cmd_lock);
380-
381-
if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) ||
382-
!(cmd->se_cmd.transport_wait_for_tasks))
383-
iscsit_release_cmd(cmd);
384-
else
385-
cmd->se_cmd.transport_wait_for_tasks(
386-
&cmd->se_cmd, 1, 0);
360+
iscsit_free_cmd(cmd);
387361
spin_lock_bh(&conn->cmd_lock);
388362
continue;
389363
}
@@ -403,13 +377,7 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn)
403377
(cmd->cmd_sn >= conn->sess->exp_cmd_sn)) {
404378
list_del(&cmd->i_list);
405379
spin_unlock_bh(&conn->cmd_lock);
406-
407-
if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) ||
408-
!(cmd->se_cmd.transport_wait_for_tasks))
409-
iscsit_release_cmd(cmd);
410-
else
411-
cmd->se_cmd.transport_wait_for_tasks(
412-
&cmd->se_cmd, 1, 1);
380+
iscsit_free_cmd(cmd);
413381
spin_lock_bh(&conn->cmd_lock);
414382
continue;
415383
}
@@ -434,10 +402,7 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn)
434402

435403
iscsit_free_all_datain_reqs(cmd);
436404

437-
if ((cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) &&
438-
cmd->se_cmd.transport_wait_for_tasks)
439-
cmd->se_cmd.transport_wait_for_tasks(&cmd->se_cmd,
440-
0, 0);
405+
transport_wait_for_tasks(&cmd->se_cmd);
441406
/*
442407
* Add the struct iscsi_cmd to the connection recovery cmd list
443408
*/

‎drivers/target/iscsi/iscsi_target_tmr.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static int iscsit_task_reassign_complete_write(
250250
* so if we have received all DataOUT we can safety ignore Initiator.
251251
*/
252252
if (cmd->cmd_flags & ICF_GOT_LAST_DATAOUT) {
253-
if (!atomic_read(&cmd->transport_sent)) {
253+
if (!atomic_read(&cmd->se_cmd.t_transport_sent)) {
254254
pr_debug("WRITE ITT: 0x%08x: t_state: %d"
255255
" never sent to transport\n",
256256
cmd->init_task_tag, cmd->se_cmd.t_state);
@@ -314,11 +314,11 @@ static int iscsit_task_reassign_complete_read(
314314
cmd->acked_data_sn = (tmr_req->exp_data_sn - 1);
315315
}
316316

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

‎drivers/target/iscsi/iscsi_target_util.c‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ struct iscsi_cmd *iscsit_allocate_se_cmd_for_tmr(
289289
}
290290

291291
se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd,
292-
(void *)cmd->tmr_req, tcm_function);
292+
(void *)cmd->tmr_req, tcm_function,
293+
GFP_KERNEL);
293294
if (!se_cmd->se_tmr_req)
294295
goto out;
295296

@@ -839,6 +840,23 @@ void iscsit_release_cmd(struct iscsi_cmd *cmd)
839840
kmem_cache_free(lio_cmd_cache, cmd);
840841
}
841842

843+
void iscsit_free_cmd(struct iscsi_cmd *cmd)
844+
{
845+
/*
846+
* Determine if a struct se_cmd is assoicated with
847+
* this struct iscsi_cmd.
848+
*/
849+
switch (cmd->iscsi_opcode) {
850+
case ISCSI_OP_SCSI_CMD:
851+
case ISCSI_OP_SCSI_TMFUNC:
852+
transport_generic_free_cmd(&cmd->se_cmd, 1);
853+
break;
854+
default:
855+
iscsit_release_cmd(cmd);
856+
break;
857+
}
858+
}
859+
842860
int iscsit_check_session_usage_count(struct iscsi_session *sess)
843861
{
844862
spin_lock_bh(&sess->session_usage_lock);

‎drivers/target/iscsi/iscsi_target_util.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ extern struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_c
3030
extern void iscsit_remove_cmd_from_tx_queues(struct iscsi_cmd *, struct iscsi_conn *);
3131
extern void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *);
3232
extern void iscsit_release_cmd(struct iscsi_cmd *);
33+
extern void iscsit_free_cmd(struct iscsi_cmd *);
3334
extern int iscsit_check_session_usage_count(struct iscsi_session *);
3435
extern void iscsit_dec_session_usage_count(struct iscsi_session *);
3536
extern void iscsit_inc_session_usage_count(struct iscsi_session *);

‎drivers/target/loopback/tcm_loop.c‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ static void tcm_loop_check_stop_free(struct se_cmd *se_cmd)
200200
* Release the struct se_cmd, which will make a callback to release
201201
* struct tcm_loop_cmd * in tcm_loop_deallocate_core_cmd()
202202
*/
203-
transport_generic_free_cmd(se_cmd, 0, 0);
203+
transport_generic_free_cmd(se_cmd, 0);
204204
}
205205

206206
static void tcm_loop_release_cmd(struct se_cmd *se_cmd)
@@ -290,6 +290,15 @@ static int tcm_loop_queuecommand(
290290
*/
291291
tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host);
292292
tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id];
293+
/*
294+
* Ensure that this tl_tpg reference from the incoming sc->device->id
295+
* has already been configured via tcm_loop_make_naa_tpg().
296+
*/
297+
if (!tl_tpg->tl_hba) {
298+
set_host_byte(sc, DID_NO_CONNECT);
299+
sc->scsi_done(sc);
300+
return 0;
301+
}
293302
se_tpg = &tl_tpg->tl_se_tpg;
294303
/*
295304
* Determine the SAM Task Attribute and allocate tl_cmd and
@@ -366,7 +375,7 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc)
366375
* Allocate the LUN_RESET TMR
367376
*/
368377
se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd, tl_tmr,
369-
TMR_LUN_RESET);
378+
TMR_LUN_RESET, GFP_KERNEL);
370379
if (IS_ERR(se_cmd->se_tmr_req))
371380
goto release;
372381
/*
@@ -388,7 +397,7 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc)
388397
SUCCESS : FAILED;
389398
release:
390399
if (se_cmd)
391-
transport_generic_free_cmd(se_cmd, 1, 0);
400+
transport_generic_free_cmd(se_cmd, 1);
392401
else
393402
kmem_cache_free(tcm_loop_cmd_cache, tl_cmd);
394403
kfree(tl_tmr);
@@ -1245,6 +1254,9 @@ void tcm_loop_drop_naa_tpg(
12451254
*/
12461255
core_tpg_deregister(se_tpg);
12471256

1257+
tl_tpg->tl_hba = NULL;
1258+
tl_tpg->tl_tpgt = 0;
1259+
12481260
pr_debug("TCM_Loop_ConfigFS: Deallocated Emulated %s"
12491261
" Target Port %s,t,0x%04x\n", tcm_loop_dump_proto_id(tl_hba),
12501262
config_item_name(&wwn->wwn_group.cg_item), tpgt);

0 commit comments

Comments
 (0)