Commit 4862c886 authored by Kevin Wolf's avatar Kevin Wolf Committed by Mikulas Patocka
Browse files

dm: Allow .prepare_ioctl to handle ioctls directly



This adds a 'bool *forward' parameter to .prepare_ioctl, which allows
device mapper targets to accept ioctls to themselves instead of the
underlying device. If the target already fully handled the ioctl, it
sets *forward to false and device mapper won't forward it to the
underlying device any more.

In order for targets to actually know what the ioctl is about and how to
handle it, pass also cmd and arg.

As long as targets restrict themselves to interpreting ioctls of type
DM_IOCTL, this is a backwards compatible change because previously, any
such ioctl would have been passed down through all device mapper layers
until it reached a device that can't understand the ioctl and would
return an error.

Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Reviewed-by: default avatarBenjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
parent 13e79076
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -534,7 +534,9 @@ static void dust_status(struct dm_target *ti, status_type_t type,
	}
}

static int dust_prepare_ioctl(struct dm_target *ti, struct block_device **bdev)
static int dust_prepare_ioctl(struct dm_target *ti, struct block_device **bdev,
			      unsigned int cmd, unsigned long arg,
			      bool *forward)
{
	struct dust_device *dd = ti->private;
	struct dm_dev *dev = dd->dev;
+2 −1
Original line number Diff line number Diff line
@@ -415,7 +415,8 @@ static void ebs_status(struct dm_target *ti, status_type_t type,
	}
}

static int ebs_prepare_ioctl(struct dm_target *ti, struct block_device **bdev)
static int ebs_prepare_ioctl(struct dm_target *ti, struct block_device **bdev,
			     unsigned int cmd, unsigned long arg, bool *forward)
{
	struct ebs_c *ec = ti->private;
	struct dm_dev *dev = ec->dev;
+3 −1
Original line number Diff line number Diff line
@@ -648,7 +648,9 @@ static void flakey_status(struct dm_target *ti, status_type_t type,
	}
}

static int flakey_prepare_ioctl(struct dm_target *ti, struct block_device **bdev)
static int flakey_prepare_ioctl(struct dm_target *ti, struct block_device **bdev,
				unsigned int cmd, unsigned long arg,
				bool *forward)
{
	struct flakey_c *fc = ti->private;

+3 −1
Original line number Diff line number Diff line
@@ -119,7 +119,9 @@ static void linear_status(struct dm_target *ti, status_type_t type,
	}
}

static int linear_prepare_ioctl(struct dm_target *ti, struct block_device **bdev)
static int linear_prepare_ioctl(struct dm_target *ti, struct block_device **bdev,
				unsigned int cmd, unsigned long arg,
				bool *forward)
{
	struct linear_c *lc = ti->private;
	struct dm_dev *dev = lc->dev;
+3 −1
Original line number Diff line number Diff line
@@ -818,7 +818,9 @@ static void log_writes_status(struct dm_target *ti, status_type_t type,
}

static int log_writes_prepare_ioctl(struct dm_target *ti,
				    struct block_device **bdev)
				    struct block_device **bdev,
				    unsigned int cmd, unsigned long arg,
				    bool *forward)
{
	struct log_writes_c *lc = ti->private;
	struct dm_dev *dev = lc->dev;
Loading