提交 4cb3e1db 编写于 作者: M Mikulas Patocka 提交者: Mike Snitzer

dm cache: return -EINVAL if the user specifies unknown cache policy

Return -EINVAL when the specified cache policy is unknown rather than
returning -ENOMEM.
Signed-off-by: NMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: NMike Snitzer <snitzer@redhat.com>
上级 dd8b0c20
......@@ -119,13 +119,13 @@ struct dm_cache_policy *dm_cache_policy_create(const char *name,
type = get_policy(name);
if (!type) {
DMWARN("unknown policy type");
return NULL;
return ERR_PTR(-EINVAL);
}
p = type->create(cache_size, origin_size, cache_block_size);
if (!p) {
put_policy(type);
return NULL;
return ERR_PTR(-ENOMEM);
}
p->private = type;
......
......@@ -1879,14 +1879,15 @@ static int set_config_values(struct cache *cache, int argc, const char **argv)
static int create_cache_policy(struct cache *cache, struct cache_args *ca,
char **error)
{
cache->policy = dm_cache_policy_create(ca->policy_name,
struct dm_cache_policy *p = dm_cache_policy_create(ca->policy_name,
cache->cache_size,
cache->origin_sectors,
cache->sectors_per_block);
if (!cache->policy) {
if (IS_ERR(p)) {
*error = "Error creating cache's policy";
return -ENOMEM;
return PTR_ERR(p);
}
cache->policy = p;
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册