Skip to contentSkip to conversation

cdrom_id (udev) causes "No disk in drive" warning for ide devices with removable media

DISCUSSION Thomas Heinz 2 participants 10 messages Sep 8, 2005 – Sep 15, 2005

lore
Share & tools
lore
#0 lore raw

Hi

The following gentoo rule is responsible for handling my ide zip drive (ide-floppy driver).

BUS="ide", KERNEL="hd[a-z]", ACTION="add", IMPORT="/sbin/cdrom_id
--export $tempnode"

cdrom_id tries to open the device and the kernel outputs the message. Debian seems to handle the issue differently with the following rule.

BUS="ide", KERNEL="hd[a-z]", SYSFS{removable}="1", \

  PROGRAM="/etc/udev/scripts/ide-model.sh %k", RESULT="IOMEGA ZIP *", \
                                        NAME="%k", 

OPTIONS+="all_partitions"

Do you consider it the distributors' job to fix the issue or would you rather fix cdrom_id?

Thanks for your input.

Regards,

Thomas

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#1 lore raw
Quoted 9 lines · Thomas Heinz

The following gentoo rule is responsible for handling my ide zip drive (ide-floppy driver).

BUS="ide", KERNEL="hd[a-z]", ACTION="add", IMPORT="/sbin/cdrom_id
--export $tempnode"

cdrom_id tries to open the device and the kernel outputs the message. Debian seems to handle the issue differently with the following rule.

Quoted 8 lines

BUS="ide", KERNEL="hd[a-z]", SYSFS{removable}="1", \

  PROGRAM="/etc/udev/scripts/ide-model.sh %k", RESULT="IOMEGA ZIP *", \
                                        NAME="%k", 

OPTIONS+="all_partitions"

Do you consider it the distributors' job to fix the issue or would you rather fix cdrom_id?

cdrom_id itself can't know what kind of device it is before it has opened it. No idea why the kernel still prints this. I thought we removed all these stupid messages.
It would be nice to have all the information available in /sys that is only in /proc, but the IDE maintainers are not really interested in proper driver core integration. Hopefully the libata effort will move everything including parallel ata to the scsi layer some day, which provides all what we need in /sys.

You may try to add something like this to the ide cdrom_id rule:
... , PROGRAM="/bin/cat /proc/ide/%k/media", RESULT="cdrom", ...

