Commit 9541db7a authored by Jianjian Huo's avatar Jianjian Huo Committed by Luis Henriques

bcache: add mutex lock for bch_is_open

commit 789d21db upstream.

Since bch_is_open will iterate linked list bch_cache_sets and
uncached_devices, it needs bch_register_lock.
Signed-off-by: default avatarJianjian Huo <samuel.huo@gmail.com>
Cc: Kamal Mostafa <kamal@canonical.com>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 393d7444
...@@ -1950,10 +1950,12 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, ...@@ -1950,10 +1950,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);
if (attr == &ksysfs_register_quiet) if (attr == &ksysfs_register_quiet)
goto out; goto out;
} }
......
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