]> err.no Git - linux-2.6/blobdiff - drivers/scsi/sd.c
[SCSI] sd: add fix for devices with last sector access problems
[linux-2.6] / drivers / scsi / sd.c
index 212f6bcfd4570f2f1d3f33e63d570373ad06fe02..24eba3118b5a415e9b76c0d5a668a72fab58d303 100644 (file)
@@ -395,6 +395,15 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
                goto out;
        }
 
+       /*
+        * Some devices (some sdcards for one) don't like it if the
+        * last sector gets read in a larger then 1 sector read.
+        */
+       if (unlikely(sdp->last_sector_bug &&
+           rq->nr_sectors > sdp->sector_size / 512 &&
+           block + this_count == get_capacity(disk)))
+               this_count -= sdp->sector_size / 512;
+
        SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, "block=%llu\n",
                                        (unsigned long long)block));