2004-01-17 23:38:43

by Andries E. Brouwer

[permalink] [raw]
Subject: Making MO drive work with ide-cd

Long ago we had a thread here with approximately the above subject.
I see fragments of discussion like

- if (drive->media == ide_cdrom)
+ if (drive->media == ide_cdrom || drive->media == ide_optical)
(void) request_module("ide-cd");

> Definitely, this looks like a fine start. As far as I'm concerned, it
> would be fine to commit to 2.5.

and still today, by default ide_optical is sent to ide-cd.

I wonder whether that is meaningful.

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.
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.

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

Andries


2004-01-18 01:16:32

by Pascal Schmidt

[permalink] [raw]
Subject: Re: Making MO drive work with ide-cd

On Sun, 18 Jan 2004 00:50:04 +0100, you wrote in linux.kernel:

> 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.

> 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.

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...

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

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.

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

--
Ciao,
Pascal

2004-01-18 12:21:01

by Andries E. Brouwer

[permalink] [raw]
Subject: Re: Making MO drive work with ide-cd

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?

> 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.

> 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

2004-01-18 12:36:19

by Pascal Schmidt

[permalink] [raw]
Subject: Re: Making MO drive work with ide-cd

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).
[...]
> 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.

>> 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.

> 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.

> 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.


--- linux-2.6.0/drivers/ide/ide-cd.c Thu Dec 18 23:36:59 2003
+++ linux-2.6.0-mo/drivers/ide/ide-cd.c Thu Dec 18 23:46:47 2003
@@ -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
--- linux-2.6.0/drivers/cdrom/cdrom.c Thu Dec 18 23:36:59 2003
+++ linux-2.6.0-mo/drivers/cdrom/cdrom.c Thu Dec 18 23:40:51 2003
@@ -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);


--
Ciao,
Pascal

2004-01-18 17:18:16

by Andries E. Brouwer

[permalink] [raw]
Subject: Re: Making MO drive work with ide-cd

From: Pascal Schmidt <[email protected]>

>> 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.

Hmm. Looked at it. But it cannot help. All it does is move
cdrom_read_capacity().

But ide-cd remains fundamentally broken for disks.
It sends cdrom commands, and they fail, and it does not do
disk things that are needed. First of all, we need partitions,
but ide-cd.c puts g->minors = 1.

Don't know whether Jens really wants to bend ide-cd.c until
it also handles disks, but it smells like a hack.

Andries

2004-01-18 17:59:04

by Kevin P. Fleming

[permalink] [raw]
Subject: Re: Making MO drive work with ide-cd

[email protected] wrote:

> Don't know whether Jens really wants to bend ide-cd.c until
> it also handles disks, but it smells like a hack.

Is Jeff Garzik's libata ever going to support parallel ATA? If so,
doesn't that handle this situation nicely, given that the SCSI sd module
should already know how to handle SCSI MO drives?

Subject: Re: Making MO drive work with ide-cd

On Sunday 18 of January 2004 18:58, Kevin P. Fleming wrote:
> [email protected] wrote:
> > Don't know whether Jens really wants to bend ide-cd.c until
> > it also handles disks, but it smells like a hack.
>
> Is Jeff Garzik's libata ever going to support parallel ATA? If so,

It will happen, but don't expect it soon (a lot of work is needed).

> doesn't that handle this situation nicely, given that the SCSI sd module
> should already know how to handle SCSI MO drives?

2004-01-18 20:49:02

by Willem Riede

[permalink] [raw]
Subject: Re: Making MO drive work with ide-cd

On Sun, 18 Jan 2004 13:20:51 +0100, Andries.Brouwer wrote:

> 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.
>
> > 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.

2004-01-18 21:29:00

by Andries E. Brouwer

[permalink] [raw]
Subject: Re: Making MO drive work with ide-cd

> I am trying to maintain ide-scsi so I'm very interested in details
> of the crash you observed. Can you post them

Not much to post - strange behaviour began, and thirty seconds
later the machine was totally dead, no reaction to keystrokes
any more.

Hope to find time one of these days to set up a serial console
and capture messages.

And to read the source.

And to hear from others. Maybe Jens once said that it was easy to fix
ide-scsi but that there was no interest. Possibly he has a more precise
idea what kind of things are broken. Or maybe you do.

Andries

2004-01-18 22:30:39

by Pascal Schmidt

[permalink] [raw]
Subject: Re: Making MO drive work with ide-cd

On Sun, 18 Jan 2004 [email protected] wrote:

> Hmm. Looked at it. But it cannot help. All it does is move
> cdrom_read_capacity().

That's enough for unpartitioned disks. It works here.

> But ide-cd remains fundamentally broken for disks.
> It sends cdrom commands, and they fail, and it does not do
> disk things that are needed. First of all, we need partitions,
> but ide-cd.c puts g->minors = 1.

Well, I'm welcome to other ideas, but to me everything is the
better than the current mainline 2.6 situation - which is "doesn't
work at all, no matter what you try".

The ide-cd solution doesn't get you partitions, but using the
medium as a superfloppy works for me.

--
Ciao,
Pascal