Commit 90467c29 authored by FUJITA Tomonori's avatar FUJITA Tomonori Committed by Jens Axboe

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: default avatarFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: James Bottomley <James.Bottomley@suse.de>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
parent b6a90315
...@@ -471,6 +471,18 @@ static int scsi_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq) ...@@ -471,6 +471,18 @@ static int scsi_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq)
return ret; return ret;
} }
static int scsi_setup_flush_cmnd(struct scsi_device *sdp, struct request *rq)
{
/* for now, we use REQ_TYPE_BLOCK_PC. */
rq->cmd_type = REQ_TYPE_BLOCK_PC;
rq->timeout = SD_TIMEOUT;
rq->retries = SD_MAX_RETRIES;
rq->cmd[0] = SYNCHRONIZE_CACHE;
rq->cmd_len = 10;
return scsi_setup_blk_pc_cmnd(sdp, rq);
}
static void sd_unprep_fn(struct request_queue *q, struct request *rq) static void sd_unprep_fn(struct request_queue *q, struct request *rq)
{ {
if (rq->cmd_flags & REQ_DISCARD) if (rq->cmd_flags & REQ_DISCARD)
...@@ -504,6 +516,9 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) ...@@ -504,6 +516,9 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
if (rq->cmd_flags & REQ_DISCARD) { if (rq->cmd_flags & REQ_DISCARD) {
ret = scsi_setup_discard_cmnd(sdp, rq); ret = scsi_setup_discard_cmnd(sdp, rq);
goto out; goto out;
} else if (rq->cmd_flags & REQ_FLUSH) {
ret = scsi_setup_flush_cmnd(sdp, rq);
goto out;
} else if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { } else if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
ret = scsi_setup_blk_pc_cmnd(sdp, rq); ret = scsi_setup_blk_pc_cmnd(sdp, rq);
goto out; goto out;
...@@ -1053,15 +1068,6 @@ static int sd_sync_cache(struct scsi_disk *sdkp) ...@@ -1053,15 +1068,6 @@ static int sd_sync_cache(struct scsi_disk *sdkp)
return 0; return 0;
} }
static void sd_prepare_flush(struct request_queue *q, struct request *rq)
{
rq->cmd_type = REQ_TYPE_BLOCK_PC;
rq->timeout = SD_TIMEOUT;
rq->retries = SD_MAX_RETRIES;
rq->cmd[0] = SYNCHRONIZE_CACHE;
rq->cmd_len = 10;
}
static void sd_rescan(struct device *dev) static void sd_rescan(struct device *dev)
{ {
struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
...@@ -2129,7 +2135,7 @@ static int sd_revalidate_disk(struct gendisk *disk) ...@@ -2129,7 +2135,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
else else
ordered = QUEUE_ORDERED_DRAIN; ordered = QUEUE_ORDERED_DRAIN;
blk_queue_ordered(sdkp->disk->queue, ordered, sd_prepare_flush); blk_queue_ordered(sdkp->disk->queue, ordered, NULL);
set_capacity(disk, sdkp->capacity); set_capacity(disk, sdkp->capacity);
kfree(buffer); kfree(buffer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment