aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@infradead.org>2006-03-23 06:00:28 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-23 10:38:11 -0500
commitc039e3134ae62863bbc8e8429b29e3c43cf21b2a (patch)
treeb9bbf4fda0844e3173bf10a5bffbaaec94fb4246
parent6f87f0deebaff2716a3ce9232f948d702690562a (diff)
[PATCH] sem2mutex: blockdev #2
Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Arjan van de Ven <arjan@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> Acked-by: Jens Axboe <axboe@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--block/ioctl.c22
-rw-r--r--drivers/block/rd.c4
-rw-r--r--drivers/s390/block/dasd_ioctl.c8
-rw-r--r--fs/block_dev.c28
-rw-r--r--fs/buffer.c6
-rw-r--r--fs/super.c4
-rw-r--r--include/linux/fs.h4
7 files changed, 38 insertions, 38 deletions
diff --git a/block/ioctl.c b/block/ioctl.c
index e1109491c234..35fdb7dc6512 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -42,9 +42,9 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
42 return -EINVAL; 42 return -EINVAL;
43 } 43 }
44 /* partition number in use? */ 44 /* partition number in use? */
45 down(&bdev->bd_sem); 45 mutex_lock(&bdev->bd_mutex);
46 if (disk->part[part - 1]) { 46 if (disk->part[part - 1]) {
47 up(&bdev->bd_sem); 47 mutex_unlock(&bdev->bd_mutex);
48 return -EBUSY; 48 return -EBUSY;
49 } 49 }
50 /* overlap? */ 50 /* overlap? */
@@ -55,13 +55,13 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
55 continue; 55 continue;
56 if (!(start+length <= s->start_sect || 56 if (!(start+length <= s->start_sect ||
57 start >= s->start_sect + s->nr_sects)) { 57 start >= s->start_sect + s->nr_sects)) {
58 up(&bdev->bd_sem); 58 mutex_unlock(&bdev->bd_mutex);
59 return -EBUSY; 59 return -EBUSY;
60 } 60 }
61 } 61 }
62 /* all seems OK */ 62 /* all seems OK */
63 add_partition(disk, part, start, length); 63 add_partition(disk, part, start, length);
64 up(&bdev->bd_sem); 64 mutex_unlock(&bdev->bd_mutex);
65 return 0; 65 return 0;
66 case BLKPG_DEL_PARTITION: 66 case BLKPG_DEL_PARTITION:
67 if (!disk->part[part-1]) 67 if (!disk->part[part-1])
@@ -71,9 +71,9 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
71 bdevp = bdget_disk(disk, part); 71 bdevp = bdget_disk(disk, part);
72 if (!bdevp) 72 if (!bdevp)
73 return -ENOMEM; 73 return -ENOMEM;
74 down(&bdevp->bd_sem); 74 mutex_lock(&bdevp->bd_mutex);
75 if (bdevp->bd_openers) { 75 if (bdevp->bd_openers) {
76 up(&bdevp->bd_sem); 76 mutex_unlock(&bdevp->bd_mutex);
77 bdput(bdevp); 77 bdput(bdevp);
78 return -EBUSY; 78 return -EBUSY;
79 } 79 }
@@ -81,10 +81,10 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
81 fsync_bdev(bdevp); 81 fsync_bdev(bdevp);
82 invalidate_bdev(bdevp, 0); 82 invalidate_bdev(bdevp, 0);
83 83
84 down(&bdev->bd_sem); 84 mutex_lock(&bdev->bd_mutex);
85 delete_partition(disk, part); 85 delete_partition(disk, part);
86 up(&bdev->bd_sem); 86 mutex_unlock(&bdev->bd_mutex);
87 up(&bdevp->bd_sem); 87 mutex_unlock(&bdevp->bd_mutex);
88 bdput(bdevp); 88 bdput(bdevp);
89 89
90 return 0; 90 return 0;
@@ -102,10 +102,10 @@ static int blkdev_reread_part(struct block_device *bdev)
102 return -EINVAL; 102 return -EINVAL;
103 if (!capable(CAP_SYS_ADMIN)) 103 if (!capable(CAP_SYS_ADMIN))
104 return -EACCES; 104 return -EACCES;
105 if (down_trylock(&bdev->bd_sem)) 105 if (!mutex_trylock(&bdev->bd_mutex))
106 return -EBUSY; 106 return -EBUSY;
107 res = rescan_partitions(disk, bdev); 107 res = rescan_partitions(disk, bdev);
108 up(&bdev->bd_sem); 108 mutex_unlock(&bdev->bd_mutex);
109 return res; 109 return res;
110} 110}
111 111
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index ffd6abd6d5a0..1c54f46d3f70 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -310,12 +310,12 @@ static int rd_ioctl(struct inode *inode, struct file *file,
310 * cache 310 * cache
311 */ 311 */
312 error = -EBUSY; 312 error = -EBUSY;
313 down(&bdev->bd_sem); 313 mutex_lock(&bdev->bd_mutex);
314 if (bdev->bd_openers <= 2) { 314 if (bdev->bd_openers <= 2) {
315 truncate_inode_pages(bdev->bd_inode->i_mapping, 0); 315 truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
316 error = 0; 316 error = 0;
317 } 317 }
318 up(&bdev->bd_sem); 318 mutex_unlock(&bdev->bd_mutex);
319 return error; 319 return error;
320} 320}
321 321
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index fafeeae52675..f9930552ab54 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -151,9 +151,9 @@ dasd_ioctl_enable(struct block_device *bdev, int no, long args)
151 return -ENODEV; 151 return -ENODEV;
152 dasd_enable_device(device); 152 dasd_enable_device(device);
153 /* Formatting the dasd device can change the capacity. */ 153 /* Formatting the dasd device can change the capacity. */
154 down(&bdev->bd_sem); 154 mutex_lock(&bdev->bd_mutex);
155 i_size_write(bdev->bd_inode, (loff_t)get_capacity(device->gdp) << 9); 155 i_size_write(bdev->bd_inode, (loff_t)get_capacity(device->gdp) << 9);
156 up(&bdev->bd_sem); 156 mutex_unlock(&bdev->bd_mutex);
157 return 0; 157 return 0;
158} 158}
159 159
@@ -184,9 +184,9 @@ dasd_ioctl_disable(struct block_device *bdev, int no, long args)
184 * Set i_size to zero, since read, write, etc. check against this 184 * Set i_size to zero, since read, write, etc. check against this
185 * value. 185 * value.
186 */ 186 */
187 down(&bdev->bd_sem); 187 mutex_lock(&bdev->bd_mutex);
188 i_size_write(bdev->bd_inode, 0); 188 i_size_write(bdev->bd_inode, 0);
189 up(&bdev->bd_sem); 189 mutex_unlock(&bdev->bd_mutex);
190 return 0; 190 return 0;
191} 191}
192 192
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 6e50346fb1ee..44d05e6e34db 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -265,8 +265,8 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
265 SLAB_CTOR_CONSTRUCTOR) 265 SLAB_CTOR_CONSTRUCTOR)
266 { 266 {
267 memset(bdev, 0, sizeof(*bdev)); 267 memset(bdev, 0, sizeof(*bdev));
268 sema_init(&bdev->bd_sem, 1); 268 mutex_init(&bdev->bd_mutex);
269 sema_init(&bdev->bd_mount_sem, 1); 269 mutex_init(&bdev->bd_mount_mutex);
270 INIT_LIST_HEAD(&bdev->bd_inodes); 270 INIT_LIST_HEAD(&bdev->bd_inodes);
271 INIT_LIST_HEAD(&bdev->bd_list); 271 INIT_LIST_HEAD(&bdev->bd_list);
272 inode_init_once(&ei->vfs_inode); 272 inode_init_once(&ei->vfs_inode);
@@ -574,7 +574,7 @@ static int do_open(struct block_device *bdev, struct file *file)
574 } 574 }
575 owner = disk->fops->owner; 575 owner = disk->fops->owner;
576 576
577 down(&bdev->bd_sem); 577 mutex_lock(&bdev->bd_mutex);
578 if (!bdev->bd_openers) { 578 if (!bdev->bd_openers) {
579 bdev->bd_disk = disk; 579 bdev->bd_disk = disk;
580 bdev->bd_contains = bdev; 580 bdev->bd_contains = bdev;
@@ -605,21 +605,21 @@ static int do_open(struct block_device *bdev, struct file *file)
605 if (ret) 605 if (ret)
606 goto out_first; 606 goto out_first;
607 bdev->bd_contains = whole; 607 bdev->bd_contains = whole;
608 down(&whole->bd_sem); 608 mutex_lock(&whole->bd_mutex);
609 whole->bd_part_count++; 609 whole->bd_part_count++;
610 p = disk->part[part - 1]; 610 p = disk->part[part - 1];
611 bdev->bd_inode->i_data.backing_dev_info = 611 bdev->bd_inode->i_data.backing_dev_info =
612 whole->bd_inode->i_data.backing_dev_info; 612 whole->bd_inode->i_data.backing_dev_info;
613 if (!(disk->flags & GENHD_FL_UP) || !p || !p->nr_sects) { 613 if (!(disk->flags & GENHD_FL_UP) || !p || !p->nr_sects) {
614 whole->bd_part_count--; 614 whole->bd_part_count--;
615 up(&whole->bd_sem); 615 mutex_unlock(&whole->bd_mutex);
616 ret = -ENXIO; 616 ret = -ENXIO;
617 goto out_first; 617 goto out_first;
618 } 618 }
619 kobject_get(&p->kobj); 619 kobject_get(&p->kobj);
620 bdev->bd_part = p; 620 bdev->bd_part = p;
621 bd_set_size(bdev, (loff_t) p->nr_sects << 9); 621 bd_set_size(bdev, (loff_t) p->nr_sects << 9);
622 up(&whole->bd_sem); 622 mutex_unlock(&whole->bd_mutex);
623 } 623 }
624 } else { 624 } else {
625 put_disk(disk); 625 put_disk(disk);
@@ -633,13 +633,13 @@ static int do_open(struct block_device *bdev, struct file *file)
633 if (bdev->bd_invalidated) 633 if (bdev->bd_invalidated)
634 rescan_partitions(bdev->bd_disk, bdev); 634 rescan_partitions(bdev->bd_disk, bdev);
635 } else { 635 } else {
636 down(&bdev->bd_contains->bd_sem); 636 mutex_lock(&bdev->bd_contains->bd_mutex);
637 bdev->bd_contains->bd_part_count++; 637 bdev->bd_contains->bd_part_count++;
638 up(&bdev->bd_contains->bd_sem); 638 mutex_unlock(&bdev->bd_contains->bd_mutex);
639 } 639 }
640 } 640 }
641 bdev->bd_openers++; 641 bdev->bd_openers++;
642 up(&bdev->bd_sem); 642 mutex_unlock(&bdev->bd_mutex);
643 unlock_kernel(); 643 unlock_kernel();
644 return 0; 644 return 0;
645 645
@@ -652,7 +652,7 @@ out_first:
652 put_disk(disk); 652 put_disk(disk);
653 module_put(owner); 653 module_put(owner);
654out: 654out:
655 up(&bdev->bd_sem); 655 mutex_unlock(&bdev->bd_mutex);
656 unlock_kernel(); 656 unlock_kernel();
657 if (ret) 657 if (ret)
658 bdput(bdev); 658 bdput(bdev);
@@ -714,7 +714,7 @@ int blkdev_put(struct block_device *bdev)
714 struct inode *bd_inode = bdev->bd_inode; 714 struct inode *bd_inode = bdev->bd_inode;
715 struct gendisk *disk = bdev->bd_disk; 715 struct gendisk *disk = bdev->bd_disk;
716 716
717 down(&bdev->bd_sem); 717 mutex_lock(&bdev->bd_mutex);
718 lock_kernel(); 718 lock_kernel();
719 if (!--bdev->bd_openers) { 719 if (!--bdev->bd_openers) {
720 sync_blockdev(bdev); 720 sync_blockdev(bdev);
@@ -724,9 +724,9 @@ int blkdev_put(struct block_device *bdev)
724 if (disk->fops->release) 724 if (disk->fops->release)
725 ret = disk->fops->release(bd_inode, NULL); 725 ret = disk->fops->release(bd_inode, NULL);
726 } else { 726 } else {
727 down(&bdev->bd_contains->bd_sem); 727 mutex_lock(&bdev->bd_contains->bd_mutex);
728 bdev->bd_contains->bd_part_count--; 728 bdev->bd_contains->bd_part_count--;
729 up(&bdev->bd_contains->bd_sem); 729 mutex_unlock(&bdev->bd_contains->bd_mutex);
730 } 730 }
731 if (!bdev->bd_openers) { 731 if (!bdev->bd_openers) {
732 struct module *owner = disk->fops->owner; 732 struct module *owner = disk->fops->owner;
@@ -746,7 +746,7 @@ int blkdev_put(struct block_device *bdev)
746 bdev->bd_contains = NULL; 746 bdev->bd_contains = NULL;
747 } 747 }
748 unlock_kernel(); 748 unlock_kernel();
749 up(&bdev->bd_sem); 749 mutex_unlock(&bdev->bd_mutex);
750 bdput(bdev); 750 bdput(bdev);
751 return ret; 751 return ret;
752} 752}
diff --git a/fs/buffer.c b/fs/buffer.c
index 1d3683d496f8..0d6ca7bac6c8 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -201,7 +201,7 @@ int fsync_bdev(struct block_device *bdev)
201 * freeze_bdev -- lock a filesystem and force it into a consistent state 201 * freeze_bdev -- lock a filesystem and force it into a consistent state
202 * @bdev: blockdevice to lock 202 * @bdev: blockdevice to lock
203 * 203 *
204 * This takes the block device bd_mount_sem to make sure no new mounts 204 * This takes the block device bd_mount_mutex to make sure no new mounts
205 * happen on bdev until thaw_bdev() is called. 205 * happen on bdev until thaw_bdev() is called.
206 * If a superblock is found on this device, we take the s_umount semaphore 206 * If a superblock is found on this device, we take the s_umount semaphore
207 * on it to make sure nobody unmounts until the snapshot creation is done. 207 * on it to make sure nobody unmounts until the snapshot creation is done.
@@ -210,7 +210,7 @@ struct super_block *freeze_bdev(struct block_device *bdev)
210{ 210{
211 struct super_block *sb; 211 struct super_block *sb;
212 212
213 down(&bdev->bd_mount_sem); 213 mutex_lock(&bdev->bd_mount_mutex);
214 sb = get_super(bdev); 214 sb = get_super(bdev);
215 if (sb && !(sb->s_flags & MS_RDONLY)) { 215 if (sb && !(sb->s_flags & MS_RDONLY)) {
216 sb->s_frozen = SB_FREEZE_WRITE; 216 sb->s_frozen = SB_FREEZE_WRITE;
@@ -264,7 +264,7 @@ void thaw_bdev(struct block_device *bdev, struct super_block *sb)
264 drop_super(sb); 264 drop_super(sb);
265 } 265 }
266 266
267 up(&bdev->bd_mount_sem); 267 mutex_unlock(&bdev->bd_mount_mutex);
268} 268}
269EXPORT_SYMBOL(thaw_bdev); 269EXPORT_SYMBOL(thaw_bdev);
270 270
diff --git a/fs/super.c b/fs/super.c
index e20b5580afd5..8f9c9b3af70c 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -693,9 +693,9 @@ struct super_block *get_sb_bdev(struct file_system_type *fs_type,
693 * will protect the lockfs code from trying to start a snapshot 693 * will protect the lockfs code from trying to start a snapshot
694 * while we are mounting 694 * while we are mounting
695 */ 695 */
696 down(&bdev->bd_mount_sem); 696 mutex_lock(&bdev->bd_mount_mutex);
697 s = sget(fs_type, test_bdev_super, set_bdev_super, bdev); 697 s = sget(fs_type, test_bdev_super, set_bdev_super, bdev);
698 up(&bdev->bd_mount_sem); 698 mutex_unlock(&bdev->bd_mount_mutex);
699 if (IS_ERR(s)) 699 if (IS_ERR(s))
700 goto out; 700 goto out;
701 701
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 128d0082522c..009ac96053fe 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -397,8 +397,8 @@ struct block_device {
397 dev_t bd_dev; /* not a kdev_t - it's a search key */ 397 dev_t bd_dev; /* not a kdev_t - it's a search key */
398 struct inode * bd_inode; /* will die */ 398 struct inode * bd_inode; /* will die */
399 int bd_openers; 399 int bd_openers;
400 struct semaphore bd_sem; /* open/close mutex */ 400 struct mutex bd_mutex; /* open/close mutex */
401 struct semaphore bd_mount_sem; /* mount mutex */ 401 struct mutex bd_mount_mutex; /* mount mutex */
402 struct list_head bd_inodes; 402 struct list_head bd_inodes;
403 void * bd_holder; 403 void * bd_holder;
404 int bd_holders; 404 int bd_holders;