Skip to content

Commit 6b1c374

Browse files
Merge branch '6.2/scsi-queue' into 6.2/scsi-fixes
Pull in remaining patches from the 6.2 queue. Signed-off-by: Martin K. Petersen <[email protected]>
2 parents 1b929c0 + 1a5665f commit 6b1c374

File tree

7 files changed

+89
-8
lines changed

7 files changed

+89
-8
lines changed

drivers/scsi/mpi3mr/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# mpi3mr makefile
2-
obj-m += mpi3mr.o
2+
obj-$(CONFIG_SCSI_MPI3MR) += mpi3mr.o
33
mpi3mr-y += mpi3mr_os.o \
44
mpi3mr_fw.o \
55
mpi3mr_app.o \

drivers/scsi/scsi_debug.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,8 +1511,6 @@ static int inquiry_vpd_b0(unsigned char *arr)
15111511
put_unaligned_be64(sdebug_write_same_length, &arr[32]);
15121512

15131513
return 0x3c; /* Mandatory page length for Logical Block Provisioning */
1514-
1515-
return sizeof(vpdb0_data);
15161514
}
15171515

15181516
/* Block device characteristics VPD page (SBC-3) */

drivers/scsi/scsi_error.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ scsi_abort_command(struct scsi_cmnd *scmd)
231231
struct Scsi_Host *shost = sdev->host;
232232
unsigned long flags;
233233

234+
if (!shost->hostt->eh_abort_handler) {
235+
/* No abort handler, fail command directly */
236+
return FAILED;
237+
}
238+
234239
if (scmd->eh_eflags & SCSI_EH_ABORT_SCHEDULED) {
235240
/*
236241
* Retry after abort failed, escalate to next level.

drivers/scsi/scsi_transport_iscsi.c

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,13 @@ static const char *iscsi_session_state_name(int state)
16771677
return name;
16781678
}
16791679

1680+
static char *iscsi_session_target_state_name[] = {
1681+
[ISCSI_SESSION_TARGET_UNBOUND] = "UNBOUND",
1682+
[ISCSI_SESSION_TARGET_ALLOCATED] = "ALLOCATED",
1683+
[ISCSI_SESSION_TARGET_SCANNED] = "SCANNED",
1684+
[ISCSI_SESSION_TARGET_UNBINDING] = "UNBINDING",
1685+
};
1686+
16801687
int iscsi_session_chkready(struct iscsi_cls_session *session)
16811688
{
16821689
int err;
@@ -1786,9 +1793,13 @@ static int iscsi_user_scan_session(struct device *dev, void *data)
17861793
if ((scan_data->channel == SCAN_WILD_CARD ||
17871794
scan_data->channel == 0) &&
17881795
(scan_data->id == SCAN_WILD_CARD ||
1789-
scan_data->id == id))
1796+
scan_data->id == id)) {
17901797
scsi_scan_target(&session->dev, 0, id,
17911798
scan_data->lun, scan_data->rescan);
1799+
spin_lock_irqsave(&session->lock, flags);
1800+
session->target_state = ISCSI_SESSION_TARGET_SCANNED;
1801+
spin_unlock_irqrestore(&session->lock, flags);
1802+
}
17921803
}
17931804

17941805
user_scan_exit:
@@ -1961,31 +1972,41 @@ static void __iscsi_unbind_session(struct work_struct *work)
19611972
struct iscsi_cls_host *ihost = shost->shost_data;
19621973
unsigned long flags;
19631974
unsigned int target_id;
1975+
bool remove_target = true;
19641976

19651977
ISCSI_DBG_TRANS_SESSION(session, "Unbinding session\n");
19661978

19671979
/* Prevent new scans and make sure scanning is not in progress */
19681980
mutex_lock(&ihost->mutex);
19691981
spin_lock_irqsave(&session->lock, flags);
1970-
if (session->target_id == ISCSI_MAX_TARGET) {
1982+
if (session->target_state == ISCSI_SESSION_TARGET_ALLOCATED) {
1983+
remove_target = false;
1984+
} else if (session->target_state != ISCSI_SESSION_TARGET_SCANNED) {
19711985
spin_unlock_irqrestore(&session->lock, flags);
19721986
mutex_unlock(&ihost->mutex);
1973-
goto unbind_session_exit;
1987+
ISCSI_DBG_TRANS_SESSION(session,
1988+
"Skipping target unbinding: Session is unbound/unbinding.\n");
1989+
return;
19741990
}
19751991

1992+
session->target_state = ISCSI_SESSION_TARGET_UNBINDING;
19761993
target_id = session->target_id;
19771994
session->target_id = ISCSI_MAX_TARGET;
19781995
spin_unlock_irqrestore(&session->lock, flags);
19791996
mutex_unlock(&ihost->mutex);
19801997

1981-
scsi_remove_target(&session->dev);
1998+
if (remove_target)
1999+
scsi_remove_target(&session->dev);
19822000

19832001
if (session->ida_used)
19842002
ida_free(&iscsi_sess_ida, target_id);
19852003

1986-
unbind_session_exit:
19872004
iscsi_session_event(session, ISCSI_KEVENT_UNBIND_SESSION);
19882005
ISCSI_DBG_TRANS_SESSION(session, "Completed target removal\n");
2006+
2007+
spin_lock_irqsave(&session->lock, flags);
2008+
session->target_state = ISCSI_SESSION_TARGET_UNBOUND;
2009+
spin_unlock_irqrestore(&session->lock, flags);
19892010
}
19902011

19912012
static void __iscsi_destroy_session(struct work_struct *work)
@@ -2062,6 +2083,9 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
20622083
session->ida_used = true;
20632084
} else
20642085
session->target_id = target_id;
2086+
spin_lock_irqsave(&session->lock, flags);
2087+
session->target_state = ISCSI_SESSION_TARGET_ALLOCATED;
2088+
spin_unlock_irqrestore(&session->lock, flags);
20652089

