Skip to content

Commit 06c9440

Browse files
committed
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley: "Two basic fixes: one for the sparse problem with the blacklist flags and another for a hang forever in bnx2i" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: Use 'blist_flags_t' for scsi_devinfo flags scsi: bnx2fc: Fix hung task messages when a cleanup response is not received during abort
2 parents b64f26c + 5ebde46 commit 06c9440

File tree

6 files changed

+78
-51
lines changed

6 files changed

+78
-51
lines changed

drivers/scsi/bnx2fc/bnx2fc_io.c

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,24 +1084,35 @@ static int bnx2fc_abts_cleanup(struct bnx2fc_cmd *io_req)
10841084
{
10851085
struct bnx2fc_rport *tgt = io_req->tgt;
10861086
int rc = SUCCESS;
1087+
unsigned int time_left;
10871088

10881089
io_req->wait_for_comp = 1;
10891090
bnx2fc_initiate_cleanup(io_req);
10901091

10911092
spin_unlock_bh(&tgt->tgt_lock);
10921093

1093-
wait_for_completion(&io_req->tm_done);
1094-
1094+
/*
1095+
* Can't wait forever on cleanup response lest we let the SCSI error
1096+
* handler wait forever
1097+
*/
1098+
time_left = wait_for_completion_timeout(&io_req->tm_done,
1099+
BNX2FC_FW_TIMEOUT);
10951100
io_req->wait_for_comp = 0;
1101+
if (!time_left)
1102+
BNX2FC_IO_DBG(io_req, "%s(): Wait for cleanup timed out.\n",
1103+
__func__);
1104+
10961105
/*
1097-
* release the reference taken in eh_abort to allow the
1098-
* target to re-login after flushing IOs
1106+
* Release reference held by SCSI command the cleanup completion
1107+
* hits the BNX2FC_CLEANUP case in bnx2fc_process_cq_compl() and
1108+
* thus the SCSI command is not returnedi by bnx2fc_scsi_done().
10991109
*/
11001110
kref_put(&io_req->refcount, bnx2fc_cmd_release);
11011111

11021112
spin_lock_bh(&tgt->tgt_lock);
11031113
return rc;
11041114
}
1115+
11051116
/**
11061117
* bnx2fc_eh_abort - eh_abort_handler api to abort an outstanding
11071118
* SCSI command
@@ -1118,6 +1129,7 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd)
11181129
struct fc_lport *lport;
11191130
struct bnx2fc_rport *tgt;
11201131
int rc;
1132+
unsigned int time_left;
11211133

11221134
rc = fc_block_scsi_eh(sc_cmd);
11231135
if (rc)
@@ -1194,14 +1206,19 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd)
11941206
if (cancel_delayed_work(&io_req->timeout_work))
11951207
kref_put(&io_req->refcount,
11961208
bnx2fc_cmd_release); /* drop timer hold */
1209+
/*
1210+
* We don't want to hold off the upper layer timer so simply
1211+
* cleanup the command and return that I/O was successfully
1212+
* aborted.
1213+
*/
11971214
rc = bnx2fc_abts_cleanup(io_req);
11981215
/* This only occurs when an task abort was requested while ABTS
11991216
is in progress. Setting the IO_CLEANUP flag will skip the
12001217
RRQ process in the case when the fw generated SCSI_CMD cmpl
12011218
was a result from the ABTS request rather than the CLEANUP
12021219
request */
12031220
set_bit(BNX2FC_FLAG_IO_CLEANUP, &io_req->req_flags);
1204-
goto out;
1221+
goto done;
12051222
}
12061223

12071224
/* Cancel the current timer running on this io_req */
@@ -1221,7 +1238,11 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd)
12211238
}
12221239
spin_unlock_bh(&tgt->tgt_lock);
12231240

1224-
wait_for_completion(&io_req->tm_done);
1241+
/* Wait 2 * RA_TOV + 1 to be sure timeout function hasn't fired */
1242+
time_left = wait_for_completion_timeout(&io_req->tm_done,
1243+
(2 * rp->r_a_tov + 1) * HZ);
1244+
if (time_left)
1245+
BNX2FC_IO_DBG(io_req, "Timed out in eh_abort waiting for tm_done");
12251246

