aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/dm.c41
1 files changed, 41 insertions, 0 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
292static 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
324out:
325 dm_table_put(map);
326
327 lock_kernel();
328 return r;
329}
330
291static inline struct dm_io *alloc_io(struct mapped_device *md) 331static 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)
1377static struct block_device_operations dm_blk_dops = { 1417static 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};