diff options
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r-- | drivers/scsi/sd.c | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 84044233b637..878b17a9af30 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -384,9 +384,9 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) | |||
384 | struct scsi_device *sdp = q->queuedata; | 384 | struct scsi_device *sdp = q->queuedata; |
385 | struct gendisk *disk = rq->rq_disk; | 385 | struct gendisk *disk = rq->rq_disk; |
386 | struct scsi_disk *sdkp; | 386 | struct scsi_disk *sdkp; |
387 | sector_t block = rq->sector; | 387 | sector_t block = blk_rq_pos(rq); |
388 | sector_t threshold; | 388 | sector_t threshold; |
389 | unsigned int this_count = rq->nr_sectors; | 389 | unsigned int this_count = blk_rq_sectors(rq); |
390 | int ret, host_dif; | 390 | int ret, host_dif; |
391 | 391 | ||
392 | if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { | 392 | if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { |
@@ -413,10 +413,10 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) | |||
413 | this_count)); | 413 | this_count)); |
414 | 414 | ||
415 | if (!sdp || !scsi_device_online(sdp) || | 415 | if (!sdp || !scsi_device_online(sdp) || |
416 | block + rq->nr_sectors > get_capacity(disk)) { | 416 | block + blk_rq_sectors(rq) > get_capacity(disk)) { |
417 | SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, | 417 | SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, |
418 | "Finishing %ld sectors\n", | 418 | "Finishing %u sectors\n", |
419 | rq->nr_sectors)); | 419 | blk_rq_sectors(rq))); |
420 | SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, | 420 | SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, |
421 | "Retry with 0x%p\n", SCpnt)); | 421 | "Retry with 0x%p\n", SCpnt)); |
422 | goto out; | 422 | goto out; |
@@ -463,7 +463,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) | |||
463 | * for this. | 463 | * for this. |
464 | */ | 464 | */ |
465 | if (sdp->sector_size == 1024) { | 465 | if (sdp->sector_size == 1024) { |
466 | if ((block & 1) || (rq->nr_sectors & 1)) { | 466 | if ((block & 1) || (blk_rq_sectors(rq) & 1)) { |
467 | scmd_printk(KERN_ERR, SCpnt, | 467 | scmd_printk(KERN_ERR, SCpnt, |
468 | "Bad block number requested\n"); | 468 | "Bad block number requested\n"); |
469 | goto out; | 469 | goto out; |
@@ -473,7 +473,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) | |||
473 | } | 473 | } |
474 | } | 474 | } |
475 | if (sdp->sector_size == 2048) { | 475 | if (sdp->sector_size == 2048) { |
476 | if ((block & 3) || (rq->nr_sectors & 3)) { | 476 | if ((block & 3) || (blk_rq_sectors(rq) & 3)) { |
477 | scmd_printk(KERN_ERR, SCpnt, | 477 | scmd_printk(KERN_ERR, SCpnt, |
478 | "Bad block number requested\n"); | 478 | "Bad block number requested\n"); |
479 | goto out; | 479 | goto out; |
@@ -483,7 +483,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) | |||
483 | } | 483 | } |
484 | } | 484 | } |
485 | if (sdp->sector_size == 4096) { | 485 | if (sdp->sector_size == 4096) { |
486 | if ((block & 7) || (rq->nr_sectors & 7)) { | 486 | if ((block & 7) || (blk_rq_sectors(rq) & 7)) { |
487 | scmd_printk(KERN_ERR, SCpnt, | 487 | scmd_printk(KERN_ERR, SCpnt, |
488 | "Bad block number requested\n"); | 488 | "Bad block number requested\n"); |
489 | goto out; | 489 | goto out; |
@@ -512,10 +512,10 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) | |||
512 | } | 512 | } |
513 | 513 | ||
514 | SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, | 514 | SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, |
515 | "%s %d/%ld 512 byte blocks.\n", | 515 | "%s %d/%u 512 byte blocks.\n", |
516 | (rq_data_dir(rq) == WRITE) ? | 516 | (rq_data_dir(rq) == WRITE) ? |
517 | "writing" : "reading", this_count, | 517 | "writing" : "reading", this_count, |
518 | rq->nr_sectors)); | 518 | blk_rq_sectors(rq))); |
519 | 519 | ||
520 | /* Set RDPROTECT/WRPROTECT if disk is formatted with DIF */ | 520 | /* Set RDPROTECT/WRPROTECT if disk is formatted with DIF */ |
521 | host_dif = scsi_host_dif_capable(sdp->host, sdkp->protection_type); | 521 | host_dif = scsi_host_dif_capable(sdp->host, sdkp->protection_type); |
@@ -971,8 +971,8 @@ static struct block_device_operations sd_fops = { | |||
971 | 971 | ||
972 | static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd) | 972 | static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd) |
973 | { | 973 | { |
974 | u64 start_lba = scmd->request->sector; | 974 | u64 start_lba = blk_rq_pos(scmd->request); |
975 | u64 end_lba = scmd->request->sector + (scsi_bufflen(scmd) / 512); | 975 | u64 end_lba = blk_rq_pos(scmd->request) + (scsi_bufflen(scmd) / 512); |
976 | u64 bad_lba; | 976 | u64 bad_lba; |
977 | int info_valid; | 977 | int info_valid; |
978 | 978 | ||
@@ -1510,7 +1510,7 @@ got_data: | |||
1510 | */ | 1510 | */ |
1511 | sector_size = 512; | 1511 | sector_size = 512; |
1512 | } | 1512 | } |
1513 | blk_queue_hardsect_size(sdp->request_queue, sector_size); | 1513 | blk_queue_logical_block_size(sdp->request_queue, sector_size); |
1514 | 1514 | ||
1515 | { | 1515 | { |
1516 | char cap_str_2[10], cap_str_10[10]; | 1516 | char cap_str_2[10], cap_str_10[10]; |
@@ -1902,24 +1902,6 @@ static void sd_probe_async(void *data, async_cookie_t cookie) | |||
1902 | index = sdkp->index; | 1902 | index = sdkp->index; |
1903 | dev = &sdp->sdev_gendev; | 1903 | dev = &sdp->sdev_gendev; |
1904 | 1904 | ||
1905 | if (!sdp->request_queue->rq_timeout) { | ||
1906 | if (sdp->type != TYPE_MOD) | ||
1907 | blk_queue_rq_timeout(sdp->request_queue, SD_TIMEOUT); | ||
1908 | else | ||
1909 | blk_queue_rq_timeout(sdp->request_queue, | ||
1910 | SD_MOD_TIMEOUT); | ||
1911 | } | ||
1912 | |||
1913 | device_initialize(&sdkp->dev); | ||
1914 | sdkp->dev.parent = &sdp->sdev_gendev; | ||
1915 | sdkp->dev.class = &sd_disk_class; | ||
1916 | dev_set_name(&sdkp->dev, dev_name(&sdp->sdev_gendev)); | ||
1917 | |||
1918 | if (device_add(&sdkp->dev)) | ||
1919 | goto out_free_index; | ||
1920 | |||
1921 | get_device(&sdp->sdev_gendev); | ||
1922 | |||
1923 | if (index < SD_MAX_DISKS) { | 1905 | if (index < SD_MAX_DISKS) { |
1924 | gd->major = sd_major((index & 0xf0) >> 4); | 1906 | gd->major = sd_major((index & 0xf0) >> 4); |
1925 | gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00); | 1907 | gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00); |
@@ -1954,11 +1936,6 @@ static void sd_probe_async(void *data, async_cookie_t cookie) | |||
1954 | 1936 | ||
1955 | sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n", | 1937 | sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n", |
1956 | sdp->removable ? "removable " : ""); | 1938 | sdp->removable ? "removable " : ""); |
1957 | |||
1958 | return; | ||
1959 | |||
1960 | out_free_index: | ||
1961 | ida_remove(&sd_index_ida, index); | ||
1962 | } | 1939 | } |
1963 | 1940 | ||
1964 | /** | 1941 | /** |
@@ -2026,6 +2003,24 @@ static int sd_probe(struct device *dev) | |||
2026 | sdkp->openers = 0; | 2003 | sdkp->openers = 0; |
2027 | sdkp->previous_state = 1; | 2004 | sdkp->previous_state = 1; |
2028 | 2005 | ||
2006 | if (!sdp->request_queue->rq_timeout) { | ||
2007 | if (sdp->type != TYPE_MOD) | ||
2008 | blk_queue_rq_timeout(sdp->request_queue, SD_TIMEOUT); | ||
2009 | else | ||
2010 | blk_queue_rq_timeout(sdp->request_queue, | ||
2011 | SD_MOD_TIMEOUT); | ||
2012 | } | ||
2013 | |||
2014 | device_initialize(&sdkp->dev); | ||
2015 | sdkp->dev.parent = &sdp->sdev_gendev; | ||
2016 | sdkp->dev.class = &sd_disk_class; | ||
2017 | dev_set_name(&sdkp->dev, dev_name(&sdp->sdev_gendev)); | ||
2018 | |||
2019 | if (device_add(&sdkp->dev)) | ||
2020 | goto out_free_index; | ||
2021 | |||
2022 | get_device(&sdp->sdev_gendev); | ||
2023 | |||
2029 | async_schedule(sd_probe_async, sdkp); | 2024 | async_schedule(sd_probe_async, sdkp); |
2030 | 2025 | ||
2031 | return 0; | 2026 | return 0; |
@@ -2055,8 +2050,10 @@ static int sd_probe(struct device *dev) | |||
2055 | **/ | 2050 | **/ |
2056 | static int sd_remove(struct device *dev) | 2051 | static int sd_remove(struct device *dev) |
2057 | { | 2052 | { |
2058 | struct scsi_disk *sdkp = dev_get_drvdata(dev); | 2053 | struct scsi_disk *sdkp; |
2059 | 2054 | ||
2055 | async_synchronize_full(); | ||
2056 | sdkp = dev_get_drvdata(dev); | ||
2060 | device_del(&sdkp->dev); | 2057 | device_del(&sdkp->dev); |
2061 | del_gendisk(sdkp->disk); | 2058 | del_gendisk(sdkp->disk); |
2062 | sd_shutdown(dev); | 2059 | sd_shutdown(dev); |