> > I am tempted to think that sd_attach() might be a better place to
hook
> > in. The idea is that at the start we look to see if the device is of a
type
> > that the disk driver wants to handle, and then it snarfs an entry in
> > rscsi_disks[]. Use that as something to key off of - when allocate the
> > disk_struct when we reserve an entry in rscsi_disks[], and free it when
we
> > release it.
>
> Right, but how soon after attach can we start accessing it? IOW, how bad
> will be the attempt to read from it at the end of sd_attach()?
Ewww. You would have to ask that.
There are a couple of problems that I can think of. First of all, there
won't be any commandblocks attached to the device yet, so it wouldn't be
possible to queue any commands. Secondly, we won't have set the capacity or
the sectorsize for the device, and there are a few other flags which get set
at the same time sd_finish is called. Finally, sd_finish will spin up a
disk if it isn't spinning, and I think we can all agree that it would be
tough to read a partition table from the disk that isn't spinning :-).
The missing commandblocks is something that is fixable - I have a
potential outstanding bug in this area anyways, and I believe that the best
fix is to move away from using pre-allocated command blocks for things like
ioctls and so forth. For block device disk I/O we would need at least some
pre-allocated command blocks - we need to be able to guarantee that we can
queue a request without forcing the swapper to try and write out a page in
order to free up some memory. I haven't coded up a change to fix this yet,
as I don't believe that anybody has seen this one in the field.
The main reason we need the device size and sectorsize is that the disk
driver does a little bit of sanity checking. A partition table is
traditionally at the start of a disk, so for the purposes of reading the
partition table we could initialize the capacity to some small value in
sd_attach. Similarily the sectorsize is something that is used mainly to
ensure that we request at least one sector when we read the partition table
(i.e. if you had a 1K blocksize, it wouldn't do to request 512 bytes).
So the question is what should you do? After a little thought, I am
going to have to back away from suggesting using sd_attach. Using sd_finish
is probably better. If you look closely, you will see that rscsi_disks[]
has a field "has_part_table" which is zeroed in sd_attach. In sd_finish,
this field can trivially be used to see which devices need to be probed (in
fact the existing logic already uses this to some extent). Obviously at
boot time all devices need to be probed, but the module load case
demonstrates how this flag is used.
-Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]