Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] kill the rest of struct file propagation in block ioctls

Now we can switch blkdev_ioctl() block_device/mode

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by

Al Viro and committed by
Al Viro
56b26add 6af3a56e

+14 -17
+5 -5
block/compat_ioctl.c
··· 177 177 compat_caddr_t data; 178 178 }; 179 179 180 - static int compat_blkpg_ioctl(struct inode *inode, struct file *file, 180 + static int compat_blkpg_ioctl(struct block_device *bdev, fmode_t mode, 181 181 unsigned int cmd, struct compat_blkpg_ioctl_arg __user *ua32) 182 182 { 183 183 struct blkpg_ioctl_arg __user *a = compat_alloc_user_space(sizeof(*a)); ··· 196 196 if (err) 197 197 return err; 198 198 199 - return blkdev_ioctl(inode, file, cmd, (unsigned long)a); 199 + return blkdev_ioctl(bdev, mode, cmd, (unsigned long)a); 200 200 } 201 201 202 202 #define BLKBSZGET_32 _IOR(0x12, 112, int) ··· 715 715 * but we call blkdev_ioctl, which gets the lock for us 716 716 */ 717 717 case BLKRRPART: 718 - return blkdev_ioctl(inode, file, cmd, 718 + return blkdev_ioctl(bdev, mode, cmd, 719 719 (unsigned long)compat_ptr(arg)); 720 720 case BLKBSZSET_32: 721 - return blkdev_ioctl(inode, file, BLKBSZSET, 721 + return blkdev_ioctl(bdev, mode, BLKBSZSET, 722 722 (unsigned long)compat_ptr(arg)); 723 723 case BLKPG: 724 - return compat_blkpg_ioctl(inode, file, cmd, compat_ptr(arg)); 724 + return compat_blkpg_ioctl(bdev, mode, cmd, compat_ptr(arg)); 725 725 case BLKRAGET: 726 726 case BLKFRAGET: 727 727 if (!arg)
+1 -8
block/ioctl.c
··· 230 230 * always keep this in sync with compat_blkdev_ioctl() and 231 231 * compat_blkdev_locked_ioctl() 232 232 */ 233 - int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd, 233 + int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, 234 234 unsigned long arg) 235 235 { 236 - struct block_device *bdev = inode->i_bdev; 237 236 struct gendisk *disk = bdev->bd_disk; 238 237 struct backing_dev_info *bdi; 239 238 loff_t size; 240 239 int ret, n; 241 - fmode_t mode = 0; 242 - if (file) { 243 - mode = file->f_mode; 244 - if (file->f_flags & O_NDELAY) 245 - mode |= FMODE_NDELAY_NOW; 246 - } 247 240 248 241 switch(cmd) { 249 242 case BLKFLSBUF:
+1 -1
drivers/char/raw.c
··· 125 125 { 126 126 struct block_device *bdev = filp->private_data; 127 127 128 - return blkdev_ioctl(bdev->bd_inode, NULL, command, arg); 128 + return blkdev_ioctl(bdev, 0, command, arg); 129 129 } 130 130 131 131 static void bind_device(struct raw_config_request *rq)
+6 -2
fs/block_dev.c
··· 1202 1202 1203 1203 static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg) 1204 1204 { 1205 - return blkdev_ioctl(file->f_mapping->host, file, cmd, arg); 1205 + struct block_device *bdev = I_BDEV(file->f_mapping->host); 1206 + fmode_t mode = file->f_mode; 1207 + if (file->f_flags & O_NDELAY) 1208 + mode |= FMODE_NDELAY_NOW; 1209 + return blkdev_ioctl(bdev, mode, cmd, arg); 1206 1210 } 1207 1211 1208 1212 static const struct address_space_operations def_blk_aops = { ··· 1242 1238 int res; 1243 1239 mm_segment_t old_fs = get_fs(); 1244 1240 set_fs(KERNEL_DS); 1245 - res = blkdev_ioctl(bdev->bd_inode, NULL, cmd, arg); 1241 + res = blkdev_ioctl(bdev, 0, cmd, arg); 1246 1242 set_fs(old_fs); 1247 1243 return res; 1248 1244 }
+1 -1
include/linux/fs.h
··· 1717 1717 extern const struct file_operations def_fifo_fops; 1718 1718 #ifdef CONFIG_BLOCK 1719 1719 extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long); 1720 - extern int blkdev_ioctl(struct inode *, struct file *, unsigned, unsigned long); 1720 + extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long); 1721 1721 extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long); 1722 1722 extern int blkdev_get(struct block_device *, fmode_t); 1723 1723 extern int blkdev_put(struct block_device *, fmode_t);