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/mpt2sas/mpt2sas_ctl.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/mpt2sas/mpt2sas_ctl.c')
-rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_ctl.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c b/drivers/scsi/mpt2sas/mpt2sas_ctl.c index b774973f076..31cf126ed44 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c +++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c | |||
@@ -51,7 +51,7 @@ | |||
51 | #include <linux/types.h> | 51 | #include <linux/types.h> |
52 | #include <linux/pci.h> | 52 | #include <linux/pci.h> |
53 | #include <linux/delay.h> | 53 | #include <linux/delay.h> |
54 | #include <linux/smp_lock.h> | 54 | #include <linux/mutex.h> |
55 | #include <linux/compat.h> | 55 | #include <linux/compat.h> |
56 | #include <linux/poll.h> | 56 | #include <linux/poll.h> |
57 | 57 | ||
@@ -61,6 +61,7 @@ | |||
61 | #include "mpt2sas_base.h" | 61 | #include "mpt2sas_base.h" |
62 | #include "mpt2sas_ctl.h" | 62 | #include "mpt2sas_ctl.h" |
63 | 63 | ||
64 | static DEFINE_MUTEX(_ctl_mutex); | ||
64 | static struct fasync_struct *async_queue; | 65 | static struct fasync_struct *async_queue; |
65 | static DECLARE_WAIT_QUEUE_HEAD(ctl_poll_wait); | 66 | static DECLARE_WAIT_QUEUE_HEAD(ctl_poll_wait); |
66 | 67 | ||
@@ -2238,9 +2239,9 @@ _ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
2238 | { | 2239 | { |
2239 | long ret; | 2240 | long ret; |
2240 | 2241 | ||
2241 | lock_kernel(); | 2242 | mutex_lock(&_ctl_mutex); |
2242 | ret = _ctl_ioctl_main(file, cmd, (void __user *)arg); | 2243 | ret = _ctl_ioctl_main(file, cmd, (void __user *)arg); |
2243 | unlock_kernel(); | 2244 | mutex_unlock(&_ctl_mutex); |
2244 | return ret; | 2245 | return ret; |
2245 | } | 2246 | } |
2246 | 2247 | ||
@@ -2309,12 +2310,12 @@ _ctl_ioctl_compat(struct file *file, unsigned cmd, unsigned long arg) | |||
2309 | { | 2310 | { |
2310 | long ret; | 2311 | long ret; |
2311 | 2312 | ||
2312 | lock_kernel(); | 2313 | mutex_lock(&_ctl_mutex); |
2313 | if (cmd == MPT2COMMAND32) | 2314 | if (cmd == MPT2COMMAND32) |
2314 | ret = _ctl_compat_mpt_command(file, cmd, arg); | 2315 | ret = _ctl_compat_mpt_command(file, cmd, arg); |
2315 | else | 2316 | else |
2316 | ret = _ctl_ioctl_main(file, cmd, (void __user *)arg); | 2317 | ret = _ctl_ioctl_main(file, cmd, (void __user *)arg); |
2317 | unlock_kernel(); | 2318 | mutex_unlock(&_ctl_mutex); |
2318 | return ret; | 2319 | return ret; |
2319 | } | 2320 | } |
2320 | #endif | 2321 | #endif |