* small block layer ioctl cleanups
@ 2021-10-12 10:44 Christoph Hellwig
2021-10-12 10:44 ` [PATCH 1/3] block: unexport blkdev_ioctl Christoph Hellwig
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Christoph Hellwig @ 2021-10-12 10:44 UTC (permalink / raw)
To: axboe; +Cc: linux-block
Hi Jens,
this series cleans up a few minors bits in the ioctl path.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] block: unexport blkdev_ioctl
2021-10-12 10:44 small block layer ioctl cleanups Christoph Hellwig
@ 2021-10-12 10:44 ` Christoph Hellwig
2021-10-12 10:44 ` [PATCH 2/3] block: move the *blkdev_ioctl declarations out of blkdev.h Christoph Hellwig
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2021-10-12 10:44 UTC (permalink / raw)
To: axboe; +Cc: linux-block
With the raw driver gone, there is no modular user left.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/ioctl.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/block/ioctl.c b/block/ioctl.c
index eb0491e90b9a0..0f823444cc557 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -588,7 +588,6 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
return -ENOTTY;
return bdev->bd_disk->fops->ioctl(bdev, mode, cmd, arg);
}
-EXPORT_SYMBOL_GPL(blkdev_ioctl); /* for /dev/raw */
#ifdef CONFIG_COMPAT
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] block: move the *blkdev_ioctl declarations out of blkdev.h
2021-10-12 10:44 small block layer ioctl cleanups Christoph Hellwig
2021-10-12 10:44 ` [PATCH 1/3] block: unexport blkdev_ioctl Christoph Hellwig
@ 2021-10-12 10:44 ` Christoph Hellwig
2021-10-12 10:44 ` [PATCH 3/3] block: merge block_ioctl into blkdev_ioctl Christoph Hellwig
2021-10-12 14:54 ` small block layer ioctl cleanups Jens Axboe
3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2021-10-12 10:44 UTC (permalink / raw)
To: axboe; +Cc: linux-block
These are only used inside of block/.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk.h | 4 ++++
include/linux/genhd.h | 4 ----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/blk.h b/block/blk.h
index 38867b4c5c7ed..bca4ba1a1f8dd 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -403,6 +403,10 @@ static inline void bio_clear_hipri(struct bio *bio)
bio->bi_opf &= ~REQ_HIPRI;
}
+int blkdev_ioctl(struct block_device *bdev, fmode_t mode, 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;
#endif /* BLK_INTERNAL_H */
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index c1639c16b74c3..082a3e5fd8fa1 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -280,10 +280,6 @@ bool bdev_check_media_change(struct block_device *bdev);
int __invalidate_device(struct block_device *bdev, bool kill_dirty);
void set_capacity(struct gendisk *disk, sector_t size);
-/* for drivers/char/raw.c: */
-int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long);
-long compat_blkdev_ioctl(struct file *, unsigned, unsigned long);
-
#ifdef CONFIG_BLOCK_HOLDER_DEPRECATED
int bd_link_disk_holder(struct block_device *bdev, struct gendisk *disk);
void bd_unlink_disk_holder(struct block_device *bdev, struct gendisk *disk);
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] block: merge block_ioctl into blkdev_ioctl
2021-10-12 10:44 small block layer ioctl cleanups Christoph Hellwig
2021-10-12 10:44 ` [PATCH 1/3] block: unexport blkdev_ioctl Christoph Hellwig
2021-10-12 10:44 ` [PATCH 2/3] block: move the *blkdev_ioctl declarations out of blkdev.h Christoph Hellwig
@ 2021-10-12 10:44 ` Christoph Hellwig
2021-10-12 14:54 ` small block layer ioctl cleanups Jens Axboe
3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2021-10-12 10:44 UTC (permalink / raw)
To: axboe; +Cc: linux-block
Simplify the ioctl path and match the code structure on the compat side.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk.h | 3 +--
block/fops.c | 19 +------------------
block/ioctl.c | 18 ++++++++++++++----
3 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/block/blk.h b/block/blk.h
index bca4ba1a1f8dd..35ca73355f90c 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -403,8 +403,7 @@ static inline void bio_clear_hipri(struct bio *bio)
bio->bi_opf &= ~REQ_HIPRI;
}
-int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
- unsigned long arg);
+long 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;
diff --git a/block/fops.c b/block/fops.c
index 1e970c247e0eb..7bb9581a146cf 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -461,23 +461,6 @@ static int blkdev_close(struct inode *inode, struct file *filp)
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
* and the raw driver which basically is a fake block device.
@@ -621,7 +604,7 @@ const struct file_operations def_blk_fops = {
.iopoll = blkdev_iopoll,
.mmap = generic_file_mmap,
.fsync = blkdev_fsync,
- .unlocked_ioctl = block_ioctl,
+ .unlocked_ioctl = blkdev_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = compat_blkdev_ioctl,
#endif
diff --git a/block/ioctl.c b/block/ioctl.c
index 0f823444cc557..77b1b2453f395 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -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
*/
-int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
- unsigned long arg)
+long blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
{
- int ret;
- loff_t size;
+ struct block_device *bdev = I_BDEV(file->f_mapping->host);
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) {
/* These need separate implementations for the data structure */
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: small block layer ioctl cleanups
2021-10-12 10:44 small block layer ioctl cleanups Christoph Hellwig
` (2 preceding siblings ...)
2021-10-12 10:44 ` [PATCH 3/3] block: merge block_ioctl into blkdev_ioctl Christoph Hellwig
@ 2021-10-12 14:54 ` Jens Axboe
3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2021-10-12 14:54 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-block
On 10/12/21 4:44 AM, Christoph Hellwig wrote:
> Hi Jens,
>
> this series cleans up a few minors bits in the ioctl path.
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-10-12 14:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12 10:44 small block layer ioctl cleanups Christoph Hellwig
2021-10-12 10:44 ` [PATCH 1/3] block: unexport blkdev_ioctl Christoph Hellwig
2021-10-12 10:44 ` [PATCH 2/3] block: move the *blkdev_ioctl declarations out of blkdev.h Christoph Hellwig
2021-10-12 10:44 ` [PATCH 3/3] block: merge block_ioctl into blkdev_ioctl Christoph Hellwig
2021-10-12 14:54 ` small block layer ioctl cleanups Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).