Skip to contentSkip to conversation

Making MO drive work with ide-cd

DISCUSSION [email protected] 3 participants 3 messages Jan 18, 2004 Uniform cdrom driver

lore
Share & tools
lore
#0 lore raw

From [email protected] Sun Jan 18 02:16:30 2004
From: Pascal Schmidt <[email protected]>

> By some coincidence I got hold of an MO drive today. Under 2.4.21 > and 2.6.1 using ide-scsi all seems to work at first sight.

For me, it doesn't work at all with ide-scsi in 2.6. 2.4 is fine in that regard.

Please fill the whole disk and then reread and compare via ide-scsi. That never worked for me in 2.6 using ide-scsi, but it does work with the patch in -mm.

Yes, you are right. Yesterday night I tried a small amount of I/O, and that worked fine, but today the kernel couldn't cope with a diff between two 640MB trees.

Unable to handle kernel paging request at virtual address 6b6b6b6b.

Followed by a bad kernel crash (vanilla 2.6.1).

OK. So, just like the rumours said already, ide-scsi is badly broken.

Since small amounts of I/O work - a race somewhere? bad locking?

Quoted 4 lines

With ide-cd I get errors only.
Not surprising: ide-cd expects a CD so sends READ_TOC and gets "illegal request / invalid command" back. The appropriate command is READ CAPACITY.

There is a patch by me with some rework by Jens Axboe in -mm that corrects this situation. It hasn't seen much testing, though.

OK, will find that and try later.

By the way, what hardware sector size does your MO use? I have only tested my patch with 2048 byte sector size - everything else is unlikely to work with ide-cd...

It uses media with 512-byte and media with 2048-byte sectors.

Quoted 2 lines

Are there cases where ide-cd is useful?
Should we retarget ide_optical to ide-scsi?

I agree that the situation in mainline as it is now is undesirable, only mounting prewritten discs read-only works.

Yes. We must find out what is wrong in ide-scsi and fix it.

Andries

#1 lore raw
Quoted 2 lines · On Sun, 18 Jan 2004 [email protected] wrote:
Unable to handle kernel paging request at virtual address 6b6b6b6b.

Followed by a bad kernel crash (vanilla 2.6.1).

[...]

Quoted 1 line

Since small amounts of I/O work - a race somewhere? bad locking?

The above virtual address looks like a poison value, so maybe there's a use-after-free bug somewhere.

Quoted 3 lines
Quoted 2 lines

There is a patch by me with some rework by Jens Axboe in -mm that corrects this situation. It hasn't seen much testing, though.

OK, will find that and try later.

I've included my old patch (not exactly what is in -mm) at the end of the mail. It's for 2.6.0 but maybe it applies to vanilla 2.6.1 still.

Quoted 1 line

It uses media with 512-byte and media with 2048-byte sectors.

The 2048 byte ones should work with my patch, but I guess the 512 byte ones will not.

Quoted 1 line

Yes. We must find out what is wrong in ide-scsi and fix it.

Or make one of the ide drivers work with MO drives. The problem there is the different sector sizes, it seems. ide-cd is not happy with sector sizes other than 2048 and ide-floppy (my first try) doesn't want to play with anything different from 512 bytes. That leaves ide-disk where I suspect it doesn't do removable media, apart from the sector size issue.

drivers/ide/ide-cd.c +15 -8
@@ -2242,6 +2242,7 @@ static int cdrom_read_toc(ide_drive_t *d
 		struct atapi_toc_header hdr;
 		struct atapi_toc_entry  ent;
 	} ms_tmp;
+	long last_written;
 
 	if (toc == NULL) {
 		/* Try to allocate space. */
@@ -2261,6 +2262,13 @@ static int cdrom_read_toc(ide_drive_t *d
 	if (CDROM_STATE_FLAGS(drive)->toc_valid)
 		return 0;
 
+	/* Try to get the total cdrom capacity. */
+	stat = cdrom_read_capacity(drive, &toc->capacity, sense);
+	if (stat)
+		toc->capacity = 0x1fffff;
+
+	set_capacity(drive->disk, toc->capacity * SECTORS_PER_FRAME);
+
 	/* First read just the header, so we know how long the TOC is. */
 	stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr,
 				    sizeof(struct atapi_toc_header), sense);
@@ -2368,13 +2376,11 @@ static int cdrom_read_toc(ide_drive_t *d
 	toc->xa_flag = (ms_tmp.hdr.first_track != ms_tmp.hdr.last_track);
 
 	/* Now try to get the total cdrom capacity. */
-	stat = cdrom_get_last_written(cdi, (long *) &toc->capacity);
-	if (stat || !toc->capacity)
-		stat = cdrom_read_capacity(drive, &toc->capacity, sense);
-	if (stat)
-		toc->capacity = 0x1fffff;
-
-	set_capacity(drive->disk, toc->capacity * SECTORS_PER_FRAME);
+	stat = cdrom_get_last_written(cdi, &last_written);
+	if (!stat && last_written) {
+		toc->capacity = last_written;
+		set_capacity(drive->disk, toc->capacity * SECTORS_PER_FRAME);
+	}
 
 	/* Remember that we've read this stuff. */
 	CDROM_STATE_FLAGS(drive)->toc_valid = 1;
@@ -3215,7 +3221,8 @@ int ide_cdrom_setup (ide_drive_t *drive)
 
 	nslots = ide_cdrom_probe_capabilities (drive);
 
-	if (CDROM_CONFIG_FLAGS(drive)->dvd_ram)
+	if (CDROM_CONFIG_FLAGS(drive)->dvd_ram ||
+	    CDROM_CONFIG_FLAGS(drive)->mo_drive)
 		set_disk_ro(drive->disk, 0);
 
 #if 0
drivers/cdrom/cdrom.c +2 -1
@@ -426,7 +426,8 @@ int cdrom_open(struct cdrom_device_info 
 	if ((fp->f_flags & O_NONBLOCK) && (cdi->options & CDO_USE_FFLAGS))
 		ret = cdi->ops->open(cdi, 1);
 	else {
-		if ((fp->f_mode & FMODE_WRITE) && !CDROM_CAN(CDC_DVD_RAM))
+		if ((fp->f_mode & FMODE_WRITE) &&
+		    !(CDROM_CAN(CDC_DVD_RAM) || CDROM_CAN(CDC_MO_DRIVE)))
 			return -EROFS;
 
 		ret = open_for_data(cdi);
Signature · 2 lines
Ciao,
Pascal
#2 lore raw
In reply to [email protected]
Quoted 21 lines · Andries.Brouwer

From [email protected] Sun Jan 18 02:16:30 2004
From: Pascal Schmidt <[email protected]>

Please fill the whole disk and then reread and compare via ide-scsi. That never worked for me in 2.6 using ide-scsi, but it does work with the patch in -mm.

Yes, you are right. Yesterday night I tried a small amount of I/O, and that worked fine, but today the kernel couldn't cope with a diff between two 640MB trees.

Unable to handle kernel paging request at virtual address 6b6b6b6b.

Followed by a bad kernel crash (vanilla 2.6.1).

OK. So, just like the rumours said already, ide-scsi is badly broken.

By the way, what hardware sector size does your MO use? I have only tested my patch with 2048 byte sector size - everything else is unlikely to work with ide-cd...

It uses media with 512-byte and media with 2048-byte sectors.

Quoted 7 lines
Quoted 2 lines

Are there cases where ide-cd is useful?
Should we retarget ide_optical to ide-scsi?

I agree that the situation in mainline as it is now is undesirable, only mounting prewritten discs read-only works.

Yes. We must find out what is wrong in ide-scsi and fix it.

I am trying to maintain ide-scsi so I'm very interested in details of the crash you observed. Can you post them, or mail directly to me if that's not appropriate?

Thanks, Willem Riede.