Re: [RFC] Push BKL into chrdev opens

Dave Hansen (haveblue@us.ibm.com)
Thu, 01 Aug 2002 11:02:43 -0700


Dave Hansen wrote:
> This patch adds the BKL to each character device's open() function. The
> BKL will remain in chrdev_open() until the module unload races are
> fixed, but this makes it unnecessary there for any other reason.

Greg KH noticed that I'd touched USB, and wondered about the places
where get/put_fops were used to make sure the driver gets called
directly the next time, instead of going through the subsystem. I
don't believe that the BKL is needed in the devices in this case, only
in the subsystem itself.

During inode init (init_special_inode) f_op is set to def_chr_fops,
which contains chrdev_open
First open of char device file:
if (f->f_op && f->f_op->open) {
error = f->f_op->open(inode,f);
}
The ->open() call goes to chrdev_open
USB is determined to handle the device
BKL is grabbed in chrdev_open
generic USB ->open() called (usb_open())
driver ->open() is called
f_op is replaced with the driver's f_op struct.
BKL is released

Subsequent calls:
if (f->f_op && f->f_op->open) {
error = f->f_op->open(inode,f);
}
->open() goes directly to driver. No BKL grabbed after first call.
The drivers were only protected during the first call, not during
subsequent ones. The addition of the BKL to usb_open() alone
duplicates this behavior. Adding BKL to individual devices in cases
like this is not required.

The tree is available for pulling from:
http://linux-bkl.bkbits.net/linux-2.5-bkl

-- 
Dave Hansen
haveblue@us.ibm.com

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/