aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2010-07-20 21:29:37 -0400
committerJens Axboe <jaxboe@fusionio.com>2010-08-07 12:52:31 -0400
commit6a32a8aed509e71137043d464db4a7fcd88c903e (patch)
tree66689f31e570805a29ef129cc9ebe4c088d47837 /drivers
parent8112586063fe53958d60218631d661533f304504 (diff)
scsi: convert discard to REQ_TYPE_FS from REQ_TYPE_BLOCK_PC
Jens, any reason why this isn't included in your for-2.6.36 yet? = From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Subject: [PATCH resend] scsi: convert discard to REQ_TYPE_FS from REQ_TYPE_BLOCK_PC The block layer (file systems) sends discard requests as REQ_TYPE_FS (the role of REQ_TYPE_FS is that setting up commands and interpreting the results). But SCSI-ml treats discard requests as REQ_TYPE_BLOCK_PC. scsi-ml can handle discard requests as REQ_TYPE_FS easily. scsi_setup_discard_cmnd() sets up struct request and the bio nicely. Only remaining issue is that discard requests can't be completed partially so we need to modify sd_done. This conversion also fixes the problem that discard requests aren't retried when possible (e.g. UNIT ATTENTION). Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/sd.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index fc5d69a84af5..e63b85ac8cd1 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -434,7 +434,6 @@ static int scsi_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq)
434 nr_sectors >>= 3; 434 nr_sectors >>= 3;
435 } 435 }
436 436
437 rq->cmd_type = REQ_TYPE_BLOCK_PC;
438 rq->timeout = SD_TIMEOUT; 437 rq->timeout = SD_TIMEOUT;
439 438
440 memset(rq->cmd, 0, rq->cmd_len); 439 memset(rq->cmd, 0, rq->cmd_len);
@@ -1200,6 +1199,12 @@ static int sd_done(struct scsi_cmnd *SCpnt)
1200 int sense_valid = 0; 1199 int sense_valid = 0;
1201 int sense_deferred = 0; 1200 int sense_deferred = 0;
1202 1201
1202 if (SCpnt->request->cmd_flags & REQ_DISCARD) {
1203 if (!result)
1204 scsi_set_resid(SCpnt, 0);
1205 return good_bytes;
1206 }
1207
1203 if (result) { 1208 if (result) {
1204 sense_valid = scsi_command_normalize_sense(SCpnt, &sshdr); 1209 sense_valid = scsi_command_normalize_sense(SCpnt, &sshdr);
1205 if (sense_valid) 1210 if (sense_valid)