12261247
spin_lock_bh(&tgt->tgt_lock);
12271248
io_req->wait_for_comp = 0;
@@ -1233,8 +1254,12 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd)
12331254
/* Let the scsi-ml try to recover this command */
12341255
printk(KERN_ERR PFX "abort failed, xid = 0x%x\n",
12351256
io_req->xid);
1257+
/*
1258+
* Cleanup firmware residuals before returning control back
1259+
* to SCSI ML.
1260+
*/
12361261
rc = bnx2fc_abts_cleanup(io_req);
1237-
goto out;
1262+
goto done;
12381263
} else {
12391264
/*
12401265
* We come here even when there was a race condition
@@ -1249,7 +1274,6 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd)
12491274
done:
12501275
/* release the reference taken in eh_abort */
12511276
kref_put(&io_req->refcount, bnx2fc_cmd_release);
1252-
out:
12531277
spin_unlock_bh(&tgt->tgt_lock);
12541278
return rc;
12551279
}

drivers/scsi/scsi_devinfo.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct scsi_dev_info_list {
2222
struct list_head dev_info_list;
2323
char vendor[8];
2424
char model[16];
25-
unsigned flags;
25+
blist_flags_t flags;
2626
unsigned compatible; /* for use with scsi_static_device_list entries */
2727
};
2828

