aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-ioctl.c4
-rw-r--r--drivers/md/dm-linear.c13
-rw-r--r--drivers/md/dm-mpath.c14
-rw-r--r--drivers/md/dm-table.c16
-rw-r--r--drivers/md/dm.c27
-rw-r--r--drivers/md/md.c20
6 files changed, 34 insertions, 60 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index dca401dc70a0..777c948180f9 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -988,9 +988,9 @@ static int dev_wait(struct dm_ioctl *param, size_t param_size)
988 return r; 988 return r;
989} 989}
990 990
991static inline int get_mode(struct dm_ioctl *param) 991static inline fmode_t get_mode(struct dm_ioctl *param)
992{ 992{
993 int mode = FMODE_READ | FMODE_WRITE; 993 fmode_t mode = FMODE_READ | FMODE_WRITE;
994 994
995 if (param->flags & DM_READONLY_FLAG) 995 if (param->flags & DM_READONLY_FLAG)
996 mode = FMODE_READ; 996 mode = FMODE_READ;
diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c
index 1b29e9136758..44042becad8a 100644
--- a/drivers/md/dm-linear.c
+++ b/drivers/md/dm-linear.c
@@ -110,20 +110,11 @@ static int linear_status(struct dm_target *ti, status_type_t type,
110 return 0; 110 return 0;
111} 111}
112 112
113static int linear_ioctl(struct dm_target *ti, struct inode *inode, 113static int linear_ioctl(struct dm_target *ti, unsigned int cmd,
114 struct file *filp, unsigned int cmd,
115 unsigned long arg) 114 unsigned long arg)
116{ 115{
117 struct linear_c *lc = (struct linear_c *) ti->private; 116 struct linear_c *lc = (struct linear_c *) ti->private;
118 struct block_device *bdev = lc->dev->bdev; 117 return __blkdev_driver_ioctl(lc->dev->bdev, lc->dev->mode, cmd, arg);
119 struct file fake_file = {};
120 struct dentry fake_dentry = {};
121
122 fake_file.f_mode = lc->dev->mode;
123 fake_file.f_path.dentry = &fake_dentry;
124 fake_dentry.d_inode = bdev->bd_inode;
125
126 return blkdev_driver_ioctl(bdev->bd_inode, &fake_file, bdev->bd_disk, cmd, arg);
127} 118}
128 119
129static int linear_merge(struct dm_target *ti, struct bvec_merge_data *bvm, 120static 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 abf6e8cfaedb..4840733cd903 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -1396,19 +1396,15 @@ error:
1396 return -EINVAL; 1396 return -EINVAL;
1397} 1397}
1398 1398
1399static int multipath_ioctl(struct dm_target *ti, struct inode *inode, 1399static int multipath_ioctl(struct dm_target *ti, unsigned int cmd,
1400 struct file *filp, unsigned int cmd,
1401 unsigned long arg) 1400 unsigned long arg)
1402{ 1401{
1403 struct multipath *m = (struct multipath *) ti->private; 1402 struct multipath *m = (struct multipath *) ti->private;
1404 struct block_device *bdev = NULL; 1403 struct block_device *bdev = NULL;
1404 fmode_t mode = 0;
1405 unsigned long flags; 1405 unsigned long flags;
1406 struct file fake_file = {};
1407 struct dentry fake_dentry = {};
1408 int r = 0; 1406 int r = 0;
1409 1407
1410 fake_file.f_path.dentry = &fake_dentry;
1411
1412 spin_lock_irqsave(&m->lock, flags); 1408 spin_lock_irqsave(&m->lock, flags);
1413 1409
1414 if (!m->current_pgpath) 1410 if (!m->current_pgpath)
@@ -1416,8 +1412,7 @@ static int multipath_ioctl(struct dm_target *ti, struct inode *inode,
1416 1412
1417 if (m->current_pgpath) { 1413 if (m->current_pgpath) {
1418 bdev = m->current_pgpath->path.dev->bdev; 1414 bdev = m->current_pgpath->path.dev->bdev;
1419 fake_dentry.d_inode = bdev->bd_inode; 1415 mode = m->current_pgpath->path.dev->mode;
1420 fake_file.f_mode = m->current_pgpath->path.dev->mode;
1421 } 1416 }
1422 1417
1423 if (m->queue_io) 1418 if (m->queue_io)
@@ -1427,8 +1422,7 @@ static int multipath_ioctl(struct dm_target *ti, struct inode *inode,
1427 1422
1428 spin_unlock_irqrestore(&m->lock, flags); 1423 spin_unlock_irqrestore(&m->lock, flags);
1429 1424
1430 return r ? : blkdev_driver_ioctl(bdev->bd_inode, &fake_file, 1425 return r ? : __blkdev_driver_ioctl(bdev, mode, cmd, arg);
1431 bdev->bd_disk, cmd, arg);
1432} 1426}
1433 1427
1434/*----------------------------------------------------------------- 1428/*-----------------------------------------------------------------
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 1407eb96f1a4..a63161aec487 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -43,7 +43,7 @@ struct dm_table {
43 * device. This should be a combination of FMODE_READ 43 * device. This should be a combination of FMODE_READ
44 * and FMODE_WRITE. 44 * and FMODE_WRITE.
45 */ 45 */
46 int mode; 46 fmode_t mode;
47 47
48 /* a list of devices used by this table */ 48 /* a list of devices used by this table */
49 struct list_head devices; 49 struct list_head devices;
@@ -217,7 +217,7 @@ static int alloc_targets(struct dm_table *t, unsigned int num)
217 return 0; 217 return 0;
218} 218}
219 219
220int dm_table_create(struct dm_table **result, int mode, 220int dm_table_create(struct dm_table **result, fmode_t mode,
221 unsigned num_targets, struct mapped_device *md) 221 unsigned num_targets, struct mapped_device *md)
222{ 222{
223 struct dm_table *t = kzalloc(sizeof(*t), GFP_KERNEL); 223 struct dm_table *t = kzalloc(sizeof(*t), GFP_KERNEL);
@@ -344,7 +344,7 @@ static int open_dev(struct dm_dev_internal *d, dev_t dev,
344 return PTR_ERR(bdev); 344 return PTR_ERR(bdev);
345 r = bd_claim_by_disk(bdev, _claim_ptr, dm_disk(md)); 345 r = bd_claim_by_disk(bdev, _claim_ptr, dm_disk(md));
346 if (r) 346 if (r)
347 blkdev_put(bdev); 347 blkdev_put(bdev, d->dm_dev.mode);
348 else 348 else
349 d->dm_dev.bdev = bdev; 349 d->dm_dev.bdev = bdev;
350 return r; 350 return r;
@@ -359,7 +359,7 @@ static void close_dev(struct dm_dev_internal *d, struct mapped_device *md)
359 return; 359 return;
360 360
361 bd_release_from_disk(d->dm_dev.bdev, dm_disk(md)); 361 bd_release_from_disk(d->dm_dev.bdev, dm_disk(md));
362 blkdev_put(d->dm_dev.bdev); 362 blkdev_put(d->dm_dev.bdev, d->dm_dev.mode);
363 d->dm_dev.bdev = NULL; 363 d->dm_dev.bdev = NULL;
364} 364}
365 365
@@ -382,7 +382,7 @@ static int check_device_area(struct dm_dev_internal *dd, sector_t start,
382 * careful to leave things as they were if we fail to reopen the 382 * careful to leave things as they were if we fail to reopen the
383 * device. 383 * device.
384 */ 384 */
385static int upgrade_mode(struct dm_dev_internal *dd, int new_mode, 385static int upgrade_mode(struct dm_dev_internal *dd, fmode_t new_mode,
386 struct mapped_device *md) 386 struct mapped_device *md)
387{ 387{
388 int r; 388 int r;
@@ -408,7 +408,7 @@ static int upgrade_mode(struct dm_dev_internal *dd, int new_mode,
408 */ 408 */
409static int __table_get_device(struct dm_table *t, struct dm_target *ti, 409static int __table_get_device(struct dm_table *t, struct dm_target *ti,
410 const char *path, sector_t start, sector_t len, 410 const char *path, sector_t start, sector_t len,
411 int mode, struct dm_dev **result) 411 fmode_t mode, struct dm_dev **result)
412{ 412{
413 int r; 413 int r;
414 dev_t uninitialized_var(dev); 414 dev_t uninitialized_var(dev);
@@ -528,7 +528,7 @@ void dm_set_device_limits(struct dm_target *ti, struct block_device *bdev)
528EXPORT_SYMBOL_GPL(dm_set_device_limits); 528EXPORT_SYMBOL_GPL(dm_set_device_limits);
529 529
530int dm_get_device(struct dm_target *ti, const char *path, sector_t start, 530int dm_get_device(struct dm_target *ti, const char *path, sector_t start,
531 sector_t len, int mode, struct dm_dev **result) 531 sector_t len, fmode_t mode, struct dm_dev **result)
532{ 532{
533 int r = __table_get_device(ti->table, ti, path, 533 int r = __table_get_device(ti->table, ti, path,
534 start, len, mode, result); 534 start, len, mode, result);
@@ -878,7 +878,7 @@ struct list_head *dm_table_get_devices(struct dm_table *t)
878 return &t->devices; 878 return &t->devices;
879} 879}
880 880
881int dm_table_get_mode(struct dm_table *t) 881fmode_t dm_table_get_mode(struct dm_table *t)
882{ 882{
883 return t->mode; 883 return t->mode;
884} 884}
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
diff --git a/drivers/md/md.c b/drivers/md/md.c
index aaa3d465de4e..c1a837ca193c 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1520,7 +1520,7 @@ static int lock_rdev(mdk_rdev_t *rdev, dev_t dev, int shared)
1520 if (err) { 1520 if (err) {
1521 printk(KERN_ERR "md: could not bd_claim %s.\n", 1521 printk(KERN_ERR "md: could not bd_claim %s.\n",
1522 bdevname(bdev, b)); 1522 bdevname(bdev, b));
1523 blkdev_put(bdev); 1523 blkdev_put(bdev, FMODE_READ|FMODE_WRITE);
1524 return err; 1524 return err;
1525 } 1525 }
1526 if (!shared) 1526 if (!shared)
@@ -1536,7 +1536,7 @@ static void unlock_rdev(mdk_rdev_t *rdev)
1536 if (!bdev) 1536 if (!bdev)
1537 MD_BUG(); 1537 MD_BUG();
1538 bd_release(bdev); 1538 bd_release(bdev);
1539 blkdev_put(bdev); 1539 blkdev_put(bdev, FMODE_READ|FMODE_WRITE);
1540} 1540}
1541 1541
1542void md_autodetect_dev(dev_t dev); 1542void md_autodetect_dev(dev_t dev);
@@ -4785,7 +4785,7 @@ static int md_getgeo(struct block_device *bdev, struct hd_geometry *geo)
4785 return 0; 4785 return 0;
4786} 4786}
4787 4787
4788static int md_ioctl(struct inode *inode, struct file *file, 4788static int md_ioctl(struct block_device *bdev, fmode_t mode,
4789 unsigned int cmd, unsigned long arg) 4789 unsigned int cmd, unsigned long arg)
4790{ 4790{
4791 int err = 0; 4791 int err = 0;
@@ -4823,7 +4823,7 @@ static int md_ioctl(struct inode *inode, struct file *file,
4823 * Commands creating/starting a new array: 4823 * Commands creating/starting a new array:
4824 */ 4824 */
4825 4825
4826 mddev = inode->i_bdev->bd_disk->private_data; 4826 mddev = bdev->bd_disk->private_data;
4827 4827
4828 if (!mddev) { 4828 if (!mddev) {
4829 BUG(); 4829 BUG();
@@ -4996,13 +4996,13 @@ abort:
4996 return err; 4996 return err;
4997} 4997}
4998 4998
4999static int md_open(struct inode *inode, struct file *file) 4999static int md_open(struct block_device *bdev, fmode_t mode)
5000{ 5000{
5001 /* 5001 /*
5002 * Succeed if we can lock the mddev, which confirms that 5002 * Succeed if we can lock the mddev, which confirms that
5003 * it isn't being stopped right now. 5003 * it isn't being stopped right now.
5004 */ 5004 */
5005 mddev_t *mddev = inode->i_bdev->bd_disk->private_data; 5005 mddev_t *mddev = bdev->bd_disk->private_data;
5006 int err; 5006 int err;
5007 5007
5008 if ((err = mutex_lock_interruptible_nested(&mddev->reconfig_mutex, 1))) 5008 if ((err = mutex_lock_interruptible_nested(&mddev->reconfig_mutex, 1)))
@@ -5013,14 +5013,14 @@ static int md_open(struct inode *inode, struct file *file)
5013 atomic_inc(&mddev->openers); 5013 atomic_inc(&mddev->openers);
5014 mddev_unlock(mddev); 5014 mddev_unlock(mddev);
5015 5015
5016 check_disk_change(inode->i_bdev); 5016 check_disk_change(bdev);
5017 out: 5017 out:
5018 return err; 5018 return err;
5019} 5019}
5020 5020
5021static int md_release(struct inode *inode, struct file * file) 5021static int md_release(struct gendisk *disk, fmode_t mode)
5022{ 5022{
5023 mddev_t *mddev = inode->i_bdev->bd_disk->private_data; 5023 mddev_t *mddev = disk->private_data;
5024 5024
5025 BUG_ON(!mddev); 5025 BUG_ON(!mddev);
5026 atomic_dec(&mddev->openers); 5026 atomic_dec(&mddev->openers);
@@ -5048,7 +5048,7 @@ static struct block_device_operations md_fops =
5048 .owner = THIS_MODULE, 5048 .owner = THIS_MODULE,
5049 .open = md_open, 5049 .open = md_open,
5050 .release = md_release, 5050 .release = md_release,
5051 .ioctl = md_ioctl, 5051 .locked_ioctl = md_ioctl,
5052 .getgeo = md_getgeo, 5052 .getgeo = md_getgeo,
5053 .media_changed = md_media_changed, 5053 .media_changed = md_media_changed,
5054 .revalidate_disk= md_revalidate, 5054 .revalidate_disk= md_revalidate,