Skip to content

Commit b1c94fb

Browse files
James BottomleyJames Bottomley
authored andcommitted
Merge branch 'fixes' into for-next
2 parents 82e1f00 + b481f64 commit b1c94fb

File tree

6 files changed

+63
-29
lines changed

6 files changed

+63
-29
lines changed

drivers/s390/scsi/zfcp_aux.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,12 +518,12 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn,
518518
if (port) {
519519
put_device(&port->dev);
520520
retval = -EEXIST;
521-
goto err_out;
521+
goto err_put;
522522
}
523523

524524
port = kzalloc(sizeof(struct zfcp_port), GFP_KERNEL);
525525
if (!port)
526-
goto err_out;
526+
goto err_put;
527527

528528
rwlock_init(&port->unit_list_lock);
529529
INIT_LIST_HEAD(&port->unit_list);
@@ -546,7 +546,7 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn,
546546

547547
if (dev_set_name(&port->dev, "0x%016llx", (unsigned long long)wwpn)) {
548548
kfree(port);
549-
goto err_out;
549+
goto err_put;
550550
}
551551
retval = -EINVAL;
552552

@@ -563,7 +563,8 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn,
563563

564564
return port;
565565

566-
err_out:
566+
err_put:
567567
zfcp_ccw_adapter_put(adapter);
568+
err_out:
568569
return ERR_PTR(retval);
569570
}

drivers/scsi/fnic/fnic.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#define DRV_NAME "fnic"
2929
#define DRV_DESCRIPTION "Cisco FCoE HBA Driver"
30-
#define DRV_VERSION "1.6.0.56"
30+
#define DRV_VERSION "1.6.0.57"
3131
#define PFX DRV_NAME ": "
3232
#define DFX DRV_NAME "%d: "
3333

