diff options
author | Arnd Bergmann <arnd@arndb.de> | 2010-06-02 08:28:52 -0400 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2010-10-05 09:01:10 -0400 |
commit | 2a48fc0ab24241755dc93bfd4f01d68efab47f5a (patch) | |
tree | fa9ae10ce89b26b7d8ae9ce24bdfda5e3007b763 /drivers/block/drbd/drbd_main.c | |
parent | 613655fa39ff6957754fa8ceb8559980920eb8ee (diff) |
block: autoconvert trivial BKL users to private mutex
The block device drivers have all gained new lock_kernel
calls from a recent pushdown, and some of the drivers
were already using the BKL before.
This turns the BKL into a set of per-driver mutexes.
Still need to check whether this is safe to do.
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>
Diffstat (limited to 'drivers/block/drbd/drbd_main.c')
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index fa650dd85b90..e4b56119866e 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <asm/types.h> | 32 | #include <asm/types.h> |
33 | #include <net/sock.h> | 33 | #include <net/sock.h> |
34 | #include <linux/ctype.h> | 34 | #include <linux/ctype.h> |
35 | #include <linux/smp_lock.h> | 35 | #include <linux/mutex.h> |
36 | #include <linux/fs.h> | 36 | #include <linux/fs.h> |
37 | #include <linux/file.h> | 37 | #include <linux/file.h> |
38 | #include <linux/proc_fs.h> | 38 | #include <linux/proc_fs.h> |
@@ -64,6 +64,7 @@ struct after_state_chg_work { | |||
64 | struct completion *done; | 64 | struct completion *done; |
65 | }; | 65 | }; |
66 | 66 | ||
67 | static DEFINE_MUTEX(drbd_main_mutex); | ||
67 | int drbdd_init(struct drbd_thread *); | 68 | int drbdd_init(struct drbd_thread *); |
68 | int drbd_worker(struct drbd_thread *); | 69 | int drbd_worker(struct drbd_thread *); |
69 | int drbd_asender(struct drbd_thread *); | 70 | int drbd_asender(struct drbd_thread *); |
@@ -2536,7 +2537,7 @@ static int drbd_open(struct block_device *bdev, fmode_t mode) | |||
2536 | unsigned long flags; | 2537 | unsigned long flags; |
2537 | int rv = 0; | 2538 | int rv = 0; |
2538 | 2539 | ||
2539 | lock_kernel(); | 2540 | mutex_lock(&drbd_main_mutex); |
2540 | spin_lock_irqsave(&mdev->req_lock, flags); | 2541 | spin_lock_irqsave(&mdev->req_lock, flags); |
2541 | /* to have a stable mdev->state.role | 2542 | /* to have a stable mdev->state.role |
2542 | * and no race with updating open_cnt */ | 2543 | * and no race with updating open_cnt */ |
@@ -2551,7 +2552,7 @@ static int drbd_open(struct block_device *bdev, fmode_t mode) | |||
2551 | if (!rv) | 2552 | if (!rv) |
2552 | mdev->open_cnt++; | 2553 | mdev->open_cnt++; |
2553 | spin_unlock_irqrestore(&mdev->req_lock, flags); | 2554 | spin_unlock_irqrestore(&mdev->req_lock, flags); |
2554 | unlock_kernel(); | 2555 | mutex_unlock(&drbd_main_mutex); |
2555 | 2556 | ||
2556 | return rv; | 2557 | return rv; |
2557 | } | 2558 | } |
@@ -2559,9 +2560,9 @@ static int drbd_open(struct block_device *bdev, fmode_t mode) | |||
2559 | static int drbd_release(struct gendisk *gd, fmode_t mode) | 2560 | static int drbd_release(struct gendisk *gd, fmode_t mode) |
2560 | { | 2561 | { |
2561 | struct drbd_conf *mdev = gd->private_data; | 2562 | struct drbd_conf *mdev = gd->private_data; |
2562 | lock_kernel(); | 2563 | mutex_lock(&drbd_main_mutex); |
2563 | mdev->open_cnt--; | 2564 | mdev->open_cnt--; |
2564 | unlock_kernel(); | 2565 | mutex_unlock(&drbd_main_mutex); |
2565 | return 0; | 2566 | return 0; |
2566 | } | 2567 | } |
2567 | 2568 | ||