aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/xen-blkfront.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-06-02 08:28:52 -0400
committerArnd Bergmann <arnd@arndb.de>2010-10-05 09:01:10 -0400
commit2a48fc0ab24241755dc93bfd4f01d68efab47f5a (patch)
treefa9ae10ce89b26b7d8ae9ce24bdfda5e3007b763 /drivers/block/xen-blkfront.c
parent613655fa39ff6957754fa8ceb8559980920eb8ee (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/xen-blkfront.c')
-rw-r--r--drivers/block/xen-blkfront.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index ab735a605cf3..3ff06f475eef 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -41,7 +41,7 @@
41#include <linux/cdrom.h> 41#include <linux/cdrom.h>
42#include <linux/module.h> 42#include <linux/module.h>
43#include <linux/slab.h> 43#include <linux/slab.h>
44#include <linux/smp_lock.h> 44#include <linux/mutex.h>
45#include <linux/scatterlist.h> 45#include <linux/scatterlist.h>
46 46
47#include <xen/xen.h> 47#include <xen/xen.h>
@@ -69,6 +69,7 @@ struct blk_shadow {
69 unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 69 unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST];
70}; 70};
71 71
72static DEFINE_MUTEX(blkfront_mutex);
72static const struct block_device_operations xlvbd_block_fops; 73static const struct block_device_operations xlvbd_block_fops;
73 74
74#define BLK_RING_SIZE __RING_SIZE((struct blkif_sring *)0, PAGE_SIZE) 75#define BLK_RING_SIZE __RING_SIZE((struct blkif_sring *)0, PAGE_SIZE)
@@ -1201,7 +1202,7 @@ static int blkif_open(struct block_device *bdev, fmode_t mode)
1201 struct blkfront_info *info; 1202 struct blkfront_info *info;
1202 int err = 0; 1203 int err = 0;
1203 1204
1204 lock_kernel(); 1205 mutex_lock(&blkfront_mutex);
1205 1206
1206 info = disk->private_data; 1207 info = disk->private_data;
1207 if (!info) { 1208 if (!info) {
@@ -1219,7 +1220,7 @@ static int blkif_open(struct block_device *bdev, fmode_t mode)
1219 mutex_unlock(&info->mutex); 1220 mutex_unlock(&info->mutex);
1220 1221
1221out: 1222out:
1222 unlock_kernel(); 1223 mutex_unlock(&blkfront_mutex);
1223 return err; 1224 return err;
1224} 1225}
1225 1226
@@ -1229,7 +1230,7 @@ static int blkif_release(struct gendisk *disk, fmode_t mode)
1229 struct block_device *bdev; 1230 struct block_device *bdev;
1230 struct xenbus_device *xbdev; 1231 struct xenbus_device *xbdev;
1231 1232
1232 lock_kernel(); 1233 mutex_lock(&blkfront_mutex);
1233 1234
1234 bdev = bdget_disk(disk, 0); 1235 bdev = bdget_disk(disk, 0);
1235 bdput(bdev); 1236 bdput(bdev);
@@ -1263,7 +1264,7 @@ static int blkif_release(struct gendisk *disk, fmode_t mode)
1263 } 1264 }
1264 1265
1265out: 1266out:
1266 unlock_kernel(); 1267 mutex_unlock(&blkfront_mutex);
1267 return 0; 1268 return 0;
1268} 1269}
1269 1270