提交 1751c6ad 编写于 作者: L Li Ruilin 提交者: Zheng Zengkai

bcache: Delay to invalidate cache data in writearound write

euleros inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I4LOJ6
CVE: NA

------------------------------

In writearound cache mode, read request quickly followed by write
request may overwrite the invalidate bkey inserted by the write
request.

The function bch_data_insert() is invoked asynchronously as the bio
subbmited to backend block device, therefore there may be a read
request subbmited after the bch_data_insert() done and ended before
the backend bio is end. This read request will read data from the
backend block device, and insert dirty data to cache device. However
by writearound cache mode, bcache will not invalidate data again,
so that read request after will read dirty data from the cache,
causing a data corruption.

By this patch we delay the invalidation to end of backend bio to
avoid this corruption.
Signed-off-by: NLi Ruilin <liruilin4@huawei.com>
Reviewed-by: NLuan Jianhai <luanjianhai@huawei.com>
Reviewed-by: NPeng Junyi <pengjunyi1@huawei.com>
Acked-by: NXie Xiuqi <xiexiuqi@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
Reviewed-by: NGuangxing Deng <dengguangxing@huawei.com>
Reviewed-by: Nchao song <chao.song@huawei.com>
Reviewed-by: Nchao song <chao.song@huawei.com>
Reviewed-by: Nchao song <chao.song@huawei.com>
Reviewed-by: Nchao song <chao.song@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 08a3ac0e
......@@ -993,8 +993,11 @@ static void cached_dev_write_complete(struct closure *cl)
struct search *s = container_of(cl, struct search, cl);
struct cached_dev *dc = container_of(s->d, struct cached_dev, disk);
if (!s->iop.bypass)
closure_call(&s->iop.cl, bch_data_insert, NULL, cl);
up_read_non_owner(&dc->writeback_lock);
cached_dev_bio_complete(cl);
continue_at(cl, cached_dev_bio_complete, NULL);
}
static void cached_dev_write(struct cached_dev *dc, struct search *s)
......@@ -1077,7 +1080,8 @@ static void cached_dev_write(struct cached_dev *dc, struct search *s)
}
insert_data:
closure_call(&s->iop.cl, bch_data_insert, NULL, cl);
if (!s->iop.bypass)
closure_call(&s->iop.cl, bch_data_insert, NULL, cl);
continue_at(cl, cached_dev_write_complete, NULL);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册