diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2010-07-03 04:45:34 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-08-07 12:23:58 -0400 |
commit | 90467c294aba7f911bdae72ed86995cf1de4d364 (patch) | |
tree | f1b516586b02a477d78ccc627b0c298c2be982a3 /drivers/scsi/sd.c | |
parent | b6a903151d05e3912ab66b186f74c61851efb88c (diff) |
scsi: stop using q->prepare_flush_fn
scsi-ml builds flush requests via q->prepare_flush_fn(), however,
builds discard requests via q->prep_rq_fn.
Using two different mechnisms for the similar requests (building
commands in SCSI ULD) doesn't make sense.
Handing both via q->prep_rq_fn makes the code design simpler.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: James Bottomley <James.Bottomley@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r-- | drivers/scsi/sd.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index aa6b48ba78b1..e8c295e01466 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -471,6 +471,18 @@ static int scsi_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq) | |||
471 | return ret; | 471 | return ret; |
472 | } | 472 | } |
473 | 473 | ||
474 | static int scsi_setup_flush_cmnd(struct scsi_device *sdp, struct request *rq) | ||
475 | { | ||
476 | /* for now, we use REQ_TYPE_BLOCK_PC. */ | ||
477 | rq->cmd_type = REQ_TYPE_BLOCK_PC; | ||
478 | rq->timeout = SD_TIMEOUT; | ||
479 | rq->retries = SD_MAX_RETRIES; | ||
480 | rq->cmd[0] = SYNCHRONIZE_CACHE; | ||
481 | rq->cmd_len = 10; | ||
482 | |||
483 | return scsi_setup_blk_pc_cmnd(sdp, rq); | ||
484 | } | ||
485 | |||
474 | static void sd_unprep_fn(struct request_queue *q, struct request *rq) | 486 | static void sd_unprep_fn(struct request_queue *q, struct request *rq) |
475 | { | 487 | { |
476 | if (rq->cmd_flags & REQ_DISCARD) | 488 | if (rq->cmd_flags & REQ_DISCARD) |
@@ -504,6 +516,9 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) | |||
504 | if (rq->cmd_flags & REQ_DISCARD) { | 516 | if (rq->cmd_flags & REQ_DISCARD) { |
505 | ret = scsi_setup_discard_cmnd(sdp, rq); | 517 | ret = scsi_setup_discard_cmnd(sdp, rq); |
506 | goto out; | 518 | goto out; |
519 | } else if (rq->cmd_flags & REQ_FLUSH) { | ||
520 | ret = scsi_setup_flush_cmnd(sdp, rq); | ||
521 | goto out; | ||
507 | } else if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { | 522 | } else if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { |
508 | ret = scsi_setup_blk_pc_cmnd(sdp, rq); | 523 | ret = scsi_setup_blk_pc_cmnd(sdp, rq); |
509 | goto out; | 524 | goto out; |
@@ -1053,15 +1068,6 @@ static int sd_sync_cache(struct scsi_disk *sdkp) | |||
1053 | return 0; | 1068 | return 0; |
1054 | } | 1069 | } |
1055 | 1070 | ||
1056 | static void sd_prepare_flush(struct request_queue *q, struct request *rq) | ||
1057 | { | ||
1058 | rq->cmd_type = REQ_TYPE_BLOCK_PC; | ||
1059 | rq->timeout = SD_TIMEOUT; | ||
1060 | rq->retries = SD_MAX_RETRIES; | ||
1061 | rq->cmd[0] = SYNCHRONIZE_CACHE; | ||
1062 | rq->cmd_len = 10; | ||
1063 | } | ||
1064 | |||
1065 | static void sd_rescan(struct device *dev) | 1071 | static void sd_rescan(struct device *dev) |
1066 | { | 1072 | { |
1067 | struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); | 1073 | struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); |
@@ -2129,7 +2135,7 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
2129 | else | 2135 | else |
2130 | ordered = QUEUE_ORDERED_DRAIN; | 2136 | ordered = QUEUE_ORDERED_DRAIN; |
2131 | 2137 | ||
2132 | blk_queue_ordered(sdkp->disk->queue, ordered, sd_prepare_flush); | 2138 | blk_queue_ordered(sdkp->disk->queue, ordered, NULL); |
2133 | 2139 | ||
2134 | set_capacity(disk, sdkp->capacity); | 2140 | set_capacity(disk, sdkp->capacity); |
2135 | kfree(buffer); | 2141 | kfree(buffer); |