Skip to content

Commit c1ca10c

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: "Three fixes: the two fnic ones are a revert and a refix, which is why the diffstat is a bit big. The target one also extracts a function to add a check for configuration and so looks bigger than it is" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: fnic: Move fnic_fnic_flush_tx() to a work queue scsi: Revert "scsi: fcoe: Fix potential deadlock on &fip->ctlr_lock" scsi: target: Fix unmap setup during configuration
2 parents 975b26a + 379a58c commit c1ca10c

File tree

6 files changed

+48
-33
lines changed

6 files changed

+48
-33
lines changed

drivers/scsi/fcoe/fcoe_ctlr.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -319,17 +319,16 @@ static void fcoe_ctlr_announce(struct fcoe_ctlr *fip)
319319
{
320320
struct fcoe_fcf *sel;
321321
struct fcoe_fcf *fcf;
322-
unsigned long flags;
323322

324323
mutex_lock(&fip->ctlr_mutex);
325-
spin_lock_irqsave(&fip->ctlr_lock, flags);
324+
spin_lock_bh(&fip->ctlr_lock);
326325

327326
kfree_skb(fip->flogi_req);
328327
fip->flogi_req = NULL;
329328
list_for_each_entry(fcf, &fip->fcfs, list)
330329
fcf->flogi_sent = 0;
331330

332-
spin_unlock_irqrestore(&fip->ctlr_lock, flags);
331+
spin_unlock_bh(&fip->ctlr_lock);
333332
sel = fip->sel_fcf;
334333

335334
if (sel && ether_addr_equal(sel->fcf_mac, fip->dest_addr))
@@ -700,7 +699,6 @@ int fcoe_ctlr_els_send(struct fcoe_ctlr *fip, struct fc_lport *lport,
700699
{
701700
struct fc_frame *fp;
702701
struct fc_frame_header *fh;
703-
unsigned long flags;
704702
u16 old_xid;
705703
u8 op;
706704
u8 mac[ETH_ALEN];
@@ -734,11 +732,11 @@ int fcoe_ctlr_els_send(struct fcoe_ctlr *fip, struct fc_lport *lport,
734732
op = FIP_DT_FLOGI;
735733
if (fip->mode == FIP_MODE_VN2VN)
736734
break;
737-
spin_lock_irqsave(&fip->ctlr_lock, flags);
735+
spin_lock_bh(&fip->ctlr_lock);
738736
kfree_skb(fip->flogi_req);
739737
fip->flogi_req = skb;
740738
fip->flogi_req_send = 1;
741-
spin_unlock_irqrestore(&fip->ctlr_lock, flags);
739+
spin_unlock_bh(&fip->ctlr_lock);
742740
schedule_work(&fip->timer_work);
743741
return -EINPROGRESS;
744742
case ELS_FDISC:
@@ -1707,11 +1705,10 @@ static int fcoe_ctlr_flogi_send_locked(struct fcoe_ctlr *fip)
17071705
static int fcoe_ctlr_flogi_retry(struct fcoe_ctlr *fip)
17081706
{
17091707
struct fcoe_fcf *fcf;
1710-
unsigned long flags;
17111708
int error;
17121709

17131710
mutex_lock(&fip->ctlr_mutex);
1714-
spin_lock_irqsave(&fip->ctlr_lock, flags);
1711+
spin_lock_bh(&fip->ctlr_lock);
17151712
LIBFCOE_FIP_DBG(fip, "re-sending FLOGI - reselect\n");
17161713
fcf = fcoe_ctlr_select(fip);
17171714
if (!fcf || fcf->flogi_sent) {
@@ -1722,7 +1719,7 @@ static int fcoe_ctlr_flogi_retry(struct fcoe_ctlr *fip)
17221719
fcoe_ctlr_solicit(fip, NULL);
17231720
error = fcoe_ctlr_flogi_send_locked(fip);
17241721
}
1725-
spin_unlock_irqrestore(&fip->ctlr_lock, flags);
1722+
spin_unlock_bh(&fip->ctlr_lock);
17261723
mutex_unlock(&fip->ctlr_mutex);
17271724
return error;
17281725
}
@@ -1739,9 +1736,8 @@ static int fcoe_ctlr_flogi_retry(struct fcoe_ctlr *fip)
17391736
static void fcoe_ctlr_flogi_send(struct fcoe_ctlr *fip)
17401737
{
17411738
struct fcoe_fcf *fcf;
1742-
unsigned long flags;
17431739

1744-
spin_lock_irqsave(&fip->ctlr_lock, flags);
1740+
spin_lock_bh(&fip->ctlr_lock);
17451741
fcf = fip->sel_fcf;
17461742
if (!fcf || !fip->flogi_req_send)
17471743
goto unlock;
@@ -1768,7 +1764,7 @@ static void fcoe_ctlr_flogi_send(struct fcoe_ctlr *fip)
17681764
} else /* XXX */
17691765
LIBFCOE_FIP_DBG(fip, "No FCF selected - defer send\n");
17701766
unlock:
1771-
spin_unlock_irqrestore(&fip->ctlr_lock, flags);
1767+
spin_unlock_bh(&fip->ctlr_lock);
17721768
}
17731769

17741770
/**

drivers/scsi/fnic/fnic.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ struct fnic {
305305
unsigned int copy_wq_base;
306306
struct work_struct link_work;
307307
struct work_struct frame_work;
308+
struct work_struct flush_work;
308309
struct sk_buff_head frame_queue;
309310
struct sk_buff_head tx_queue;
310311

@@ -363,7 +364,7 @@ void fnic_handle_event(struct work_struct *work);
363364
int fnic_rq_cmpl_handler(struct fnic *fnic, int);
364365
int fnic_alloc_rq_frame(struct vnic_rq *rq);
365366
void fnic_free_rq_buf(struct vnic_rq *rq, struct vnic_rq_buf *buf);
366-
void fnic_flush_tx(struct fnic *);
367+
void fnic_flush_tx(struct work_struct *work);
367368
void fnic_eth_send(struct fcoe_ctlr *, struct sk_buff *skb);
368369
void fnic_set_port_id(struct fc_lport *, u32, struct fc_frame *);
369370
void fnic_update_mac(struct fc_lport *, u8 *new);

drivers/scsi/fnic/fnic_fcs.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,16 +1182,17 @@ int fnic_send(struct fc_lport *lp, struct fc_frame *fp)
11821182

11831183
/**
11841184
* fnic_flush_tx() - send queued frames.
1185-
* @fnic: fnic device
1185+
* @work: pointer to work element
11861186
*
11871187
* Send frames that were waiting to go out in FC or Ethernet mode.
11881188
* Whenever changing modes we purge queued frames, so these frames should
11891189
* be queued for the stable mode that we're in, either FC or Ethernet.
11901190
*
11911191
* Called without fnic_lock held.
11921192
*/
1193-
void fnic_flush_tx(struct fnic *fnic)
1193+
void fnic_flush_tx(struct work_struct *work)
11941194
{
1195+
struct fnic *fnic = container_of(work, struct fnic, flush_work);
11951196
struct sk_buff *skb;
11961197
struct fc_frame *fp;
11971198

drivers/scsi/fnic/fnic_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
830830
spin_lock_init(&fnic->vlans_lock);
831831
INIT_WORK(&fnic->fip_frame_work, fnic_handle_fip_frame);
832832
INIT_WORK(&fnic->event_work, fnic_handle_event);
833+
INIT_WORK(&fnic->flush_work, fnic_flush_tx);
833834
skb_queue_head_init(&fnic->fip_frame_queue);
834835
INIT_LIST_HEAD(&fnic->evlist);
835836
INIT_LIST_HEAD(&fnic->vlans);

drivers/scsi/fnic/fnic_scsi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic *fnic,
680680

681681
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
682682

683-
fnic_flush_tx(fnic);
683+
queue_work(fnic_event_queue, &fnic->flush_work);
684684

685685
reset_cmpl_handler_end:
686686
fnic_clear_state_flags(fnic, FNIC_FLAGS_FWRESET);
@@ -736,7 +736,7 @@ static int fnic_fcpio_flogi_reg_cmpl_handler(struct fnic *fnic,
736736
}
737737
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
738738

739-
fnic_flush_tx(fnic);
739+
queue_work(fnic_event_queue, &fnic->flush_work);
740740
queue_work(fnic_event_queue, &fnic->frame_work);
741741
} else {
742742
spin_unlock_irqrestore(&fnic->fnic_lock, flags);

drivers/target/target_core_configfs.c

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,29 @@ static ssize_t emulate_tas_store(struct config_item *item,
759759
return count;
760760
}
761761

762+
static int target_try_configure_unmap(struct se_device *dev,
763+
const char *config_opt)
764+
{
765+
if (!dev->transport->configure_unmap) {
766+
pr_err("Generic Block Discard not supported\n");
767+
return -ENOSYS;
768+
}
769+
770+
if (!target_dev_configured(dev)) {
771+
pr_err("Generic Block Discard setup for %s requires device to be configured\n",
772+
config_opt);
773+
return -ENODEV;
774+
}
775+
776+
if (!dev->transport->configure_unmap(dev)) {
777+
pr_err("Generic Block Discard setup for %s failed\n",
778+
config_opt);
779+
return -ENOSYS;
780+
}
781+
782+
return 0;
783+
}
784+
762785
static ssize_t emulate_tpu_store(struct config_item *item,
763786
const char *page, size_t count)
764787
{
@@ -776,11 +799,9 @@ static ssize_t emulate_tpu_store(struct config_item *item,
776799
* Discard supported is detected iblock_create_virtdevice().
777800
*/
778801
if (flag && !da->max_unmap_block_desc_count) {
779-
if (!dev->transport->configure_unmap ||
780-
!dev->transport->configure_unmap(dev)) {
781-
pr_err("Generic Block Discard not supported\n");
782-
return -ENOSYS;
783-
}
802+
ret = target_try_configure_unmap(dev, "emulate_tpu");
803+
if (ret)
804+
return ret;
784805
}
785806

786807
da->emulate_tpu = flag;
@@ -806,11 +827,9 @@ static ssize_t emulate_tpws_store(struct config_item *item,
806827
* Discard supported is detected iblock_create_virtdevice().
807828
*/
808829
if (flag && !da->max_unmap_block_desc_count) {
809-
if (!dev->transport->configure_unmap ||
810-
!dev->transport->configure_unmap(dev)) {
811-
pr_err("Generic Block Discard not supported\n");
812-
return -ENOSYS;
813-
}
830+
ret = target_try_configure_unmap(dev, "emulate_tpws");
831+
if (ret)
832+
return ret;
814833
}
815834

816835
da->emulate_tpws = flag;
@@ -1022,12 +1041,9 @@ static ssize_t unmap_zeroes_data_store(struct config_item *item,
10221041
* Discard supported is detected iblock_configure_device().
10231042
*/
10241043
if (flag && !da->max_unmap_block_desc_count) {
1025-
if (!dev->transport->configure_unmap ||
1026-
!dev->transport->configure_unmap(dev)) {
1027-
pr_err("dev[%p]: Thin Provisioning LBPRZ will not be set because max_unmap_block_desc_count is zero\n",
1028-
da->da_dev);
1029-
return -ENOSYS;
1030-
}
1044+
ret = target_try_configure_unmap(dev, "unmap_zeroes_data");
1045+
if (ret)
1046+
return ret;
10311047
}
10321048
da->unmap_zeroes_data = flag;
10331049
pr_debug("dev[%p]: SE Device Thin Provisioning LBPRZ bit: %d\n",

0 commit comments

Comments
 (0)