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>

+277 -250
-3
block/bsg.c
··· 20 #include <linux/uio.h> 21 #include <linux/idr.h> 22 #include <linux/bsg.h> 23 - #include <linux/smp_lock.h> 24 #include <linux/slab.h> 25 26 #include <scsi/scsi.h> ··· 842 { 843 struct bsg_device *bd; 844 845 - lock_kernel(); 846 bd = bsg_get_device(inode, file); 847 - unlock_kernel(); 848 849 if (IS_ERR(bd)) 850 return PTR_ERR(bd);
··· 20 #include <linux/uio.h> 21 #include <linux/idr.h> 22 #include <linux/bsg.h> 23 #include <linux/slab.h> 24 25 #include <scsi/scsi.h> ··· 843 { 844 struct bsg_device *bd; 845 846 bd = bsg_get_device(inode, file); 847 848 if (IS_ERR(bd)) 849 return PTR_ERR(bd);
+6 -5
drivers/block/DAC960.c
··· 36 #include <linux/ioport.h> 37 #include <linux/mm.h> 38 #include <linux/slab.h> 39 - #include <linux/smp_lock.h> 40 #include <linux/proc_fs.h> 41 #include <linux/seq_file.h> 42 #include <linux/reboot.h> ··· 54 #define DAC960_GAM_MINOR 252 55 56 57 static DAC960_Controller_T *DAC960_Controllers[DAC960_MaxControllers]; 58 static int DAC960_ControllerCount; 59 static struct proc_dir_entry *DAC960_ProcDirectoryEntry; ··· 82 int drive_nr = (long)disk->private_data; 83 int ret = -ENXIO; 84 85 - lock_kernel(); 86 if (p->FirmwareType == DAC960_V1_Controller) { 87 if (p->V1.LogicalDriveInformation[drive_nr]. 88 LogicalDriveState == DAC960_V1_LogicalDrive_Offline) ··· 100 goto out; 101 ret = 0; 102 out: 103 - unlock_kernel(); 104 return ret; 105 } 106 ··· 6626 long ErrorCode = 0; 6627 if (!capable(CAP_SYS_ADMIN)) return -EACCES; 6628 6629 - lock_kernel(); 6630 switch (Request) 6631 { 6632 case DAC960_IOCTL_GET_CONTROLLER_COUNT: ··· 7057 default: 7058 ErrorCode = -ENOTTY; 7059 } 7060 - unlock_kernel(); 7061 return ErrorCode; 7062 } 7063
··· 36 #include <linux/ioport.h> 37 #include <linux/mm.h> 38 #include <linux/slab.h> 39 + #include <linux/mutex.h> 40 #include <linux/proc_fs.h> 41 #include <linux/seq_file.h> 42 #include <linux/reboot.h> ··· 54 #define DAC960_GAM_MINOR 252 55 56 57 + static DEFINE_MUTEX(DAC960_mutex); 58 static DAC960_Controller_T *DAC960_Controllers[DAC960_MaxControllers]; 59 static int DAC960_ControllerCount; 60 static struct proc_dir_entry *DAC960_ProcDirectoryEntry; ··· 81 int drive_nr = (long)disk->private_data; 82 int ret = -ENXIO; 83 84 + mutex_lock(&DAC960_mutex); 85 if (p->FirmwareType == DAC960_V1_Controller) { 86 if (p->V1.LogicalDriveInformation[drive_nr]. 87 LogicalDriveState == DAC960_V1_LogicalDrive_Offline) ··· 99 goto out; 100 ret = 0; 101 out: 102 + mutex_unlock(&DAC960_mutex); 103 return ret; 104 } 105 ··· 6625 long ErrorCode = 0; 6626 if (!capable(CAP_SYS_ADMIN)) return -EACCES; 6627 6628 + mutex_lock(&DAC960_mutex); 6629 switch (Request) 6630 { 6631 case DAC960_IOCTL_GET_CONTROLLER_COUNT: ··· 7056 default: 7057 ErrorCode = -ENOTTY; 7058 } 7059 + mutex_unlock(&DAC960_mutex); 7060 return ErrorCode; 7061 } 7062
+10 -9
drivers/block/amiflop.c
··· 60 #include <linux/hdreg.h> 61 #include <linux/delay.h> 62 #include <linux/init.h> 63 - #include <linux/smp_lock.h> 64 #include <linux/amifdreg.h> 65 #include <linux/amifd.h> 66 #include <linux/buffer_head.h> ··· 109 #define FD_HD_3 0x55555555 /* high-density 3.5" (1760K) drive */ 110 #define FD_DD_5 0xaaaaaaaa /* double-density 5.25" (440K) drive */ 111 112 static unsigned long int fd_def_df0 = FD_DD_3; /* default for df0 if it doesn't identify */ 113 114 module_param(fd_def_df0, ulong, 0); ··· 1507 { 1508 int ret; 1509 1510 - lock_kernel(); 1511 ret = fd_locked_ioctl(bdev, mode, cmd, param); 1512 - unlock_kernel(); 1513 1514 return ret; 1515 } ··· 1556 int old_dev; 1557 unsigned long flags; 1558 1559 - lock_kernel(); 1560 old_dev = fd_device[drive]; 1561 1562 if (fd_ref[drive] && old_dev != system) { 1563 - unlock_kernel(); 1564 return -EBUSY; 1565 } 1566 ··· 1576 rel_fdc(); 1577 1578 if (wrprot) { 1579 - unlock_kernel(); 1580 return -EROFS; 1581 } 1582 } ··· 1595 printk(KERN_INFO "fd%d: accessing %s-disk with %s-layout\n",drive, 1596 unit[drive].type->name, data_types[system].name); 1597 1598 - unlock_kernel(); 1599 return 0; 1600 } 1601 ··· 1604 struct amiga_floppy_struct *p = disk->private_data; 1605 int drive = p - unit; 1606 1607 - lock_kernel(); 1608 if (unit[drive].dirty == 1) { 1609 del_timer (flush_track_timer + drive); 1610 non_int_flush_track (drive); ··· 1618 /* the mod_use counter is handled this way */ 1619 floppy_off (drive | 0x40000000); 1620 #endif 1621 - unlock_kernel(); 1622 return 0; 1623 } 1624
··· 60 #include <linux/hdreg.h> 61 #include <linux/delay.h> 62 #include <linux/init.h> 63 + #include <linux/mutex.h> 64 #include <linux/amifdreg.h> 65 #include <linux/amifd.h> 66 #include <linux/buffer_head.h> ··· 109 #define FD_HD_3 0x55555555 /* high-density 3.5" (1760K) drive */ 110 #define FD_DD_5 0xaaaaaaaa /* double-density 5.25" (440K) drive */ 111 112 + static DEFINE_MUTEX(amiflop_mutex); 113 static unsigned long int fd_def_df0 = FD_DD_3; /* default for df0 if it doesn't identify */ 114 115 module_param(fd_def_df0, ulong, 0); ··· 1506 { 1507 int ret; 1508 1509 + mutex_lock(&amiflop_mutex); 1510 ret = fd_locked_ioctl(bdev, mode, cmd, param); 1511 + mutex_unlock(&amiflop_mutex); 1512 1513 return ret; 1514 } ··· 1555 int old_dev; 1556 unsigned long flags; 1557 1558 + mutex_lock(&amiflop_mutex); 1559 old_dev = fd_device[drive]; 1560 1561 if (fd_ref[drive] && old_dev != system) { 1562 + mutex_unlock(&amiflop_mutex); 1563 return -EBUSY; 1564 } 1565 ··· 1575 rel_fdc(); 1576 1577 if (wrprot) { 1578 + mutex_unlock(&amiflop_mutex); 1579 return -EROFS; 1580 } 1581 } ··· 1594 printk(KERN_INFO "fd%d: accessing %s-disk with %s-layout\n",drive, 1595 unit[drive].type->name, data_types[system].name); 1596 1597 + mutex_unlock(&amiflop_mutex); 1598 return 0; 1599 } 1600 ··· 1603 struct amiga_floppy_struct *p = disk->private_data; 1604 int drive = p - unit; 1605 1606 + mutex_lock(&amiflop_mutex); 1607 if (unit[drive].dirty == 1) { 1608 del_timer (flush_track_timer + drive); 1609 non_int_flush_track (drive); ··· 1617 /* the mod_use counter is handled this way */ 1618 floppy_off (drive | 0x40000000); 1619 #endif 1620 + mutex_unlock(&amiflop_mutex); 1621 return 0; 1622 } 1623
+5 -4
drivers/block/aoe/aoeblk.c
··· 12 #include <linux/slab.h> 13 #include <linux/genhd.h> 14 #include <linux/netdevice.h> 15 - #include <linux/smp_lock.h> 16 #include "aoe.h" 17 18 static struct kmem_cache *buf_pool_cache; 19 20 static ssize_t aoedisk_show_state(struct device *dev, ··· 126 struct aoedev *d = bdev->bd_disk->private_data; 127 ulong flags; 128 129 - lock_kernel(); 130 spin_lock_irqsave(&d->lock, flags); 131 if (d->flags & DEVFL_UP) { 132 d->nopen++; 133 spin_unlock_irqrestore(&d->lock, flags); 134 - unlock_kernel(); 135 return 0; 136 } 137 spin_unlock_irqrestore(&d->lock, flags); 138 - unlock_kernel(); 139 return -ENODEV; 140 } 141
··· 12 #include <linux/slab.h> 13 #include <linux/genhd.h> 14 #include <linux/netdevice.h> 15 + #include <linux/mutex.h> 16 #include "aoe.h" 17 18 + static DEFINE_MUTEX(aoeblk_mutex); 19 static struct kmem_cache *buf_pool_cache; 20 21 static ssize_t aoedisk_show_state(struct device *dev, ··· 125 struct aoedev *d = bdev->bd_disk->private_data; 126 ulong flags; 127 128 + mutex_lock(&aoeblk_mutex); 129 spin_lock_irqsave(&d->lock, flags); 130 if (d->flags & DEVFL_UP) { 131 d->nopen++; 132 spin_unlock_irqrestore(&d->lock, flags); 133 + mutex_unlock(&aoeblk_mutex); 134 return 0; 135 } 136 spin_unlock_irqrestore(&d->lock, flags); 137 + mutex_unlock(&aoeblk_mutex); 138 return -ENODEV; 139 } 140
+5 -4
drivers/block/aoe/aoechr.c
··· 9 #include <linux/completion.h> 10 #include <linux/delay.h> 11 #include <linux/slab.h> 12 - #include <linux/smp_lock.h> 13 #include <linux/skbuff.h> 14 #include "aoe.h" 15 ··· 37 char *msg; 38 }; 39 40 static struct ErrMsg emsgs[NMSG]; 41 static int emsgs_head_idx, emsgs_tail_idx; 42 static struct completion emsgs_comp; ··· 184 { 185 int n, i; 186 187 - lock_kernel(); 188 n = iminor(inode); 189 filp->private_data = (void *) (unsigned long) n; 190 191 for (i = 0; i < ARRAY_SIZE(chardevs); ++i) 192 if (chardevs[i].minor == n) { 193 - unlock_kernel(); 194 return 0; 195 } 196 - unlock_kernel(); 197 return -EINVAL; 198 } 199
··· 9 #include <linux/completion.h> 10 #include <linux/delay.h> 11 #include <linux/slab.h> 12 + #include <linux/mutex.h> 13 #include <linux/skbuff.h> 14 #include "aoe.h" 15 ··· 37 char *msg; 38 }; 39 40 + static DEFINE_MUTEX(aoechr_mutex); 41 static struct ErrMsg emsgs[NMSG]; 42 static int emsgs_head_idx, emsgs_tail_idx; 43 static struct completion emsgs_comp; ··· 183 { 184 int n, i; 185 186 + mutex_lock(&aoechr_mutex); 187 n = iminor(inode); 188 filp->private_data = (void *) (unsigned long) n; 189 190 for (i = 0; i < ARRAY_SIZE(chardevs); ++i) 191 if (chardevs[i].minor == n) { 192 + mutex_unlock(&aoechr_mutex); 193 return 0; 194 } 195 + mutex_unlock(&aoechr_mutex); 196 return -EINVAL; 197 } 198
+8 -7
drivers/block/ataflop.c
··· 67 #include <linux/delay.h> 68 #include <linux/init.h> 69 #include <linux/blkdev.h> 70 - #include <linux/smp_lock.h> 71 72 #include <asm/atafd.h> 73 #include <asm/atafdreg.h> ··· 79 80 #undef DEBUG 81 82 static struct request_queue *floppy_queue; 83 static struct request *fd_request; 84 ··· 1672 { 1673 int ret; 1674 1675 - lock_kernel(); 1676 ret = fd_locked_ioctl(bdev, mode, cmd, arg); 1677 - unlock_kernel(); 1678 1679 return ret; 1680 } ··· 1855 { 1856 int ret; 1857 1858 - lock_kernel(); 1859 ret = floppy_open(bdev, mode); 1860 - unlock_kernel(); 1861 1862 return ret; 1863 } ··· 1865 static int floppy_release(struct gendisk *disk, fmode_t mode) 1866 { 1867 struct atari_floppy_struct *p = disk->private_data; 1868 - lock_kernel(); 1869 if (p->ref < 0) 1870 p->ref = 0; 1871 else if (!p->ref--) { 1872 printk(KERN_ERR "floppy_release with fd_ref == 0"); 1873 p->ref = 0; 1874 } 1875 - unlock_kernel(); 1876 return 0; 1877 } 1878
··· 67 #include <linux/delay.h> 68 #include <linux/init.h> 69 #include <linux/blkdev.h> 70 + #include <linux/mutex.h> 71 72 #include <asm/atafd.h> 73 #include <asm/atafdreg.h> ··· 79 80 #undef DEBUG 81 82 + static DEFINE_MUTEX(ataflop_mutex); 83 static struct request_queue *floppy_queue; 84 static struct request *fd_request; 85 ··· 1671 { 1672 int ret; 1673 1674 + mutex_lock(&ataflop_mutex); 1675 ret = fd_locked_ioctl(bdev, mode, cmd, arg); 1676 + mutex_unlock(&ataflop_mutex); 1677 1678 return ret; 1679 } ··· 1854 { 1855 int ret; 1856 1857 + mutex_lock(&ataflop_mutex); 1858 ret = floppy_open(bdev, mode); 1859 + mutex_unlock(&ataflop_mutex); 1860 1861 return ret; 1862 } ··· 1864 static int floppy_release(struct gendisk *disk, fmode_t mode) 1865 { 1866 struct atari_floppy_struct *p = disk->private_data; 1867 + mutex_lock(&ataflop_mutex); 1868 if (p->ref < 0) 1869 p->ref = 0; 1870 else if (!p->ref--) { 1871 printk(KERN_ERR "floppy_release with fd_ref == 0"); 1872 p->ref = 0; 1873 } 1874 + mutex_unlock(&ataflop_mutex); 1875 return 0; 1876 } 1877
+4 -3
drivers/block/brd.c
··· 15 #include <linux/blkdev.h> 16 #include <linux/bio.h> 17 #include <linux/highmem.h> 18 - #include <linux/smp_lock.h> 19 #include <linux/radix-tree.h> 20 #include <linux/buffer_head.h> /* invalidate_bh_lrus() */ 21 #include <linux/slab.h> ··· 55 /* 56 * Look up and return a brd's page for a given sector. 57 */ 58 static struct page *brd_lookup_page(struct brd_device *brd, sector_t sector) 59 { 60 pgoff_t idx; ··· 403 * ram device BLKFLSBUF has special semantics, we want to actually 404 * release and destroy the ramdisk data. 405 */ 406 - lock_kernel(); 407 mutex_lock(&bdev->bd_mutex); 408 error = -EBUSY; 409 if (bdev->bd_openers <= 1) { ··· 420 error = 0; 421 } 422 mutex_unlock(&bdev->bd_mutex); 423 - unlock_kernel(); 424 425 return error; 426 }
··· 15 #include <linux/blkdev.h> 16 #include <linux/bio.h> 17 #include <linux/highmem.h> 18 + #include <linux/mutex.h> 19 #include <linux/radix-tree.h> 20 #include <linux/buffer_head.h> /* invalidate_bh_lrus() */ 21 #include <linux/slab.h> ··· 55 /* 56 * Look up and return a brd's page for a given sector. 57 */ 58 + static DEFINE_MUTEX(brd_mutex); 59 static struct page *brd_lookup_page(struct brd_device *brd, sector_t sector) 60 { 61 pgoff_t idx; ··· 402 * ram device BLKFLSBUF has special semantics, we want to actually 403 * release and destroy the ramdisk data. 404 */ 405 + mutex_lock(&brd_mutex); 406 mutex_lock(&bdev->bd_mutex); 407 error = -EBUSY; 408 if (bdev->bd_openers <= 1) { ··· 419 error = 0; 420 } 421 mutex_unlock(&bdev->bd_mutex); 422 + mutex_unlock(&brd_mutex); 423 424 return error; 425 }
+7 -7
drivers/block/cciss.c
··· 26 #include <linux/pci.h> 27 #include <linux/kernel.h> 28 #include <linux/slab.h> 29 - #include <linux/smp_lock.h> 30 #include <linux/delay.h> 31 #include <linux/major.h> 32 #include <linux/fs.h> ··· 65 MODULE_VERSION("3.6.26"); 66 MODULE_LICENSE("GPL"); 67 68 static int cciss_allow_hpsa; 69 module_param(cciss_allow_hpsa, int, S_IRUGO|S_IWUSR); 70 MODULE_PARM_DESC(cciss_allow_hpsa, ··· 1059 { 1060 int ret; 1061 1062 - lock_kernel(); 1063 ret = cciss_open(bdev, mode); 1064 - unlock_kernel(); 1065 1066 return ret; 1067 } ··· 1074 ctlr_info_t *h; 1075 drive_info_struct *drv; 1076 1077 - lock_kernel(); 1078 h = get_host(disk); 1079 drv = get_drv(disk); 1080 dev_dbg(&h->pdev->dev, "cciss_release %s\n", disk->disk_name); 1081 drv->usage_count--; 1082 h->usage_count--; 1083 - unlock_kernel(); 1084 return 0; 1085 } 1086 ··· 1088 unsigned cmd, unsigned long arg) 1089 { 1090 int ret; 1091 - lock_kernel(); 1092 ret = cciss_ioctl(bdev, mode, cmd, arg); 1093 - unlock_kernel(); 1094 return ret; 1095 } 1096
··· 26 #include <linux/pci.h> 27 #include <linux/kernel.h> 28 #include <linux/slab.h> 29 #include <linux/delay.h> 30 #include <linux/major.h> 31 #include <linux/fs.h> ··· 66 MODULE_VERSION("3.6.26"); 67 MODULE_LICENSE("GPL"); 68 69 + static DEFINE_MUTEX(cciss_mutex); 70 static int cciss_allow_hpsa; 71 module_param(cciss_allow_hpsa, int, S_IRUGO|S_IWUSR); 72 MODULE_PARM_DESC(cciss_allow_hpsa, ··· 1059 { 1060 int ret; 1061 1062 + mutex_lock(&cciss_mutex); 1063 ret = cciss_open(bdev, mode); 1064 + mutex_unlock(&cciss_mutex); 1065 1066 return ret; 1067 } ··· 1074 ctlr_info_t *h; 1075 drive_info_struct *drv; 1076 1077 + mutex_lock(&cciss_mutex); 1078 h = get_host(disk); 1079 drv = get_drv(disk); 1080 dev_dbg(&h->pdev->dev, "cciss_release %s\n", disk->disk_name); 1081 drv->usage_count--; 1082 h->usage_count--; 1083 + mutex_unlock(&cciss_mutex); 1084 return 0; 1085 } 1086 ··· 1088 unsigned cmd, unsigned long arg) 1089 { 1090 int ret; 1091 + mutex_lock(&cciss_mutex); 1092 ret = cciss_ioctl(bdev, mode, cmd, arg); 1093 + mutex_unlock(&cciss_mutex); 1094 return ret; 1095 } 1096
+8 -7
drivers/block/cpqarray.c
··· 35 #include <linux/seq_file.h> 36 #include <linux/init.h> 37 #include <linux/hdreg.h> 38 - #include <linux/smp_lock.h> 39 #include <linux/spinlock.h> 40 #include <linux/blkdev.h> 41 #include <linux/genhd.h> ··· 68 69 #define CPQARRAY_DMA_MASK 0xFFFFFFFF /* 32 bit DMA */ 70 71 static int nr_ctlr; 72 static ctlr_info_t *hba[MAX_CTLR]; 73 ··· 846 { 847 int ret; 848 849 - lock_kernel(); 850 ret = ida_open(bdev, mode); 851 - unlock_kernel(); 852 853 return ret; 854 } ··· 860 { 861 ctlr_info_t *host; 862 863 - lock_kernel(); 864 host = get_host(disk); 865 host->usage_count--; 866 - unlock_kernel(); 867 868 return 0; 869 } ··· 1218 { 1219 int ret; 1220 1221 - lock_kernel(); 1222 ret = ida_locked_ioctl(bdev, mode, cmd, param); 1223 - unlock_kernel(); 1224 1225 return ret; 1226 }
··· 35 #include <linux/seq_file.h> 36 #include <linux/init.h> 37 #include <linux/hdreg.h> 38 + #include <linux/mutex.h> 39 #include <linux/spinlock.h> 40 #include <linux/blkdev.h> 41 #include <linux/genhd.h> ··· 68 69 #define CPQARRAY_DMA_MASK 0xFFFFFFFF /* 32 bit DMA */ 70 71 + static DEFINE_MUTEX(cpqarray_mutex); 72 static int nr_ctlr; 73 static ctlr_info_t *hba[MAX_CTLR]; 74 ··· 845 { 846 int ret; 847 848 + mutex_lock(&cpqarray_mutex); 849 ret = ida_open(bdev, mode); 850 + mutex_unlock(&cpqarray_mutex); 851 852 return ret; 853 } ··· 859 { 860 ctlr_info_t *host; 861 862 + mutex_lock(&cpqarray_mutex); 863 host = get_host(disk); 864 host->usage_count--; 865 + mutex_unlock(&cpqarray_mutex); 866 867 return 0; 868 } ··· 1217 { 1218 int ret; 1219 1220 + mutex_lock(&cpqarray_mutex); 1221 ret = ida_locked_ioctl(bdev, mode, cmd, param); 1222 + mutex_unlock(&cpqarray_mutex); 1223 1224 return ret; 1225 }
+6 -5
drivers/block/drbd/drbd_main.c
··· 32 #include <asm/types.h> 33 #include <net/sock.h> 34 #include <linux/ctype.h> 35 - #include <linux/smp_lock.h> 36 #include <linux/fs.h> 37 #include <linux/file.h> 38 #include <linux/proc_fs.h> ··· 64 struct completion *done; 65 }; 66 67 int drbdd_init(struct drbd_thread *); 68 int drbd_worker(struct drbd_thread *); 69 int drbd_asender(struct drbd_thread *); ··· 2537 unsigned long flags; 2538 int rv = 0; 2539 2540 - lock_kernel(); 2541 spin_lock_irqsave(&mdev->req_lock, flags); 2542 /* to have a stable mdev->state.role 2543 * and no race with updating open_cnt */ ··· 2552 if (!rv) 2553 mdev->open_cnt++; 2554 spin_unlock_irqrestore(&mdev->req_lock, flags); 2555 - unlock_kernel(); 2556 2557 return rv; 2558 } ··· 2560 static int drbd_release(struct gendisk *gd, fmode_t mode) 2561 { 2562 struct drbd_conf *mdev = gd->private_data; 2563 - lock_kernel(); 2564 mdev->open_cnt--; 2565 - unlock_kernel(); 2566 return 0; 2567 } 2568
··· 32 #include <asm/types.h> 33 #include <net/sock.h> 34 #include <linux/ctype.h> 35 + #include <linux/mutex.h> 36 #include <linux/fs.h> 37 #include <linux/file.h> 38 #include <linux/proc_fs.h> ··· 64 struct completion *done; 65 }; 66 67 + static DEFINE_MUTEX(drbd_main_mutex); 68 int drbdd_init(struct drbd_thread *); 69 int drbd_worker(struct drbd_thread *); 70 int drbd_asender(struct drbd_thread *); ··· 2536 unsigned long flags; 2537 int rv = 0; 2538 2539 + mutex_lock(&drbd_main_mutex); 2540 spin_lock_irqsave(&mdev->req_lock, flags); 2541 /* to have a stable mdev->state.role 2542 * and no race with updating open_cnt */ ··· 2551 if (!rv) 2552 mdev->open_cnt++; 2553 spin_unlock_irqrestore(&mdev->req_lock, flags); 2554 + mutex_unlock(&drbd_main_mutex); 2555 2556 return rv; 2557 } ··· 2559 static int drbd_release(struct gendisk *gd, fmode_t mode) 2560 { 2561 struct drbd_conf *mdev = gd->private_data; 2562 + mutex_lock(&drbd_main_mutex); 2563 mdev->open_cnt--; 2564 + mutex_unlock(&drbd_main_mutex); 2565 return 0; 2566 } 2567
+8 -8
drivers/block/floppy.c
··· 178 #include <linux/slab.h> 179 #include <linux/mm.h> 180 #include <linux/bio.h> 181 - #include <linux/smp_lock.h> 182 #include <linux/string.h> 183 #include <linux/jiffies.h> 184 #include <linux/fcntl.h> ··· 198 * It's been recommended that take about 1/4 of the default speed 199 * in some more extreme cases. 200 */ 201 static int slow_floppy; 202 203 #include <asm/dma.h> ··· 3553 { 3554 int ret; 3555 3556 - lock_kernel(); 3557 ret = fd_locked_ioctl(bdev, mode, cmd, param); 3558 - unlock_kernel(); 3559 3560 return ret; 3561 } ··· 3616 { 3617 int drive = (long)disk->private_data; 3618 3619 - lock_kernel(); 3620 mutex_lock(&open_lock); 3621 if (UDRS->fd_ref < 0) 3622 UDRS->fd_ref = 0; ··· 3627 if (!UDRS->fd_ref) 3628 opened_bdev[drive] = NULL; 3629 mutex_unlock(&open_lock); 3630 - unlock_kernel(); 3631 3632 return 0; 3633 } ··· 3645 int res = -EBUSY; 3646 char *tmp; 3647 3648 - lock_kernel(); 3649 mutex_lock(&open_lock); 3650 old_dev = UDRS->fd_device; 3651 if (opened_bdev[drive] && opened_bdev[drive] != bdev) ··· 3722 goto out; 3723 } 3724 mutex_unlock(&open_lock); 3725 - unlock_kernel(); 3726 return 0; 3727 out: 3728 if (UDRS->fd_ref < 0) ··· 3733 opened_bdev[drive] = NULL; 3734 out2: 3735 mutex_unlock(&open_lock); 3736 - unlock_kernel(); 3737 return res; 3738 } 3739
··· 178 #include <linux/slab.h> 179 #include <linux/mm.h> 180 #include <linux/bio.h> 181 #include <linux/string.h> 182 #include <linux/jiffies.h> 183 #include <linux/fcntl.h> ··· 199 * It's been recommended that take about 1/4 of the default speed 200 * in some more extreme cases. 201 */ 202 + static DEFINE_MUTEX(floppy_mutex); 203 static int slow_floppy; 204 205 #include <asm/dma.h> ··· 3553 { 3554 int ret; 3555 3556 + mutex_lock(&floppy_mutex); 3557 ret = fd_locked_ioctl(bdev, mode, cmd, param); 3558 + mutex_unlock(&floppy_mutex); 3559 3560 return ret; 3561 } ··· 3616 { 3617 int drive = (long)disk->private_data; 3618 3619 + mutex_lock(&floppy_mutex); 3620 mutex_lock(&open_lock); 3621 if (UDRS->fd_ref < 0) 3622 UDRS->fd_ref = 0; ··· 3627 if (!UDRS->fd_ref) 3628 opened_bdev[drive] = NULL; 3629 mutex_unlock(&open_lock); 3630 + mutex_unlock(&floppy_mutex); 3631 3632 return 0; 3633 } ··· 3645 int res = -EBUSY; 3646 char *tmp; 3647 3648 + mutex_lock(&floppy_mutex); 3649 mutex_lock(&open_lock); 3650 old_dev = UDRS->fd_device; 3651 if (opened_bdev[drive] && opened_bdev[drive] != bdev) ··· 3722 goto out; 3723 } 3724 mutex_unlock(&open_lock); 3725 + mutex_unlock(&floppy_mutex); 3726 return 0; 3727 out: 3728 if (UDRS->fd_ref < 0) ··· 3733 opened_bdev[drive] = NULL; 3734 out2: 3735 mutex_unlock(&open_lock); 3736 + mutex_unlock(&floppy_mutex); 3737 return res; 3738 } 3739
+6 -5
drivers/block/loop.c
··· 67 #include <linux/compat.h> 68 #include <linux/suspend.h> 69 #include <linux/freezer.h> 70 - #include <linux/smp_lock.h> 71 #include <linux/writeback.h> 72 #include <linux/buffer_head.h> /* for invalidate_bdev() */ 73 #include <linux/completion.h> ··· 77 78 #include <asm/uaccess.h> 79 80 static LIST_HEAD(loop_devices); 81 static DEFINE_MUTEX(loop_devices_mutex); 82 ··· 1410 { 1411 struct loop_device *lo = bdev->bd_disk->private_data; 1412 1413 - lock_kernel(); 1414 mutex_lock(&lo->lo_ctl_mutex); 1415 lo->lo_refcnt++; 1416 mutex_unlock(&lo->lo_ctl_mutex); 1417 - unlock_kernel(); 1418 1419 return 0; 1420 } ··· 1424 struct loop_device *lo = disk->private_data; 1425 int err; 1426 1427 - lock_kernel(); 1428 mutex_lock(&lo->lo_ctl_mutex); 1429 1430 if (--lo->lo_refcnt) ··· 1449 out: 1450 mutex_unlock(&lo->lo_ctl_mutex); 1451 out_unlocked: 1452 - lock_kernel(); 1453 return 0; 1454 } 1455
··· 67 #include <linux/compat.h> 68 #include <linux/suspend.h> 69 #include <linux/freezer.h> 70 + #include <linux/mutex.h> 71 #include <linux/writeback.h> 72 #include <linux/buffer_head.h> /* for invalidate_bdev() */ 73 #include <linux/completion.h> ··· 77 78 #include <asm/uaccess.h> 79 80 + static DEFINE_MUTEX(loop_mutex); 81 static LIST_HEAD(loop_devices); 82 static DEFINE_MUTEX(loop_devices_mutex); 83 ··· 1409 { 1410 struct loop_device *lo = bdev->bd_disk->private_data; 1411 1412 + mutex_lock(&loop_mutex); 1413 mutex_lock(&lo->lo_ctl_mutex); 1414 lo->lo_refcnt++; 1415 mutex_unlock(&lo->lo_ctl_mutex); 1416 + mutex_unlock(&loop_mutex); 1417 1418 return 0; 1419 } ··· 1423 struct loop_device *lo = disk->private_data; 1424 int err; 1425 1426 + mutex_lock(&loop_mutex); 1427 mutex_lock(&lo->lo_ctl_mutex); 1428 1429 if (--lo->lo_refcnt) ··· 1448 out: 1449 mutex_unlock(&lo->lo_ctl_mutex); 1450 out_unlocked: 1451 + mutex_unlock(&loop_mutex); 1452 return 0; 1453 } 1454
+4 -3
drivers/block/nbd.c
··· 24 #include <linux/errno.h> 25 #include <linux/file.h> 26 #include <linux/ioctl.h> 27 - #include <linux/smp_lock.h> 28 #include <linux/compiler.h> 29 #include <linux/err.h> 30 #include <linux/kernel.h> ··· 53 #define DBG_BLKDEV 0x0100 54 #define DBG_RX 0x0200 55 #define DBG_TX 0x0400 56 static unsigned int debugflags; 57 #endif /* NDEBUG */ 58 ··· 718 dprintk(DBG_IOCTL, "%s: nbd_ioctl cmd=%s(0x%x) arg=%lu\n", 719 lo->disk->disk_name, ioctl_cmd_to_ascii(cmd), cmd, arg); 720 721 - lock_kernel(); 722 mutex_lock(&lo->tx_lock); 723 error = __nbd_ioctl(bdev, lo, cmd, arg); 724 mutex_unlock(&lo->tx_lock); 725 - unlock_kernel(); 726 727 return error; 728 }
··· 24 #include <linux/errno.h> 25 #include <linux/file.h> 26 #include <linux/ioctl.h> 27 + #include <linux/mutex.h> 28 #include <linux/compiler.h> 29 #include <linux/err.h> 30 #include <linux/kernel.h> ··· 53 #define DBG_BLKDEV 0x0100 54 #define DBG_RX 0x0200 55 #define DBG_TX 0x0400 56 + static DEFINE_MUTEX(nbd_mutex); 57 static unsigned int debugflags; 58 #endif /* NDEBUG */ 59 ··· 717 dprintk(DBG_IOCTL, "%s: nbd_ioctl cmd=%s(0x%x) arg=%lu\n", 718 lo->disk->disk_name, ioctl_cmd_to_ascii(cmd), cmd, arg); 719 720 + mutex_lock(&nbd_mutex); 721 mutex_lock(&lo->tx_lock); 722 error = __nbd_ioctl(bdev, lo, cmd, arg); 723 mutex_unlock(&lo->tx_lock); 724 + mutex_unlock(&nbd_mutex); 725 726 return error; 727 }
+8 -7
drivers/block/paride/pcd.c
··· 138 #include <linux/cdrom.h> 139 #include <linux/spinlock.h> 140 #include <linux/blkdev.h> 141 - #include <linux/smp_lock.h> 142 #include <asm/uaccess.h> 143 144 static DEFINE_SPINLOCK(pcd_lock); 145 146 module_param(verbose, bool, 0644); ··· 228 struct pcd_unit *cd = bdev->bd_disk->private_data; 229 int ret; 230 231 - lock_kernel(); 232 ret = cdrom_open(&cd->info, bdev, mode); 233 - unlock_kernel(); 234 235 return ret; 236 } ··· 238 static int pcd_block_release(struct gendisk *disk, fmode_t mode) 239 { 240 struct pcd_unit *cd = disk->private_data; 241 - lock_kernel(); 242 cdrom_release(&cd->info, mode); 243 - unlock_kernel(); 244 return 0; 245 } 246 ··· 250 struct pcd_unit *cd = bdev->bd_disk->private_data; 251 int ret; 252 253 - lock_kernel(); 254 ret = cdrom_ioctl(&cd->info, bdev, mode, cmd, arg); 255 - unlock_kernel(); 256 257 return ret; 258 }
··· 138 #include <linux/cdrom.h> 139 #include <linux/spinlock.h> 140 #include <linux/blkdev.h> 141 + #include <linux/mutex.h> 142 #include <asm/uaccess.h> 143 144 + static DEFINE_MUTEX(pcd_mutex); 145 static DEFINE_SPINLOCK(pcd_lock); 146 147 module_param(verbose, bool, 0644); ··· 227 struct pcd_unit *cd = bdev->bd_disk->private_data; 228 int ret; 229 230 + mutex_lock(&pcd_mutex); 231 ret = cdrom_open(&cd->info, bdev, mode); 232 + mutex_unlock(&pcd_mutex); 233 234 return ret; 235 } ··· 237 static int pcd_block_release(struct gendisk *disk, fmode_t mode) 238 { 239 struct pcd_unit *cd = disk->private_data; 240 + mutex_lock(&pcd_mutex); 241 cdrom_release(&cd->info, mode); 242 + mutex_unlock(&pcd_mutex); 243 return 0; 244 } 245 ··· 249 struct pcd_unit *cd = bdev->bd_disk->private_data; 250 int ret; 251 252 + mutex_lock(&pcd_mutex); 253 ret = cdrom_ioctl(&cd->info, bdev, mode, cmd, arg); 254 + mutex_unlock(&pcd_mutex); 255 256 return ret; 257 }
+8 -7
drivers/block/paride/pd.c
··· 153 #include <linux/blkdev.h> 154 #include <linux/blkpg.h> 155 #include <linux/kernel.h> 156 - #include <linux/smp_lock.h> 157 #include <asm/uaccess.h> 158 #include <linux/workqueue.h> 159 160 static DEFINE_SPINLOCK(pd_lock); 161 162 module_param(verbose, bool, 0); ··· 737 { 738 struct pd_unit *disk = bdev->bd_disk->private_data; 739 740 - lock_kernel(); 741 disk->access++; 742 743 if (disk->removable) { 744 pd_special_command(disk, pd_media_check); 745 pd_special_command(disk, pd_door_lock); 746 } 747 - unlock_kernel(); 748 return 0; 749 } 750 ··· 772 773 switch (cmd) { 774 case CDROMEJECT: 775 - lock_kernel(); 776 if (disk->access == 1) 777 pd_special_command(disk, pd_eject); 778 - unlock_kernel(); 779 return 0; 780 default: 781 return -EINVAL; ··· 786 { 787 struct pd_unit *disk = p->private_data; 788 789 - lock_kernel(); 790 if (!--disk->access && disk->removable) 791 pd_special_command(disk, pd_door_unlock); 792 - unlock_kernel(); 793 794 return 0; 795 }
··· 153 #include <linux/blkdev.h> 154 #include <linux/blkpg.h> 155 #include <linux/kernel.h> 156 + #include <linux/mutex.h> 157 #include <asm/uaccess.h> 158 #include <linux/workqueue.h> 159 160 + static DEFINE_MUTEX(pd_mutex); 161 static DEFINE_SPINLOCK(pd_lock); 162 163 module_param(verbose, bool, 0); ··· 736 { 737 struct pd_unit *disk = bdev->bd_disk->private_data; 738 739 + mutex_lock(&pd_mutex); 740 disk->access++; 741 742 if (disk->removable) { 743 pd_special_command(disk, pd_media_check); 744 pd_special_command(disk, pd_door_lock); 745 } 746 + mutex_unlock(&pd_mutex); 747 return 0; 748 } 749 ··· 771 772 switch (cmd) { 773 case CDROMEJECT: 774 + mutex_lock(&pd_mutex); 775 if (disk->access == 1) 776 pd_special_command(disk, pd_eject); 777 + mutex_unlock(&pd_mutex); 778 return 0; 779 default: 780 return -EINVAL; ··· 785 { 786 struct pd_unit *disk = p->private_data; 787 788 + mutex_lock(&pd_mutex); 789 if (!--disk->access && disk->removable) 790 pd_special_command(disk, pd_door_unlock); 791 + mutex_unlock(&pd_mutex); 792 793 return 0; 794 }
+9 -8
drivers/block/paride/pf.c
··· 152 #include <linux/spinlock.h> 153 #include <linux/blkdev.h> 154 #include <linux/blkpg.h> 155 - #include <linux/smp_lock.h> 156 #include <asm/uaccess.h> 157 158 static DEFINE_SPINLOCK(pf_spin_lock); 159 160 module_param(verbose, bool, 0644); ··· 303 struct pf_unit *pf = bdev->bd_disk->private_data; 304 int ret; 305 306 - lock_kernel(); 307 pf_identify(pf); 308 309 ret = -ENODEV; ··· 319 if (pf->removable) 320 pf_lock(pf, 1); 321 out: 322 - unlock_kernel(); 323 return ret; 324 } 325 ··· 350 351 if (pf->access != 1) 352 return -EBUSY; 353 - lock_kernel(); 354 pf_eject(pf); 355 - unlock_kernel(); 356 357 return 0; 358 } ··· 361 { 362 struct pf_unit *pf = disk->private_data; 363 364 - lock_kernel(); 365 if (pf->access <= 0) { 366 - unlock_kernel(); 367 return -EINVAL; 368 } 369 ··· 372 if (!pf->access && pf->removable) 373 pf_lock(pf, 0); 374 375 - unlock_kernel(); 376 return 0; 377 378 }
··· 152 #include <linux/spinlock.h> 153 #include <linux/blkdev.h> 154 #include <linux/blkpg.h> 155 + #include <linux/mutex.h> 156 #include <asm/uaccess.h> 157 158 + static DEFINE_MUTEX(pf_mutex); 159 static DEFINE_SPINLOCK(pf_spin_lock); 160 161 module_param(verbose, bool, 0644); ··· 302 struct pf_unit *pf = bdev->bd_disk->private_data; 303 int ret; 304 305 + mutex_lock(&pf_mutex); 306 pf_identify(pf); 307 308 ret = -ENODEV; ··· 318 if (pf->removable) 319 pf_lock(pf, 1); 320 out: 321 + mutex_unlock(&pf_mutex); 322 return ret; 323 } 324 ··· 349 350 if (pf->access != 1) 351 return -EBUSY; 352 + mutex_lock(&pf_mutex); 353 pf_eject(pf); 354 + mutex_unlock(&pf_mutex); 355 356 return 0; 357 } ··· 360 { 361 struct pf_unit *pf = disk->private_data; 362 363 + mutex_lock(&pf_mutex); 364 if (pf->access <= 0) { 365 + mutex_unlock(&pf_mutex); 366 return -EINVAL; 367 } 368 ··· 371 if (!pf->access && pf->removable) 372 pf_lock(pf, 0); 373 374 + mutex_unlock(&pf_mutex); 375 return 0; 376 377 }
+8 -8
drivers/block/pktcdvd.c
··· 57 #include <linux/seq_file.h> 58 #include <linux/miscdevice.h> 59 #include <linux/freezer.h> 60 - #include <linux/smp_lock.h> 61 #include <linux/mutex.h> 62 #include <linux/slab.h> 63 #include <scsi/scsi_cmnd.h> ··· 85 86 #define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1)) 87 88 static struct pktcdvd_device *pkt_devs[MAX_WRITERS]; 89 static struct proc_dir_entry *pkt_proc; 90 static int pktdev_major; ··· 2383 2384 VPRINTK(DRIVER_NAME": entering open\n"); 2385 2386 - lock_kernel(); 2387 mutex_lock(&ctl_mutex); 2388 pd = pkt_find_dev_from_minor(MINOR(bdev->bd_dev)); 2389 if (!pd) { ··· 2411 } 2412 2413 mutex_unlock(&ctl_mutex); 2414 - unlock_kernel(); 2415 return 0; 2416 2417 out_dec: ··· 2419 out: 2420 VPRINTK(DRIVER_NAME": failed open (%d)\n", ret); 2421 mutex_unlock(&ctl_mutex); 2422 - unlock_kernel(); 2423 return ret; 2424 } 2425 ··· 2428 struct pktcdvd_device *pd = disk->private_data; 2429 int ret = 0; 2430 2431 - lock_kernel(); 2432 mutex_lock(&ctl_mutex); 2433 pd->refcnt--; 2434 BUG_ON(pd->refcnt < 0); ··· 2437 pkt_release_dev(pd, flush); 2438 } 2439 mutex_unlock(&ctl_mutex); 2440 - unlock_kernel(); 2441 return ret; 2442 } 2443 ··· 2773 VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, 2774 MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev)); 2775 2776 - lock_kernel(); 2777 switch (cmd) { 2778 case CDROMEJECT: 2779 /* ··· 2798 VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd); 2799 ret = -ENOTTY; 2800 } 2801 - unlock_kernel(); 2802 2803 return ret; 2804 }
··· 57 #include <linux/seq_file.h> 58 #include <linux/miscdevice.h> 59 #include <linux/freezer.h> 60 #include <linux/mutex.h> 61 #include <linux/slab.h> 62 #include <scsi/scsi_cmnd.h> ··· 86 87 #define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1)) 88 89 + static DEFINE_MUTEX(pktcdvd_mutex); 90 static struct pktcdvd_device *pkt_devs[MAX_WRITERS]; 91 static struct proc_dir_entry *pkt_proc; 92 static int pktdev_major; ··· 2383 2384 VPRINTK(DRIVER_NAME": entering open\n"); 2385 2386 + mutex_lock(&pktcdvd_mutex); 2387 mutex_lock(&ctl_mutex); 2388 pd = pkt_find_dev_from_minor(MINOR(bdev->bd_dev)); 2389 if (!pd) { ··· 2411 } 2412 2413 mutex_unlock(&ctl_mutex); 2414 + mutex_unlock(&pktcdvd_mutex); 2415 return 0; 2416 2417 out_dec: ··· 2419 out: 2420 VPRINTK(DRIVER_NAME": failed open (%d)\n", ret); 2421 mutex_unlock(&ctl_mutex); 2422 + mutex_unlock(&pktcdvd_mutex); 2423 return ret; 2424 } 2425 ··· 2428 struct pktcdvd_device *pd = disk->private_data; 2429 int ret = 0; 2430 2431 + mutex_lock(&pktcdvd_mutex); 2432 mutex_lock(&ctl_mutex); 2433 pd->refcnt--; 2434 BUG_ON(pd->refcnt < 0); ··· 2437 pkt_release_dev(pd, flush); 2438 } 2439 mutex_unlock(&ctl_mutex); 2440 + mutex_unlock(&pktcdvd_mutex); 2441 return ret; 2442 } 2443 ··· 2773 VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, 2774 MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev)); 2775 2776 + mutex_lock(&pktcdvd_mutex); 2777 switch (cmd) { 2778 case CDROMEJECT: 2779 /* ··· 2798 VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd); 2799 ret = -ENOTTY; 2800 } 2801 + mutex_unlock(&pktcdvd_mutex); 2802 2803 return ret; 2804 }
+8 -7
drivers/block/swim.c
··· 20 #include <linux/fd.h> 21 #include <linux/slab.h> 22 #include <linux/blkdev.h> 23 - #include <linux/smp_lock.h> 24 #include <linux/hdreg.h> 25 #include <linux/kernel.h> 26 #include <linux/delay.h> ··· 222 extern int swim_read_sector_data(struct swim __iomem *base, 223 unsigned char *data); 224 225 static inline void set_swim_mode(struct swim __iomem *base, int enable) 226 { 227 struct iwm __iomem *iwm_base; ··· 667 { 668 int ret; 669 670 - lock_kernel(); 671 ret = floppy_open(bdev, mode); 672 - unlock_kernel(); 673 674 return ret; 675 } ··· 679 struct floppy_state *fs = disk->private_data; 680 struct swim __iomem *base = fs->swd->base; 681 682 - lock_kernel(); 683 if (fs->ref_count < 0) 684 fs->ref_count = 0; 685 else if (fs->ref_count > 0) ··· 687 688 if (fs->ref_count == 0) 689 swim_motor(base, OFF); 690 - unlock_kernel(); 691 692 return 0; 693 } ··· 705 case FDEJECT: 706 if (fs->ref_count != 1) 707 return -EBUSY; 708 - lock_kernel(); 709 err = floppy_eject(fs); 710 - unlock_kernel(); 711 return err; 712 713 case FDGETPRM:
··· 20 #include <linux/fd.h> 21 #include <linux/slab.h> 22 #include <linux/blkdev.h> 23 + #include <linux/mutex.h> 24 #include <linux/hdreg.h> 25 #include <linux/kernel.h> 26 #include <linux/delay.h> ··· 222 extern int swim_read_sector_data(struct swim __iomem *base, 223 unsigned char *data); 224 225 + static DEFINE_MUTEX(swim_mutex); 226 static inline void set_swim_mode(struct swim __iomem *base, int enable) 227 { 228 struct iwm __iomem *iwm_base; ··· 666 { 667 int ret; 668 669 + mutex_lock(&swim_mutex); 670 ret = floppy_open(bdev, mode); 671 + mutex_unlock(&swim_mutex); 672 673 return ret; 674 } ··· 678 struct floppy_state *fs = disk->private_data; 679 struct swim __iomem *base = fs->swd->base; 680 681 + mutex_lock(&swim_mutex); 682 if (fs->ref_count < 0) 683 fs->ref_count = 0; 684 else if (fs->ref_count > 0) ··· 686 687 if (fs->ref_count == 0) 688 swim_motor(base, OFF); 689 + mutex_unlock(&swim_mutex); 690 691 return 0; 692 } ··· 704 case FDEJECT: 705 if (fs->ref_count != 1) 706 return -EBUSY; 707 + mutex_lock(&swim_mutex); 708 err = floppy_eject(fs); 709 + mutex_unlock(&swim_mutex); 710 return err; 711 712 case FDGETPRM:
+8 -7
drivers/block/swim3.c
··· 25 #include <linux/ioctl.h> 26 #include <linux/blkdev.h> 27 #include <linux/interrupt.h> 28 - #include <linux/smp_lock.h> 29 #include <linux/module.h> 30 #include <linux/spinlock.h> 31 #include <asm/io.h> ··· 36 #include <asm/machdep.h> 37 #include <asm/pmac_feature.h> 38 39 static struct request_queue *swim3_queue; 40 static struct gendisk *disks[2]; 41 static struct request *fd_req; ··· 874 { 875 int ret; 876 877 - lock_kernel(); 878 ret = floppy_locked_ioctl(bdev, mode, cmd, param); 879 - unlock_kernel(); 880 881 return ret; 882 } ··· 954 { 955 int ret; 956 957 - lock_kernel(); 958 ret = floppy_open(bdev, mode); 959 - unlock_kernel(); 960 961 return ret; 962 } ··· 965 { 966 struct floppy_state *fs = disk->private_data; 967 struct swim3 __iomem *sw = fs->swim3; 968 - lock_kernel(); 969 if (fs->ref_count > 0 && --fs->ref_count == 0) { 970 swim3_action(fs, MOTOR_OFF); 971 out_8(&sw->control_bic, 0xff); 972 swim3_select(fs, RELAX); 973 } 974 - unlock_kernel(); 975 return 0; 976 } 977
··· 25 #include <linux/ioctl.h> 26 #include <linux/blkdev.h> 27 #include <linux/interrupt.h> 28 + #include <linux/mutex.h> 29 #include <linux/module.h> 30 #include <linux/spinlock.h> 31 #include <asm/io.h> ··· 36 #include <asm/machdep.h> 37 #include <asm/pmac_feature.h> 38 39 + static DEFINE_MUTEX(swim3_mutex); 40 static struct request_queue *swim3_queue; 41 static struct gendisk *disks[2]; 42 static struct request *fd_req; ··· 873 { 874 int ret; 875 876 + mutex_lock(&swim3_mutex); 877 ret = floppy_locked_ioctl(bdev, mode, cmd, param); 878 + mutex_unlock(&swim3_mutex); 879 880 return ret; 881 } ··· 953 { 954 int ret; 955 956 + mutex_lock(&swim3_mutex); 957 ret = floppy_open(bdev, mode); 958 + mutex_unlock(&swim3_mutex); 959 960 return ret; 961 } ··· 964 { 965 struct floppy_state *fs = disk->private_data; 966 struct swim3 __iomem *sw = fs->swim3; 967 + mutex_lock(&swim3_mutex); 968 if (fs->ref_count > 0 && --fs->ref_count == 0) { 969 swim3_action(fs, MOTOR_OFF); 970 out_8(&sw->control_bic, 0xff); 971 swim3_select(fs, RELAX); 972 } 973 + mutex_unlock(&swim3_mutex); 974 return 0; 975 } 976
+8 -7
drivers/block/ub.c
··· 28 #include <linux/timer.h> 29 #include <linux/scatterlist.h> 30 #include <linux/slab.h> 31 - #include <linux/smp_lock.h> 32 #include <scsi/scsi.h> 33 34 #define DRV_NAME "ub" ··· 248 spinlock_t lock; 249 }; 250 251 static inline void ub_init_completion(struct ub_completion *x) 252 { 253 x->done = 0; ··· 1716 { 1717 int ret; 1718 1719 - lock_kernel(); 1720 ret = ub_bd_open(bdev, mode); 1721 - unlock_kernel(); 1722 1723 return ret; 1724 } ··· 1731 struct ub_lun *lun = disk->private_data; 1732 struct ub_dev *sc = lun->udev; 1733 1734 - lock_kernel(); 1735 ub_put(sc); 1736 - unlock_kernel(); 1737 1738 return 0; 1739 } ··· 1748 void __user *usermem = (void __user *) arg; 1749 int ret; 1750 1751 - lock_kernel(); 1752 ret = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, usermem); 1753 - unlock_kernel(); 1754 1755 return ret; 1756 }
··· 28 #include <linux/timer.h> 29 #include <linux/scatterlist.h> 30 #include <linux/slab.h> 31 + #include <linux/mutex.h> 32 #include <scsi/scsi.h> 33 34 #define DRV_NAME "ub" ··· 248 spinlock_t lock; 249 }; 250 251 + static DEFINE_MUTEX(ub_mutex); 252 static inline void ub_init_completion(struct ub_completion *x) 253 { 254 x->done = 0; ··· 1715 { 1716 int ret; 1717 1718 + mutex_lock(&ub_mutex); 1719 ret = ub_bd_open(bdev, mode); 1720 + mutex_unlock(&ub_mutex); 1721 1722 return ret; 1723 } ··· 1730 struct ub_lun *lun = disk->private_data; 1731 struct ub_dev *sc = lun->udev; 1732 1733 + mutex_lock(&ub_mutex); 1734 ub_put(sc); 1735 + mutex_unlock(&ub_mutex); 1736 1737 return 0; 1738 } ··· 1747 void __user *usermem = (void __user *) arg; 1748 int ret; 1749 1750 + mutex_lock(&ub_mutex); 1751 ret = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, usermem); 1752 + mutex_unlock(&ub_mutex); 1753 1754 return ret; 1755 }
+6 -5
drivers/block/viodasd.c
··· 41 #include <linux/errno.h> 42 #include <linux/init.h> 43 #include <linux/string.h> 44 - #include <linux/smp_lock.h> 45 #include <linux/dma-mapping.h> 46 #include <linux/completion.h> 47 #include <linux/device.h> ··· 73 MAX_DISK_NAME = FIELD_SIZEOF(struct gendisk, disk_name) 74 }; 75 76 static DEFINE_SPINLOCK(viodasd_spinlock); 77 78 #define VIOMAXREQ 16 ··· 181 { 182 int ret; 183 184 - lock_kernel(); 185 ret = viodasd_open(bdev, mode); 186 - unlock_kernel(); 187 188 return ret; 189 } ··· 197 struct viodasd_device *d = disk->private_data; 198 HvLpEvent_Rc hvrc; 199 200 - lock_kernel(); 201 /* Send the event to OS/400. We DON'T expect a response */ 202 hvrc = HvCallEvent_signalLpEventFast(viopath_hostLp, 203 HvLpEvent_Type_VirtualIo, ··· 211 if (hvrc != 0) 212 pr_warning("HV close call failed %d\n", (int)hvrc); 213 214 - unlock_kernel(); 215 216 return 0; 217 }
··· 41 #include <linux/errno.h> 42 #include <linux/init.h> 43 #include <linux/string.h> 44 + #include <linux/mutex.h> 45 #include <linux/dma-mapping.h> 46 #include <linux/completion.h> 47 #include <linux/device.h> ··· 73 MAX_DISK_NAME = FIELD_SIZEOF(struct gendisk, disk_name) 74 }; 75 76 + static DEFINE_MUTEX(viodasd_mutex); 77 static DEFINE_SPINLOCK(viodasd_spinlock); 78 79 #define VIOMAXREQ 16 ··· 180 { 181 int ret; 182 183 + mutex_lock(&viodasd_mutex); 184 ret = viodasd_open(bdev, mode); 185 + mutex_unlock(&viodasd_mutex); 186 187 return ret; 188 } ··· 196 struct viodasd_device *d = disk->private_data; 197 HvLpEvent_Rc hvrc; 198 199 + mutex_lock(&viodasd_mutex); 200 /* Send the event to OS/400. We DON'T expect a response */ 201 hvrc = HvCallEvent_signalLpEventFast(viopath_hostLp, 202 HvLpEvent_Type_VirtualIo, ··· 210 if (hvrc != 0) 211 pr_warning("HV close call failed %d\n", (int)hvrc); 212 213 + mutex_unlock(&viodasd_mutex); 214 215 return 0; 216 }
+4 -3
drivers/block/xd.c
··· 46 #include <linux/init.h> 47 #include <linux/wait.h> 48 #include <linux/blkdev.h> 49 - #include <linux/smp_lock.h> 50 #include <linux/blkpg.h> 51 #include <linux/delay.h> 52 #include <linux/io.h> ··· 58 59 #include "xd.h" 60 61 static void __init do_xd_setup (int *integers); 62 #ifdef MODULE 63 static int xd[5] = { -1,-1,-1,-1, }; ··· 382 { 383 int ret; 384 385 - lock_kernel(); 386 ret = xd_locked_ioctl(bdev, mode, cmd, param); 387 - unlock_kernel(); 388 389 return ret; 390 }
··· 46 #include <linux/init.h> 47 #include <linux/wait.h> 48 #include <linux/blkdev.h> 49 + #include <linux/mutex.h> 50 #include <linux/blkpg.h> 51 #include <linux/delay.h> 52 #include <linux/io.h> ··· 58 59 #include "xd.h" 60 61 + static DEFINE_MUTEX(xd_mutex); 62 static void __init do_xd_setup (int *integers); 63 #ifdef MODULE 64 static int xd[5] = { -1,-1,-1,-1, }; ··· 381 { 382 int ret; 383 384 + mutex_lock(&xd_mutex); 385 ret = xd_locked_ioctl(bdev, mode, cmd, param); 386 + mutex_unlock(&xd_mutex); 387 388 return ret; 389 }
+6 -5
drivers/block/xen-blkfront.c
··· 41 #include <linux/cdrom.h> 42 #include <linux/module.h> 43 #include <linux/slab.h> 44 - #include <linux/smp_lock.h> 45 #include <linux/scatterlist.h> 46 47 #include <xen/xen.h> ··· 69 unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 70 }; 71 72 static const struct block_device_operations xlvbd_block_fops; 73 74 #define BLK_RING_SIZE __RING_SIZE((struct blkif_sring *)0, PAGE_SIZE) ··· 1202 struct blkfront_info *info; 1203 int err = 0; 1204 1205 - lock_kernel(); 1206 1207 info = disk->private_data; 1208 if (!info) { ··· 1220 mutex_unlock(&info->mutex); 1221 1222 out: 1223 - unlock_kernel(); 1224 return err; 1225 } 1226 ··· 1230 struct block_device *bdev; 1231 struct xenbus_device *xbdev; 1232 1233 - lock_kernel(); 1234 1235 bdev = bdget_disk(disk, 0); 1236 bdput(bdev); ··· 1264 } 1265 1266 out: 1267 - unlock_kernel(); 1268 return 0; 1269 } 1270
··· 41 #include <linux/cdrom.h> 42 #include <linux/module.h> 43 #include <linux/slab.h> 44 + #include <linux/mutex.h> 45 #include <linux/scatterlist.h> 46 47 #include <xen/xen.h> ··· 69 unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 70 }; 71 72 + static DEFINE_MUTEX(blkfront_mutex); 73 static const struct block_device_operations xlvbd_block_fops; 74 75 #define BLK_RING_SIZE __RING_SIZE((struct blkif_sring *)0, PAGE_SIZE) ··· 1201 struct blkfront_info *info; 1202 int err = 0; 1203 1204 + mutex_lock(&blkfront_mutex); 1205 1206 info = disk->private_data; 1207 if (!info) { ··· 1219 mutex_unlock(&info->mutex); 1220 1221 out: 1222 + mutex_unlock(&blkfront_mutex); 1223 return err; 1224 } 1225 ··· 1229 struct block_device *bdev; 1230 struct xenbus_device *xbdev; 1231 1232 + mutex_lock(&blkfront_mutex); 1233 1234 bdev = bdget_disk(disk, 0); 1235 bdput(bdev); ··· 1263 } 1264 1265 out: 1266 + mutex_unlock(&blkfront_mutex); 1267 return 0; 1268 } 1269
+6 -5
drivers/block/xsysace.c
··· 89 #include <linux/delay.h> 90 #include <linux/slab.h> 91 #include <linux/blkdev.h> 92 - #include <linux/smp_lock.h> 93 #include <linux/ata.h> 94 #include <linux/hdreg.h> 95 #include <linux/platform_device.h> ··· 214 u16 cf_id[ATA_ID_WORDS]; 215 }; 216 217 static int ace_major; 218 219 /* --------------------------------------------------------------------- ··· 904 905 dev_dbg(ace->dev, "ace_open() users=%i\n", ace->users + 1); 906 907 - lock_kernel(); 908 spin_lock_irqsave(&ace->lock, flags); 909 ace->users++; 910 spin_unlock_irqrestore(&ace->lock, flags); 911 912 check_disk_change(bdev); 913 - unlock_kernel(); 914 915 return 0; 916 } ··· 923 924 dev_dbg(ace->dev, "ace_release() users=%i\n", ace->users - 1); 925 926 - lock_kernel(); 927 spin_lock_irqsave(&ace->lock, flags); 928 ace->users--; 929 if (ace->users == 0) { ··· 931 ace_out(ace, ACE_CTRL, val & ~ACE_CTRL_LOCKREQ); 932 } 933 spin_unlock_irqrestore(&ace->lock, flags); 934 - unlock_kernel(); 935 return 0; 936 } 937
··· 89 #include <linux/delay.h> 90 #include <linux/slab.h> 91 #include <linux/blkdev.h> 92 + #include <linux/mutex.h> 93 #include <linux/ata.h> 94 #include <linux/hdreg.h> 95 #include <linux/platform_device.h> ··· 214 u16 cf_id[ATA_ID_WORDS]; 215 }; 216 217 + static DEFINE_MUTEX(xsysace_mutex); 218 static int ace_major; 219 220 /* --------------------------------------------------------------------- ··· 903 904 dev_dbg(ace->dev, "ace_open() users=%i\n", ace->users + 1); 905 906 + mutex_lock(&xsysace_mutex); 907 spin_lock_irqsave(&ace->lock, flags); 908 ace->users++; 909 spin_unlock_irqrestore(&ace->lock, flags); 910 911 check_disk_change(bdev); 912 + mutex_unlock(&xsysace_mutex); 913 914 return 0; 915 } ··· 922 923 dev_dbg(ace->dev, "ace_release() users=%i\n", ace->users - 1); 924 925 + mutex_lock(&xsysace_mutex); 926 spin_lock_irqsave(&ace->lock, flags); 927 ace->users--; 928 if (ace->users == 0) { ··· 930 ace_out(ace, ACE_CTRL, val & ~ACE_CTRL_LOCKREQ); 931 } 932 spin_unlock_irqrestore(&ace->lock, flags); 933 + mutex_unlock(&xsysace_mutex); 934 return 0; 935 } 936
+8 -7
drivers/block/z2ram.c
··· 33 #include <linux/module.h> 34 #include <linux/blkdev.h> 35 #include <linux/bitops.h> 36 - #include <linux/smp_lock.h> 37 #include <linux/slab.h> 38 39 #include <asm/setup.h> ··· 57 58 #define Z2RAM_CHUNK1024 ( Z2RAM_CHUNKSIZE >> 10 ) 59 60 static u_long *z2ram_map = NULL; 61 static u_long z2ram_size = 0; 62 static int z2_count = 0; ··· 155 156 device = MINOR(bdev->bd_dev); 157 158 - lock_kernel(); 159 if ( current_device != -1 && current_device != device ) 160 { 161 rc = -EBUSY; ··· 297 set_capacity(z2ram_gendisk, z2ram_size >> 9); 298 } 299 300 - unlock_kernel(); 301 return 0; 302 303 err_out_kfree: 304 kfree(z2ram_map); 305 err_out: 306 - unlock_kernel(); 307 return rc; 308 } 309 310 static int 311 z2_release(struct gendisk *disk, fmode_t mode) 312 { 313 - lock_kernel(); 314 if ( current_device == -1 ) { 315 - unlock_kernel(); 316 return 0; 317 } 318 - unlock_kernel(); 319 /* 320 * FIXME: unmap memory 321 */
··· 33 #include <linux/module.h> 34 #include <linux/blkdev.h> 35 #include <linux/bitops.h> 36 + #include <linux/mutex.h> 37 #include <linux/slab.h> 38 39 #include <asm/setup.h> ··· 57 58 #define Z2RAM_CHUNK1024 ( Z2RAM_CHUNKSIZE >> 10 ) 59 60 + static DEFINE_MUTEX(z2ram_mutex); 61 static u_long *z2ram_map = NULL; 62 static u_long z2ram_size = 0; 63 static int z2_count = 0; ··· 154 155 device = MINOR(bdev->bd_dev); 156 157 + mutex_lock(&z2ram_mutex); 158 if ( current_device != -1 && current_device != device ) 159 { 160 rc = -EBUSY; ··· 296 set_capacity(z2ram_gendisk, z2ram_size >> 9); 297 } 298 299 + mutex_unlock(&z2ram_mutex); 300 return 0; 301 302 err_out_kfree: 303 kfree(z2ram_map); 304 err_out: 305 + mutex_unlock(&z2ram_mutex); 306 return rc; 307 } 308 309 static int 310 z2_release(struct gendisk *disk, fmode_t mode) 311 { 312 + mutex_lock(&z2ram_mutex); 313 if ( current_device == -1 ) { 314 + mutex_unlock(&z2ram_mutex); 315 return 0; 316 } 317 + mutex_unlock(&z2ram_mutex); 318 /* 319 * FIXME: unmap memory 320 */
+8 -7
drivers/cdrom/gdrom.c
··· 34 #include <linux/blkdev.h> 35 #include <linux/interrupt.h> 36 #include <linux/device.h> 37 - #include <linux/smp_lock.h> 38 #include <linux/wait.h> 39 #include <linux/workqueue.h> 40 #include <linux/platform_device.h> ··· 81 82 #define GDROM_DEFAULT_TIMEOUT (HZ * 7) 83 84 static const struct { 85 int sense_key; 86 const char * const text; ··· 495 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode) 496 { 497 int ret; 498 - lock_kernel(); 499 ret = cdrom_open(gd.cd_info, bdev, mode); 500 - unlock_kernel(); 501 return ret; 502 } 503 504 static int gdrom_bdops_release(struct gendisk *disk, fmode_t mode) 505 { 506 - lock_kernel(); 507 cdrom_release(gd.cd_info, mode); 508 - unlock_kernel(); 509 return 0; 510 } 511 ··· 519 { 520 int ret; 521 522 - lock_kernel(); 523 ret = cdrom_ioctl(gd.cd_info, bdev, mode, cmd, arg); 524 - unlock_kernel(); 525 526 return ret; 527 }
··· 34 #include <linux/blkdev.h> 35 #include <linux/interrupt.h> 36 #include <linux/device.h> 37 + #include <linux/mutex.h> 38 #include <linux/wait.h> 39 #include <linux/workqueue.h> 40 #include <linux/platform_device.h> ··· 81 82 #define GDROM_DEFAULT_TIMEOUT (HZ * 7) 83 84 + static DEFINE_MUTEX(gdrom_mutex); 85 static const struct { 86 int sense_key; 87 const char * const text; ··· 494 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode) 495 { 496 int ret; 497 + mutex_lock(&gdrom_mutex); 498 ret = cdrom_open(gd.cd_info, bdev, mode); 499 + mutex_unlock(&gdrom_mutex); 500 return ret; 501 } 502 503 static int gdrom_bdops_release(struct gendisk *disk, fmode_t mode) 504 { 505 + mutex_lock(&gdrom_mutex); 506 cdrom_release(gd.cd_info, mode); 507 + mutex_unlock(&gdrom_mutex); 508 return 0; 509 } 510 ··· 518 { 519 int ret; 520 521 + mutex_lock(&gdrom_mutex); 522 ret = cdrom_ioctl(gd.cd_info, bdev, mode, cmd, arg); 523 + mutex_unlock(&gdrom_mutex); 524 525 return ret; 526 }
+8 -7
drivers/cdrom/viocd.c
··· 42 #include <linux/module.h> 43 #include <linux/completion.h> 44 #include <linux/proc_fs.h> 45 - #include <linux/smp_lock.h> 46 #include <linux/seq_file.h> 47 #include <linux/scatterlist.h> 48 ··· 61 */ 62 #define VIOCD_MAX_CD HVMAXARCHITECTEDVIRTUALCDROMS 63 64 static const struct vio_error_entry viocd_err_table[] = { 65 {0x0201, EINVAL, "Invalid Range"}, 66 {0x0202, EINVAL, "Invalid Token"}, ··· 157 struct disk_info *di = bdev->bd_disk->private_data; 158 int ret; 159 160 - lock_kernel(); 161 ret = cdrom_open(&di->viocd_info, bdev, mode); 162 - unlock_kernel(); 163 164 return ret; 165 } ··· 167 static int viocd_blk_release(struct gendisk *disk, fmode_t mode) 168 { 169 struct disk_info *di = disk->private_data; 170 - lock_kernel(); 171 cdrom_release(&di->viocd_info, mode); 172 - unlock_kernel(); 173 return 0; 174 } 175 ··· 179 struct disk_info *di = bdev->bd_disk->private_data; 180 int ret; 181 182 - lock_kernel(); 183 ret = cdrom_ioctl(&di->viocd_info, bdev, mode, cmd, arg); 184 - unlock_kernel(); 185 186 return ret; 187 }
··· 42 #include <linux/module.h> 43 #include <linux/completion.h> 44 #include <linux/proc_fs.h> 45 + #include <linux/mutex.h> 46 #include <linux/seq_file.h> 47 #include <linux/scatterlist.h> 48 ··· 61 */ 62 #define VIOCD_MAX_CD HVMAXARCHITECTEDVIRTUALCDROMS 63 64 + static DEFINE_MUTEX(viocd_mutex); 65 static const struct vio_error_entry viocd_err_table[] = { 66 {0x0201, EINVAL, "Invalid Range"}, 67 {0x0202, EINVAL, "Invalid Token"}, ··· 156 struct disk_info *di = bdev->bd_disk->private_data; 157 int ret; 158 159 + mutex_lock(&viocd_mutex); 160 ret = cdrom_open(&di->viocd_info, bdev, mode); 161 + mutex_unlock(&viocd_mutex); 162 163 return ret; 164 } ··· 166 static int viocd_blk_release(struct gendisk *disk, fmode_t mode) 167 { 168 struct disk_info *di = disk->private_data; 169 + mutex_lock(&viocd_mutex); 170 cdrom_release(&di->viocd_info, mode); 171 + mutex_unlock(&viocd_mutex); 172 return 0; 173 } 174 ··· 178 struct disk_info *di = bdev->bd_disk->private_data; 179 int ret; 180 181 + mutex_lock(&viocd_mutex); 182 ret = cdrom_ioctl(&di->viocd_info, bdev, mode, cmd, arg); 183 + mutex_unlock(&viocd_mutex); 184 185 return ret; 186 }
+7 -7
drivers/ide/ide-cd.c
··· 31 #include <linux/delay.h> 32 #include <linux/timer.h> 33 #include <linux/seq_file.h> 34 - #include <linux/smp_lock.h> 35 #include <linux/slab.h> 36 #include <linux/interrupt.h> 37 #include <linux/errno.h> ··· 51 52 #include "ide-cd.h" 53 54 static DEFINE_MUTEX(idecd_ref_mutex); 55 56 static void ide_cd_release(struct device *); ··· 1602 struct cdrom_info *info; 1603 int rc = -ENXIO; 1604 1605 - lock_kernel(); 1606 info = ide_cd_get(bdev->bd_disk); 1607 if (!info) 1608 goto out; ··· 1611 if (rc < 0) 1612 ide_cd_put(info); 1613 out: 1614 - unlock_kernel(); 1615 return rc; 1616 } 1617 ··· 1619 { 1620 struct cdrom_info *info = ide_drv_g(disk, cdrom_info); 1621 1622 - lock_kernel(); 1623 cdrom_release(&info->devinfo, mode); 1624 1625 ide_cd_put(info); 1626 - unlock_kernel(); 1627 1628 return 0; 1629 } ··· 1694 { 1695 int ret; 1696 1697 - lock_kernel(); 1698 ret = idecd_locked_ioctl(bdev, mode, cmd, arg); 1699 - unlock_kernel(); 1700 1701 return ret; 1702 }
··· 31 #include <linux/delay.h> 32 #include <linux/timer.h> 33 #include <linux/seq_file.h> 34 #include <linux/slab.h> 35 #include <linux/interrupt.h> 36 #include <linux/errno.h> ··· 52 53 #include "ide-cd.h" 54 55 + static DEFINE_MUTEX(ide_cd_mutex); 56 static DEFINE_MUTEX(idecd_ref_mutex); 57 58 static void ide_cd_release(struct device *); ··· 1602 struct cdrom_info *info; 1603 int rc = -ENXIO; 1604 1605 + mutex_lock(&ide_cd_mutex); 1606 info = ide_cd_get(bdev->bd_disk); 1607 if (!info) 1608 goto out; ··· 1611 if (rc < 0) 1612 ide_cd_put(info); 1613 out: 1614 + mutex_unlock(&ide_cd_mutex); 1615 return rc; 1616 } 1617 ··· 1619 { 1620 struct cdrom_info *info = ide_drv_g(disk, cdrom_info); 1621 1622 + mutex_lock(&ide_cd_mutex); 1623 cdrom_release(&info->devinfo, mode); 1624 1625 ide_cd_put(info); 1626 + mutex_unlock(&ide_cd_mutex); 1627 1628 return 0; 1629 } ··· 1694 { 1695 int ret; 1696 1697 + mutex_lock(&ide_cd_mutex); 1698 ret = idecd_locked_ioctl(bdev, mode, cmd, arg); 1699 + mutex_unlock(&ide_cd_mutex); 1700 1701 return ret; 1702 }
+4 -3
drivers/ide/ide-disk_ioctl.c
··· 1 #include <linux/kernel.h> 2 #include <linux/ide.h> 3 #include <linux/hdreg.h> 4 - #include <linux/smp_lock.h> 5 6 #include "ide-disk.h" 7 8 static const struct ide_ioctl_devset ide_disk_ioctl_settings[] = { 9 { HDIO_GET_ADDRESS, HDIO_SET_ADDRESS, &ide_devset_address }, 10 { HDIO_GET_MULTCOUNT, HDIO_SET_MULTCOUNT, &ide_devset_multcount }, ··· 20 { 21 int err; 22 23 - lock_kernel(); 24 err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings); 25 if (err != -EOPNOTSUPP) 26 goto out; 27 28 err = generic_ide_ioctl(drive, bdev, cmd, arg); 29 out: 30 - unlock_kernel(); 31 return err; 32 }
··· 1 #include <linux/kernel.h> 2 #include <linux/ide.h> 3 #include <linux/hdreg.h> 4 + #include <linux/mutex.h> 5 6 #include "ide-disk.h" 7 8 + static DEFINE_MUTEX(ide_disk_ioctl_mutex); 9 static const struct ide_ioctl_devset ide_disk_ioctl_settings[] = { 10 { HDIO_GET_ADDRESS, HDIO_SET_ADDRESS, &ide_devset_address }, 11 { HDIO_GET_MULTCOUNT, HDIO_SET_MULTCOUNT, &ide_devset_multcount }, ··· 19 { 20 int err; 21 22 + mutex_lock(&ide_disk_ioctl_mutex); 23 err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings); 24 if (err != -EOPNOTSUPP) 25 goto out; 26 27 err = generic_ide_ioctl(drive, bdev, cmd, arg); 28 out: 29 + mutex_unlock(&ide_disk_ioctl_mutex); 30 return err; 31 }
+4 -3
drivers/ide/ide-floppy_ioctl.c
··· 5 #include <linux/kernel.h> 6 #include <linux/ide.h> 7 #include <linux/cdrom.h> 8 - #include <linux/smp_lock.h> 9 10 #include <asm/unaligned.h> 11 ··· 32 * On exit we set nformats to the number of records we've actually initialized. 33 */ 34 35 static int ide_floppy_get_format_capacities(ide_drive_t *drive, 36 struct ide_atapi_pc *pc, 37 int __user *arg) ··· 277 void __user *argp = (void __user *)arg; 278 int err; 279 280 - lock_kernel(); 281 if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR) { 282 err = ide_floppy_lockdoor(drive, &pc, arg, cmd); 283 goto out; ··· 299 err = generic_ide_ioctl(drive, bdev, cmd, arg); 300 301 out: 302 - unlock_kernel(); 303 return err; 304 }
··· 5 #include <linux/kernel.h> 6 #include <linux/ide.h> 7 #include <linux/cdrom.h> 8 + #include <linux/mutex.h> 9 10 #include <asm/unaligned.h> 11 ··· 32 * On exit we set nformats to the number of records we've actually initialized. 33 */ 34 35 + static DEFINE_MUTEX(ide_floppy_ioctl_mutex); 36 static int ide_floppy_get_format_capacities(ide_drive_t *drive, 37 struct ide_atapi_pc *pc, 38 int __user *arg) ··· 276 void __user *argp = (void __user *)arg; 277 int err; 278 279 + mutex_lock(&ide_floppy_ioctl_mutex); 280 if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR) { 281 err = ide_floppy_lockdoor(drive, &pc, arg, cmd); 282 goto out; ··· 298 err = generic_ide_ioctl(drive, bdev, cmd, arg); 299 300 out: 301 + mutex_unlock(&ide_floppy_ioctl_mutex); 302 return err; 303 }
+5 -5
drivers/ide/ide-gd.c
··· 1 - #include <linux/smp_lock.h> 2 #include <linux/module.h> 3 #include <linux/types.h> 4 #include <linux/string.h> ··· 22 #define IDE_GD_VERSION "1.18" 23 24 /* module parameters */ 25 static unsigned long debug_mask; 26 module_param(debug_mask, ulong, 0644); 27 ··· 242 { 243 int ret; 244 245 - lock_kernel(); 246 ret = ide_gd_open(bdev, mode); 247 - unlock_kernel(); 248 249 return ret; 250 } ··· 257 258 ide_debug_log(IDE_DBG_FUNC, "enter"); 259 260 - lock_kernel(); 261 if (idkp->openers == 1) 262 drive->disk_ops->flush(drive); 263 ··· 269 idkp->openers--; 270 271 ide_disk_put(idkp); 272 - unlock_kernel(); 273 274 return 0; 275 }
··· 1 #include <linux/module.h> 2 #include <linux/types.h> 3 #include <linux/string.h> ··· 23 #define IDE_GD_VERSION "1.18" 24 25 /* module parameters */ 26 + static DEFINE_MUTEX(ide_gd_mutex); 27 static unsigned long debug_mask; 28 module_param(debug_mask, ulong, 0644); 29 ··· 242 { 243 int ret; 244 245 + mutex_lock(&ide_gd_mutex); 246 ret = ide_gd_open(bdev, mode); 247 + mutex_unlock(&ide_gd_mutex); 248 249 return ret; 250 } ··· 257 258 ide_debug_log(IDE_DBG_FUNC, "enter"); 259 260 + mutex_lock(&ide_gd_mutex); 261 if (idkp->openers == 1) 262 drive->disk_ops->flush(drive); 263 ··· 269 idkp->openers--; 270 271 ide_disk_put(idkp); 272 + mutex_unlock(&ide_gd_mutex); 273 274 return 0; 275 }
+9 -10
drivers/ide/ide-tape.c
··· 32 #include <linux/errno.h> 33 #include <linux/genhd.h> 34 #include <linux/seq_file.h> 35 - #include <linux/smp_lock.h> 36 #include <linux/slab.h> 37 #include <linux/pci.h> 38 #include <linux/ide.h> 39 - #include <linux/smp_lock.h> 40 #include <linux/completion.h> 41 #include <linux/bitops.h> 42 #include <linux/mutex.h> ··· 218 char write_prot; 219 } idetape_tape_t; 220 221 static DEFINE_MUTEX(idetape_ref_mutex); 222 223 static DEFINE_MUTEX(idetape_chrdev_mutex); ··· 1425 unsigned int cmd, unsigned long arg) 1426 { 1427 long ret; 1428 - lock_kernel(); 1429 ret = do_idetape_chrdev_ioctl(file, cmd, arg); 1430 - unlock_kernel(); 1431 return ret; 1432 } 1433 ··· 1908 { 1909 struct ide_tape_obj *tape; 1910 1911 - lock_kernel(); 1912 tape = ide_tape_get(bdev->bd_disk, false, 0); 1913 - unlock_kernel(); 1914 1915 if (!tape) 1916 return -ENXIO; ··· 1922 { 1923 struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj); 1924 1925 - lock_kernel(); 1926 ide_tape_put(tape); 1927 - unlock_kernel(); 1928 1929 return 0; 1930 } ··· 1936 ide_drive_t *drive = tape->drive; 1937 int err; 1938 1939 - lock_kernel(); 1940 err = generic_ide_ioctl(drive, bdev, cmd, arg); 1941 if (err == -EINVAL) 1942 err = idetape_blkdev_ioctl(drive, cmd, arg); 1943 - unlock_kernel(); 1944 1945 return err; 1946 }
··· 32 #include <linux/errno.h> 33 #include <linux/genhd.h> 34 #include <linux/seq_file.h> 35 #include <linux/slab.h> 36 #include <linux/pci.h> 37 #include <linux/ide.h> 38 #include <linux/completion.h> 39 #include <linux/bitops.h> 40 #include <linux/mutex.h> ··· 220 char write_prot; 221 } idetape_tape_t; 222 223 + static DEFINE_MUTEX(ide_tape_mutex); 224 static DEFINE_MUTEX(idetape_ref_mutex); 225 226 static DEFINE_MUTEX(idetape_chrdev_mutex); ··· 1426 unsigned int cmd, unsigned long arg) 1427 { 1428 long ret; 1429 + mutex_lock(&ide_tape_mutex); 1430 ret = do_idetape_chrdev_ioctl(file, cmd, arg); 1431 + mutex_unlock(&ide_tape_mutex); 1432 return ret; 1433 } 1434 ··· 1909 { 1910 struct ide_tape_obj *tape; 1911 1912 + mutex_lock(&ide_tape_mutex); 1913 tape = ide_tape_get(bdev->bd_disk, false, 0); 1914 + mutex_unlock(&ide_tape_mutex); 1915 1916 if (!tape) 1917 return -ENXIO; ··· 1923 { 1924 struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj); 1925 1926 + mutex_lock(&ide_tape_mutex); 1927 ide_tape_put(tape); 1928 + mutex_unlock(&ide_tape_mutex); 1929 1930 return 0; 1931 } ··· 1937 ide_drive_t *drive = tape->drive; 1938 int err; 1939 1940 + mutex_lock(&ide_tape_mutex); 1941 err = generic_ide_ioctl(drive, bdev, cmd, arg); 1942 if (err == -EINVAL) 1943 err = idetape_blkdev_ioctl(drive, cmd, arg); 1944 + mutex_unlock(&ide_tape_mutex); 1945 1946 return err; 1947 }
+5 -5
drivers/md/dm.c
··· 15 #include <linux/blkpg.h> 16 #include <linux/bio.h> 17 #include <linux/buffer_head.h> 18 - #include <linux/smp_lock.h> 19 #include <linux/mempool.h> 20 #include <linux/slab.h> 21 #include <linux/idr.h> ··· 32 #define DM_COOKIE_ENV_VAR_NAME "DM_COOKIE" 33 #define DM_COOKIE_LENGTH 24 34 35 static const char *_name = DM_NAME; 36 37 static unsigned int major = 0; ··· 344 { 345 struct mapped_device *md; 346 347 - lock_kernel(); 348 spin_lock(&_minor_lock); 349 350 md = bdev->bd_disk->private_data; ··· 362 363 out: 364 spin_unlock(&_minor_lock); 365 - unlock_kernel(); 366 367 return md ? 0 : -ENXIO; 368 } ··· 371 { 372 struct mapped_device *md = disk->private_data; 373 374 - lock_kernel(); 375 atomic_dec(&md->open_count); 376 dm_put(md); 377 - unlock_kernel(); 378 379 return 0; 380 }
··· 15 #include <linux/blkpg.h> 16 #include <linux/bio.h> 17 #include <linux/buffer_head.h> 18 #include <linux/mempool.h> 19 #include <linux/slab.h> 20 #include <linux/idr.h> ··· 33 #define DM_COOKIE_ENV_VAR_NAME "DM_COOKIE" 34 #define DM_COOKIE_LENGTH 24 35 36 + static DEFINE_MUTEX(dm_mutex); 37 static const char *_name = DM_NAME; 38 39 static unsigned int major = 0; ··· 344 { 345 struct mapped_device *md; 346 347 + mutex_lock(&dm_mutex); 348 spin_lock(&_minor_lock); 349 350 md = bdev->bd_disk->private_data; ··· 362 363 out: 364 spin_unlock(&_minor_lock); 365 + mutex_unlock(&dm_mutex); 366 367 return md ? 0 : -ENXIO; 368 } ··· 371 { 372 struct mapped_device *md = disk->private_data; 373 374 + mutex_lock(&dm_mutex); 375 atomic_dec(&md->open_count); 376 dm_put(md); 377 + mutex_unlock(&dm_mutex); 378 379 return 0; 380 }
+7 -6
drivers/md/md.c
··· 36 #include <linux/blkdev.h> 37 #include <linux/sysctl.h> 38 #include <linux/seq_file.h> 39 - #include <linux/smp_lock.h> 40 #include <linux/buffer_head.h> /* for invalidate_bdev */ 41 #include <linux/poll.h> 42 #include <linux/ctype.h> ··· 57 #define DEBUG 0 58 #define dprintk(x...) ((void)(DEBUG && printk(x))) 59 60 61 #ifndef MODULE 62 static void autostart_arrays(int part); ··· 5950 mddev_t *mddev = mddev_find(bdev->bd_dev); 5951 int err; 5952 5953 - lock_kernel(); 5954 if (mddev->gendisk != bdev->bd_disk) { 5955 /* we are racing with mddev_put which is discarding this 5956 * bd_disk. ··· 5959 /* Wait until bdev->bd_disk is definitely gone */ 5960 flush_scheduled_work(); 5961 /* Then retry the open from the top */ 5962 - unlock_kernel(); 5963 return -ERESTARTSYS; 5964 } 5965 BUG_ON(mddev != bdev->bd_disk->private_data); ··· 5973 5974 check_disk_size_change(mddev->gendisk, bdev); 5975 out: 5976 - unlock_kernel(); 5977 return err; 5978 } 5979 ··· 5982 mddev_t *mddev = disk->private_data; 5983 5984 BUG_ON(!mddev); 5985 - lock_kernel(); 5986 atomic_dec(&mddev->openers); 5987 mddev_put(mddev); 5988 - unlock_kernel(); 5989 5990 return 0; 5991 }
··· 36 #include <linux/blkdev.h> 37 #include <linux/sysctl.h> 38 #include <linux/seq_file.h> 39 + #include <linux/mutex.h> 40 #include <linux/buffer_head.h> /* for invalidate_bdev */ 41 #include <linux/poll.h> 42 #include <linux/ctype.h> ··· 57 #define DEBUG 0 58 #define dprintk(x...) ((void)(DEBUG && printk(x))) 59 60 + static DEFINE_MUTEX(md_mutex); 61 62 #ifndef MODULE 63 static void autostart_arrays(int part); ··· 5949 mddev_t *mddev = mddev_find(bdev->bd_dev); 5950 int err; 5951 5952 + mutex_lock(&md_mutex); 5953 if (mddev->gendisk != bdev->bd_disk) { 5954 /* we are racing with mddev_put which is discarding this 5955 * bd_disk. ··· 5958 /* Wait until bdev->bd_disk is definitely gone */ 5959 flush_scheduled_work(); 5960 /* Then retry the open from the top */ 5961 + mutex_unlock(&md_mutex); 5962 return -ERESTARTSYS; 5963 } 5964 BUG_ON(mddev != bdev->bd_disk->private_data); ··· 5972 5973 check_disk_size_change(mddev->gendisk, bdev); 5974 out: 5975 + mutex_unlock(&md_mutex); 5976 return err; 5977 } 5978 ··· 5981 mddev_t *mddev = disk->private_data; 5982 5983 BUG_ON(!mddev); 5984 + mutex_lock(&md_mutex); 5985 atomic_dec(&mddev->openers); 5986 mddev_put(mddev); 5987 + mutex_unlock(&md_mutex); 5988 5989 return 0; 5990 }
+6 -5
drivers/memstick/core/mspro_block.c
··· 18 #include <linux/kthread.h> 19 #include <linux/delay.h> 20 #include <linux/slab.h> 21 - #include <linux/smp_lock.h> 22 #include <linux/memstick.h> 23 24 #define DRIVER_NAME "mspro_block" 25 26 static int major; 27 module_param(major, int, 0644); 28 ··· 181 struct mspro_block_data *msb = disk->private_data; 182 int rc = -ENXIO; 183 184 - lock_kernel(); 185 mutex_lock(&mspro_block_disk_lock); 186 187 if (msb && msb->card) { ··· 193 } 194 195 mutex_unlock(&mspro_block_disk_lock); 196 - unlock_kernel(); 197 198 return rc; 199 } ··· 226 static int mspro_block_bd_release(struct gendisk *disk, fmode_t mode) 227 { 228 int ret; 229 - lock_kernel(); 230 ret = mspro_block_disk_release(disk); 231 - unlock_kernel(); 232 return ret; 233 } 234
··· 18 #include <linux/kthread.h> 19 #include <linux/delay.h> 20 #include <linux/slab.h> 21 + #include <linux/mutex.h> 22 #include <linux/memstick.h> 23 24 #define DRIVER_NAME "mspro_block" 25 26 + static DEFINE_MUTEX(mspro_block_mutex); 27 static int major; 28 module_param(major, int, 0644); 29 ··· 180 struct mspro_block_data *msb = disk->private_data; 181 int rc = -ENXIO; 182 183 + mutex_lock(&mspro_block_mutex); 184 mutex_lock(&mspro_block_disk_lock); 185 186 if (msb && msb->card) { ··· 192 } 193 194 mutex_unlock(&mspro_block_disk_lock); 195 + mutex_unlock(&mspro_block_mutex); 196 197 return rc; 198 } ··· 225 static int mspro_block_bd_release(struct gendisk *disk, fmode_t mode) 226 { 227 int ret; 228 + mutex_lock(&mspro_block_mutex); 229 ret = mspro_block_disk_release(disk); 230 + mutex_unlock(&mspro_block_mutex); 231 return ret; 232 } 233
+8 -7
drivers/message/i2o/i2o_block.c
··· 53 #include <linux/module.h> 54 #include <linux/slab.h> 55 #include <linux/i2o.h> 56 - #include <linux/smp_lock.h> 57 58 #include <linux/mempool.h> 59 ··· 69 #define OSM_VERSION "1.325" 70 #define OSM_DESCRIPTION "I2O Block Device OSM" 71 72 static struct i2o_driver i2o_block_driver; 73 74 /* global Block OSM request mempool */ ··· 579 if (!dev->i2o_dev) 580 return -ENODEV; 581 582 - lock_kernel(); 583 if (dev->power > 0x1f) 584 i2o_block_device_power(dev, 0x02); 585 ··· 588 i2o_block_device_lock(dev->i2o_dev, -1); 589 590 osm_debug("Ready.\n"); 591 - unlock_kernel(); 592 593 return 0; 594 }; ··· 619 if (!dev->i2o_dev) 620 return 0; 621 622 - lock_kernel(); 623 i2o_block_device_flush(dev->i2o_dev); 624 625 i2o_block_device_unlock(dev->i2o_dev, -1); ··· 630 operation = 0x24; 631 632 i2o_block_device_power(dev, operation); 633 - unlock_kernel(); 634 635 return 0; 636 } ··· 665 if (!capable(CAP_SYS_ADMIN)) 666 return -EPERM; 667 668 - lock_kernel(); 669 switch (cmd) { 670 case BLKI2OGRSTRAT: 671 ret = put_user(dev->rcache, (int __user *)arg); ··· 689 ret = 0; 690 break; 691 } 692 - unlock_kernel(); 693 694 return ret; 695 };
··· 53 #include <linux/module.h> 54 #include <linux/slab.h> 55 #include <linux/i2o.h> 56 + #include <linux/mutex.h> 57 58 #include <linux/mempool.h> 59 ··· 69 #define OSM_VERSION "1.325" 70 #define OSM_DESCRIPTION "I2O Block Device OSM" 71 72 + static DEFINE_MUTEX(i2o_block_mutex); 73 static struct i2o_driver i2o_block_driver; 74 75 /* global Block OSM request mempool */ ··· 578 if (!dev->i2o_dev) 579 return -ENODEV; 580 581 + mutex_lock(&i2o_block_mutex); 582 if (dev->power > 0x1f) 583 i2o_block_device_power(dev, 0x02); 584 ··· 587 i2o_block_device_lock(dev->i2o_dev, -1); 588 589 osm_debug("Ready.\n"); 590 + mutex_unlock(&i2o_block_mutex); 591 592 return 0; 593 }; ··· 618 if (!dev->i2o_dev) 619 return 0; 620 621 + mutex_lock(&i2o_block_mutex); 622 i2o_block_device_flush(dev->i2o_dev); 623 624 i2o_block_device_unlock(dev->i2o_dev, -1); ··· 629 operation = 0x24; 630 631 i2o_block_device_power(dev, operation); 632 + mutex_unlock(&i2o_block_mutex); 633 634 return 0; 635 } ··· 664 if (!capable(CAP_SYS_ADMIN)) 665 return -EPERM; 666 667 + mutex_lock(&i2o_block_mutex); 668 switch (cmd) { 669 case BLKI2OGRSTRAT: 670 ret = put_user(dev->rcache, (int __user *)arg); ··· 688 ret = 0; 689 break; 690 } 691 + mutex_unlock(&i2o_block_mutex); 692 693 return ret; 694 };
+5 -5
drivers/mmc/card/block.c
··· 29 #include <linux/kdev_t.h> 30 #include <linux/blkdev.h> 31 #include <linux/mutex.h> 32 - #include <linux/smp_lock.h> 33 #include <linux/scatterlist.h> 34 #include <linux/string_helpers.h> 35 ··· 50 #define MMC_SHIFT 3 51 #define MMC_NUM_MINORS (256 >> MMC_SHIFT) 52 53 static DECLARE_BITMAP(dev_use, MMC_NUM_MINORS); 54 55 /* ··· 108 struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk); 109 int ret = -ENXIO; 110 111 - lock_kernel(); 112 if (md) { 113 if (md->usage == 2) 114 check_disk_change(bdev); ··· 119 ret = -EROFS; 120 } 121 } 122 - unlock_kernel(); 123 124 return ret; 125 } ··· 128 { 129 struct mmc_blk_data *md = disk->private_data; 130 131 - lock_kernel(); 132 mmc_blk_put(md); 133 - unlock_kernel(); 134 return 0; 135 } 136
··· 29 #include <linux/kdev_t.h> 30 #include <linux/blkdev.h> 31 #include <linux/mutex.h> 32 #include <linux/scatterlist.h> 33 #include <linux/string_helpers.h> 34 ··· 51 #define MMC_SHIFT 3 52 #define MMC_NUM_MINORS (256 >> MMC_SHIFT) 53 54 + static DEFINE_MUTEX(block_mutex); 55 static DECLARE_BITMAP(dev_use, MMC_NUM_MINORS); 56 57 /* ··· 108 struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk); 109 int ret = -ENXIO; 110 111 + mutex_lock(&block_mutex); 112 if (md) { 113 if (md->usage == 2) 114 check_disk_change(bdev); ··· 119 ret = -EROFS; 120 } 121 } 122 + mutex_unlock(&block_mutex); 123 124 return ret; 125 } ··· 128 { 129 struct mmc_blk_data *md = disk->private_data; 130 131 + mutex_lock(&block_mutex); 132 mmc_blk_put(md); 133 + mutex_unlock(&block_mutex); 134 return 0; 135 } 136
+7 -7
drivers/mtd/mtd_blkdevs.c
··· 29 #include <linux/blkdev.h> 30 #include <linux/blkpg.h> 31 #include <linux/spinlock.h> 32 - #include <linux/smp_lock.h> 33 #include <linux/hdreg.h> 34 #include <linux/init.h> 35 #include <linux/mutex.h> ··· 37 38 #include "mtdcore.h" 39 40 static LIST_HEAD(blktrans_majors); 41 static DEFINE_MUTEX(blktrans_ref_mutex); 42 ··· 181 if (!dev) 182 return -ERESTARTSYS; /* FIXME: busy loop! -arnd*/ 183 184 - lock_kernel(); 185 mutex_lock(&dev->lock); 186 187 if (!dev->mtd) { ··· 198 unlock: 199 mutex_unlock(&dev->lock); 200 blktrans_dev_put(dev); 201 - unlock_kernel(); 202 return ret; 203 } 204 ··· 210 if (!dev) 211 return ret; 212 213 - lock_kernel(); 214 mutex_lock(&dev->lock); 215 216 /* Release one reference, we sure its not the last one here*/ ··· 223 unlock: 224 mutex_unlock(&dev->lock); 225 blktrans_dev_put(dev); 226 - unlock_kernel(); 227 return ret; 228 } 229 ··· 256 if (!dev) 257 return ret; 258 259 - lock_kernel(); 260 mutex_lock(&dev->lock); 261 262 if (!dev->mtd) ··· 271 } 272 unlock: 273 mutex_unlock(&dev->lock); 274 - unlock_kernel(); 275 blktrans_dev_put(dev); 276 return ret; 277 }
··· 29 #include <linux/blkdev.h> 30 #include <linux/blkpg.h> 31 #include <linux/spinlock.h> 32 #include <linux/hdreg.h> 33 #include <linux/init.h> 34 #include <linux/mutex.h> ··· 38 39 #include "mtdcore.h" 40 41 + static DEFINE_MUTEX(mtd_blkdevs_mutex); 42 static LIST_HEAD(blktrans_majors); 43 static DEFINE_MUTEX(blktrans_ref_mutex); 44 ··· 181 if (!dev) 182 return -ERESTARTSYS; /* FIXME: busy loop! -arnd*/ 183 184 + mutex_lock(&mtd_blkdevs_mutex); 185 mutex_lock(&dev->lock); 186 187 if (!dev->mtd) { ··· 198 unlock: 199 mutex_unlock(&dev->lock); 200 blktrans_dev_put(dev); 201 + mutex_unlock(&mtd_blkdevs_mutex); 202 return ret; 203 } 204 ··· 210 if (!dev) 211 return ret; 212 213 + mutex_lock(&mtd_blkdevs_mutex); 214 mutex_lock(&dev->lock); 215 216 /* Release one reference, we sure its not the last one here*/ ··· 223 unlock: 224 mutex_unlock(&dev->lock); 225 blktrans_dev_put(dev); 226 + mutex_unlock(&mtd_blkdevs_mutex); 227 return ret; 228 } 229 ··· 256 if (!dev) 257 return ret; 258 259 + mutex_lock(&mtd_blkdevs_mutex); 260 mutex_lock(&dev->lock); 261 262 if (!dev->mtd) ··· 271 } 272 unlock: 273 mutex_unlock(&dev->lock); 274 + mutex_unlock(&mtd_blkdevs_mutex); 275 blktrans_dev_put(dev); 276 return ret; 277 }
+7 -6
drivers/s390/char/tape_block.c
··· 16 #include <linux/fs.h> 17 #include <linux/module.h> 18 #include <linux/blkdev.h> 19 - #include <linux/smp_lock.h> 20 #include <linux/interrupt.h> 21 #include <linux/buffer_head.h> 22 #include <linux/kernel.h> ··· 45 /* 46 * file operation structure for tape block frontend 47 */ 48 static int tapeblock_open(struct block_device *, fmode_t); 49 static int tapeblock_release(struct gendisk *, fmode_t); 50 static int tapeblock_medium_changed(struct gendisk *); ··· 362 struct tape_device * device; 363 int rc; 364 365 - lock_kernel(); 366 device = tape_get_device(disk->private_data); 367 368 if (device->required_tapemarks) { ··· 386 * is called. 387 */ 388 tape_state_set(device, TS_BLKUSE); 389 - unlock_kernel(); 390 return 0; 391 392 release: 393 tape_release(device); 394 put_device: 395 tape_put_device(device); 396 - unlock_kernel(); 397 return rc; 398 } 399 ··· 408 { 409 struct tape_device *device = disk->private_data; 410 411 - lock_kernel(); 412 tape_state_set(device, TS_IN_USE); 413 tape_release(device); 414 tape_put_device(device); 415 - unlock_kernel(); 416 417 return 0; 418 }
··· 16 #include <linux/fs.h> 17 #include <linux/module.h> 18 #include <linux/blkdev.h> 19 + #include <linux/mutex.h> 20 #include <linux/interrupt.h> 21 #include <linux/buffer_head.h> 22 #include <linux/kernel.h> ··· 45 /* 46 * file operation structure for tape block frontend 47 */ 48 + static DEFINE_MUTEX(tape_block_mutex); 49 static int tapeblock_open(struct block_device *, fmode_t); 50 static int tapeblock_release(struct gendisk *, fmode_t); 51 static int tapeblock_medium_changed(struct gendisk *); ··· 361 struct tape_device * device; 362 int rc; 363 364 + mutex_lock(&tape_block_mutex); 365 device = tape_get_device(disk->private_data); 366 367 if (device->required_tapemarks) { ··· 385 * is called. 386 */ 387 tape_state_set(device, TS_BLKUSE); 388 + mutex_unlock(&tape_block_mutex); 389 return 0; 390 391 release: 392 tape_release(device); 393 put_device: 394 tape_put_device(device); 395 + mutex_unlock(&tape_block_mutex); 396 return rc; 397 } 398 ··· 407 { 408 struct tape_device *device = disk->private_data; 409 410 + mutex_lock(&tape_block_mutex); 411 tape_state_set(device, TS_IN_USE); 412 tape_release(device); 413 tape_put_device(device); 414 + mutex_unlock(&tape_block_mutex); 415 416 return 0; 417 }
+7 -7
drivers/scsi/sr.c
··· 44 #include <linux/init.h> 45 #include <linux/blkdev.h> 46 #include <linux/mutex.h> 47 - #include <linux/smp_lock.h> 48 #include <linux/slab.h> 49 #include <asm/uaccess.h> 50 ··· 75 CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET| \ 76 CDC_MRW|CDC_MRW_W|CDC_RAM) 77 78 static int sr_probe(struct device *); 79 static int sr_remove(struct device *); 80 static int sr_done(struct scsi_cmnd *); ··· 470 struct scsi_cd *cd; 471 int ret = -ENXIO; 472 473 - lock_kernel(); 474 cd = scsi_cd_get(bdev->bd_disk); 475 if (cd) { 476 ret = cdrom_open(&cd->cdi, bdev, mode); 477 if (ret) 478 scsi_cd_put(cd); 479 } 480 - unlock_kernel(); 481 return ret; 482 } 483 484 static int sr_block_release(struct gendisk *disk, fmode_t mode) 485 { 486 struct scsi_cd *cd = scsi_cd(disk); 487 - lock_kernel(); 488 cdrom_release(&cd->cdi, mode); 489 scsi_cd_put(cd); 490 - unlock_kernel(); 491 return 0; 492 } 493 ··· 499 void __user *argp = (void __user *)arg; 500 int ret; 501 502 - lock_kernel(); 503 504 /* 505 * Send SCSI addressing ioctls directly to mid level, send other ··· 529 ret = scsi_ioctl(sdev, cmd, argp); 530 531 out: 532 - unlock_kernel(); 533 return ret; 534 } 535
··· 44 #include <linux/init.h> 45 #include <linux/blkdev.h> 46 #include <linux/mutex.h> 47 #include <linux/slab.h> 48 #include <asm/uaccess.h> 49 ··· 76 CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET| \ 77 CDC_MRW|CDC_MRW_W|CDC_RAM) 78 79 + static DEFINE_MUTEX(sr_mutex); 80 static int sr_probe(struct device *); 81 static int sr_remove(struct device *); 82 static int sr_done(struct scsi_cmnd *); ··· 470 struct scsi_cd *cd; 471 int ret = -ENXIO; 472 473 + mutex_lock(&sr_mutex); 474 cd = scsi_cd_get(bdev->bd_disk); 475 if (cd) { 476 ret = cdrom_open(&cd->cdi, bdev, mode); 477 if (ret) 478 scsi_cd_put(cd); 479 } 480 + mutex_unlock(&sr_mutex); 481 return ret; 482 } 483 484 static int sr_block_release(struct gendisk *disk, fmode_t mode) 485 { 486 struct scsi_cd *cd = scsi_cd(disk); 487 + mutex_lock(&sr_mutex); 488 cdrom_release(&cd->cdi, mode); 489 scsi_cd_put(cd); 490 + mutex_unlock(&sr_mutex); 491 return 0; 492 } 493 ··· 499 void __user *argp = (void __user *)arg; 500 int ret; 501 502 + mutex_lock(&sr_mutex); 503 504 /* 505 * Send SCSI addressing ioctls directly to mid level, send other ··· 529 ret = scsi_ioctl(sdev, cmd, argp); 530 531 out: 532 + mutex_unlock(&sr_mutex); 533 return ret; 534 } 535
+6 -6
drivers/scsi/st.c
··· 39 #include <linux/cdev.h> 40 #include <linux/delay.h> 41 #include <linux/mutex.h> 42 - #include <linux/smp_lock.h> 43 44 #include <asm/uaccess.h> 45 #include <asm/dma.h> ··· 75 #include "st_options.h" 76 #include "st.h" 77 78 static int buffer_kbs; 79 static int max_sg_segs; 80 static int try_direct_io = TRY_DIRECT_IO; ··· 1180 int dev = TAPE_NR(inode); 1181 char *name; 1182 1183 - lock_kernel(); 1184 /* 1185 * We really want to do nonseekable_open(inode, filp); here, but some 1186 * versions of tar incorrectly call lseek on tapes and bail out if that ··· 1189 filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); 1190 1191 if (!(STp = scsi_tape_get(dev))) { 1192 - unlock_kernel(); 1193 return -ENXIO; 1194 } 1195 ··· 1200 if (STp->in_use) { 1201 write_unlock(&st_dev_arr_lock); 1202 scsi_tape_put(STp); 1203 - unlock_kernel(); 1204 DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); ) 1205 return (-EBUSY); 1206 } ··· 1249 retval = (-EIO); 1250 goto err_out; 1251 } 1252 - unlock_kernel(); 1253 return 0; 1254 1255 err_out: 1256 normalize_buffer(STp->buffer); 1257 STp->in_use = 0; 1258 scsi_tape_put(STp); 1259 - unlock_kernel(); 1260 return retval; 1261 1262 }
··· 39 #include <linux/cdev.h> 40 #include <linux/delay.h> 41 #include <linux/mutex.h> 42 43 #include <asm/uaccess.h> 44 #include <asm/dma.h> ··· 76 #include "st_options.h" 77 #include "st.h" 78 79 + static DEFINE_MUTEX(st_mutex); 80 static int buffer_kbs; 81 static int max_sg_segs; 82 static int try_direct_io = TRY_DIRECT_IO; ··· 1180 int dev = TAPE_NR(inode); 1181 char *name; 1182 1183 + mutex_lock(&st_mutex); 1184 /* 1185 * We really want to do nonseekable_open(inode, filp); here, but some 1186 * versions of tar incorrectly call lseek on tapes and bail out if that ··· 1189 filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); 1190 1191 if (!(STp = scsi_tape_get(dev))) { 1192 + mutex_unlock(&st_mutex); 1193 return -ENXIO; 1194 } 1195 ··· 1200 if (STp->in_use) { 1201 write_unlock(&st_dev_arr_lock); 1202 scsi_tape_put(STp); 1203 + mutex_unlock(&st_mutex); 1204 DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); ) 1205 return (-EBUSY); 1206 } ··· 1249 retval = (-EIO); 1250 goto err_out; 1251 } 1252 + mutex_unlock(&st_mutex); 1253 return 0; 1254 1255 err_out: 1256 normalize_buffer(STp->buffer); 1257 STp->in_use = 0; 1258 scsi_tape_put(STp); 1259 + mutex_unlock(&st_mutex); 1260 return retval; 1261 1262 }
+6 -5
drivers/staging/hv/blkvsc_drv.c
··· 25 #include <linux/major.h> 26 #include <linux/delay.h> 27 #include <linux/hdreg.h> 28 - #include <linux/smp_lock.h> 29 #include <linux/slab.h> 30 #include <scsi/scsi.h> 31 #include <scsi/scsi_cmnd.h> ··· 124 }; 125 126 /* Static decl */ 127 static int blkvsc_probe(struct device *dev); 128 static int blkvsc_remove(struct device *device); 129 static void blkvsc_shutdown(struct device *device); ··· 1310 DPRINT_DBG(BLKVSC_DRV, "- users %d disk %s\n", blkdev->users, 1311 blkdev->gd->disk_name); 1312 1313 - lock_kernel(); 1314 spin_lock(&blkdev->lock); 1315 1316 if (!blkdev->users && blkdev->device_type == DVD_TYPE) { ··· 1322 blkdev->users++; 1323 1324 spin_unlock(&blkdev->lock); 1325 - unlock_kernel(); 1326 return 0; 1327 } 1328 ··· 1333 DPRINT_DBG(BLKVSC_DRV, "- users %d disk %s\n", blkdev->users, 1334 blkdev->gd->disk_name); 1335 1336 - lock_kernel(); 1337 spin_lock(&blkdev->lock); 1338 if (blkdev->users == 1) { 1339 spin_unlock(&blkdev->lock); ··· 1344 blkdev->users--; 1345 1346 spin_unlock(&blkdev->lock); 1347 - unlock_kernel(); 1348 return 0; 1349 } 1350
··· 25 #include <linux/major.h> 26 #include <linux/delay.h> 27 #include <linux/hdreg.h> 28 + #include <linux/mutex.h> 29 #include <linux/slab.h> 30 #include <scsi/scsi.h> 31 #include <scsi/scsi_cmnd.h> ··· 124 }; 125 126 /* Static decl */ 127 + static DEFINE_MUTEX(blkvsc_mutex); 128 static int blkvsc_probe(struct device *dev); 129 static int blkvsc_remove(struct device *device); 130 static void blkvsc_shutdown(struct device *device); ··· 1309 DPRINT_DBG(BLKVSC_DRV, "- users %d disk %s\n", blkdev->users, 1310 blkdev->gd->disk_name); 1311 1312 + mutex_lock(&blkvsc_mutex); 1313 spin_lock(&blkdev->lock); 1314 1315 if (!blkdev->users && blkdev->device_type == DVD_TYPE) { ··· 1321 blkdev->users++; 1322 1323 spin_unlock(&blkdev->lock); 1324 + mutex_unlock(&blkvsc_mutex); 1325 return 0; 1326 } 1327 ··· 1332 DPRINT_DBG(BLKVSC_DRV, "- users %d disk %s\n", blkdev->users, 1333 blkdev->gd->disk_name); 1334 1335 + mutex_lock(&blkvsc_mutex); 1336 spin_lock(&blkdev->lock); 1337 if (blkdev->users == 1) { 1338 spin_unlock(&blkdev->lock); ··· 1343 blkdev->users--; 1344 1345 spin_unlock(&blkdev->lock); 1346 + mutex_unlock(&blkvsc_mutex); 1347 return 0; 1348 } 1349
+4 -3
drivers/staging/spectra/ffsport.c
··· 27 #include <linux/kthread.h> 28 #include <linux/log2.h> 29 #include <linux/init.h> 30 - #include <linux/smp_lock.h> 31 #include <linux/slab.h> 32 33 /**** Helper functions used for Div, Remainder operation on u64 ****/ ··· 589 return -ENOTTY; 590 } 591 592 int GLOB_SBD_unlocked_ioctl(struct block_device *bdev, fmode_t mode, 593 unsigned int cmd, unsigned long arg) 594 { 595 int ret; 596 597 - lock_kernel(); 598 ret = GLOB_SBD_ioctl(bdev, mode, cmd, arg); 599 - unlock_kernel(); 600 601 return ret; 602 }
··· 27 #include <linux/kthread.h> 28 #include <linux/log2.h> 29 #include <linux/init.h> 30 #include <linux/slab.h> 31 32 /**** Helper functions used for Div, Remainder operation on u64 ****/ ··· 590 return -ENOTTY; 591 } 592 593 + static DEFINE_MUTEX(ffsport_mutex); 594 + 595 int GLOB_SBD_unlocked_ioctl(struct block_device *bdev, fmode_t mode, 596 unsigned int cmd, unsigned long arg) 597 { 598 int ret; 599 600 + mutex_lock(&ffsport_mutex); 601 ret = GLOB_SBD_ioctl(bdev, mode, cmd, arg); 602 + mutex_unlock(&ffsport_mutex); 603 604 return ret; 605 }