Re: [RFC] Push BKL into chrdev opens

From: Dave Hansen (
Date: Thu Aug 01 2002 - 13:02:43 EST

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:

Dave Hansen

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

This archive was generated by hypermail 2b29 : Wed Aug 07 2002 - 22:00:16 EST