Richard Gooch wrote:
Because I believe that most (maybe even all) of the problems are
solvable with a few minor tweaks. So I'd prefer to start with a few
tweaks and see if that fixes it.
I like this approach. The patch also explains why I was going crazy
trying to squeeze the solution into ide-floppy. I didn't initially
realise the problem was more generic than just my driver. Richard, you
may be pleased to know that *everyone* who emailed me assumed it was my
fault in the driver, and that devfs was perfect :-)
The solution, as I see it, is to force grok_partitions() to call
devfs_register_disc() when size==0 and the GENHD_FL_REMOVABLE flag is
set. This will cause the "disc" entry in the
/dev/ide/host*/bus*/lun*/target* directory to be created, and it will
tag that directory for media revalidation.
If you read that directory, or attempt a lookup of some leaf node, the
media will be revalidated. If there's new media in the drive, the
normal partition handling code should be invoked, and thus the
appropriate leaf nodes will be created. Take the media out, and the
next readdir or lookup will remove partition entries (assuming the
ide-floppy driver doesn't set the size back to 0). Magic. Just the way
god^H^H^HI intended.
Nope, grok_partitions does not cause existing entries to be removed,
unless the "size" is left at its original value, in which case your
system log will be filled with "unable to read partition table"
errors and errors from the ide layer trying to read non-existent
media.
So, let me get this right (I haven't looked closely at ide-floppy, so
bear with me): when there is no media present, the driver sets the
size to zero at revalidate time, even if previously the size was
non-zero?
At the moment no. But it could :-)
So please try the appended patch again. It doesn't claim to solve the
unregistering problem, but that's OK. I want to take this a step at a
time. A bit more tweaking should (I hope) take care of the remaining
problems.
Working patch below... slightly tweaked
- without media in the drive at driver load time (either kernel
startup or module load), no entries are created, no access is
possible to the drive
My patch should fix that.
The patch does fix this, by creating the disc entries regardless.
Now, the problem we still have is how to automatically revalidate when a
user tries to mount the a partition. This is the most common usage case
for zip drives, and is not working on my system with the patch below.
i.e. attempting to do this
mount /dev/ide/host0/bus1/target1/lun0/part4 /mnt/zip
with no disc inserted will fail, even with the
/dev/ide/host0/bus1/target1/lun0/disc entry present
however, having a re-validation caused, which in ide-floppy does a
grok_partitions again should create the part4 entry so that the mount
succeeds
The following items should be future work that we will fix during 2.5.
Kevin your expertise will be greatly appreciated.
- when media is ejected, invalid partition entries remain in the
directory
Future work.
- when media is repartitioned, invalid partition entries remain in
the directory
Future work, same solution as above.
- when media is reformatted, invalid partition entries remain in the
directory
Future work, same solution as above.
- when ide-floppy (or ide-hd) modules are unloaded, the
disc/partition entries (and the directory) are not removed
Future work.
Regards,
Richard....
Permanent: rgooch@xxxxxxxxxxxxx
Current: rgooch@xxxxxxxxxxxxxxx
--
Paul
Email:
paul@xxxxxxxxxxxxxxx
Web:
http://paulbristow.net
ICQ:
11965223
--- ../../../linux-2.4.16-clean/fs/partitions/check.c Fri Oct 12
02:25:10 2001
+++ check.c Thu Dec 6 21:59:14 2001
@@ -377,12 +379,19 @@
int i;
int first_minor = drive << dev->minor_shift;
int end_minor = first_minor + dev->max_p;
+ int devnum = first_minor >> dev->minor_shift;
if(!dev->sizes)
blk_size[dev->major] = NULL;
dev->part[first_minor].nr_sects = size;
/* No such device or no minors to use for partitions */
+ if ( !size && dev->flags && (dev->flags[devnum] &
GENHD_FL_REMOVABLE) )
+ devfs_register_disc (dev, first_minor);
if (!size || minors == 1)
return;
|