diff options
author | Tejun Heo <htejun@gmail.com> | 2006-01-06 03:52:55 -0500 |
---|---|---|
committer | Jens Axboe <axboe@suse.de> | 2006-01-06 03:52:55 -0500 |
commit | 461d4e90c8cd049718884cd17c955e231140d3be (patch) | |
tree | 990836cdff2f1dc952026f24b2d7b5e606d6e8be /drivers/scsi/sd.c | |
parent | 797e7dbbee0a91fa1349192f18ad5c454997d876 (diff) |
[BLOCK] update SCSI to use new blk_ordered for barriers
All ordered request related stuff delegated to HLD. Midlayer
now doens't deal with ordered setting or prepare_flush
callback. sd.c updated to deal with blk_queue_ordered
setting. Currently, ordered tag isn't used as SCSI midlayer
cannot guarantee request ordering.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r-- | drivers/scsi/sd.c | 58 |
1 files changed, 20 insertions, 38 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index d651150ee76d..2eefc9eb5da6 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -121,8 +121,7 @@ static void sd_shutdown(struct device *dev); | |||
121 | static void sd_rescan(struct device *); | 121 | static void sd_rescan(struct device *); |
122 | static int sd_init_command(struct scsi_cmnd *); | 122 | static int sd_init_command(struct scsi_cmnd *); |
123 | static int sd_issue_flush(struct device *, sector_t *); | 123 | static int sd_issue_flush(struct device *, sector_t *); |
124 | static void sd_end_flush(request_queue_t *, struct request *); | 124 | static void sd_prepare_flush(request_queue_t *, struct request *); |
125 | static int sd_prepare_flush(request_queue_t *, struct request *); | ||
126 | static void sd_read_capacity(struct scsi_disk *sdkp, char *diskname, | 125 | static void sd_read_capacity(struct scsi_disk *sdkp, char *diskname, |
127 | unsigned char *buffer); | 126 | unsigned char *buffer); |
128 | 127 | ||
@@ -137,8 +136,6 @@ static struct scsi_driver sd_template = { | |||
137 | .rescan = sd_rescan, | 136 | .rescan = sd_rescan, |
138 | .init_command = sd_init_command, | 137 | .init_command = sd_init_command, |
139 | .issue_flush = sd_issue_flush, | 138 | .issue_flush = sd_issue_flush, |
140 | .prepare_flush = sd_prepare_flush, | ||
141 | .end_flush = sd_end_flush, | ||
142 | }; | 139 | }; |
143 | 140 | ||
144 | /* | 141 | /* |
@@ -729,42 +726,13 @@ static int sd_issue_flush(struct device *dev, sector_t *error_sector) | |||
729 | return ret; | 726 | return ret; |
730 | } | 727 | } |
731 | 728 | ||
732 | static void sd_end_flush(request_queue_t *q, struct request *flush_rq) | 729 | static void sd_prepare_flush(request_queue_t *q, struct request *rq) |
733 | { | 730 | { |
734 | struct request *rq = flush_rq->end_io_data; | ||
735 | struct scsi_cmnd *cmd = rq->special; | ||
736 | unsigned int bytes = rq->hard_nr_sectors << 9; | ||
737 | |||
738 | if (!flush_rq->errors) { | ||
739 | spin_unlock(q->queue_lock); | ||
740 | scsi_io_completion(cmd, bytes, 0); | ||
741 | spin_lock(q->queue_lock); | ||
742 | } else if (blk_barrier_postflush(rq)) { | ||
743 | spin_unlock(q->queue_lock); | ||
744 | scsi_io_completion(cmd, 0, bytes); | ||
745 | spin_lock(q->queue_lock); | ||
746 | } else { | ||
747 | /* | ||
748 | * force journal abort of barriers | ||
749 | */ | ||
750 | end_that_request_first(rq, -EOPNOTSUPP, rq->hard_nr_sectors); | ||
751 | end_that_request_last(rq, -EOPNOTSUPP); | ||
752 | } | ||
753 | } | ||
754 | |||
755 | static int sd_prepare_flush(request_queue_t *q, struct request *rq) | ||
756 | { | ||
757 | struct scsi_device *sdev = q->queuedata; | ||
758 | struct scsi_disk *sdkp = dev_get_drvdata(&sdev->sdev_gendev); | ||
759 | |||
760 | if (!sdkp || !sdkp->WCE) | ||
761 | return 0; | ||
762 | |||
763 | memset(rq->cmd, 0, sizeof(rq->cmd)); | 731 | memset(rq->cmd, 0, sizeof(rq->cmd)); |
764 | rq->flags |= REQ_BLOCK_PC | REQ_SOFTBARRIER; | 732 | rq->flags |= REQ_BLOCK_PC; |
765 | rq->timeout = SD_TIMEOUT; | 733 | rq->timeout = SD_TIMEOUT; |
766 | rq->cmd[0] = SYNCHRONIZE_CACHE; | 734 | rq->cmd[0] = SYNCHRONIZE_CACHE; |
767 | return 1; | 735 | rq->cmd_len = 10; |
768 | } | 736 | } |
769 | 737 | ||
770 | static void sd_rescan(struct device *dev) | 738 | static void sd_rescan(struct device *dev) |
@@ -1462,6 +1430,7 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
1462 | struct scsi_disk *sdkp = scsi_disk(disk); | 1430 | struct scsi_disk *sdkp = scsi_disk(disk); |
1463 | struct scsi_device *sdp = sdkp->device; | 1431 | struct scsi_device *sdp = sdkp->device; |
1464 | unsigned char *buffer; | 1432 | unsigned char *buffer; |
1433 | unsigned ordered; | ||
1465 | 1434 | ||
1466 | SCSI_LOG_HLQUEUE(3, printk("sd_revalidate_disk: disk=%s\n", disk->disk_name)); | 1435 | SCSI_LOG_HLQUEUE(3, printk("sd_revalidate_disk: disk=%s\n", disk->disk_name)); |
1467 | 1436 | ||
@@ -1498,7 +1467,20 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
1498 | sd_read_write_protect_flag(sdkp, disk->disk_name, buffer); | 1467 | sd_read_write_protect_flag(sdkp, disk->disk_name, buffer); |
1499 | sd_read_cache_type(sdkp, disk->disk_name, buffer); | 1468 | sd_read_cache_type(sdkp, disk->disk_name, buffer); |
1500 | } | 1469 | } |
1501 | 1470 | ||
1471 | /* | ||
1472 | * We now have all cache related info, determine how we deal | ||
1473 | * with ordered requests. Note that as the current SCSI | ||
1474 | * dispatch function can alter request order, we cannot use | ||
1475 | * QUEUE_ORDERED_TAG_* even when ordered tag is supported. | ||
1476 | */ | ||
1477 | if (sdkp->WCE) | ||
1478 | ordered = QUEUE_ORDERED_DRAIN_FLUSH; | ||
1479 | else | ||
1480 | ordered = QUEUE_ORDERED_DRAIN; | ||
1481 | |||
1482 | blk_queue_ordered(sdkp->disk->queue, ordered, sd_prepare_flush); | ||
1483 | |||
1502 | set_capacity(disk, sdkp->capacity); | 1484 | set_capacity(disk, sdkp->capacity); |
1503 | kfree(buffer); | 1485 | kfree(buffer); |
1504 | 1486 | ||
@@ -1598,6 +1580,7 @@ static int sd_probe(struct device *dev) | |||
1598 | strcpy(gd->devfs_name, sdp->devfs_name); | 1580 | strcpy(gd->devfs_name, sdp->devfs_name); |
1599 | 1581 | ||
1600 | gd->private_data = &sdkp->driver; | 1582 | gd->private_data = &sdkp->driver; |
1583 | gd->queue = sdkp->device->request_queue; | ||
1601 | 1584 | ||
1602 | sd_revalidate_disk(gd); | 1585 | sd_revalidate_disk(gd); |
1603 | 1586 | ||
@@ -1605,7 +1588,6 @@ static int sd_probe(struct device *dev) | |||
1605 | gd->flags = GENHD_FL_DRIVERFS; | 1588 | gd->flags = GENHD_FL_DRIVERFS; |
1606 | if (sdp->removable) | 1589 | if (sdp->removable) |
1607 | gd->flags |= GENHD_FL_REMOVABLE; | 1590 | gd->flags |= GENHD_FL_REMOVABLE; |
1608 | gd->queue = sdkp->device->request_queue; | ||
1609 | 1591 | ||
1610 | dev_set_drvdata(dev, sdkp); | 1592 | dev_set_drvdata(dev, sdkp); |
1611 | add_disk(gd); | 1593 | add_disk(gd); |