diff mbox

nbd: ignore non-nbd ioctl's

Message ID 1494037518-31903-1-git-send-email-jbacik@fb.com (mailing list archive)
State New, archived
Headers show

Commit Message

Josef Bacik May 6, 2017, 2:25 a.m. UTC
In testing we noticed that nbd would spew if you ran a fio job against
the raw device itself.  This is because fio calls a block device
specific ioctl, however the block layer will first pass this back to the
driver ioctl handler in case the driver wants to do something special.
Since the device was setup using netlink this caused us to spew every
time fio called this ioctl.  Since we don't have special handling, just
error out for any non-nbd specific ioctl's that come in.  This fixes the
spew.

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 drivers/block/nbd.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Josef Bacik Sept. 20, 2017, 2:38 p.m. UTC | #1
On Fri, May 05, 2017 at 10:25:18PM -0400, Josef Bacik wrote:
> In testing we noticed that nbd would spew if you ran a fio job against
> the raw device itself.  This is because fio calls a block device
> specific ioctl, however the block layer will first pass this back to the
> driver ioctl handler in case the driver wants to do something special.
> Since the device was setup using netlink this caused us to spew every
> time fio called this ioctl.  Since we don't have special handling, just
> error out for any non-nbd specific ioctl's that come in.  This fixes the
> spew.
> 
> Signed-off-by: Josef Bacik <jbacik@fb.com>

Jens,

This fell through the cracks, could you pick it up, thanks,

Josef
Jens Axboe Sept. 20, 2017, 3:49 p.m. UTC | #2
On 09/20/2017 08:38 AM, Josef Bacik wrote:
> On Fri, May 05, 2017 at 10:25:18PM -0400, Josef Bacik wrote:
>> In testing we noticed that nbd would spew if you ran a fio job against
>> the raw device itself.  This is because fio calls a block device
>> specific ioctl, however the block layer will first pass this back to the
>> driver ioctl handler in case the driver wants to do something special.
>> Since the device was setup using netlink this caused us to spew every
>> time fio called this ioctl.  Since we don't have special handling, just
>> error out for any non-nbd specific ioctl's that come in.  This fixes the
>> spew.
>>
>> Signed-off-by: Josef Bacik <jbacik@fb.com>
> 
> Jens,
> 
> This fell through the cracks, could you pick it up, thanks,

Sure, applied.
diff mbox

Patch

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index e9e2a9e..02dd9b0 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1185,6 +1185,12 @@  static int nbd_ioctl(struct block_device *bdev, fmode_t mode,
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
+	/* The block layer will pass back some non-nbd ioctls in case we have
+	 * special handling for them, but we don't so just return an error.
+	 */
+	if (_IOC_TYPE(cmd) != 0xab)
+		return -EINVAL;
+
 	mutex_lock(&nbd->config_lock);
 
 	/* Don't allow ioctl operations on a nbd device that was created with