From 318eaaaf40b2b48791de159d0a3813666e265be2 Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Wed, 7 Aug 2019 23:53:30 +0200 Subject: block: loop: file_fmt_qcow: fix offset during the read of a cache miss The wrong offset after reading the missing QCOW2 L2 table from the disk file format is saved in the metadata of the QCOW2 cache. This patch fixes the wrong metadata by saving the correct offset of the loaded L2 cache table. Signed-off-by: Manuel Bentele --- drivers/block/loop/loop_file_fmt_qcow_cache.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/block/loop/loop_file_fmt_qcow_cache.c b/drivers/block/loop/loop_file_fmt_qcow_cache.c index 658c8582ef56..7d3af7398f04 100644 --- a/drivers/block/loop/loop_file_fmt_qcow_cache.c +++ b/drivers/block/loop/loop_file_fmt_qcow_cache.c @@ -124,6 +124,7 @@ static int __loop_file_fmt_qcow_cache_do_get(struct loop_file_fmt *lo_fmt, int lookup_index; u64 min_lru_counter = U64_MAX; int min_lru_index = -1; + u64 read_offset; size_t len; ASSERT(offset != 0); @@ -170,9 +171,10 @@ static int __loop_file_fmt_qcow_cache_do_get(struct loop_file_fmt *lo_fmt, c->entries[i].offset = 0; if (read_from_disk) { + read_offset = offset; len = kernel_read(lo->lo_backing_file, __loop_file_fmt_qcow_cache_get_table_addr(c, i), - c->table_size, &offset); + c->table_size, &read_offset); if (len < 0) { len = ret; return ret; -- cgit v1.2.3-55-g7522