]> git.baikalelectronics.ru Git - kernel.git/commit
nullb: emulate cache
authorShaohua Li <shli@fb.com>
Mon, 14 Aug 2017 22:04:59 +0000 (15:04 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 23 Aug 2017 14:54:11 +0000 (08:54 -0600)
commit8d34e9d937b5482520609ba2db6bf2bd2b790f9f
tree2d89f58f420a597dbe29c5ca0db95f094a4357a6
parentb926e0780b88a7cd1c4b03cdb74c83e4e6ab1b07
nullb: emulate cache

Software must flush disk cache to guarantee data safety. To check if
software correctly does disk cache flush, we must know the behavior of
disk. But physical disk behavior is uncontrollable. Even software
doesn't do the flush, the disk probably does the flush. This patch tries
to emulate a cache in the test disk.

All write will go to a cache first, when the cache is full, we then
flush some data to disk storage. A flush request will flush all data of
the cache to disk storage. A FUA write will write to memory store
directly and revalidate data in cache. If there is a power failure (by
writing to power attribute, 'echo 0 > disk_name/power'), we discard all
data in the cache, but preserve the data in disk storage. Later we can
power on the disk again as usual (write 1 to 'power' attribute), then we
can check data integrity and very if software does everything correctly.

A new attribute 'cache_size' (in MB) is added to configure cache size.

Based on original patch from Kyungchan Koh

Signed-off-by: Kyungchan Koh <kkc6196@fb.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/null_blk.c