Commit 8a709512 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: merge block_ioctl into blkdev_ioctl

Simplify the ioctl path and match the code structure on the compat side.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20211012104450.659013-4-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 84b8514b
...@@ -405,8 +405,7 @@ static inline void bio_clear_hipri(struct bio *bio) ...@@ -405,8 +405,7 @@ static inline void bio_clear_hipri(struct bio *bio)
bio->bi_opf &= ~REQ_HIPRI; bio->bi_opf &= ~REQ_HIPRI;
} }
int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, long blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg);
unsigned long arg);
long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg); long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg);
extern const struct address_space_operations def_blk_aops; extern const struct address_space_operations def_blk_aops;
......
...@@ -461,23 +461,6 @@ static int blkdev_close(struct inode *inode, struct file *filp) ...@@ -461,23 +461,6 @@ static int blkdev_close(struct inode *inode, struct file *filp)
return 0; return 0;
} }
static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg)
{
struct block_device *bdev = I_BDEV(bdev_file_inode(file));
fmode_t mode = file->f_mode;
/*
* O_NDELAY can be altered using fcntl(.., F_SETFL, ..), so we have
* to updated it before every ioctl.
*/
if (file->f_flags & O_NDELAY)
mode |= FMODE_NDELAY;
else
mode &= ~FMODE_NDELAY;
return blkdev_ioctl(bdev, mode, cmd, arg);
}
/* /*
* Write data to the block device. Only intended for the block device itself * Write data to the block device. Only intended for the block device itself
* and the raw driver which basically is a fake block device. * and the raw driver which basically is a fake block device.
...@@ -621,7 +604,7 @@ const struct file_operations def_blk_fops = { ...@@ -621,7 +604,7 @@ const struct file_operations def_blk_fops = {
.iopoll = blkdev_iopoll, .iopoll = blkdev_iopoll,
.mmap = generic_file_mmap, .mmap = generic_file_mmap,
.fsync = blkdev_fsync, .fsync = blkdev_fsync,
.unlocked_ioctl = block_ioctl, .unlocked_ioctl = blkdev_ioctl,
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
.compat_ioctl = compat_blkdev_ioctl, .compat_ioctl = compat_blkdev_ioctl,
#endif #endif
......
...@@ -538,12 +538,22 @@ static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode, ...@@ -538,12 +538,22 @@ static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode,
* *
* New commands must be compatible and go into blkdev_common_ioctl * New commands must be compatible and go into blkdev_common_ioctl
*/ */
int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, long blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
unsigned long arg)
{ {
int ret; struct block_device *bdev = I_BDEV(file->f_mapping->host);
loff_t size;
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
fmode_t mode = file->f_mode;
loff_t size;
int ret;
/*
* O_NDELAY can be altered using fcntl(.., F_SETFL, ..), so we have
* to updated it before every ioctl.
*/
if (file->f_flags & O_NDELAY)
mode |= FMODE_NDELAY;
else
mode &= ~FMODE_NDELAY;
switch (cmd) { switch (cmd) {
/* These need separate implementations for the data structure */ /* These need separate implementations for the data structure */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment