bcache: add mutex lock for bch_is_open
Since bch_is_open will iterate linked list bch_cache_sets and uncached_devices, it needs bch_register_lock. Signed-off-by: Jianjian Huo <samuel.huo@gmail.com>
This commit is contained in:

committed by
Kent Overstreet

parent
5b25abade2
commit
789d21dbd9
@@ -1966,10 +1966,12 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
|
|||||||
if (IS_ERR(bdev)) {
|
if (IS_ERR(bdev)) {
|
||||||
if (bdev == ERR_PTR(-EBUSY)) {
|
if (bdev == ERR_PTR(-EBUSY)) {
|
||||||
bdev = lookup_bdev(strim(path));
|
bdev = lookup_bdev(strim(path));
|
||||||
|
mutex_lock(&bch_register_lock);
|
||||||
if (!IS_ERR(bdev) && bch_is_open(bdev))
|
if (!IS_ERR(bdev) && bch_is_open(bdev))
|
||||||
err = "device already registered";
|
err = "device already registered";
|
||||||
else
|
else
|
||||||
err = "device busy";
|
err = "device busy";
|
||||||
|
mutex_unlock(&bch_register_lock);
|
||||||
}
|
}
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user