many many loop devices & devfs

Peter J. Braam (
Sun, 6 Dec 1998 22:05:10 -0500 (EST)


To summarize my question differently: how do I arrange that MAJOR(dev)
always gives me PETER_LOOP_MJR and not different values when using more
than 256 devices?

Setting the f_ops is not enough. Block devices are mostly used through
the ll_rw_block function (from the readpage functions). This is in
(drivers/block/ll_rw_blk.c). Looking at that routine, one sees that:

The key function to be called is dev->request_fn -- where the latter
already depends on MAJOR.

These request functions are attached to devices in the following way.
Every driver says:

blk_dev[MAJOR_NR].request_fn = .......

Now let's follow the path down. Typically a read request starts with
generic_readpage (fs/buffer.c). This calls brw_page with dev the
inode->i_dev, which is the i_rdev field of the special file describing the
block device on which the inode resides.

This function sets up an array of buffers, in which the dev field is
copied in. This array is then passed to ll_rw_block.

So perhaps merely fixing ll_rw_block to interpret certain device numbers
very differently from others when it comes to MAJOR is enough?

Interestingly, the MINOR macro suffers a similar fate with the rdev values
you assign with devfs_register this however appears to be a matter private
to the device drivers to sort out - so in my case I started reorganizing
the loop driver.

Merely calling devfs_register and then using them leads to totally wrong
results. The drivers are still calling MINORS and MAJORS that are no good
with the many devices numbering.

Is my question clearer now?

- Peter -

ps: The pcmcia package is in need of a devfs update too. I didn't get a
serial port anymore (perhaps merely a configuration error.)

On Mon, 7 Dec 1998, Richard Gooch wrote:

> Hi, Peter.
> > I'm trying to modify the loop block driver to support 1000's of devices.
> > Mostly it looks like I'm successful but there is one point which you could
> > maybe clarify.
> >
> > I'm using your automatic assignment of device numbers when registering the
> > devices.
> Good.
> > How do I register a request function for the loop block device?
> > There are now many majors, so I don't know how the device layer will
> > reach me? This surely has a simple explanation.
> I don't really understand your question. Which request function are
> you talking about?
> You just need to pass a file_operations structure when registering a
> device node. When userspace attempts to open a device file, the open()
> member of the appropriate file_operations structure is called by
> devfs.
> Regards,
> Richard....

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at