aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm.c
diff options
context:
space:
mode:
authorMilan Broz <mbroz@redhat.com>2006-10-03 04:15:15 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-03 11:04:13 -0400
commitaa129a2247b164173d45da8ad43cca5de9211403 (patch)
tree8adecb4d15d49b0a1fd4b459a24dff22a961d71c /drivers/md/dm.c
parent70abac6e4f4bfb05a8198e22225f9e066239c7a2 (diff)
[PATCH] dm: support ioctls on mapped devices
Extend the core device-mapper infrastructure to accept arbitrary ioctls on a mapped device provided that it has exactly one target and it is capable of supporting ioctls. [We can't use unlocked_ioctl because we need 'inode': 'file' might be NULL. Is it worth changing this?] Signed-off-by: Milan Broz <mbroz@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com> Arnd Bergmann <arnd@arndb.de> wrote: > Am Wednesday 21 June 2006 21:31 schrieb Alasdair G Kergon: > > static struct block_device_operations dm_blk_dops = { > > .open = dm_blk_open, > > .release = dm_blk_close, > > +.ioctl = dm_blk_ioctl, > > .getgeo = dm_blk_getgeo, > > .owner = THIS_MODULE > > I guess this also needs a ->compat_ioctl method, otherwise it won't > work for ioctl numbers that have a compat_ioctl implementation in the > low-level device driver. Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/md/dm.c')
-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};