diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-01-12 10:01:29 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-14 18:07:24 -0500 |
commit | ec8013beddd717d1740cfefb1a9b900deef85462 (patch) | |
tree | 7aa28de51cb2f375baf6fe943afd85e75ca7bcb9 /drivers/md | |
parent | 0bfc96cb77224736dfa35c3c555d37b3646ef35e (diff) |
dm: do not forward ioctls from logical volumes to the underlying device
A logical volume can map to just part of underlying physical volume.
In this case, it must be treated like a partition.
Based on a patch from Alasdair G Kergon.
Cc: Alasdair G Kergon <agk@redhat.com>
Cc: dm-devel@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/dm-flakey.c | 11 | ||||
-rw-r--r-- | drivers/md/dm-linear.c | 12 | ||||
-rw-r--r-- | drivers/md/dm-mpath.c | 6 |
3 files changed, 27 insertions, 2 deletions
diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c index f84c08029b21..9fb18c147825 100644 --- a/drivers/md/dm-flakey.c +++ b/drivers/md/dm-flakey.c | |||
@@ -368,8 +368,17 @@ static int flakey_status(struct dm_target *ti, status_type_t type, | |||
368 | static int flakey_ioctl(struct dm_target *ti, unsigned int cmd, unsigned long arg) | 368 | static int flakey_ioctl(struct dm_target *ti, unsigned int cmd, unsigned long arg) |
369 | { | 369 | { |
370 | struct flakey_c *fc = ti->private; | 370 | struct flakey_c *fc = ti->private; |
371 | struct dm_dev *dev = fc->dev; | ||
372 | int r = 0; | ||
371 | 373 | ||
372 | return __blkdev_driver_ioctl(fc->dev->bdev, fc->dev->mode, cmd, arg); | 374 | /* |
375 | * Only pass ioctls through if the device sizes match exactly. | ||
376 | */ | ||
377 | if (fc->start || | ||
378 | ti->len != i_size_read(dev->bdev->bd_inode) >> SECTOR_SHIFT) | ||
379 | r = scsi_verify_blk_ioctl(NULL, cmd); | ||
380 | |||
381 | return r ? : __blkdev_driver_ioctl(dev->bdev, dev->mode, cmd, arg); | ||
373 | } | 382 | } |
374 | 383 | ||
375 | static int flakey_merge(struct dm_target *ti, struct bvec_merge_data *bvm, | 384 | static int flakey_merge(struct dm_target *ti, struct bvec_merge_data *bvm, |
diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index 3921e3bb43c1..9728839f844a 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c | |||
@@ -116,7 +116,17 @@ static int linear_ioctl(struct dm_target *ti, unsigned int cmd, | |||
116 | unsigned long arg) | 116 | unsigned long arg) |
117 | { | 117 | { |
118 | struct linear_c *lc = (struct linear_c *) ti->private; | 118 | struct linear_c *lc = (struct linear_c *) ti->private; |
119 | return __blkdev_driver_ioctl(lc->dev->bdev, lc->dev->mode, cmd, arg); | 119 | struct dm_dev *dev = lc->dev; |
120 | int r = 0; | ||
121 | |||
122 | /* | ||
123 | * Only pass ioctls through if the device sizes match exactly. | ||
124 | */ | ||
125 | if (lc->start || | ||
126 | ti->len != i_size_read(dev->bdev->bd_inode) >> SECTOR_SHIFT) | ||
127 | r = scsi_verify_blk_ioctl(NULL, cmd); | ||
128 | |||
129 | return r ? : __blkdev_driver_ioctl(dev->bdev, dev->mode, cmd, arg); | ||
120 | } | 130 | } |
121 | 131 | ||
122 | static int linear_merge(struct dm_target *ti, struct bvec_merge_data *bvm, | 132 | 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 5e0090ef4182..801d92d237cf 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c | |||
@@ -1520,6 +1520,12 @@ static int multipath_ioctl(struct dm_target *ti, unsigned int cmd, | |||
1520 | 1520 | ||
1521 | spin_unlock_irqrestore(&m->lock, flags); | 1521 | spin_unlock_irqrestore(&m->lock, flags); |
1522 | 1522 | ||
1523 | /* | ||
1524 | * Only pass ioctls through if the device sizes match exactly. | ||
1525 | */ | ||
1526 | if (!r && ti->len != i_size_read(bdev->bd_inode) >> SECTOR_SHIFT) | ||
1527 | r = scsi_verify_blk_ioctl(NULL, cmd); | ||
1528 | |||
1523 | return r ? : __blkdev_driver_ioctl(bdev, mode, cmd, arg); | 1529 | return r ? : __blkdev_driver_ioctl(bdev, mode, cmd, arg); |
1524 | } | 1530 | } |
1525 | 1531 | ||