20662090
dev_set_name(&session->dev, "session%u", session->sid);
20672091
err = device_add(&session->dev);
@@ -4369,6 +4393,19 @@ iscsi_session_attr(def_taskmgmt_tmo, ISCSI_PARAM_DEF_TASKMGMT_TMO, 0);
43694393
iscsi_session_attr(discovery_parent_idx, ISCSI_PARAM_DISCOVERY_PARENT_IDX, 0);
43704394
iscsi_session_attr(discovery_parent_type, ISCSI_PARAM_DISCOVERY_PARENT_TYPE, 0);
43714395

4396+
static ssize_t
4397+
show_priv_session_target_state(struct device *dev, struct device_attribute *attr,
4398+
char *buf)
4399+
{
4400+
struct iscsi_cls_session *session = iscsi_dev_to_session(dev->parent);
4401+
4402+
return sysfs_emit(buf, "%s\n",
4403+
iscsi_session_target_state_name[session->target_state]);
4404+
}
4405+
4406+
static ISCSI_CLASS_ATTR(priv_sess, target_state, S_IRUGO,
4407+
show_priv_session_target_state, NULL);
4408+
43724409
static ssize_t
43734410
show_priv_session_state(struct device *dev, struct device_attribute *attr,
43744411
char *buf)
@@ -4471,6 +4508,7 @@ static struct attribute *iscsi_session_attrs[] = {
44714508
&dev_attr_sess_boot_target.attr,
44724509
&dev_attr_priv_sess_recovery_tmo.attr,
44734510
&dev_attr_priv_sess_state.attr,
4511+
&dev_attr_priv_sess_target_state.attr,
44744512
&dev_attr_priv_sess_creator.attr,
44754513
&dev_attr_sess_chap_out_idx.attr,
44764514
&dev_attr_sess_chap_in_idx.attr,
@@ -4584,6 +4622,8 @@ static umode_t iscsi_session_attr_is_visible(struct kobject *kobj,
45844622
return S_IRUGO | S_IWUSR;
45854623
else if (attr == &dev_attr_priv_sess_state.attr)
45864624
return S_IRUGO;
4625+
else if (attr == &dev_attr_priv_sess_target_state.attr)
4626+
return S_IRUGO;
45874627
else if (attr == &dev_attr_priv_sess_creator.attr)
45884628
return S_IRUGO;
45894629
else if (attr == &dev_attr_priv_sess_target_id.attr)

drivers/scsi/storvsc_drv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,9 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
18231823
ret = storvsc_do_io(dev, cmd_request, get_cpu());
18241824
put_cpu();
18251825

1826+
if (ret)
1827+
scsi_dma_unmap(scmnd);
1828+
18261829
if (ret == -EAGAIN) {
18271830
/* no more space */
18281831
ret = SCSI_MLQUEUE_DEVICE_BUSY;

drivers/ufs/core/ufshcd.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6056,6 +6056,14 @@ void ufshcd_schedule_eh_work(struct ufs_hba *hba)
60566056
}
60576057
}
60586058

6059+
static void ufshcd_force_error_recovery(struct ufs_hba *hba)
6060+
{
6061+
spin_lock_irq(hba->host->host_lock);
6062+
hba->force_reset = true;
6063+
ufshcd_schedule_eh_work(hba);
6064+
spin_unlock_irq(hba->host->host_lock);
6065+
}
6066+
60596067
static void ufshcd_clk_scaling_allow(struct ufs_hba *hba, bool allow)
60606068
{
60616069
down_write(&hba->clk_scaling_lock);
@@ -9083,6 +9091,15 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
90839091

90849092
if (!hba->dev_info.b_rpm_dev_flush_capable) {
90859093
ret = ufshcd_set_dev_pwr_mode(hba, req_dev_pwr_mode);
9094+
if (ret && pm_op != UFS_SHUTDOWN_PM) {
9095+
/*
9096+
* If return err in suspend flow, IO will hang.
9097+
* Trigger error handler and break suspend for
9098+
* error recovery.
9099+
*/
9100+
ufshcd_force_error_recovery(hba);
9101+
ret = -EBUSY;
9102+
}
90869103
if (ret)
90879104
goto enable_scaling;
90889105
}
@@ -9094,6 +9111,15 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
90949111
*/
90959112
check_for_bkops = !ufshcd_is_ufs_dev_deepsleep(hba);
90969113
ret = ufshcd_link_state_transition(hba, req_link_state, check_for_bkops);
9114+
if (ret && pm_op != UFS_SHUTDOWN_PM) {
9115+
/*
9116+
* If return err in suspend flow, IO will hang.
9117+
* Trigger error handler and break suspend for
9118+
* error recovery.
9119+
*/
9120+
ufshcd_force_error_recovery(hba);
9121+
ret = -EBUSY;
9122+
}
90979123
if (ret)
90989124
goto set_dev_active;
90999125

include/scsi/scsi_transport_iscsi.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,14 @@ enum {
236236
ISCSI_SESSION_FREE,
237237
};
238238

239+
enum {
240+
ISCSI_SESSION_TARGET_UNBOUND,
241+
ISCSI_SESSION_TARGET_ALLOCATED,
242+
ISCSI_SESSION_TARGET_SCANNED,
243+
ISCSI_SESSION_TARGET_UNBINDING,
244+
ISCSI_SESSION_TARGET_MAX,
245+
};
246+
239247
#define ISCSI_MAX_TARGET -1
240248

241249
struct iscsi_cls_session {
@@ -264,6 +272,7 @@ struct iscsi_cls_session {
264272
*/
265273
pid_t creator;
266274
int state;
275+
int target_state; /* session target bind state */
267276
int sid; /* session id */
268277
void *dd_data; /* LLD private data */
269278
struct device dev; /* sysfs transport/container device */

0 commit comments

Comments
 (0)