* Re: open write failure not predicted by blockdev getro
2004-07-14 5:36 ` Jens Axboe
@ 2004-07-15 0:00 ` Pat LaVarre
0 siblings, 0 replies; 3+ messages in thread
From: Pat LaVarre @ 2004-07-15 0:00 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-scsi
> > inserting a read-only DVD disc into a USB drive, ...
> > the paradoxical contradiction:
> > ...
> > $ sudo blockdev --getro /dev/scd0
> > 0
> > $ sudo dd of=/dev/scd0 bs=64K count=1 if=/dev/zero
> > dd: opening `/dev/scd0': Read-only file system
> > $
> ...
> does interest me, ...
Excellent, hi.
> please see if you can track this problem down.
printk tells me,
We call set_disk_ro of drivers/block/genhd.c only once per device plug
in, not once per disc insert.
Logically therefore, given a mixed collection of rewritable and
read-only discs, our guessing blockdev --getro 1 at plug in will prevent
writes of rewritable discs, and our guessing blockdev --getro 0 at plug
in will allow writes of read-only discs.
We necessarily lose both ways.
Do we care?
May we say that blockdev --setrw --setro --getro is a facility for
write-protecting DVD/ CD devices, not DVD/ CD discs, and take on the job
of guessing which devices don't want blanket write protection?
Or do we learn to refresh set_disk_ro once per disc insert?
We can decide in light of the drivers/scsi/sd.c precedent. I see there
a comment telling me we call set_disk_ro once per disc insert:
--- http://lxr.linux.no/source/drivers/scsi/sd.c?v=2.6.5#L1109
...
* read write protect setting, if possible - called only in sd_revalidate_disk()
...
---
Pat LaVarre
P.S. Newbie, me I haven't yet found the lines of cdrom.ko code we run
only once per disc insert.
The following patch ain't it, at least not yet. dmesg tells me this
source line executes indefinitely often while I have a USB DVD disc
(specifically an Iomega RRD disc) present. Even with PATAPI alone
connected, still it ran more often than the count of discs present.
diff -urp linux-2.6.8-rc1/drivers/cdrom/cdrom.c linux-2.6.8-rc1-pel/drivers/cdrom/cdrom.c
--- linux-2.6.8-rc1/drivers/cdrom/cdrom.c 2004-07-13 08:26:02.000000000 -0600
+++ linux-2.6.8-rc1-pel/drivers/cdrom/cdrom.c 2004-07-14 17:46:24.013859464 -0600
@@ -1297,6 +1297,7 @@ int media_changed(struct cdrom_device_in
return ret;
/* changed since last call? */
if (cdi->ops->media_changed(cdi, CDSL_CURRENT)) {
+printk("PEL: could refresh set_disk_ro\n");
cdi->mc_flags = 0x3; /* set bit on both queues */
ret |= 1;
}
^ permalink raw reply [flat|nested] 3+ messages in thread