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/message/fusion | |
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/message/fusion')
-rw-r--r-- | drivers/message/fusion/mptctl.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c index d8ddfdf8be14..a3856ed90aef 100644 --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c | |||
@@ -54,7 +54,7 @@ | |||
54 | #include <linux/pci.h> | 54 | #include <linux/pci.h> |
55 | #include <linux/delay.h> /* for mdelay */ | 55 | #include <linux/delay.h> /* for mdelay */ |
56 | #include <linux/miscdevice.h> | 56 | #include <linux/miscdevice.h> |
57 | #include <linux/smp_lock.h> | 57 | #include <linux/mutex.h> |
58 | #include <linux/compat.h> | 58 | #include <linux/compat.h> |
59 | 59 | ||
60 | #include <asm/io.h> | 60 | #include <asm/io.h> |
@@ -83,6 +83,7 @@ MODULE_VERSION(my_VERSION); | |||
83 | 83 | ||
84 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 84 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
85 | 85 | ||
86 | static DEFINE_MUTEX(mpctl_mutex); | ||
86 | static u8 mptctl_id = MPT_MAX_PROTOCOL_DRIVERS; | 87 | static u8 mptctl_id = MPT_MAX_PROTOCOL_DRIVERS; |
87 | static u8 mptctl_taskmgmt_id = MPT_MAX_PROTOCOL_DRIVERS; | 88 | static u8 mptctl_taskmgmt_id = MPT_MAX_PROTOCOL_DRIVERS; |
88 | 89 | ||
@@ -601,12 +602,12 @@ mptctl_fasync(int fd, struct file *filep, int mode) | |||
601 | MPT_ADAPTER *ioc; | 602 | MPT_ADAPTER *ioc; |
602 | int ret; | 603 | int ret; |
603 | 604 | ||
604 | lock_kernel(); | 605 | mutex_lock(&mpctl_mutex); |
605 | list_for_each_entry(ioc, &ioc_list, list) | 606 | list_for_each_entry(ioc, &ioc_list, list) |
606 | ioc->aen_event_read_flag=0; | 607 | ioc->aen_event_read_flag=0; |
607 | 608 | ||
608 | ret = fasync_helper(fd, filep, mode, &async_queue); | 609 | ret = fasync_helper(fd, filep, mode, &async_queue); |
609 | unlock_kernel(); | 610 | mutex_unlock(&mpctl_mutex); |
610 | return ret; | 611 | return ret; |
611 | } | 612 | } |
612 | 613 | ||
@@ -698,9 +699,9 @@ static long | |||
698 | mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 699 | mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
699 | { | 700 | { |
700 | long ret; | 701 | long ret; |
701 | lock_kernel(); | 702 | mutex_lock(&mpctl_mutex); |
702 | ret = __mptctl_ioctl(file, cmd, arg); | 703 | ret = __mptctl_ioctl(file, cmd, arg); |
703 | unlock_kernel(); | 704 | mutex_unlock(&mpctl_mutex); |
704 | return ret; | 705 | return ret; |
705 | } | 706 | } |
706 | 707 | ||
@@ -2926,7 +2927,7 @@ compat_mpt_command(struct file *filp, unsigned int cmd, | |||
2926 | static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long arg) | 2927 | static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long arg) |
2927 | { | 2928 | { |
2928 | long ret; | 2929 | long ret; |
2929 | lock_kernel(); | 2930 | mutex_lock(&mpctl_mutex); |
2930 | switch (cmd) { | 2931 | switch (cmd) { |
2931 | case MPTIOCINFO: | 2932 | case MPTIOCINFO: |
2932 | case MPTIOCINFO1: | 2933 | case MPTIOCINFO1: |
@@ -2951,7 +2952,7 @@ static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long a | |||
2951 | ret = -ENOIOCTLCMD; | 2952 | ret = -ENOIOCTLCMD; |
2952 | break; | 2953 | break; |
2953 | } | 2954 | } |
2954 | unlock_kernel(); | 2955 | mutex_unlock(&mpctl_mutex); |
2955 | return ret; | 2956 | return ret; |
2956 | } | 2957 | } |
2957 | 2958 | ||