@@ -237,6 +237,8 @@ struct fnic {
237237
unsigned int cq_count;
238238

239239
struct mutex sgreset_mutex;
240+
spinlock_t sgreset_lock; /* lock for sgreset */
241+
struct scsi_cmnd *sgreset_sc;
240242
struct dentry *fnic_stats_debugfs_host;
241243
struct dentry *fnic_stats_debugfs_file;
242244
struct dentry *fnic_reset_debugfs_file;

drivers/scsi/fnic/fnic_io.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ struct fnic_io_req {
5252
unsigned long start_time; /* in jiffies */
5353
struct completion *abts_done; /* completion for abts */
5454
struct completion *dr_done; /* completion for device reset */
55+
unsigned int tag;
56+
struct scsi_cmnd *sc; /* midlayer's cmd pointer */
5557
};
5658

5759
enum fnic_port_speeds {

drivers/scsi/fnic/fnic_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
754754
for (i = 0; i < FNIC_IO_LOCKS; i++)
755755
spin_lock_init(&fnic->io_req_lock[i]);
756756

757+
spin_lock_init(&fnic->sgreset_lock);
758+
757759
err = -ENOMEM;
758760
fnic->io_req_pool = mempool_create_slab_pool(2, fnic_io_req_cache);
759761
if (!fnic->io_req_pool)

drivers/scsi/fnic/fnic_scsi.c

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,9 +1047,9 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
10471047
{
10481048
u8 type;
10491049
u8 hdr_status;
1050-
struct fcpio_tag tag;
1050+
struct fcpio_tag ftag;
10511051
u32 id;
1052-
struct scsi_cmnd *sc;
1052+
struct scsi_cmnd *sc = NULL;
10531053
struct fnic_io_req *io_req;
10541054
struct fnic_stats *fnic_stats = &fnic->fnic_stats;
10551055
struct abort_stats *abts_stats = &fnic->fnic_stats.abts_stats;
@@ -1058,27 +1058,43 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
10581058
unsigned long flags;
10591059
spinlock_t *io_lock;
10601060
unsigned long start_time;
1061+
unsigned int tag;
10611062

1062-
fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag);
1063-
fcpio_tag_id_dec(&tag, &id);
1063+
fcpio_header_dec(&desc->hdr, &type, &hdr_status, &ftag);
1064+
fcpio_tag_id_dec(&ftag, &id);
10641065

1065-
if ((id & FNIC_TAG_MASK) >= fnic->fnic_max_tag_id) {
1066+
tag = id & FNIC_TAG_MASK;
1067+
if (tag == fnic->fnic_max_tag_id) {
1068+
if (!(id & FNIC_TAG_DEV_RST)) {
1069+
shost_printk(KERN_ERR, fnic->lport->host,
1070+
"Tag out of range id 0x%x hdr status = %s\n",
1071+
id, fnic_fcpio_status_to_str(hdr_status));
1072+
return;
1073+
}
1074+
} else if (tag > fnic->fnic_max_tag_id) {
10661075
shost_printk(KERN_ERR, fnic->lport->host,
1067-
"Tag out of range tag %x hdr status = %s\n",
1068-
id, fnic_fcpio_status_to_str(hdr_status));
1076+
"Tag out of range tag 0x%x hdr status = %s\n",
1077+
tag, fnic_fcpio_status_to_str(hdr_status));
10691078
return;
10701079
}
10711080

1072-
sc = scsi_host_find_tag(fnic->lport->host, id & FNIC_TAG_MASK);
1081+
if ((tag == fnic->fnic_max_tag_id) && (id & FNIC_TAG_DEV_RST)) {
1082+
sc = fnic->sgreset_sc;
1083+
io_lock = &fnic->sgreset_lock;
1084+
} else {
1085+
sc = scsi_host_find_tag(fnic->lport->host, id & FNIC_TAG_MASK);
1086+
io_lock = fnic_io_lock_hash(fnic, sc);
1087+
}
1088+
10731089
WARN_ON_ONCE(!sc);
10741090
if (!sc) {
10751091
atomic64_inc(&fnic_stats->io_stats.sc_null);
10761092
shost_printk(KERN_ERR, fnic->lport->host,
10771093
"itmf_cmpl sc is null - hdr status = %s tag = 0x%x\n",
1078-
fnic_fcpio_status_to_str(hdr_status), id);
1094+
fnic_fcpio_status_to_str(hdr_status), tag);
10791095
return;
10801096
}
1081-
io_lock = fnic_io_lock_hash(fnic, sc);
1097+
10821098
spin_lock_irqsave(io_lock, flags);
10831099
io_req = fnic_priv(sc)->io_req;
10841100
WARN_ON_ONCE(!io_req);
@@ -1089,7 +1105,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
10891105
shost_printk(KERN_ERR, fnic->lport->host,
10901106
"itmf_cmpl io_req is null - "
10911107
"hdr status = %s tag = 0x%x sc 0x%p\n",
1092-
fnic_fcpio_status_to_str(hdr_status), id, sc);
1108+
fnic_fcpio_status_to_str(hdr_status), tag, sc);
10931109
return;
10941110
}
10951111
start_time = io_req->start_time;
@@ -1938,6 +1954,10 @@ static inline int fnic_queue_dr_io_req(struct fnic *fnic,
19381954
struct scsi_lun fc_lun;
19391955
int ret = 0;
19401956
unsigned long intr_flags;
1957+
unsigned int tag = scsi_cmd_to_rq(sc)->tag;
1958+
1959+
if (tag == SCSI_NO_TAG)
1960+
tag = io_req->tag;
19411961

19421962
spin_lock_irqsave(host->host_lock, intr_flags);
19431963
if (unlikely(fnic_chk_state_flags_locked(fnic,
@@ -1964,7 +1984,8 @@ static inline int fnic_queue_dr_io_req(struct fnic *fnic,
19641984
/* fill in the lun info */
19651985
int_to_scsilun(sc->device->lun, &fc_lun);
19661986

1967-
fnic_queue_wq_copy_desc_itmf(wq, scsi_cmd_to_rq(sc)->tag | FNIC_TAG_DEV_RST,
1987+
tag |= FNIC_TAG_DEV_RST;
1988+
fnic_queue_wq_copy_desc_itmf(wq, tag,
19681989
0, FCPIO_ITMF_LUN_RESET, SCSI_NO_TAG,
19691990
fc_lun.scsi_lun, io_req->port_id,
19701991
fnic->config.ra_tov, fnic->config.ed_tov);
@@ -2146,8 +2167,7 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
21462167
.ret = SUCCESS,
21472168
};
21482169

2149-
if (new_sc)
2150-
iter_data.lr_sc = lr_sc;
2170+
iter_data.lr_sc = lr_sc;
21512171

21522172
scsi_host_busy_iter(fnic->lport->host,
21532173
fnic_pending_aborts_iter, &iter_data);
@@ -2230,8 +2250,14 @@ int fnic_device_reset(struct scsi_cmnd *sc)
22302250
mutex_lock(&fnic->sgreset_mutex);
22312251
tag = fnic->fnic_max_tag_id;
22322252
new_sc = 1;
2233-
}
2234-
io_lock = fnic_io_lock_hash(fnic, sc);
2253+
fnic->sgreset_sc = sc;
2254+
io_lock = &fnic->sgreset_lock;
2255+
FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host,
2256+
"fcid: 0x%x lun: 0x%llx flags: 0x%x tag: 0x%x Issuing sgreset\n",
2257+
rport->port_id, sc->device->lun, fnic_priv(sc)->flags, tag);
2258+
} else
2259+
io_lock = fnic_io_lock_hash(fnic, sc);
2260+
22352261
spin_lock_irqsave(io_lock, flags);
22362262
io_req = fnic_priv(sc)->io_req;
22372263

@@ -2247,6 +2273,8 @@ int fnic_device_reset(struct scsi_cmnd *sc)
22472273
}
22482274
memset(io_req, 0, sizeof(*io_req));
22492275
io_req->port_id = rport->port_id;
2276+
io_req->tag = tag;
2277+
io_req->sc = sc;
22502278
fnic_priv(sc)->io_req = io_req;
22512279
}
22522280
io_req->dr_done = &tm_done;
@@ -2400,8 +2428,10 @@ int fnic_device_reset(struct scsi_cmnd *sc)
24002428
(u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
24012429
fnic_flags_and_state(sc));
24022430

