The block layer is one of the remaining usersof the Big Kernel Lock. In there, it is usedmainly for serializing the blkdev_get andblkdev_put functions and some ioctl implementationsas well as some less common open functions ofrelated character devices following a previouspushdown and parts of the blktrace code.

The only one that seems to be a bit nasty is theblkdev_get function which is actually recursiveand may try to get the BKL twice.

The ctl_mutex (pktcdvd.ko), raw_mutex (raw.ko),state_mutex (dasd.ko), reconfig_mutex (md.ko),and jfs_log_mutex (jfs.ko) may be held whenblkdev_get is called, but as far as I can tell,these mutexes are never acquired from any of thefunctions that get converted in this patch.

In order to get rid of the BKL, this introducesa new global mutex called blkdev_mutex, whichreplaces the BKL in all drivers that directlyinteract with the block layer. In case of blkdev_get,the mutex is moved outside of the function itselfin order to avoid the recursive taking of blkdev_mutex.

Testing so far has shown no problems whatsoeverfrom this patch, but the usage in blkdev_getmay introduce extra latencies, and I may havemissed corner cases where an block device ioctlfunction sleeps for a significant amount of time,which may be harmful to the performance of otherthreads.