未验证 提交 3c4533bd 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!1349 [sync] PR-1294: dm stats: check for and propagate alloc_percpu failure

Merge Pull Request from: @openeuler-sync-bot 
 

Origin pull request: 
https://gitee.com/openeuler/kernel/pulls/1294 
 
PR sync from: Li Lingfeng <lilingfeng3@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/JMXBT7PXZENQ6R7L2JBRQLXB3NS26AY2/ 
 
 
Link:https://gitee.com/openeuler/kernel/pulls/1349 

Reviewed-by: Yu Kuai <yukuai3@huawei.com> 
Reviewed-by: Jialin Zhang <zhangjialin11@huawei.com> 
Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com> 
......@@ -188,7 +188,7 @@ static int dm_stat_in_flight(struct dm_stat_shared *shared)
atomic_read(&shared->in_flight[WRITE]);
}
void dm_stats_init(struct dm_stats *stats)
int dm_stats_init(struct dm_stats *stats)
{
int cpu;
struct dm_stats_last_position *last;
......@@ -196,11 +196,16 @@ void dm_stats_init(struct dm_stats *stats)
mutex_init(&stats->mutex);
INIT_LIST_HEAD(&stats->list);
stats->last = alloc_percpu(struct dm_stats_last_position);
if (!stats->last)
return -ENOMEM;
for_each_possible_cpu(cpu) {
last = per_cpu_ptr(stats->last, cpu);
last->last_sector = (sector_t)ULLONG_MAX;
last->last_rw = UINT_MAX;
}
return 0;
}
void dm_stats_cleanup(struct dm_stats *stats)
......
......@@ -22,7 +22,7 @@ struct dm_stats_aux {
unsigned long long duration_ns;
};
void dm_stats_init(struct dm_stats *st);
int dm_stats_init(struct dm_stats *st);
void dm_stats_cleanup(struct dm_stats *st);
struct mapped_device;
......
......@@ -1899,7 +1899,9 @@ static struct mapped_device *alloc_dev(int minor)
if (!md->bdev)
goto bad;
dm_stats_init(&md->stats);
r = dm_stats_init(&md->stats);
if (r < 0)
goto bad;
/* Populate the mapping, nobody knows we exist yet */
spin_lock(&_minor_lock);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册