diff options
author | James Bottomley <James.Bottomley@steeleye.com> | 2007-08-03 17:41:11 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.localdomain> | 2007-08-04 09:37:04 -0400 |
commit | 03a5743a12b58e10eaa936a02498539db645ba4e (patch) | |
tree | dd3d80da57e3efd26a60f4d369224b41b7008947 | |
parent | 66dbfbe6fde35c881deda5cebb6ecaa0dcc1c975 (diff) |
[SCSI] sd: disentangle barriers in SCSI
Our current implementation has a generic set of barrier functions that
go through the SCSI driver model. Realistically, this is unnecessary,
because the only device that can use barriers (sd) can set the flush
functions up at probe or revalidate time. This patch pulls the barrier
functions out of the mid layer and scsi driver model and relocates them
directly in sd.
Acked-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
-rw-r--r-- | drivers/scsi/scsi_lib.c | 17 | ||||
-rw-r--r-- | drivers/scsi/sd.c | 14 | ||||
-rw-r--r-- | include/scsi/scsi_driver.h | 2 | ||||
-rw-r--r-- | include/scsi/sd.h | 2 |
4 files changed, 11 insertions, 24 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 21c075d44db1..a417a6ff9f97 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -1038,22 +1038,6 @@ static int scsi_init_io(struct scsi_cmnd *cmd) | |||
1038 | return BLKPREP_KILL; | 1038 | return BLKPREP_KILL; |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | static int scsi_issue_flush_fn(struct request_queue *q, struct gendisk *disk, | ||
1042 | sector_t *error_sector) | ||
1043 | { | ||
1044 | struct scsi_device *sdev = q->queuedata; | ||
1045 | struct scsi_driver *drv; | ||
1046 | |||
1047 | if (sdev->sdev_state != SDEV_RUNNING) | ||
1048 | return -ENXIO; | ||
1049 | |||
1050 | drv = *(struct scsi_driver **) disk->private_data; | ||
1051 | if (drv->issue_flush) | ||
1052 | return drv->issue_flush(&sdev->sdev_gendev, error_sector); | ||
1053 | |||
1054 | return -EOPNOTSUPP; | ||
1055 | } | ||
1056 | |||
1057 | static struct scsi_cmnd *scsi_get_cmd_from_req(struct scsi_device *sdev, | 1041 | static struct scsi_cmnd *scsi_get_cmd_from_req(struct scsi_device *sdev, |
1058 | struct request *req) | 1042 | struct request *req) |
1059 | { | 1043 | { |
@@ -1596,7 +1580,6 @@ struct request_queue *scsi_alloc_queue(struct scsi_device *sdev) | |||
1596 | return NULL; | 1580 | return NULL; |
1597 | 1581 | ||
1598 | blk_queue_prep_rq(q, scsi_prep_fn); | 1582 | blk_queue_prep_rq(q, scsi_prep_fn); |
1599 | blk_queue_issue_flush_fn(q, scsi_issue_flush_fn); | ||
1600 | blk_queue_softirq_done(q, scsi_softirq_done); | 1583 | blk_queue_softirq_done(q, scsi_softirq_done); |
1601 | return q; | 1584 | return q; |
1602 | } | 1585 | } |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index e21c7142a3ea..2c6116fd4578 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -241,7 +241,6 @@ static struct scsi_driver sd_template = { | |||
241 | }, | 241 | }, |
242 | .rescan = sd_rescan, | 242 | .rescan = sd_rescan, |
243 | .init_command = sd_init_command, | 243 | .init_command = sd_init_command, |
244 | .issue_flush = sd_issue_flush, | ||
245 | }; | 244 | }; |
246 | 245 | ||
247 | /* | 246 | /* |
@@ -800,10 +799,17 @@ static int sd_sync_cache(struct scsi_disk *sdkp) | |||
800 | return 0; | 799 | return 0; |
801 | } | 800 | } |
802 | 801 | ||
803 | static int sd_issue_flush(struct device *dev, sector_t *error_sector) | 802 | static int sd_issue_flush(struct request_queue *q, struct gendisk *disk, |
803 | sector_t *error_sector) | ||
804 | { | 804 | { |
805 | int ret = 0; | 805 | int ret = 0; |
806 | struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); | 806 | struct scsi_device *sdp = q->queuedata; |
807 | struct scsi_disk *sdkp; | ||
808 | |||
809 | if (sdp->sdev_state != SDEV_RUNNING) | ||
810 | return -ENXIO; | ||
811 | |||
812 | sdkp = scsi_disk_get_from_dev(&sdp->sdev_gendev); | ||
807 | 813 | ||
808 | if (!sdkp) | 814 | if (!sdkp) |
809 | return -ENODEV; | 815 | return -ENODEV; |
@@ -1663,6 +1669,8 @@ static int sd_probe(struct device *dev) | |||
1663 | 1669 | ||
1664 | sd_revalidate_disk(gd); | 1670 | sd_revalidate_disk(gd); |
1665 | 1671 | ||
1672 | blk_queue_issue_flush_fn(sdp->request_queue, sd_issue_flush); | ||
1673 | |||
1666 | gd->driverfs_dev = &sdp->sdev_gendev; | 1674 | gd->driverfs_dev = &sdp->sdev_gendev; |
1667 | gd->flags = GENHD_FL_DRIVERFS; | 1675 | gd->flags = GENHD_FL_DRIVERFS; |
1668 | if (sdp->removable) | 1676 | if (sdp->removable) |
diff --git a/include/scsi/scsi_driver.h b/include/scsi/scsi_driver.h index 02e26c1672bf..3465f31a21c4 100644 --- a/include/scsi/scsi_driver.h +++ b/include/scsi/scsi_driver.h | |||
@@ -13,8 +13,6 @@ struct scsi_driver { | |||
13 | 13 | ||
14 | int (*init_command)(struct scsi_cmnd *); | 14 | int (*init_command)(struct scsi_cmnd *); |
15 | void (*rescan)(struct device *); | 15 | void (*rescan)(struct device *); |
16 | int (*issue_flush)(struct device *, sector_t *); | ||
17 | int (*prepare_flush)(struct request_queue *, struct request *); | ||
18 | }; | 16 | }; |
19 | #define to_scsi_driver(drv) \ | 17 | #define to_scsi_driver(drv) \ |
20 | container_of((drv), struct scsi_driver, gendrv) | 18 | container_of((drv), struct scsi_driver, gendrv) |
diff --git a/include/scsi/sd.h b/include/scsi/sd.h index 78583fee0ab2..ce02ad1f5185 100644 --- a/include/scsi/sd.h +++ b/include/scsi/sd.h | |||
@@ -56,8 +56,6 @@ static int sd_suspend(struct device *dev, pm_message_t state); | |||
56 | static int sd_resume(struct device *dev); | 56 | static int sd_resume(struct device *dev); |
57 | static void sd_rescan(struct device *); | 57 | static void sd_rescan(struct device *); |
58 | static int sd_init_command(struct scsi_cmnd *); | 58 | static int sd_init_command(struct scsi_cmnd *); |
59 | static int sd_issue_flush(struct device *, sector_t *); | ||
60 | static void sd_prepare_flush(struct request_queue *, struct request *); | ||
61 | static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer); | 59 | static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer); |
62 | static void scsi_disk_release(struct class_device *cdev); | 60 | static void scsi_disk_release(struct class_device *cdev); |
63 | static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *); | 61 | static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *); |