aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/dm.c')
-rw-r--r--drivers/md/dm.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index d1d0cd0f5750..6963ad148408 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -21,7 +21,6 @@
21#include <linux/idr.h> 21#include <linux/idr.h>
22#include <linux/hdreg.h> 22#include <linux/hdreg.h>
23#include <linux/blktrace_api.h> 23#include <linux/blktrace_api.h>
24#include <linux/smp_lock.h>
25 24
26#define DM_MSG_PREFIX "core" 25#define DM_MSG_PREFIX "core"
27 26
@@ -248,13 +247,13 @@ static void __exit dm_exit(void)
248/* 247/*
249 * Block device functions 248 * Block device functions
250 */ 249 */
251static int dm_blk_open(struct inode *inode, struct file *file) 250static int dm_blk_open(struct block_device *bdev, fmode_t mode)
252{ 251{
253 struct mapped_device *md; 252 struct mapped_device *md;
254 253
255 spin_lock(&_minor_lock); 254 spin_lock(&_minor_lock);
256 255
257 md = inode->i_bdev->bd_disk->private_data; 256 md = bdev->bd_disk->private_data;
258 if (!md) 257 if (!md)
259 goto out; 258 goto out;
260 259
@@ -273,11 +272,9 @@ out:
273 return md ? 0 : -ENXIO; 272 return md ? 0 : -ENXIO;
274} 273}
275 274
276static int dm_blk_close(struct inode *inode, struct file *file) 275static int dm_blk_close(struct gendisk *disk, fmode_t mode)
277{ 276{
278 struct mapped_device *md; 277 struct mapped_device *md = disk->private_data;
279
280 md = inode->i_bdev->bd_disk->private_data;
281 atomic_dec(&md->open_count); 278 atomic_dec(&md->open_count);
282 dm_put(md); 279 dm_put(md);
283 return 0; 280 return 0;
@@ -314,21 +311,14 @@ static int dm_blk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
314 return dm_get_geometry(md, geo); 311 return dm_get_geometry(md, geo);
315} 312}
316 313
317static int dm_blk_ioctl(struct inode *inode, struct file *file, 314static int dm_blk_ioctl(struct block_device *bdev, fmode_t mode,
318 unsigned int cmd, unsigned long arg) 315 unsigned int cmd, unsigned long arg)
319{ 316{
320 struct mapped_device *md; 317 struct mapped_device *md = bdev->bd_disk->private_data;
321 struct dm_table *map; 318 struct dm_table *map = dm_get_table(md);
322 struct dm_target *tgt; 319 struct dm_target *tgt;
323 int r = -ENOTTY; 320 int r = -ENOTTY;
324 321
325 /* We don't really need this lock, but we do need 'inode'. */
326 unlock_kernel();
327
328 md = inode->i_bdev->bd_disk->private_data;
329
330 map = dm_get_table(md);
331
332 if (!map || !dm_table_get_size(map)) 322 if (!map || !dm_table_get_size(map))
333 goto out; 323 goto out;
334 324
@@ -344,12 +334,11 @@ static int dm_blk_ioctl(struct inode *inode, struct file *file,
344 } 334 }
345 335
346 if (tgt->type->ioctl) 336 if (tgt->type->ioctl)
347 r = tgt->type->ioctl(tgt, inode, file, cmd, arg); 337 r = tgt->type->ioctl(tgt, cmd, arg);
348 338
349out: 339out:
350 dm_table_put(map); 340 dm_table_put(map);
351 341
352 lock_kernel();
353 return r; 342 return r;
354} 343}
355 344