aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/md/dm-ioctl.c9
-rw-r--r--drivers/md/dm.c35
-rw-r--r--drivers/md/dm.h13
3 files changed, 26 insertions, 31 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index f7e743691aa8..c826b3e1799a 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited. 2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited.
3 * Copyright (C) 2004 - 2005 Red Hat, Inc. All rights reserved. 3 * Copyright (C) 2004 - 2006 Red Hat, Inc. All rights reserved.
4 * 4 *
5 * This file is released under the GPL. 5 * This file is released under the GPL.
6 */ 6 */
@@ -578,7 +578,7 @@ static int __dev_status(struct mapped_device *md, struct dm_ioctl *param)
578 578
579static int dev_create(struct dm_ioctl *param, size_t param_size) 579static int dev_create(struct dm_ioctl *param, size_t param_size)
580{ 580{
581 int r; 581 int r, m = DM_ANY_MINOR;
582 struct mapped_device *md; 582 struct mapped_device *md;
583 583
584 r = check_name(param->name); 584 r = check_name(param->name);
@@ -586,10 +586,9 @@ static int dev_create(struct dm_ioctl *param, size_t param_size)
586 return r; 586 return r;
587 587
588 if (param->flags & DM_PERSISTENT_DEV_FLAG) 588 if (param->flags & DM_PERSISTENT_DEV_FLAG)
589 r = dm_create_with_minor(MINOR(huge_decode_dev(param->dev)), &md); 589 m = MINOR(huge_decode_dev(param->dev));
590 else
591 r = dm_create(&md);
592 590
591 r = dm_create(m, &md);
593 if (r) 592 if (r)
594 return r; 593 return r;
595 594
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index dfd037858902..59bf797de9a5 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited. 2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited.
3 * Copyright (C) 2004 Red Hat, Inc. All rights reserved. 3 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
4 * 4 *
5 * This file is released under the GPL. 5 * This file is released under the GPL.
6 */ 6 */
@@ -764,7 +764,7 @@ static int dm_any_congested(void *congested_data, int bdi_bits)
764 *---------------------------------------------------------------*/ 764 *---------------------------------------------------------------*/
765static DEFINE_IDR(_minor_idr); 765static DEFINE_IDR(_minor_idr);
766 766
767static void free_minor(unsigned int minor) 767static void free_minor(int minor)
768{ 768{
769 spin_lock(&_minor_lock); 769 spin_lock(&_minor_lock);
770 idr_remove(&_minor_idr, minor); 770 idr_remove(&_minor_idr, minor);
@@ -774,7 +774,7 @@ static void free_minor(unsigned int minor)
774/* 774/*
775 * See if the device with a specific minor # is free. 775 * See if the device with a specific minor # is free.
776 */ 776 */
777static int specific_minor(struct mapped_device *md, unsigned int minor) 777static int specific_minor(struct mapped_device *md, int minor)
778{ 778{
779 int r, m; 779 int r, m;
780 780
@@ -807,10 +807,9 @@ out:
807 return r; 807 return r;
808} 808}
809 809
810static int next_free_minor(struct mapped_device *md, unsigned int *minor) 810static int next_free_minor(struct mapped_device *md, int *minor)
811{ 811{
812 int r; 812 int r, m;
813 unsigned int m;
814 813
815 r = idr_pre_get(&_minor_idr, GFP_KERNEL); 814 r = idr_pre_get(&_minor_idr, GFP_KERNEL);
816 if (!r) 815 if (!r)
@@ -841,7 +840,7 @@ static struct block_device_operations dm_blk_dops;
841/* 840/*
842 * Allocate and initialise a blank device with a given minor. 841 * Allocate and initialise a blank device with a given minor.
843 */ 842 */
844static struct mapped_device *alloc_dev(unsigned int minor, int persistent) 843static struct mapped_device *alloc_dev(int minor)
845{ 844{
846 int r; 845 int r;
847 struct mapped_device *md = kmalloc(sizeof(*md), GFP_KERNEL); 846 struct mapped_device *md = kmalloc(sizeof(*md), GFP_KERNEL);
@@ -856,7 +855,10 @@ static struct mapped_device *alloc_dev(unsigned int minor, int persistent)
856 goto bad0; 855 goto bad0;
857 856
858 /* get a minor number for the dev */ 857 /* get a minor number for the dev */
859 r = persistent ? specific_minor(md, minor) : next_free_minor(md, &minor); 858 if (minor == DM_ANY_MINOR)
859 r = next_free_minor(md, &minor);
860 else
861 r = specific_minor(md, minor);
860 if (r < 0) 862 if (r < 0)
861 goto bad1; 863 goto bad1;
862 864
@@ -929,7 +931,7 @@ static struct mapped_device *alloc_dev(unsigned int minor, int persistent)
929 931
930static void free_dev(struct mapped_device *md) 932static void free_dev(struct mapped_device *md)
931{ 933{
932 unsigned int minor = md->disk->first_minor; 934 int minor = md->disk->first_minor;
933 935
934 if (md->suspended_bdev) { 936 if (md->suspended_bdev) {
935 thaw_bdev(md->suspended_bdev, NULL); 937 thaw_bdev(md->suspended_bdev, NULL);
@@ -1015,12 +1017,11 @@ static void __unbind(struct mapped_device *md)
1015/* 1017/*
1016 * Constructor for a new device. 1018 * Constructor for a new device.
1017 */ 1019 */
1018static int create_aux(unsigned int minor, int persistent, 1020int dm_create(int minor, struct mapped_device **result)
1019 struct mapped_device **result)
1020{ 1021{
1021 struct mapped_device *md; 1022 struct mapped_device *md;
1022 1023
1023 md = alloc_dev(minor, persistent); 1024 md = alloc_dev(minor);
1024 if (!md) 1025 if (!md)
1025 return -ENXIO; 1026 return -ENXIO;
1026 1027
@@ -1028,16 +1029,6 @@ static int create_aux(unsigned int minor, int persistent,
1028 return 0; 1029 return 0;
1029} 1030}
1030 1031
1031int dm_create(struct mapped_device **result)
1032{
1033 return create_aux(0, 0, result);
1034}
1035
1036int dm_create_with_minor(unsigned int minor, struct mapped_device **result)
1037{
1038 return create_aux(minor, 1, result);
1039}
1040
1041static struct mapped_device *dm_find_md(dev_t dev) 1032static struct mapped_device *dm_find_md(dev_t dev)
1042{ 1033{
1043 struct mapped_device *md; 1034 struct mapped_device *md;
diff --git a/drivers/md/dm.h b/drivers/md/dm.h
index fd90bc8f9e45..2901ab943191 100644
--- a/drivers/md/dm.h
+++ b/drivers/md/dm.h
@@ -2,7 +2,7 @@
2 * Internal header file for device mapper 2 * Internal header file for device mapper
3 * 3 *
4 * Copyright (C) 2001, 2002 Sistina Software 4 * Copyright (C) 2001, 2002 Sistina Software
5 * Copyright (C) 2004 Red Hat, Inc. All rights reserved. 5 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
6 * 6 *
7 * This file is released under the LGPL. 7 * This file is released under the LGPL.
8 */ 8 */
@@ -45,16 +45,21 @@ struct mapped_device;
45 * Functions for manipulating a struct mapped_device. 45 * Functions for manipulating a struct mapped_device.
46 * Drop the reference with dm_put when you finish with the object. 46 * Drop the reference with dm_put when you finish with the object.
47 *---------------------------------------------------------------*/ 47 *---------------------------------------------------------------*/
48int dm_create(struct mapped_device **md); 48
49int dm_create_with_minor(unsigned int minor, struct mapped_device **md); 49/*
50 * DM_ANY_MINOR allocates any available minor number.
51 */
52#define DM_ANY_MINOR (-1)
53int dm_create(int minor, struct mapped_device **md);
54
50void dm_set_mdptr(struct mapped_device *md, void *ptr); 55void dm_set_mdptr(struct mapped_device *md, void *ptr);
51void *dm_get_mdptr(struct mapped_device *md); 56void *dm_get_mdptr(struct mapped_device *md);
52struct mapped_device *dm_get_md(dev_t dev);
53 57
54/* 58/*
55 * Reference counting for md. 59 * Reference counting for md.
56 */ 60 */
57void dm_get(struct mapped_device *md); 61void dm_get(struct mapped_device *md);
62struct mapped_device *dm_get_md(dev_t dev);
58void dm_put(struct mapped_device *md); 63void dm_put(struct mapped_device *md);
59 64
60/* 65/*