Skip to content

Commit f281233

Browse files
Jeff Garziktorvalds
authored andcommitted
SCSI host lock push-down
Move the mid-layer's ->queuecommand() invocation from being locked with the host lock to being unlocked to facilitate speeding up the critical path for drivers who don't need this lock taken anyway. The patch below presents a simple SCSI host lock push-down as an equivalent transformation. No locking or other behavior should change with this patch. All existing bugs and locking orders are preserved. Additionally, add one parameter to queuecommand, struct Scsi_Host * and remove one parameter from queuecommand, void (*done)(struct scsi_cmnd *) Scsi_Host* is a convenient pointer that most host drivers need anyway, and 'done' is redundant to struct scsi_cmnd->scsi_done. Minimal code disturbance was attempted with this change. Most drivers needed only two one-line modifications for their host lock push-down. Signed-off-by: Jeff Garzik <jgarzik@redhat.com> Acked-by: James Bottomley <James.Bottomley@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent bdbd01a commit f281233

115 files changed

Lines changed: 347 additions & 199 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎arch/ia64/hp/sim/simscsi.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ simscsi_readwrite10 (struct scsi_cmnd *sc, int mode)
202202
}
203203

204204
static int
205-
simscsi_queuecommand (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
205+
simscsi_queuecommand_lck (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
206206
{
207207
unsigned int target_id = sc->device->id;
208208
char fname[MAX_ROOT_LEN+16];
@@ -326,6 +326,8 @@ simscsi_queuecommand (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
326326
return 0;
327327
}
328328

329+
static DEF_SCSI_QCMD(simscsi_queuecommand)
330+
329331
static int
330332
simscsi_host_reset (struct scsi_cmnd *sc)
331333
{

‎drivers/ata/libata-scsi.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3183,7 +3183,7 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd,
31833183
* Return value from __ata_scsi_queuecmd() if @cmd can be queued,
31843184
* 0 otherwise.
31853185
*/
3186-
int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
3186+
static int ata_scsi_queuecmd_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
31873187
{
31883188
struct ata_port *ap;
31893189
struct ata_device *dev;
@@ -3211,6 +3211,8 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
32113211
return rc;
32123212
}
32133213

3214+
DEF_SCSI_QCMD(ata_scsi_queuecmd)
3215+
32143216
/**
32153217
* ata_scsi_simulate - simulate SCSI command on ATA device
32163218
* @dev: the target device

‎drivers/block/cciss_scsi.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ static int cciss_scsi_proc_info(
6262
int length, /* length of data in buffer */
6363
int func); /* 0 == read, 1 == write */
6464

65-
static int cciss_scsi_queue_command (struct scsi_cmnd *cmd,
66-
void (* done)(struct scsi_cmnd *));
65+
static int cciss_scsi_queue_command (struct Scsi_Host *h,
66+
struct scsi_cmnd *cmd);
6767
static int cciss_eh_device_reset_handler(struct scsi_cmnd *);
6868
static int cciss_eh_abort_handler(struct scsi_cmnd *);
6969

@@ -1406,7 +1406,7 @@ static void cciss_scatter_gather(ctlr_info_t *h, CommandList_struct *c,
14061406

14071407

14081408
static int
1409-
cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
1409+
cciss_scsi_queue_command_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
14101410
{
14111411
ctlr_info_t *h;
14121412
int rc;
@@ -1504,6 +1504,8 @@ cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd
15041504
return 0;
15051505
}
15061506

1507+
static DEF_SCSI_QCMD(cciss_scsi_queue_command)
1508+
15071509
static void cciss_unregister_scsi(ctlr_info_t *h)
15081510
{
15091511
struct cciss_scsi_adapter_data_t *sa;

‎drivers/firewire/sbp2.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ static int sbp2_map_scatterlist(struct sbp2_command_orb *orb,
14681468

14691469
/* SCSI stack integration */
14701470

1471-
static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1471+
static int sbp2_scsi_queuecommand_lck(struct scsi_cmnd *cmd, scsi_done_fn_t done)
14721472
{
14731473
struct sbp2_logical_unit *lu = cmd->device->hostdata;
14741474
struct fw_device *device = target_device(lu->tgt);
@@ -1534,6 +1534,8 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
15341534
return retval;
15351535
}
15361536

1537+
static DEF_SCSI_QCMD(sbp2_scsi_queuecommand)
1538+
15371539
static int sbp2_scsi_slave_alloc(struct scsi_device *sdev)
15381540
{
15391541
struct sbp2_logical_unit *lu = sdev->hostdata;

‎drivers/infiniband/ulp/srp/ib_srp.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ static void srp_send_completion(struct ib_cq *cq, void *target_ptr)
11231123
}
11241124
}
11251125

1126-
static int srp_queuecommand(struct scsi_cmnd *scmnd,
1126+
static int srp_queuecommand_lck(struct scsi_cmnd *scmnd,
11271127
void (*done)(struct scsi_cmnd *))
11281128
{
11291129
struct srp_target_port *target = host_to_target(scmnd->device->host);
@@ -1196,6 +1196,8 @@ static int srp_queuecommand(struct scsi_cmnd *scmnd,
11961196
return SCSI_MLQUEUE_HOST_BUSY;
11971197
}
11981198

1199+
static DEF_SCSI_QCMD(srp_queuecommand)
1200+
11991201
static int srp_alloc_iu_bufs(struct srp_target_port *target)
12001202
{
12011203
int i;

‎drivers/message/fusion/mptfc.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ static u8 mptfcInternalCtx = MPT_MAX_PROTOCOL_DRIVERS;
9797

9898
static int mptfc_target_alloc(struct scsi_target *starget);
9999
static int mptfc_slave_alloc(struct scsi_device *sdev);
100-
static int mptfc_qcmd(struct scsi_cmnd *SCpnt,
101-
void (*done)(struct scsi_cmnd *));
100+
static int mptfc_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *SCpnt);
102101
static void mptfc_target_destroy(struct scsi_target *starget);
103102
static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout);
104103
static void __devexit mptfc_remove(struct pci_dev *pdev);
@@ -650,7 +649,7 @@ mptfc_slave_alloc(struct scsi_device *sdev)
650649
}
651650

652651
static int
653-
mptfc_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
652+
mptfc_qcmd_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
654653
{
655654
struct mptfc_rport_info *ri;
656655
struct fc_rport *rport = starget_to_rport(scsi_target(SCpnt->device));
@@ -681,6 +680,8 @@ mptfc_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
681680
return mptscsih_qcmd(SCpnt,done);
682681
}
683682

683+
static DEF_SCSI_QCMD(mptfc_qcmd)
684+
684685
/*
685686
* mptfc_display_port_link_speed - displaying link speed
686687
* @ioc: Pointer to MPT_ADAPTER structure

‎drivers/message/fusion/mptsas.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,7 @@ mptsas_slave_alloc(struct scsi_device *sdev)
18891889
}
18901890

18911891
static int
1892-
mptsas_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1892+
mptsas_qcmd_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
18931893
{
18941894
MPT_SCSI_HOST *hd;
18951895
MPT_ADAPTER *ioc;
@@ -1913,6 +1913,8 @@ mptsas_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
19131913
return mptscsih_qcmd(SCpnt,done);
19141914
}
19151915

1916+
static DEF_SCSI_QCMD(mptsas_qcmd)
1917+
19161918
/**
19171919
* mptsas_mptsas_eh_timed_out - resets the scsi_cmnd timeout
19181920
* if the device under question is currently in the

‎drivers/message/fusion/mptspi.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ static int mptspi_slave_configure(struct scsi_device *sdev)
780780
}
781781

782782
static int
783-
mptspi_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
783+
mptspi_qcmd_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
784784
{
785785
struct _MPT_SCSI_HOST *hd = shost_priv(SCpnt->device->host);
786786
VirtDevice *vdevice = SCpnt->device->hostdata;
@@ -805,6 +805,8 @@ mptspi_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
805805
return mptscsih_qcmd(SCpnt,done);
806806
}
807807

808+
static DEF_SCSI_QCMD(mptspi_qcmd)
809+
808810
static void mptspi_slave_destroy(struct scsi_device *sdev)
809811
{
810812
struct scsi_target *starget = scsi_target(sdev);

‎drivers/message/i2o/i2o_scsi.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ static struct i2o_driver i2o_scsi_driver = {
506506
* Locks: takes the controller lock on error path only
507507
*/
508508

509-
static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,
509+
static int i2o_scsi_queuecommand_lck(struct scsi_cmnd *SCpnt,
510510
void (*done) (struct scsi_cmnd *))
511511
{
512512
struct i2o_controller *c;
@@ -688,7 +688,9 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,
688688

689689
exit:
690690
return rc;
691-
};
691+
}
692+
693+
static DEF_SCSI_QCMD(i2o_scsi_queuecommand)
692694

693695
/**
694696
* i2o_scsi_abort - abort a running command

‎drivers/s390/scsi/zfcp_scsi.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ static void zfcp_scsi_command_fail(struct scsi_cmnd *scpnt, int result)
7676
scpnt->scsi_done(scpnt);
7777
}
7878

79-
static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt,
79+
static int zfcp_scsi_queuecommand_lck(struct scsi_cmnd *scpnt,
8080
void (*done) (struct scsi_cmnd *))
8181
{
8282
struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scpnt->device);
@@ -127,6 +127,8 @@ static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt,
127127
return ret;
128128
}
129129

130+
static DEF_SCSI_QCMD(zfcp_scsi_queuecommand)
131+
130132
static int zfcp_scsi_slave_alloc(struct scsi_device *sdev)
131133
{
132134
struct fc_rport *rport = starget_to_rport(scsi_target(sdev));

0 commit comments

Comments
 (0)