|
@@ -15,12 +15,13 @@
|
|
#include <linux/kmod.h>
|
|
#include <linux/kmod.h>
|
|
#include <linux/kobj_map.h>
|
|
#include <linux/kobj_map.h>
|
|
#include <linux/buffer_head.h>
|
|
#include <linux/buffer_head.h>
|
|
|
|
+#include <linux/mutex.h>
|
|
|
|
|
|
#define MAX_PROBE_HASH 255 /* random */
|
|
#define MAX_PROBE_HASH 255 /* random */
|
|
|
|
|
|
static struct subsystem block_subsys;
|
|
static struct subsystem block_subsys;
|
|
|
|
|
|
-static DECLARE_MUTEX(block_subsys_sem);
|
|
|
|
|
|
+static DEFINE_MUTEX(block_subsys_lock);
|
|
|
|
|
|
/*
|
|
/*
|
|
* Can be deleted altogether. Later.
|
|
* Can be deleted altogether. Later.
|
|
@@ -46,7 +47,7 @@ struct blkdev_info {
|
|
/*
|
|
/*
|
|
* iterate over a list of blkdev_info structures. allows
|
|
* iterate over a list of blkdev_info structures. allows
|
|
* the major_names array to be iterated over from outside this file
|
|
* the major_names array to be iterated over from outside this file
|
|
- * must be called with the block_subsys_sem held
|
|
|
|
|
|
+ * must be called with the block_subsys_lock held
|
|
*/
|
|
*/
|
|
void *get_next_blkdev(void *dev)
|
|
void *get_next_blkdev(void *dev)
|
|
{
|
|
{
|
|
@@ -85,20 +86,20 @@ out:
|
|
|
|
|
|
void *acquire_blkdev_list(void)
|
|
void *acquire_blkdev_list(void)
|
|
{
|
|
{
|
|
- down(&block_subsys_sem);
|
|
|
|
|
|
+ mutex_lock(&block_subsys_lock);
|
|
return get_next_blkdev(NULL);
|
|
return get_next_blkdev(NULL);
|
|
}
|
|
}
|
|
|
|
|
|
void release_blkdev_list(void *dev)
|
|
void release_blkdev_list(void *dev)
|
|
{
|
|
{
|
|
- up(&block_subsys_sem);
|
|
|
|
|
|
+ mutex_unlock(&block_subsys_lock);
|
|
kfree(dev);
|
|
kfree(dev);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
* Count the number of records in the blkdev_list.
|
|
* Count the number of records in the blkdev_list.
|
|
- * must be called with the block_subsys_sem held
|
|
|
|
|
|
+ * must be called with the block_subsys_lock held
|
|
*/
|
|
*/
|
|
int count_blkdev_list(void)
|
|
int count_blkdev_list(void)
|
|
{
|
|
{
|
|
@@ -118,7 +119,7 @@ int count_blkdev_list(void)
|
|
/*
|
|
/*
|
|
* extract the major and name values from a blkdev_info struct
|
|
* extract the major and name values from a blkdev_info struct
|
|
* passed in as a void to *dev. Must be called with
|
|
* passed in as a void to *dev. Must be called with
|
|
- * block_subsys_sem held
|
|
|
|
|
|
+ * block_subsys_lock held
|
|
*/
|
|
*/
|
|
int get_blkdev_info(void *dev, int *major, char **name)
|
|
int get_blkdev_info(void *dev, int *major, char **name)
|
|
{
|
|
{
|
|
@@ -138,7 +139,7 @@ int register_blkdev(unsigned int major, const char *name)
|
|
struct blk_major_name **n, *p;
|
|
struct blk_major_name **n, *p;
|
|
int index, ret = 0;
|
|
int index, ret = 0;
|
|
|
|
|
|
- down(&block_subsys_sem);
|
|
|
|
|
|
+ mutex_lock(&block_subsys_lock);
|
|
|
|
|
|
/* temporary */
|
|
/* temporary */
|
|
if (major == 0) {
|
|
if (major == 0) {
|
|
@@ -183,7 +184,7 @@ int register_blkdev(unsigned int major, const char *name)
|
|
kfree(p);
|
|
kfree(p);
|
|
}
|
|
}
|
|
out:
|
|
out:
|
|
- up(&block_subsys_sem);
|
|
|
|
|
|
+ mutex_unlock(&block_subsys_lock);
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -197,7 +198,7 @@ int unregister_blkdev(unsigned int major, const char *name)
|
|
int index = major_to_index(major);
|
|
int index = major_to_index(major);
|
|
int ret = 0;
|
|
int ret = 0;
|
|
|
|
|
|
- down(&block_subsys_sem);
|
|
|
|
|
|
+ mutex_lock(&block_subsys_lock);
|
|
for (n = &major_names[index]; *n; n = &(*n)->next)
|
|
for (n = &major_names[index]; *n; n = &(*n)->next)
|
|
if ((*n)->major == major)
|
|
if ((*n)->major == major)
|
|
break;
|
|
break;
|
|
@@ -207,7 +208,7 @@ int unregister_blkdev(unsigned int major, const char *name)
|
|
p = *n;
|
|
p = *n;
|
|
*n = p->next;
|
|
*n = p->next;
|
|
}
|
|
}
|
|
- up(&block_subsys_sem);
|
|
|
|
|
|
+ mutex_unlock(&block_subsys_lock);
|
|
kfree(p);
|
|
kfree(p);
|
|
|
|
|
|
return ret;
|
|
return ret;
|
|
@@ -301,7 +302,7 @@ static void *part_start(struct seq_file *part, loff_t *pos)
|
|
struct list_head *p;
|
|
struct list_head *p;
|
|
loff_t l = *pos;
|
|
loff_t l = *pos;
|
|
|
|
|
|
- down(&block_subsys_sem);
|
|
|
|
|
|
+ mutex_lock(&block_subsys_lock);
|
|
list_for_each(p, &block_subsys.kset.list)
|
|
list_for_each(p, &block_subsys.kset.list)
|
|
if (!l--)
|
|
if (!l--)
|
|
return list_entry(p, struct gendisk, kobj.entry);
|
|
return list_entry(p, struct gendisk, kobj.entry);
|
|
@@ -318,7 +319,7 @@ static void *part_next(struct seq_file *part, void *v, loff_t *pos)
|
|
|
|
|
|
static void part_stop(struct seq_file *part, void *v)
|
|
static void part_stop(struct seq_file *part, void *v)
|
|
{
|
|
{
|
|
- up(&block_subsys_sem);
|
|
|
|
|
|
+ mutex_unlock(&block_subsys_lock);
|
|
}
|
|
}
|
|
|
|
|
|
static int show_partition(struct seq_file *part, void *v)
|
|
static int show_partition(struct seq_file *part, void *v)
|
|
@@ -377,7 +378,7 @@ static struct kobject *base_probe(dev_t dev, int *part, void *data)
|
|
|
|
|
|
static int __init genhd_device_init(void)
|
|
static int __init genhd_device_init(void)
|
|
{
|
|
{
|
|
- bdev_map = kobj_map_init(base_probe, &block_subsys_sem);
|
|
|
|
|
|
+ bdev_map = kobj_map_init(base_probe, &block_subsys_lock);
|
|
blk_dev_init();
|
|
blk_dev_init();
|
|
subsystem_register(&block_subsys);
|
|
subsystem_register(&block_subsys);
|
|
return 0;
|
|
return 0;
|
|
@@ -611,7 +612,7 @@ static void *diskstats_start(struct seq_file *part, loff_t *pos)
|
|
loff_t k = *pos;
|
|
loff_t k = *pos;
|
|
struct list_head *p;
|
|
struct list_head *p;
|
|
|
|
|
|
- down(&block_subsys_sem);
|
|
|
|
|
|
+ mutex_lock(&block_subsys_lock);
|
|
list_for_each(p, &block_subsys.kset.list)
|
|
list_for_each(p, &block_subsys.kset.list)
|
|
if (!k--)
|
|
if (!k--)
|
|
return list_entry(p, struct gendisk, kobj.entry);
|
|
return list_entry(p, struct gendisk, kobj.entry);
|
|
@@ -628,7 +629,7 @@ static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos)
|
|
|
|
|
|
static void diskstats_stop(struct seq_file *part, void *v)
|
|
static void diskstats_stop(struct seq_file *part, void *v)
|
|
{
|
|
{
|
|
- up(&block_subsys_sem);
|
|
|
|
|
|
+ mutex_unlock(&block_subsys_lock);
|
|
}
|
|
}
|
|
|
|
|
|
static int diskstats_show(struct seq_file *s, void *v)
|
|
static int diskstats_show(struct seq_file *s, void *v)
|