diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2008-03-02 09:29:48 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2008-10-21 07:47:51 -0400 |
commit | bb21488482bd36eae6b30b014d93619063773fd4 (patch) | |
tree | 1d15cb67c966d1984349d344f18d142c293fa0f4 /drivers | |
parent | a4af9b48cb480f5016947bbd3f396c265c7cb368 (diff) |
[PATCH] switch loop
ioctl doesn't need BKL here
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/loop.c | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 6faca2b7ae37..67d7bc812364 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c | |||
@@ -652,8 +652,8 @@ static void do_loop_switch(struct loop_device *lo, struct switch_request *p) | |||
652 | * This can only work if the loop device is used read-only, and if the | 652 | * This can only work if the loop device is used read-only, and if the |
653 | * new backing store is the same size and type as the old backing store. | 653 | * new backing store is the same size and type as the old backing store. |
654 | */ | 654 | */ |
655 | static int loop_change_fd(struct loop_device *lo, struct file *lo_file, | 655 | static int loop_change_fd(struct loop_device *lo, struct block_device *bdev, |
656 | struct block_device *bdev, unsigned int arg) | 656 | unsigned int arg) |
657 | { | 657 | { |
658 | struct file *file, *old_file; | 658 | struct file *file, *old_file; |
659 | struct inode *inode; | 659 | struct inode *inode; |
@@ -712,7 +712,7 @@ static inline int is_loop_device(struct file *file) | |||
712 | return i && S_ISBLK(i->i_mode) && MAJOR(i->i_rdev) == LOOP_MAJOR; | 712 | return i && S_ISBLK(i->i_mode) && MAJOR(i->i_rdev) == LOOP_MAJOR; |
713 | } | 713 | } |
714 | 714 | ||
715 | static int loop_set_fd(struct loop_device *lo, struct file *lo_file, | 715 | static int loop_set_fd(struct loop_device *lo, fmode_t mode, |
716 | struct block_device *bdev, unsigned int arg) | 716 | struct block_device *bdev, unsigned int arg) |
717 | { | 717 | { |
718 | struct file *file, *f; | 718 | struct file *file, *f; |
@@ -740,7 +740,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file, | |||
740 | while (is_loop_device(f)) { | 740 | while (is_loop_device(f)) { |
741 | struct loop_device *l; | 741 | struct loop_device *l; |
742 | 742 | ||
743 | if (f->f_mapping->host->i_rdev == lo_file->f_mapping->host->i_rdev) | 743 | if (f->f_mapping->host->i_bdev == bdev) |
744 | goto out_putf; | 744 | goto out_putf; |
745 | 745 | ||
746 | l = f->f_mapping->host->i_bdev->bd_disk->private_data; | 746 | l = f->f_mapping->host->i_bdev->bd_disk->private_data; |
@@ -786,7 +786,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file, | |||
786 | goto out_putf; | 786 | goto out_putf; |
787 | } | 787 | } |
788 | 788 | ||
789 | if (!(lo_file->f_mode & FMODE_WRITE)) | 789 | if (!(mode & FMODE_WRITE)) |
790 | lo_flags |= LO_FLAGS_READ_ONLY; | 790 | lo_flags |= LO_FLAGS_READ_ONLY; |
791 | 791 | ||
792 | set_device_ro(bdev, (lo_flags & LO_FLAGS_READ_ONLY) != 0); | 792 | set_device_ro(bdev, (lo_flags & LO_FLAGS_READ_ONLY) != 0); |
@@ -918,9 +918,11 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev) | |||
918 | memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE); | 918 | memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE); |
919 | memset(lo->lo_crypt_name, 0, LO_NAME_SIZE); | 919 | memset(lo->lo_crypt_name, 0, LO_NAME_SIZE); |
920 | memset(lo->lo_file_name, 0, LO_NAME_SIZE); | 920 | memset(lo->lo_file_name, 0, LO_NAME_SIZE); |
921 | invalidate_bdev(bdev); | 921 | if (bdev) |
922 | invalidate_bdev(bdev); | ||
922 | set_capacity(lo->lo_disk, 0); | 923 | set_capacity(lo->lo_disk, 0); |
923 | bd_set_size(bdev, 0); | 924 | if (bdev) |
925 | bd_set_size(bdev, 0); | ||
924 | mapping_set_gfp_mask(filp->f_mapping, gfp); | 926 | mapping_set_gfp_mask(filp->f_mapping, gfp); |
925 | lo->lo_state = Lo_unbound; | 927 | lo->lo_state = Lo_unbound; |
926 | fput(filp); | 928 | fput(filp); |
@@ -1137,22 +1139,22 @@ loop_get_status64(struct loop_device *lo, struct loop_info64 __user *arg) { | |||
1137 | return err; | 1139 | return err; |
1138 | } | 1140 | } |
1139 | 1141 | ||
1140 | static int lo_ioctl(struct inode * inode, struct file * file, | 1142 | static int lo_ioctl(struct block_device *bdev, fmode_t mode, |
1141 | unsigned int cmd, unsigned long arg) | 1143 | unsigned int cmd, unsigned long arg) |
1142 | { | 1144 | { |
1143 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; | 1145 | struct loop_device *lo = bdev->bd_disk->private_data; |
1144 | int err; | 1146 | int err; |
1145 | 1147 | ||
1146 | mutex_lock(&lo->lo_ctl_mutex); | 1148 | mutex_lock(&lo->lo_ctl_mutex); |
1147 | switch (cmd) { | 1149 | switch (cmd) { |
1148 | case LOOP_SET_FD: | 1150 | case LOOP_SET_FD: |
1149 | err = loop_set_fd(lo, file, inode->i_bdev, arg); | 1151 | err = loop_set_fd(lo, mode, bdev, arg); |
1150 | break; | 1152 | break; |
1151 | case LOOP_CHANGE_FD: | 1153 | case LOOP_CHANGE_FD: |
1152 | err = loop_change_fd(lo, file, inode->i_bdev, arg); | 1154 | err = loop_change_fd(lo, bdev, arg); |
1153 | break; | 1155 | break; |
1154 | case LOOP_CLR_FD: | 1156 | case LOOP_CLR_FD: |
1155 | err = loop_clr_fd(lo, inode->i_bdev); | 1157 | err = loop_clr_fd(lo, bdev); |
1156 | break; | 1158 | break; |
1157 | case LOOP_SET_STATUS: | 1159 | case LOOP_SET_STATUS: |
1158 | err = loop_set_status_old(lo, (struct loop_info __user *) arg); | 1160 | err = loop_set_status_old(lo, (struct loop_info __user *) arg); |
@@ -1292,10 +1294,10 @@ loop_get_status_compat(struct loop_device *lo, | |||
1292 | return err; | 1294 | return err; |
1293 | } | 1295 | } |
1294 | 1296 | ||
1295 | static long lo_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 1297 | static int lo_compat_ioctl(struct block_device *bdev, fmode_t mode, |
1298 | unsigned int cmd, unsigned long arg) | ||
1296 | { | 1299 | { |
1297 | struct inode *inode = file->f_path.dentry->d_inode; | 1300 | struct loop_device *lo = bdev->bd_disk->private_data; |
1298 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; | ||
1299 | int err; | 1301 | int err; |
1300 | 1302 | ||
1301 | switch(cmd) { | 1303 | switch(cmd) { |
@@ -1317,7 +1319,7 @@ static long lo_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a | |||
1317 | arg = (unsigned long) compat_ptr(arg); | 1319 | arg = (unsigned long) compat_ptr(arg); |
1318 | case LOOP_SET_FD: | 1320 | case LOOP_SET_FD: |
1319 | case LOOP_CHANGE_FD: | 1321 | case LOOP_CHANGE_FD: |
1320 | err = lo_ioctl(inode, file, cmd, arg); | 1322 | err = lo_ioctl(bdev, mode, cmd, arg); |
1321 | break; | 1323 | break; |
1322 | default: | 1324 | default: |
1323 | err = -ENOIOCTLCMD; | 1325 | err = -ENOIOCTLCMD; |
@@ -1327,9 +1329,9 @@ static long lo_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a | |||
1327 | } | 1329 | } |
1328 | #endif | 1330 | #endif |
1329 | 1331 | ||
1330 | static int lo_open(struct inode *inode, struct file *file) | 1332 | static int lo_open(struct block_device *bdev, fmode_t mode) |
1331 | { | 1333 | { |
1332 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; | 1334 | struct loop_device *lo = bdev->bd_disk->private_data; |
1333 | 1335 | ||
1334 | mutex_lock(&lo->lo_ctl_mutex); | 1336 | mutex_lock(&lo->lo_ctl_mutex); |
1335 | lo->lo_refcnt++; | 1337 | lo->lo_refcnt++; |
@@ -1338,15 +1340,15 @@ static int lo_open(struct inode *inode, struct file *file) | |||
1338 | return 0; | 1340 | return 0; |
1339 | } | 1341 | } |
1340 | 1342 | ||
1341 | static int lo_release(struct inode *inode, struct file *file) | 1343 | static int lo_release(struct gendisk *disk, fmode_t mode) |
1342 | { | 1344 | { |
1343 | struct loop_device *lo = inode->i_bdev->bd_disk->private_data; | 1345 | struct loop_device *lo = disk->private_data; |
1344 | 1346 | ||
1345 | mutex_lock(&lo->lo_ctl_mutex); | 1347 | mutex_lock(&lo->lo_ctl_mutex); |
1346 | --lo->lo_refcnt; | 1348 | --lo->lo_refcnt; |
1347 | 1349 | ||
1348 | if ((lo->lo_flags & LO_FLAGS_AUTOCLEAR) && !lo->lo_refcnt) | 1350 | if ((lo->lo_flags & LO_FLAGS_AUTOCLEAR) && !lo->lo_refcnt) |
1349 | loop_clr_fd(lo, inode->i_bdev); | 1351 | loop_clr_fd(lo, NULL); |
1350 | 1352 | ||
1351 | mutex_unlock(&lo->lo_ctl_mutex); | 1353 | mutex_unlock(&lo->lo_ctl_mutex); |
1352 | 1354 | ||
@@ -1355,11 +1357,11 @@ static int lo_release(struct inode *inode, struct file *file) | |||
1355 | 1357 | ||
1356 | static struct block_device_operations lo_fops = { | 1358 | static struct block_device_operations lo_fops = { |
1357 | .owner = THIS_MODULE, | 1359 | .owner = THIS_MODULE, |
1358 | .__open = lo_open, | 1360 | .open = lo_open, |
1359 | .__release = lo_release, | 1361 | .release = lo_release, |
1360 | .__ioctl = lo_ioctl, | 1362 | .ioctl = lo_ioctl, |
1361 | #ifdef CONFIG_COMPAT | 1363 | #ifdef CONFIG_COMPAT |
1362 | .__compat_ioctl = lo_compat_ioctl, | 1364 | .compat_ioctl = lo_compat_ioctl, |
1363 | #endif | 1365 | #endif |
1364 | }; | 1366 | }; |
1365 | 1367 | ||