summaryrefslogtreecommitdiff
path: root/drivers/md/bcache
diff options
context:
space:
mode:
authorJianjian Huo <samuel.huo@gmail.com>2014-07-13 16:08:59 (GMT)
committerKent Overstreet <kmo@daterainc.com>2014-08-04 22:23:04 (GMT)
commit789d21dbd9d8889e62c79ec19585fcc97e42ef07 (patch)
treeb0b8e1f363d871b67fa9197da6b671e5a485d790 /drivers/md/bcache
parent5b25abade29616d42d60f9bd5e6a5ad07f7314e3 (diff)
downloadlinux-789d21dbd9d8889e62c79ec19585fcc97e42ef07.tar.xz
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>
Diffstat (limited to 'drivers/md/bcache')
-rw-r--r--drivers/md/bcache/super.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index b6114d6..60e7513 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1966,10 +1966,12 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
if (IS_ERR(bdev)) {
if (bdev == ERR_PTR(-EBUSY)) {
bdev = lookup_bdev(strim(path));
+ mutex_lock(&bch_register_lock);
if (!IS_ERR(bdev) && bch_is_open(bdev))
err = "device already registered";
else
err = "device busy";
+ mutex_unlock(&bch_register_lock);
}
goto err;
}