Skip to content

Commit 0923699

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Pull SCSI target fixes from Nicholas Bellinger: "The executive summary includes: - Post-merge review comments for tcm_vhost (MST + nab) - Avoid debugging overhead when not debugging for tcm-fc(FCoE) (MDR) - Fix NULL pointer dereference bug on alloc_page failulre (Yi Zou) - Fix REPORT_LUNs regression bug with pSCSI export (AlexE + nab) - Fix regression bug with handling of zero-length data CDBs (nab) - Fix vhost_scsi_target structure alignment (MST) Thanks again to everyone who contributed a bugfix patch, gave review feedback on tcm_vhost code, and/or reported a bug during their own testing over the last weeks. There is one other outstanding bug reported by Roland recently related to SCSI transfer length overflow handling, for which the current proposed bugfix has been left in queue pending further testing with other non iscsi-target based fabric drivers. As the patch is verified with loopback (local SGL memory from SCSI LLD) + tcm_qla2xxx (TCM allocated SGL memory mapped to PCI HW) fabric ports, it will be included into the next 3.6-rc-fixes PULL request." * git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: target: Remove unused se_cmd.cmd_spdtl tcm_fc: rcu_deref outside rcu lock/unlock section tcm_vhost: Fix vhost_scsi_target structure alignment target: Fix regression bug with handling of zero-length data CDBs target/pscsi: Fix bug with REPORT_LUNs handling for SCSI passthrough tcm_vhost: Change vhost_scsi_target->vhost_wwpn to char * target: fix NULL pointer dereference bug alloc_page() fails to get memory tcm_fc: Avoid debug overhead when not debugging tcm_vhost: Post-merge review changes requested by MST tcm_vhost: Fix incorrect IS_ERR() usage in vhost_scsi_map_iov_to_sgl
2 parents 2e2d8c9 + af74115 commit 0923699

File tree

8 files changed

+146
-108
lines changed

8 files changed

+146
-108
lines changed

drivers/target/target_core_pscsi.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,15 @@ static int pscsi_transport_complete(struct se_cmd *cmd, struct scatterlist *sg)
673673
struct scsi_device *sd = pdv->pdv_sd;
674674
int result;
675675
struct pscsi_plugin_task *pt = cmd->priv;
676-
unsigned char *cdb = &pt->pscsi_cdb[0];
676+
unsigned char *cdb;
677+
/*
678+
* Special case for REPORT_LUNs handling where pscsi_plugin_task has
679+
* not been allocated because TCM is handling the emulation directly.
680+
*/
681+
if (!pt)
682+
return 0;
677683

684+
cdb = &pt->pscsi_cdb[0];
678685
result = pt->pscsi_result;
679686
/*
680687
* Hack to make sure that Write-Protect modepage is set if R/O mode is

drivers/target/target_core_transport.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,8 +1165,6 @@ int target_cmd_size_check(struct se_cmd *cmd, unsigned int size)
11651165
" 0x%02x\n", cmd->se_tfo->get_fabric_name(),
11661166
cmd->data_length, size, cmd->t_task_cdb[0]);
11671167

1168-
cmd->cmd_spdtl = size;
1169-
11701168
if (cmd->data_direction == DMA_TO_DEVICE) {
11711169
pr_err("Rejecting underflow/overflow"
11721170
" WRITE data\n");
@@ -2294,9 +2292,9 @@ transport_generic_get_mem(struct se_cmd *cmd)
22942292
return 0;
22952293

22962294
out:
2297-
while (i >= 0) {
2298-
__free_page(sg_page(&cmd->t_data_sg[i]));
2295+
while (i > 0) {
22992296
i--;
2297+
__free_page(sg_page(&cmd->t_data_sg[i]));
23002298
}
23012299
kfree(cmd->t_data_sg);
23022300
cmd->t_data_sg = NULL;
@@ -2323,9 +2321,12 @@ int transport_generic_new_cmd(struct se_cmd *cmd)
23232321
if (ret < 0)
23242322
goto out_fail;
23252323
}
2326-
2327-
/* Workaround for handling zero-length control CDBs */
2328-
if (!(cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) && !cmd->data_length) {
2324+
/*
2325+
* If this command doesn't have any payload and we don't have to call
2326+
* into the fabric for data transfers, go ahead and complete it right
2327+
* away.
2328+
*/
2329+
if (!cmd->data_length) {
23292330
spin_lock_irq(&cmd->t_state_lock);
23302331
cmd->t_state = TRANSPORT_COMPLETE;
23312332
cmd->transport_state |= CMD_T_ACTIVE;

drivers/target/tcm_fc/tcm_fc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ extern struct list_head ft_lport_list;
131131
extern struct mutex ft_lport_lock;
132132
extern struct fc4_prov ft_prov;
133133
extern struct target_fabric_configfs *ft_configfs;
134+
extern unsigned int ft_debug_logging;
134135

135136
/*
136137
* Fabric methods.

drivers/target/tcm_fc/tfc_cmd.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
/*
4949
* Dump cmd state for debugging.
5050
*/
51-
void ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
51+
static void _ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
5252
{
5353
struct fc_exch *ep;
5454
struct fc_seq *sp;
@@ -80,6 +80,12 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
8080
}
8181
}
8282

83+
void ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
84+
{
85+
if (unlikely(ft_debug_logging))
86+
_ft_dump_cmd(cmd, caller);
87+
}
88+
8389
static void ft_free_cmd(struct ft_cmd *cmd)
8490
{
8591
struct fc_frame *fp;

drivers/target/tcm_fc/tfc_sess.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,9 @@ static void ft_prlo(struct fc_rport_priv *rdata)
456456
struct ft_tport *tport;
457457

458458
mutex_lock(&ft_lport_lock);
459-
tport = rcu_dereference(rdata->local_port->prov[FC_TYPE_FCP]);
459+
tport = rcu_dereference_protected(rdata->local_port->prov[FC_TYPE_FCP],
460+
lockdep_is_held(&ft_lport_lock));
461+
460462
if (!tport) {
461463
mutex_unlock(&ft_lport_lock);
462464
return;

0 commit comments

Comments
 (0)