I didn't test it and I don't remember if "cdrom" was the right value here. (I don't have cdrom in the last box that uses the old ide drivers.)

Would be nice if you could test this?

Thanks,
Kay

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#2 lore raw
In reply to Thomas Heinz

Hi Kay,

thanks for your quick response.

Quoted 3 lines · You

cdrom_id itself can't know what kind of device it is before it has opened it. No idea why the kernel still prints this. I thought we removed all these stupid messages.

It appears that the error message comes from drivers/ide/ide-floppy.c. Both idefloppy_setup() and idefloppy_open() call idefloppy_capacity which in turn outputs the message. So either the printk() should be removed or the logic should be changed somehow assuming that there is some case where the output makes sense.

Quoted 8 lines

You may try to add something like this to the ide cdrom_id rule:
... , PROGRAM="/bin/cat /proc/ide/%k/media", RESULT="cdrom", ...

I didn't test it and I don't remember if "cdrom" was the right value here. (I don't have cdrom in the last box that uses the old ide drivers.)

Would be nice if you could test this?

Good idea, works nicely. I will suggest this modification to the gentoo maintainers.

Best regards,

Thomas

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#3 lore raw
In reply to Thomas Heinz

Unfortunately, a similar problem occurs with my SCSI CD-RW drive. It is caused by the rule:

BUS="scsi", KERNEL="sr[0-9]*", ACTION="add", IMPORT="/sbin/cdrom_id
--export $tempnode"

Now in this case, it is really about a "cdrom". The message seems to be from drivers/scsi/scsi_ioctl.c. Interestingly, my other SCSI "cdrom" (in fact a DVD-RAM drive) does not cause such a warning.

What is your suggestion?

Regards,

Thomas

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#4 lore raw
In reply to Thomas Heinz
Quoted 11 lines · Thomas Heinz

Unfortunately, a similar problem occurs with my SCSI CD-RW drive. It is caused by the rule:

BUS=="scsi", KERNEL="sr[0-9]*", ACTION=="add", IMPORT="/sbin/cdrom_id
--export $tempnode"

Now in this case, it is really about a "cdrom". The message seems to be from drivers/scsi/scsi_ioctl.c. Interestingly, my other SCSI "cdrom" (in fact a DVD-RAM drive) does not cause such a warning.

What is your suggestion?

Can you try this patch? Only a wild guess that it may help...

Kay

extras/cdrom_id/cdrom_id.c +11 -2
@@ -36,6 +36,8 @@
  * with all of the DVD flags.  So we just include our own, aren't
  * we so nice...
  */
+#define CDO_USE_FFLAGS		0x4	/* use O_NONBLOCK information on open */
+#define CDROM_SET_OPTIONS	0x5320	/* Set behavior options */
 #define CDROM_GET_CAPABILITY	0x5331	/* get capabilities */
 
 /* capability flags used with the uniform CD-ROM driver */
@@ -115,14 +117,21 @@ int main(int argc, char *argv[])
 	fd = open(node, O_RDONLY|O_NONBLOCK);
 	if (fd < 0) {
 		info("unable to open '%s'", node);
-		rc = 1;
+		rc = 2;
 		goto exit;
 	}
 
+	result = ioctl(fd, CDROM_SET_OPTIONS, CDO_USE_FFLAGS);
+	if (result < 0) {
+		info("CDROM_SET_OPTIONS failed for '%s'", node);
+		rc = 3;
+		goto close;
+	}
+
 	result = ioctl(fd, CDROM_GET_CAPABILITY, NULL);
 	if (result < 0) {
 		info("CDROM_GET_CAPABILITY failed for '%s'", node);
-		rc = 3;
+		rc = 4;
 		goto close;
 	}
 
#5 lore raw
In reply to Thomas Heinz

Thanks for your help Kay.

Quoted 1 line · You

Can you try this patch? Only a wild guess that it may help...

Unfortunately, it does not.

Interestingly, I found out that the kernel message is generated on close(fd) (line 151).

Does this help you further?

Best regards,

Thomas

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#6 lore raw
In reply to Thomas Heinz
Quoted 11 lines · Thomas Heinz

Thanks for your help Kay.

Quoted 1 line · You

Can you try this patch? Only a wild guess that it may help...

Unfortunately, it does not.

Interestingly, I found out that the kernel message is generated on close(fd) (line 151).

Does this help you further?

Hmm, no idea. I tested it remotely on a few boxes with a SCSI cdrom and none of them prints anything on a cdrom_id run.

Kay

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#7 lore raw
In reply to Thomas Heinz

Hi Kay

Quoted 5 lines · You
Quoted 2 lines

Interestingly, I found out that the kernel message is generated on close(fd) (line 151).

Hmm, no idea. I tested it remotely on a few boxes with a SCSI cdrom and none of them prints anything on a cdrom_id run.

On close(), scsi_set_medium_removal() is called which again calls ioctl_internal_command(). The scsi request is initiated here:
http://lxr.linux.no/source/drivers/scsi/scsi_ioctl.c#L109
It "returns" NOT_READY which effectively causes the kernel message.

In order to avoid the message during bootup, I have defined some rules before the default rule set which mimic the effect of executing cdrom_id without actually doing it. The execution of the default rule set for the specific scsi device is avoided by the last_rule option.

Since only one of my scsi cdrom devices behaves like this (and moreover you could not reproduce the behaviour), it is probably not a general problem. What do you suggest to further track the problem down?

Regards,

Thomas

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#8 lore raw
In reply to Thomas Heinz
Quoted 12 lines · Thomas Heinz
Quoted 5 lines · You
Quoted 2 lines

Interestingly, I found out that the kernel message is generated on close(fd) (line 151).

Hmm, no idea. I tested it remotely on a few boxes with a SCSI cdrom and none of them prints anything on a cdrom_id run.

On close(), scsi_set_medium_removal() is called which again calls ioctl_internal_command(). The scsi request is initiated here:
http://lxr.linux.no/source/drivers/scsi/scsi_ioctl.c#L109
It "returns" NOT_READY which effectively causes the kernel message.

Quoted 7 lines

In order to avoid the message during bootup, I have defined some rules before the default rule set which mimic the effect of executing cdrom_id without actually doing it. The execution of the default rule set for the specific scsi device is avoided by the last_rule option.

Since only one of my scsi cdrom devices behaves like this (and moreover you could not reproduce the behaviour), it is probably not a general problem.

Hmm I wouldn't call it a "problem". It's just a message from our noisy kernel. :)
I don't see a nice way to prevent that from userspace. We just asks the device to identify itself, which should not trigger media validation. Don't know if there is a trick we don't know about now.

Quoted 1 line

What do you suggest to further track the problem down?

The benefit of a lot of kernel messages for things like this is really questionable. Maybe the firmware in your device has some weird behavior. Unfortunately, I don't know how to debug this and I better go fix some of the real bugs we have. :)

Thanks,
Kay

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#9 lore raw
In reply to Thomas Heinz
Quoted 2 lines · You

Hmm I wouldn't call it a "problem". It's just a message from our noisy kernel. :)

I definitely agree. It's only a minor "cosmetic" issue.

Quoted 10 lines

I don't see a nice way to prevent that from userspace. We just asks the device to identify itself, which should not trigger media validation. Don't know if there is a trick we don't know about now.

Quoted 1 line

What do you suggest to further track the problem down?

The benefit of a lot of kernel messages for things like this is really questionable. Maybe the firmware in your device has some weird behavior. Unfortunately, I don't know how to debug this and I better go fix some of the real bugs we have. :)

Ok. I perfectly understand that this issue is hardly of any importance. It might be more interesting if it would occur for a number of devices (and not only my single cd-rw ;). Maybe someone else stumbles over this thread who immediately knows what could be the reason for the behaviour. Personally, I can live with my workaround and since I am not familiar with the scsi code, it would not really pay off to delve into it just to make the boot screen look a little better :-)

Thanks for your time and support.

Regards,

Thomas

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel