patch-2.4.19 linux-2.4.19/drivers/scsi/sr.c
Next file: linux-2.4.19/drivers/scsi/sr_ioctl.c
Previous file: linux-2.4.19/drivers/scsi/sim710_u.h
Back to the patch index
Back to the overall index
- Lines: 88
- Date:
Fri Aug 2 17:39:44 2002
- Orig file:
linux-2.4.18/drivers/scsi/sr.c
- Orig date:
Mon Feb 25 11:38:04 2002
diff -urN linux-2.4.18/drivers/scsi/sr.c linux-2.4.19/drivers/scsi/sr.c
@@ -198,6 +198,7 @@
int good_sectors = (result == 0 ? this_count : 0);
int block_sectors = 0;
int device_nr = DEVICE_NR(SCpnt->request.rq_dev);
+ long error_sector;
#ifdef DEBUG
printk("sr.c done: %x %p\n", result, SCpnt->request.bh->b_data);
@@ -210,33 +211,52 @@
if (driver_byte(result) != 0 && /* An error occurred */
- SCpnt->sense_buffer[0] == 0xF0 && /* Sense data is valid */
- (SCpnt->sense_buffer[2] == MEDIUM_ERROR ||
- SCpnt->sense_buffer[2] == VOLUME_OVERFLOW ||
- SCpnt->sense_buffer[2] == ILLEGAL_REQUEST)) {
- long error_sector = (SCpnt->sense_buffer[3] << 24) |
- (SCpnt->sense_buffer[4] << 16) |
- (SCpnt->sense_buffer[5] << 8) |
- SCpnt->sense_buffer[6];
- if (SCpnt->request.bh != NULL)
- block_sectors = SCpnt->request.bh->b_size >> 9;
- if (block_sectors < 4)
- block_sectors = 4;
- if (scsi_CDs[device_nr].device->sector_size == 2048)
- error_sector <<= 2;
- error_sector &= ~(block_sectors - 1);
- good_sectors = error_sector - SCpnt->request.sector;
- if (good_sectors < 0 || good_sectors >= this_count)
- good_sectors = 0;
- /*
- * The SCSI specification allows for the value returned by READ
- * CAPACITY to be up to 75 2K sectors past the last readable
- * block. Therefore, if we hit a medium error within the last
- * 75 2K sectors, we decrease the saved size value.
- */
- if ((error_sector >> 1) < sr_sizes[device_nr] &&
- scsi_CDs[device_nr].capacity - error_sector < 4 * 75)
- sr_sizes[device_nr] = error_sector >> 1;
+ SCpnt->sense_buffer[0] == 0xF0) { /* Sense data is valid */
+ switch (SCpnt->sense_buffer[2]) {
+ case MEDIUM_ERROR:
+ case VOLUME_OVERFLOW:
+ case ILLEGAL_REQUEST:
+ error_sector = (SCpnt->sense_buffer[3] << 24) |
+ (SCpnt->sense_buffer[4] << 16) |
+ (SCpnt->sense_buffer[5] << 8) |
+ SCpnt->sense_buffer[6];
+ if (SCpnt->request.bh != NULL)
+ block_sectors = SCpnt->request.bh->b_size >> 9;
+ if (block_sectors < 4)
+ block_sectors = 4;
+ if (scsi_CDs[device_nr].device->sector_size == 2048)
+ error_sector <<= 2;
+ error_sector &= ~(block_sectors - 1);
+ good_sectors = error_sector - SCpnt->request.sector;
+ if (good_sectors < 0 || good_sectors >= this_count)
+ good_sectors = 0;
+ /*
+ * The SCSI specification allows for the value returned
+ * by READ CAPACITY to be up to 75 2K sectors past the
+ * last readable block. Therefore, if we hit a medium
+ * error within the last 75 2K sectors, we decrease the
+ * saved size value.
+ */
+ if ((error_sector >> 1) < sr_sizes[device_nr] &&
+ scsi_CDs[device_nr].capacity - error_sector < 4 *75)
+ sr_sizes[device_nr] = error_sector >> 1;
+ break;
+
+ case RECOVERED_ERROR:
+ /*
+ * An error occured, but it recovered. Inform the
+ * user, but make sure that it's not treated as a
+ * hard error.
+ */
+ print_sense("sr", SCpnt);
+ result = 0;
+ SCpnt->sense_buffer[0] = 0x0;
+ good_sectors = this_count;
+ break;
+
+ default:
+ break;
+ }
}
/*
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)