Skip to content

Commit 13ea55e

Browse files
FirstLoveLifeMikulas Patocka
authored andcommitted
dm pcache: fix segment info indexing
Segment info indexing also used sizeof(struct) instead of the 4K metadata stride, so info_index could point between slots and subsequent writes would advance incorrectly. Derive info_index from the pointer returned by the segment meta search using PCACHE_SEG_INFO_SIZE and advance to the next slot for future updates. Signed-off-by: Li Chen <chenl311@chinatelecom.cn> Signed-off-by: Dongsheng Yang <dongsheng.yang@linux.dev> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Reviewed-by: Zheng Gu <cengku@gmail.com> Cc: stable@vger.kernel.org # 6.18
1 parent ee76331 commit 13ea55e

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/md/dm-pcache/cache_segment.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ static int cache_seg_info_load(struct pcache_cache_segment *cache_seg)
5656
ret = -EIO;
5757
goto out;
5858
}
59-
cache_seg->info_index = cache_seg_info_addr - cache_seg_info_addr_base;
59+
60+
cache_seg->info_index =
61+
((char *)cache_seg_info_addr - (char *)cache_seg_info_addr_base) /
62+
PCACHE_SEG_INFO_SIZE;
6063
out:
6164
mutex_unlock(&cache_seg->info_lock);
6265

0 commit comments

Comments
 (0)