@@ -35,7 +35,7 @@ struct scsi_dev_info_list_table {
3535

3636

3737
static const char spaces[] = " "; /* 16 of them */
38-
static unsigned scsi_default_dev_flags;
38+
static blist_flags_t scsi_default_dev_flags;
3939
static LIST_HEAD(scsi_dev_info_list);
4040
static char scsi_dev_flags[256];
4141

@@ -52,7 +52,7 @@ static struct {
5252
char *vendor;
5353
char *model;
5454
char *revision; /* revision known to be bad, unused */
55-
unsigned flags;
55+
blist_flags_t flags;
5656
} scsi_static_device_list[] __initdata = {
5757
/*
5858
* The following devices are known not to tolerate a lun != 0 scan
@@ -335,7 +335,7 @@ static void scsi_strcpy_devinfo(char *name, char *to, size_t to_length,
335335
* Returns: 0 OK, -error on failure.
336336
**/
337337
static int scsi_dev_info_list_add(int compatible, char *vendor, char *model,
338-
char *strflags, int flags)
338+
char *strflags, blist_flags_t flags)
339339
{
340340
return scsi_dev_info_list_add_keyed(compatible, vendor, model,
341341
strflags, flags,
@@ -361,7 +361,7 @@ static int scsi_dev_info_list_add(int compatible, char *vendor, char *model,
361361
* Returns: 0 OK, -error on failure.
362362
**/
363363
int scsi_dev_info_list_add_keyed(int compatible, char *vendor, char *model,
364-
char *strflags, int flags, int key)
364+
char *strflags, blist_flags_t flags, int key)
365365
{
366366
struct scsi_dev_info_list *devinfo;
367367
struct scsi_dev_info_list_table *devinfo_table =
@@ -571,9 +571,9 @@ static int scsi_dev_info_list_add_str(char *dev_list)
571571
* matching flags value, else return the host or global default
572572
* settings. Called during scan time.
573573
**/
574-
int scsi_get_device_flags(struct scsi_device *sdev,
575-
const unsigned char *vendor,
576-
const unsigned char *model)
574+
blist_flags_t scsi_get_device_flags(struct scsi_device *sdev,
575+
const unsigned char *vendor,
576+
const unsigned char *model)
577577
{
578578
return scsi_get_device_flags_keyed(sdev, vendor, model,
579579
SCSI_DEVINFO_GLOBAL);
@@ -593,7 +593,7 @@ int scsi_get_device_flags(struct scsi_device *sdev,
593593
* flags value, else return the host or global default settings.
594594
* Called during scan time.
595595
**/
596-
int scsi_get_device_flags_keyed(struct scsi_device *sdev,
596+
blist_flags_t scsi_get_device_flags_keyed(struct scsi_device *sdev,
597597
const unsigned char *vendor,
598598
const unsigned char *model,
599599
int key)

drivers/scsi/scsi_priv.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,16 @@ enum {
5050
SCSI_DEVINFO_SPI,
5151
};
5252

53-
extern int scsi_get_device_flags(struct scsi_device *sdev,
54-
const unsigned char *vendor,
55-
const unsigned char *model);
56-
extern int scsi_get_device_flags_keyed(struct scsi_device *sdev,
57-
const unsigned char *vendor,
58-
const unsigned char *model, int key);
53+
extern blist_flags_t scsi_get_device_flags(struct scsi_device *sdev,
54+
const unsigned char *vendor,
55+
const unsigned char *model);
56+
extern blist_flags_t scsi_get_device_flags_keyed(struct scsi_device *sdev,
57+
const unsigned char *vendor,
58+
const unsigned char *model,
59+
int key);
5960
extern int scsi_dev_info_list_add_keyed(int compatible, char *vendor,
6061
char *model, char *strflags,
61-
int flags, int key);
62+
blist_flags_t flags, int key);
6263
extern int scsi_dev_info_list_del_keyed(char *vendor, char *model, int key);
6364
extern int scsi_dev_info_add_list(int key, const char *name);
6465
extern int scsi_dev_info_remove_list(int key);

drivers/scsi/scsi_scan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ EXPORT_SYMBOL(scsi_sanitize_inquiry_string);
566566
* are copied to the scsi_device any flags value is stored in *@bflags.
567567
**/
568568
static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
569-
int result_len, int *bflags)
569+
int result_len, blist_flags_t *bflags)
570570
{
571571
unsigned char scsi_cmd[MAX_COMMAND_SIZE];
572572
int first_inquiry_len, try_inquiry_len, next_inquiry_len;

include/scsi/scsi_device.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ struct scsi_cmnd;
1515
struct scsi_lun;
1616
struct scsi_sense_hdr;
1717

18+
typedef unsigned int __bitwise blist_flags_t;
19+
1820
struct scsi_mode_data {
1921
__u32 length;
2022
__u16 block_descriptor_length;
@@ -141,7 +143,7 @@ struct scsi_device {
141143
unsigned char current_tag; /* current tag */
142144
struct scsi_target *sdev_target; /* used only for single_lun */
143145

144-
unsigned int sdev_bflags; /* black/white flags as also found in
146+
blist_flags_t sdev_bflags; /* black/white flags as also found in
145147
* scsi_devinfo.[hc]. For now used only to
146148
* pass settings from slave_alloc to scsi
147149
* core. */

include/scsi/scsi_devinfo.h

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,55 +6,55 @@
66
*/
77

88
/* Only scan LUN 0 */
9-
#define BLIST_NOLUN ((__force __u32 __bitwise)(1 << 0))
9+
#define BLIST_NOLUN ((__force blist_flags_t)(1 << 0))
1010
/* Known to have LUNs, force scanning.
1111
* DEPRECATED: Use max_luns=N */
12-
#define BLIST_FORCELUN ((__force __u32 __bitwise)(1 << 1))
12+
#define BLIST_FORCELUN ((__force blist_flags_t)(1 << 1))
1313
/* Flag for broken handshaking */
14-
#define BLIST_BORKEN ((__force __u32 __bitwise)(1 << 2))
14+
#define BLIST_BORKEN ((__force blist_flags_t)(1 << 2))
1515
/* unlock by special command */
16-
#define BLIST_KEY ((__force __u32 __bitwise)(1 << 3))
16+
#define BLIST_KEY ((__force blist_flags_t)(1 << 3))
1717
/* Do not use LUNs in parallel */
18-
#define BLIST_SINGLELUN ((__force __u32 __bitwise)(1 << 4))
18+
#define BLIST_SINGLELUN ((__force blist_flags_t)(1 << 4))
1919
/* Buggy Tagged Command Queuing */
20-
#define BLIST_NOTQ ((__force __u32 __bitwise)(1 << 5))
20+
#define BLIST_NOTQ ((__force blist_flags_t)(1 << 5))
2121
/* Non consecutive LUN numbering */
22-
#define BLIST_SPARSELUN ((__force __u32 __bitwise)(1 << 6))
22+
#define BLIST_SPARSELUN ((__force blist_flags_t)(1 << 6))
2323
/* Avoid LUNS >= 5 */
24-
#define BLIST_MAX5LUN ((__force __u32 __bitwise)(1 << 7))
24+
#define BLIST_MAX5LUN ((__force blist_flags_t)(1 << 7))
2525
/* Treat as (removable) CD-ROM */
26-
#define BLIST_ISROM ((__force __u32 __bitwise)(1 << 8))
26+
#define BLIST_ISROM ((__force blist_flags_t)(1 << 8))
2727
/* LUNs past 7 on a SCSI-2 device */
28-
#define BLIST_LARGELUN ((__force __u32 __bitwise)(1 << 9))
28+
#define BLIST_LARGELUN ((__force blist_flags_t)(1 << 9))
2929
/* override additional length field */
30-
#define BLIST_INQUIRY_36 ((__force __u32 __bitwise)(1 << 10))
30+
#define BLIST_INQUIRY_36 ((__force blist_flags_t)(1 << 10))
3131
/* do not do automatic start on add */
32-
#define BLIST_NOSTARTONADD ((__force __u32 __bitwise)(1 << 12))
32+
#define BLIST_NOSTARTONADD ((__force blist_flags_t)(1 << 12))
3333
/* try REPORT_LUNS even for SCSI-2 devs (if HBA supports more than 8 LUNs) */
34-
#define BLIST_REPORTLUN2 ((__force __u32 __bitwise)(1 << 17))
34+
#define BLIST_REPORTLUN2 ((__force blist_flags_t)(1 << 17))
3535
/* don't try REPORT_LUNS scan (SCSI-3 devs) */
36-
#define BLIST_NOREPORTLUN ((__force __u32 __bitwise)(1 << 18))
36+
#define BLIST_NOREPORTLUN ((__force blist_flags_t)(1 << 18))
3737
/* don't use PREVENT-ALLOW commands */
38-
#define BLIST_NOT_LOCKABLE ((__force __u32 __bitwise)(1 << 19))
38+
#define BLIST_NOT_LOCKABLE ((__force blist_flags_t)(1 << 19))
3939
/* device is actually for RAID config */
40-
#define BLIST_NO_ULD_ATTACH ((__force __u32 __bitwise)(1 << 20))
40+
#define BLIST_NO_ULD_ATTACH ((__force blist_flags_t)(1 << 20))
4141
/* select without ATN */
42-
#define BLIST_SELECT_NO_ATN ((__force __u32 __bitwise)(1 << 21))
42+
#define BLIST_SELECT_NO_ATN ((__force blist_flags_t)(1 << 21))
4343
/* retry HARDWARE_ERROR */
44-
#define BLIST_RETRY_HWERROR ((__force __u32 __bitwise)(1 << 22))
44+
#define BLIST_RETRY_HWERROR ((__force blist_flags_t)(1 << 22))
4545
/* maximum 512 sector cdb length */
46-
#define BLIST_MAX_512 ((__force __u32 __bitwise)(1 << 23))
46+
#define BLIST_MAX_512 ((__force blist_flags_t)(1 << 23))
4747
/* Disable T10 PI (DIF) */
48-
#define BLIST_NO_DIF ((__force __u32 __bitwise)(1 << 25))
48+
#define BLIST_NO_DIF ((__force blist_flags_t)(1 << 25))
4949
/* Ignore SBC-3 VPD pages */
50-
#define BLIST_SKIP_VPD_PAGES ((__force __u32 __bitwise)(1 << 26))
50+
#define BLIST_SKIP_VPD_PAGES ((__force blist_flags_t)(1 << 26))
5151
/* Attempt to read VPD pages */
52-
#define BLIST_TRY_VPD_PAGES ((__force __u32 __bitwise)(1 << 28))
52+
#define BLIST_TRY_VPD_PAGES ((__force blist_flags_t)(1 << 28))
5353
/* don't try to issue RSOC */
54-
#define BLIST_NO_RSOC ((__force __u32 __bitwise)(1 << 29))
54+
#define BLIST_NO_RSOC ((__force blist_flags_t)(1 << 29))
5555
/* maximum 1024 sector cdb length */
56-
#define BLIST_MAX_1024 ((__force __u32 __bitwise)(1 << 30))
56+
#define BLIST_MAX_1024 ((__force blist_flags_t)(1 << 30))
5757
/* Use UNMAP limit for WRITE SAME */
58-
#define BLIST_UNMAP_LIMIT_WS ((__force __u32 __bitwise)(1 << 31))
58+
#define BLIST_UNMAP_LIMIT_WS ((__force blist_flags_t)(1 << 31))
5959

6060
#endif

0 commit comments

Comments
 (0)