[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH linux-2.6.18-xen] blktap: make max # of tap devices a module parameter



On Tue, 2011-02-22 at 12:34 -0500, Laszlo Ersek wrote:
> On 02/22/11 16:49, Jan Beulich wrote:
> >>>> On 22.02.11 at 15:20, Laszlo Ersek<lersek@xxxxxxxxxx>  wrote:
> >> Hi,
> >>
> >> should anybody still use the blktap(1) driver in linux-2.6.18-xen, the
> >> following patch intends to make the maximum number of tapdevs
> >> configurable at module insertion time. The number is clamped to [256 ..
> >> NR_EVENT_CHANNELS]. I removed the definition of MAX_DEV_NAME because it
> >> didn't seem to be used at all.
> >>
> >> Thanks for considering,
> >> Laszlo Ersek
> >
> > Without replacing the call to register_chrdev() with one to
> > __register_chrdev() (available only with 2.6.32 and newer) I
> > can't see how you would get beyond 256 devices with the
> > changes you propose.
> 
> Oops, sorry; I naively assumed that minor device numbers were already 
> covered by an earlier change.
> 
> I figure register_chrdev() could be reimplemented in blktap, based on 
> lower-level char_dev.c (and kobject) primitives, but I'm not sure if the 
> original goal is worth that ugliness. In any case, should I bother 
> posting a version like that eventually, or would it have no chance of 
> being accepted?

I'm pretty sure minors > 256 date way before 2.6.32. Here's the module
init fragment from blktap2, replacing the register_chrdev() call:

int __init
blktap_ring_init(void)
{
        dev_t dev = 0;
        int err;

        cdev_init(&blktap_ring_cdev, &blktap_ring_file_operations);
        blktap_ring_cdev.owner = THIS_MODULE;

        err = alloc_chrdev_region(&dev, 0, MAX_BLKTAP_DEVICE, "blktap2");
        if (err < 0) {
                BTERR("error registering ring devices: %d\n", err);
                return err;
        }

        err = cdev_add(&blktap_ring_cdev, dev, MAX_BLKTAP_DEVICE);
        if (err) {
                BTERR("error adding ring device: %d\n", err);
                unregister_chrdev_region(dev, MAX_BLKTAP_DEVICE);
                return err;
        }

        blktap_ring_major = MAJOR(dev);
        BTINFO("blktap ring major: %d\n", blktap_ring_major);

        return 0;
}

void
blktap_ring_exit(void)
{
        if (!blktap_ring_major)
                return;

        cdev_del(&blktap_ring_cdev);
        unregister_chrdev_region(MKDEV(blktap_ring_major, 0),
                                 MAX_BLKTAP_DEVICE);

        blktap_ring_major = 0;
}

Happy hacking.

Daniel


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.