Commit 345c6010 authored by Alexander Viro's avatar Alexander Viro Committed by Andy Grover

[PATCH] dm_ioctl() fix

Compile fixes, cleanup.
parent eecdce9c
...@@ -176,10 +176,10 @@ static void free_cell(struct hash_cell *hc) ...@@ -176,10 +176,10 @@ static void free_cell(struct hash_cell *hc)
*/ */
static int register_with_devfs(struct hash_cell *hc) static int register_with_devfs(struct hash_cell *hc)
{ {
kdev_t dev = dm_kdev(hc->md); struct gendisk *disk = dm_disk(hc->md);
hc->devfs_entry = hc->devfs_entry =
devfs_register(_dev_dir, hc->name, DEVFS_FL_CURRENT_OWNER, devfs_register(_dev_dir, hc->name, DEVFS_FL_CURRENT_OWNER,
major(dev), minor(dev), disk->major, disk->first_minor,
S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP, S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP,
&dm_blk_dops, NULL); &dm_blk_dops, NULL);
...@@ -448,17 +448,18 @@ static int __info(struct mapped_device *md, struct dm_ioctl *param) ...@@ -448,17 +448,18 @@ static int __info(struct mapped_device *md, struct dm_ioctl *param)
{ {
struct dm_table *table; struct dm_table *table;
struct block_device *bdev; struct block_device *bdev;
struct gendisk *disk = dm_disk(md);
param->flags = DM_EXISTS_FLAG; param->flags = DM_EXISTS_FLAG;
if (dm_suspended(md)) if (dm_suspended(md))
param->flags |= DM_SUSPEND_FLAG; param->flags |= DM_SUSPEND_FLAG;
param->dev = kdev_t_to_nr(dm_kdev(md)); param->dev = MKDEV(disk->major, disk->first_minor);
bdev = bdget(param->dev); bdev = bdget(param->dev);
if (!bdev) if (!bdev)
return -ENXIO; return -ENXIO;
if (bdev_read_only(bdev)) if (disk->policy)
param->flags |= DM_READONLY_FLAG; param->flags |= DM_READONLY_FLAG;
param->open_count = bdev->bd_openers; param->open_count = bdev->bd_openers;
...@@ -585,7 +586,7 @@ static int create(struct dm_ioctl *param, struct dm_ioctl *user) ...@@ -585,7 +586,7 @@ static int create(struct dm_ioctl *param, struct dm_ioctl *user)
} }
dm_table_put(t); /* md will have grabbed its own reference */ dm_table_put(t); /* md will have grabbed its own reference */
set_device_ro(dm_kdev(md), (param->flags & DM_READONLY_FLAG)); set_disk_ro(dm_disk(md), (param->flags & DM_READONLY_FLAG));
r = dm_hash_insert(param->name, *param->uuid ? param->uuid : NULL, md); r = dm_hash_insert(param->name, *param->uuid ? param->uuid : NULL, md);
dm_put(md); dm_put(md);
...@@ -871,7 +872,7 @@ static int reload(struct dm_ioctl *param, struct dm_ioctl *user) ...@@ -871,7 +872,7 @@ static int reload(struct dm_ioctl *param, struct dm_ioctl *user)
return r; return r;
} }
set_device_ro(dm_kdev(md), (param->flags & DM_READONLY_FLAG)); set_disk_ro(dm_disk(md), (param->flags & DM_READONLY_FLAG));
dm_put(md); dm_put(md);
r = info(param, user); r = info(param, user);
......
...@@ -749,15 +749,9 @@ int dm_resume(struct mapped_device *md) ...@@ -749,15 +749,9 @@ int dm_resume(struct mapped_device *md)
return 0; return 0;
} }
kdev_t dm_kdev(struct mapped_device *md) struct gendisk *dm_disk(struct mapped_device *md)
{ {
kdev_t dev; return md->disk;
down_read(&md->lock);
dev = md->kdev;
up_read(&md->lock);
return dev;
} }
struct dm_table *dm_get_table(struct mapped_device *md) struct dm_table *dm_get_table(struct mapped_device *md)
......
...@@ -77,7 +77,7 @@ struct dm_table *dm_get_table(struct mapped_device *md); ...@@ -77,7 +77,7 @@ struct dm_table *dm_get_table(struct mapped_device *md);
/* /*
* Info functions. * Info functions.
*/ */
kdev_t dm_kdev(struct mapped_device *md); struct gendisk *dm_disk(struct mapped_device *md);
int dm_suspended(struct mapped_device *md); int dm_suspended(struct mapped_device *md);
/*----------------------------------------------------------------- /*-----------------------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment