diff options
-rw-r--r-- | drivers/md/dm-linear.c | 10 | ||||
-rw-r--r-- | drivers/md/dm-mpath.c | 6 |
2 files changed, 15 insertions, 1 deletions
diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index 6449bcdf84c..14417baea44 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c @@ -118,12 +118,20 @@ static int linear_ioctl(struct dm_target *ti, struct inode *inode, struct block_device *bdev = lc->dev->bdev; struct file fake_file = {}; struct dentry fake_dentry = {}; + int r = 0; fake_file.f_mode = lc->dev->mode; fake_file.f_path.dentry = &fake_dentry; fake_dentry.d_inode = bdev->bd_inode; - return blkdev_driver_ioctl(bdev->bd_inode, &fake_file, bdev->bd_disk, cmd, arg); + /* + * Only pass ioctls through if the device sizes match exactly. + */ + if (lc->start || + ti->len != i_size_read(bdev->bd_inode) >> SECTOR_SHIFT) + r = scsi_verify_blk_ioctl(NULL, cmd); + + return r ? : blkdev_driver_ioctl(bdev->bd_inode, &fake_file, bdev->bd_disk, cmd, arg); } static int linear_merge(struct dm_target *ti, struct bvec_merge_data *bvm, diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index 7830b01ca58..088cf5c1d54 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c @@ -1421,6 +1421,12 @@ static int multipath_ioctl(struct dm_target *ti, struct inode *inode, spin_unlock_irqrestore(&m->lock, flags); + /* + * Only pass ioctls through if the device sizes match exactly. + */ + if (!r && ti->len != i_size_read(bdev->bd_inode) >> SECTOR_SHIFT) + r = scsi_verify_blk_ioctl(NULL, cmd); + return r ? : blkdev_driver_ioctl(bdev->bd_inode, &fake_file, bdev->bd_disk, cmd, arg); } |