diff options
Diffstat (limited to 'drivers/md/dm.c')
| -rw-r--r-- | drivers/md/dm.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 973e63d530ae..4d710b7a133b 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
| 12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
| 13 | #include <linux/mutex.h> | ||
| 13 | #include <linux/moduleparam.h> | 14 | #include <linux/moduleparam.h> |
| 14 | #include <linux/blkpg.h> | 15 | #include <linux/blkpg.h> |
| 15 | #include <linux/bio.h> | 16 | #include <linux/bio.h> |
| @@ -743,14 +744,14 @@ static int dm_any_congested(void *congested_data, int bdi_bits) | |||
| 743 | /*----------------------------------------------------------------- | 744 | /*----------------------------------------------------------------- |
| 744 | * An IDR is used to keep track of allocated minor numbers. | 745 | * An IDR is used to keep track of allocated minor numbers. |
| 745 | *---------------------------------------------------------------*/ | 746 | *---------------------------------------------------------------*/ |
| 746 | static DECLARE_MUTEX(_minor_lock); | 747 | static DEFINE_MUTEX(_minor_lock); |
| 747 | static DEFINE_IDR(_minor_idr); | 748 | static DEFINE_IDR(_minor_idr); |
| 748 | 749 | ||
| 749 | static void free_minor(unsigned int minor) | 750 | static void free_minor(unsigned int minor) |
| 750 | { | 751 | { |
| 751 | down(&_minor_lock); | 752 | mutex_lock(&_minor_lock); |
| 752 | idr_remove(&_minor_idr, minor); | 753 | idr_remove(&_minor_idr, minor); |
| 753 | up(&_minor_lock); | 754 | mutex_unlock(&_minor_lock); |
| 754 | } | 755 | } |
| 755 | 756 | ||
| 756 | /* | 757 | /* |
| @@ -763,7 +764,7 @@ static int specific_minor(struct mapped_device *md, unsigned int minor) | |||
| 763 | if (minor >= (1 << MINORBITS)) | 764 | if (minor >= (1 << MINORBITS)) |
| 764 | return -EINVAL; | 765 | return -EINVAL; |
| 765 | 766 | ||
| 766 | down(&_minor_lock); | 767 | mutex_lock(&_minor_lock); |
| 767 | 768 | ||
| 768 | if (idr_find(&_minor_idr, minor)) { | 769 | if (idr_find(&_minor_idr, minor)) { |
| 769 | r = -EBUSY; | 770 | r = -EBUSY; |
| @@ -788,7 +789,7 @@ static int specific_minor(struct mapped_device *md, unsigned int minor) | |||
| 788 | } | 789 | } |
| 789 | 790 | ||
| 790 | out: | 791 | out: |
| 791 | up(&_minor_lock); | 792 | mutex_unlock(&_minor_lock); |
| 792 | return r; | 793 | return r; |
| 793 | } | 794 | } |
| 794 | 795 | ||
| @@ -797,7 +798,7 @@ static int next_free_minor(struct mapped_device *md, unsigned int *minor) | |||
| 797 | int r; | 798 | int r; |
| 798 | unsigned int m; | 799 | unsigned int m; |
| 799 | 800 | ||
| 800 | down(&_minor_lock); | 801 | mutex_lock(&_minor_lock); |
| 801 | 802 | ||
| 802 | r = idr_pre_get(&_minor_idr, GFP_KERNEL); | 803 | r = idr_pre_get(&_minor_idr, GFP_KERNEL); |
| 803 | if (!r) { | 804 | if (!r) { |
| @@ -819,7 +820,7 @@ static int next_free_minor(struct mapped_device *md, unsigned int *minor) | |||
| 819 | *minor = m; | 820 | *minor = m; |
| 820 | 821 | ||
| 821 | out: | 822 | out: |
| 822 | up(&_minor_lock); | 823 | mutex_unlock(&_minor_lock); |
| 823 | return r; | 824 | return r; |
| 824 | } | 825 | } |
| 825 | 826 | ||
| @@ -1014,13 +1015,13 @@ static struct mapped_device *dm_find_md(dev_t dev) | |||
| 1014 | if (MAJOR(dev) != _major || minor >= (1 << MINORBITS)) | 1015 | if (MAJOR(dev) != _major || minor >= (1 << MINORBITS)) |
| 1015 | return NULL; | 1016 | return NULL; |
| 1016 | 1017 | ||
| 1017 | down(&_minor_lock); | 1018 | mutex_lock(&_minor_lock); |
| 1018 | 1019 | ||
| 1019 | md = idr_find(&_minor_idr, minor); | 1020 | md = idr_find(&_minor_idr, minor); |
| 1020 | if (!md || (dm_disk(md)->first_minor != minor)) | 1021 | if (!md || (dm_disk(md)->first_minor != minor)) |
| 1021 | md = NULL; | 1022 | md = NULL; |
| 1022 | 1023 | ||
| 1023 | up(&_minor_lock); | 1024 | mutex_unlock(&_minor_lock); |
| 1024 | 1025 | ||
| 1025 | return md; | 1026 | return md; |
| 1026 | } | 1027 | } |
