Skip to content

Commit

Permalink
sd: Disable support for 256 byte/sector disks
Browse files Browse the repository at this point in the history
256 bytes per sector support has been broken since 2.6.X,
and no-one stepped up to fix this.
So disable support for it.

Signed-off-by: Mark Hounschell <dmarkh@cfl.rr.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Cc: stable@vger.kernel.org
Signed-off-by: James Bottomley <JBottomley@Odin.com>
  • Loading branch information
Mark Hounschell authored and James Bottomley committed May 18, 2015
1 parent 8b2564e commit 74856fb
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions drivers/scsi/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,7 @@ static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
{
u64 start_lba = blk_rq_pos(scmd->request);
u64 end_lba = blk_rq_pos(scmd->request) + (scsi_bufflen(scmd) / 512);
u64 factor = scmd->device->sector_size / 512;
u64 bad_lba;
int info_valid;
/*
Expand All @@ -1621,16 +1622,9 @@ static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
if (scsi_bufflen(scmd) <= scmd->device->sector_size)
return 0;

if (scmd->device->sector_size < 512) {
/* only legitimate sector_size here is 256 */
start_lba <<= 1;
end_lba <<= 1;
} else {
/* be careful ... don't want any overflows */
unsigned int factor = scmd->device->sector_size / 512;
do_div(start_lba, factor);
do_div(end_lba, factor);
}
/* be careful ... don't want any overflows */
do_div(start_lba, factor);
do_div(end_lba, factor);

/* The bad lba was reported incorrectly, we have no idea where
* the error is.
Expand Down Expand Up @@ -2188,8 +2182,7 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
if (sector_size != 512 &&
sector_size != 1024 &&
sector_size != 2048 &&
sector_size != 4096 &&
sector_size != 256) {
sector_size != 4096) {
sd_printk(KERN_NOTICE, sdkp, "Unsupported sector size %d.\n",
sector_size);
/*
Expand Down Expand Up @@ -2244,8 +2237,6 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
sdkp->capacity <<= 2;
else if (sector_size == 1024)
sdkp->capacity <<= 1;
else if (sector_size == 256)
sdkp->capacity >>= 1;

blk_queue_physical_block_size(sdp->request_queue,
sdkp->physical_block_size);
Expand Down

0 comments on commit 74856fb

Please sign in to comment.