2403-
if (new_sc)
2431+
if (new_sc) {
2432+
fnic->sgreset_sc = NULL;
24042433
mutex_unlock(&fnic->sgreset_mutex);
2434+
}
24052435

24062436
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
24072437
"Returning from device reset %s\n",

drivers/target/target_core_device.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,6 @@ sector_t target_to_linux_sector(struct se_device *dev, sector_t lb)
843843
EXPORT_SYMBOL(target_to_linux_sector);
844844

845845
struct devices_idr_iter {
846-
struct config_item *prev_item;
847846
int (*fn)(struct se_device *dev, void *data);
848847
void *data;
849848
};
@@ -853,11 +852,9 @@ static int target_devices_idr_iter(int id, void *p, void *data)
853852
{
854853
struct devices_idr_iter *iter = data;
855854
struct se_device *dev = p;
855+
struct config_item *item;
856856
int ret;
857857

858-
config_item_put(iter->prev_item);
859-
iter->prev_item = NULL;
860-
861858
/*
862859
* We add the device early to the idr, so it can be used
863860
* by backend modules during configuration. We do not want
@@ -867,12 +864,13 @@ static int target_devices_idr_iter(int id, void *p, void *data)
867864
if (!target_dev_configured(dev))
868865
return 0;
869866

870-
iter->prev_item = config_item_get_unless_zero(&dev->dev_group.cg_item);
871-
if (!iter->prev_item)
867+
item = config_item_get_unless_zero(&dev->dev_group.cg_item);
868+
if (!item)
872869
return 0;
873870
mutex_unlock(&device_mutex);
874871

875872
ret = iter->fn(dev, iter->data);
873+
config_item_put(item);
876874

877875
mutex_lock(&device_mutex);
878876
return ret;
@@ -895,7 +893,6 @@ int target_for_each_device(int (*fn)(struct se_device *dev, void *data),
895893
mutex_lock(&device_mutex);
896894
ret = idr_for_each(&devices_idr, target_devices_idr_iter, &iter);
897895
mutex_unlock(&device_mutex);
898-
config_item_put(iter.prev_item);
899896
return ret;
900897
}
901898

0 commit comments

Comments
 (0)