diff options
author | Arnd Bergmann <arnd@arndb.de> | 2010-06-02 08:28:52 -0400 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2010-09-15 15:00:45 -0400 |
commit | c45d15d24eb2b49bf734e1e5e7e103befb76b19b (patch) | |
tree | dd768c089fd3393e8fa2c4f4fb50cedb1044037d /drivers/scsi/megaraid.c | |
parent | 49553c2ef88749dd502687f4eb9c258bb10a4f44 (diff) |
scsi: autoconvert trivial BKL users to private mutex
All these files use the big kernel lock in a trivial
way to serialize their private file operations,
typically resulting from an earlier semi-automatic
pushdown from VFS.
None of these drivers appears to want to lock against
other code, and they all use the BKL as the top-level
lock in their file operations, meaning that there
is no lock-order inversion problem.
Consequently, we can remove the BKL completely,
replacing it with a per-file mutex in every case.
Using a scripted approach means we can avoid
typos.
file=$1
name=$2
if grep -q lock_kernel ${file} ; then
if grep -q 'include.*linux.mutex.h' ${file} ; then
sed -i '/include.*<linux\/smp_lock.h>/d' ${file}
else
sed -i 's/include.*<linux\/smp_lock.h>.*$/include <linux\/mutex.h>/g' ${file}
fi
sed -i ${file} \
-e "/^#include.*linux.mutex.h/,$ {
1,/^\(static\|int\|long\)/ {
/^\(static\|int\|long\)/istatic DEFINE_MUTEX(${name}_mutex);
} }" \
-e "s/\(un\)*lock_kernel\>[ ]*()/mutex_\1lock(\&${name}_mutex)/g" \
-e '/[ ]*cycle_kernel_lock();/d'
else
sed -i -e '/include.*\<smp_lock.h\>/d' ${file} \
-e '/cycle_kernel_lock()/d'
fi
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: linux-scsi@vger.kernel.org
Cc: "James E.J. Bottomley" <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/megaraid.c')
-rw-r--r-- | drivers/scsi/megaraid.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 0b6e3228610a..4d0cf5cd82cc 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/pci.h> | 46 | #include <linux/pci.h> |
47 | #include <linux/init.h> | 47 | #include <linux/init.h> |
48 | #include <linux/dma-mapping.h> | 48 | #include <linux/dma-mapping.h> |
49 | #include <linux/smp_lock.h> | 49 | #include <linux/mutex.h> |
50 | #include <linux/slab.h> | 50 | #include <linux/slab.h> |
51 | #include <scsi/scsicam.h> | 51 | #include <scsi/scsicam.h> |
52 | 52 | ||
@@ -62,6 +62,7 @@ MODULE_DESCRIPTION ("LSI Logic MegaRAID legacy driver"); | |||
62 | MODULE_LICENSE ("GPL"); | 62 | MODULE_LICENSE ("GPL"); |
63 | MODULE_VERSION(MEGARAID_MODULE_VERSION); | 63 | MODULE_VERSION(MEGARAID_MODULE_VERSION); |
64 | 64 | ||
65 | static DEFINE_MUTEX(megadev_mutex); | ||
65 | static unsigned int max_cmd_per_lun = DEF_CMD_PER_LUN; | 66 | static unsigned int max_cmd_per_lun = DEF_CMD_PER_LUN; |
66 | module_param(max_cmd_per_lun, uint, 0); | 67 | module_param(max_cmd_per_lun, uint, 0); |
67 | MODULE_PARM_DESC(max_cmd_per_lun, "Maximum number of commands which can be issued to a single LUN (default=DEF_CMD_PER_LUN=63)"); | 68 | MODULE_PARM_DESC(max_cmd_per_lun, "Maximum number of commands which can be issued to a single LUN (default=DEF_CMD_PER_LUN=63)"); |
@@ -3282,7 +3283,6 @@ mega_init_scb(adapter_t *adapter) | |||
3282 | static int | 3283 | static int |
3283 | megadev_open (struct inode *inode, struct file *filep) | 3284 | megadev_open (struct inode *inode, struct file *filep) |
3284 | { | 3285 | { |
3285 | cycle_kernel_lock(); | ||
3286 | /* | 3286 | /* |
3287 | * Only allow superuser to access private ioctl interface | 3287 | * Only allow superuser to access private ioctl interface |
3288 | */ | 3288 | */ |
@@ -3701,9 +3701,9 @@ megadev_unlocked_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) | |||
3701 | { | 3701 | { |
3702 | int ret; | 3702 | int ret; |
3703 | 3703 | ||
3704 | lock_kernel(); | 3704 | mutex_lock(&megadev_mutex); |
3705 | ret = megadev_ioctl(filep, cmd, arg); | 3705 | ret = megadev_ioctl(filep, cmd, arg); |
3706 | unlock_kernel(); | 3706 | mutex_unlock(&megadev_mutex); |
3707 | 3707 | ||
3708 | return ret; | 3708 | return ret; |
3709 | } | 3709 | } |