diff options
| -rw-r--r-- | drivers/md/dm.c | 41 | ||||
| -rw-r--r-- | include/linux/device-mapper.h | 5 | ||||
| -rw-r--r-- | include/linux/dm-ioctl.h | 2 |
3 files changed, 47 insertions, 1 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index c99bf9f01759..5792686936c1 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/idr.h> | 20 | #include <linux/idr.h> |
| 21 | #include <linux/hdreg.h> | 21 | #include <linux/hdreg.h> |
| 22 | #include <linux/blktrace_api.h> | 22 | #include <linux/blktrace_api.h> |
| 23 | #include <linux/smp_lock.h> | ||
| 23 | 24 | ||
| 24 | #define DM_MSG_PREFIX "core" | 25 | #define DM_MSG_PREFIX "core" |
| 25 | 26 | ||
| @@ -288,6 +289,45 @@ static int dm_blk_getgeo(struct block_device *bdev, struct hd_geometry *geo) | |||
| 288 | return dm_get_geometry(md, geo); | 289 | return dm_get_geometry(md, geo); |
| 289 | } | 290 | } |
| 290 | 291 | ||
| 292 | static int dm_blk_ioctl(struct inode *inode, struct file *file, | ||
| 293 | unsigned int cmd, unsigned long arg) | ||
| 294 | { | ||
| 295 | struct mapped_device *md; | ||
| 296 | struct dm_table *map; | ||
| 297 | struct dm_target *tgt; | ||
| 298 | int r = -ENOTTY; | ||
| 299 | |||
| 300 | /* We don't really need this lock, but we do need 'inode'. */ | ||
| 301 | unlock_kernel(); | ||
| 302 | |||
| 303 | md = inode->i_bdev->bd_disk->private_data; | ||
| 304 | |||
| 305 | map = dm_get_table(md); | ||
| 306 | |||
| 307 | if (!map || !dm_table_get_size(map)) | ||
| 308 | goto out; | ||
| 309 | |||
| 310 | /* We only support devices that have a single target */ | ||
| 311 | if (dm_table_get_num_targets(map) != 1) | ||
| 312 | goto out; | ||
| 313 | |||
| 314 | tgt = dm_table_get_target(map, 0); | ||
| 315 | |||
| 316 | if (dm_suspended(md)) { | ||
| 317 | r = -EAGAIN; | ||
| 318 | goto out; | ||
| 319 | } | ||
| 320 | |||
| 321 | if (tgt->type->ioctl) | ||
| 322 | r = tgt->type->ioctl(tgt, inode, file, cmd, arg); | ||
| 323 | |||
| 324 | out: | ||
| 325 | dm_table_put(map); | ||
| 326 | |||
| 327 | lock_kernel(); | ||
| 328 | return r; | ||
| 329 | } | ||
| 330 | |||
| 291 | static inline struct dm_io *alloc_io(struct mapped_device *md) | 331 | static inline struct dm_io *alloc_io(struct mapped_device *md) |
| 292 | { | 332 | { |
| 293 | return mempool_alloc(md->io_pool, GFP_NOIO); | 333 | return mempool_alloc(md->io_pool, GFP_NOIO); |
| @@ -1377,6 +1417,7 @@ int dm_suspended(struct mapped_device *md) | |||
| 1377 | static struct block_device_operations dm_blk_dops = { | 1417 | static struct block_device_operations dm_blk_dops = { |
| 1378 | .open = dm_blk_open, | 1418 | .open = dm_blk_open, |
| 1379 | .release = dm_blk_close, | 1419 | .release = dm_blk_close, |
| 1420 | .ioctl = dm_blk_ioctl, | ||
| 1380 | .getgeo = dm_blk_getgeo, | 1421 | .getgeo = dm_blk_getgeo, |
| 1381 | .owner = THIS_MODULE | 1422 | .owner = THIS_MODULE |
| 1382 | }; | 1423 | }; |
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index e3d1c33d1558..d44a99650af3 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h | |||
| @@ -64,6 +64,10 @@ typedef int (*dm_status_fn) (struct dm_target *ti, status_type_t status_type, | |||
| 64 | 64 | ||
| 65 | typedef int (*dm_message_fn) (struct dm_target *ti, unsigned argc, char **argv); | 65 | typedef int (*dm_message_fn) (struct dm_target *ti, unsigned argc, char **argv); |
| 66 | 66 | ||
| 67 | typedef int (*dm_ioctl_fn) (struct dm_target *ti, struct inode *inode, | ||
| 68 | struct file *filp, unsigned int cmd, | ||
| 69 | unsigned long arg); | ||
| 70 | |||
| 67 | void dm_error(const char *message); | 71 | void dm_error(const char *message); |
| 68 | 72 | ||
| 69 | /* | 73 | /* |
| @@ -91,6 +95,7 @@ struct target_type { | |||
| 91 | dm_resume_fn resume; | 95 | dm_resume_fn resume; |
| 92 | dm_status_fn status; | 96 | dm_status_fn status; |
| 93 | dm_message_fn message; | 97 | dm_message_fn message; |
| 98 | dm_ioctl_fn ioctl; | ||
| 94 | }; | 99 | }; |
| 95 | 100 | ||
| 96 | struct io_restrictions { | 101 | struct io_restrictions { |
diff --git a/include/linux/dm-ioctl.h b/include/linux/dm-ioctl.h index 9623bb625090..b349b768df35 100644 --- a/include/linux/dm-ioctl.h +++ b/include/linux/dm-ioctl.h | |||
| @@ -285,7 +285,7 @@ typedef char ioctl_struct[308]; | |||
| 285 | #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) | 285 | #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) |
| 286 | 286 | ||
| 287 | #define DM_VERSION_MAJOR 4 | 287 | #define DM_VERSION_MAJOR 4 |
| 288 | #define DM_VERSION_MINOR 7 | 288 | #define DM_VERSION_MINOR 8 |
| 289 | #define DM_VERSION_PATCHLEVEL 0 | 289 | #define DM_VERSION_PATCHLEVEL 0 |
| 290 | #define DM_VERSION_EXTRA "-ioctl (2006-06-24)" | 290 | #define DM_VERSION_EXTRA "-ioctl (2006-06-24)" |
| 291 | 291 | ||
