| 13ea55ea | 05-Dec-2025 |
Li Chen <chenl311@chinatelecom.cn> |
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 inc
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
show more ...
|
| ee763317 | 05-Dec-2025 |
Li Chen <chenl311@chinatelecom.cn> |
dm pcache: fix cache info indexing
The on-media cache_info index used sizeof(struct) instead of the 4K metadata stride, so gc_percent updates from dmsetup message were written between slots and lost
dm pcache: fix cache info indexing
The on-media cache_info index used sizeof(struct) instead of the 4K metadata stride, so gc_percent updates from dmsetup message were written between slots and lost after reboot. Use PCACHE_CACHE_INFO_SIZE in get_cache_info_addr() and align info_index with the slot returned by pcache_meta_find_latest().
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
show more ...
|
| a6ee8422 | 11-Nov-2025 |
Li Chen <chenl311@chinatelecom.cn> |
dm-pcache: zero cache_info before default init
pcache_meta_find_latest() leaves whatever it last copied into the caller’s buffer even when it returns NULL. For cache_info_init(), that meant cache->c
dm-pcache: zero cache_info before default init
pcache_meta_find_latest() leaves whatever it last copied into the caller’s buffer even when it returns NULL. For cache_info_init(), that meant cache->cache_info could still contain CRC-bad garbage when no valid metadata exists, leading later initialization paths to read bogus flags.
Explicitly memset cache->cache_info in cache_info_init_default() so new-cache paths start from a clean slate. The default sequence number assignment becomes redundant with this reset, so it drops out.
Signed-off-by: Li Chen <chenl311@chinatelecom.cn> Reviewed-by: Zheng Gu <cengku@gmail.com> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
show more ...
|
| 840b80af | 11-Nov-2025 |
Li Chen <chenl311@chinatelecom.cn> |
dm-pcache: reuse meta_addr in pcache_meta_find_latest
pcache_meta_find_latest() already computes the metadata address as meta_addr. Reuse that instead of recomputing.
Signed-off-by: Li Chen <chenl3
dm-pcache: reuse meta_addr in pcache_meta_find_latest
pcache_meta_find_latest() already computes the metadata address as meta_addr. Reuse that instead of recomputing.
Signed-off-by: Li Chen <chenl311@chinatelecom.cn> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
show more ...
|
| 4466dd3d | 29-Aug-2025 |
Qianfeng Rong <rongqianfeng@vivo.com> |
dm-pcache: use int type to store negative error codes
Change the 'ret' variable from u32 to int to store negative error codes or zero returned by cache_kset_close().
Storing the negative error code
dm-pcache: use int type to store negative error codes
Change the 'ret' variable from u32 to int to store negative error codes or zero returned by cache_kset_close().
Storing the negative error codes in unsigned type, doesn't cause an issue at runtime but it's ugly. Additionally, assigning negative error codes to unsigned type may trigger a GCC warning when the -Wsign-conversion flag is enabled.
No effect on runtime.
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
show more ...
|
| 24735771 | 01-Sep-2025 |
Dongsheng Yang <dongsheng.yang@linux.dev> |
dm-pcache: cleanup: fix coding style report by checkpatch.pl
A patch from a few days ago fixed the division issue on 32-bit machines, but it introduced a coding style problem.
WARNING: Missing a bl
dm-pcache: cleanup: fix coding style report by checkpatch.pl
A patch from a few days ago fixed the division issue on 32-bit machines, but it introduced a coding style problem.
WARNING: Missing a blank line after declarations + u32 rem; + div_u64_rem(off >> PCACHE_CACHE_SUBTREE_SIZE_SHIFT, cache->n_ksets, &rem);
total: 0 errors, 1 warnings, 634 lines checked
Signed-off-by: Dongsheng Yang <dongsheng.yang@linux.dev> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
show more ...
|
| 1f9ad14a | 01-Sep-2025 |
Dongsheng Yang <dongsheng.yang@linux.dev> |
dm-pcache: remove ctrl_lock for pcache_cache_segment
The smatch checker reports a “scheduler in atomic context” problem in the following call chain:
miss_read_end_req() -> cache_seg_put()
dm-pcache: remove ctrl_lock for pcache_cache_segment
The smatch checker reports a “scheduler in atomic context” problem in the following call chain:
miss_read_end_req() -> cache_seg_put() -> cache_seg_invalidate() -> cache_seg_gen_increase() -> mutex_lock(&cache_seg->ctrl_lock);
In practice, this `mutex_lock` will not actually schedule, because it is only called when `cache_seg_put()` drops the last reference, which is single-threaded. That is also why the issue never shows up during real testing.
However, the code is still buggy. The original purpose of `ctrl_lock` was to prevent read/write conflicts on the cache segment control information. Looking at the current usage, all control information accesses are single-threaded: reads only occur during the init phase, where no conflicts are possible, and writes happen once in the init phase (also single-threaded) and once when `cache_seg_put()` drops the last reference (again single-threaded).
Therefore, this patch removes `ctrl_lock` entirely and adds comments in the appropriate places to document this logic.
Signed-off-by: Dongsheng Yang <dongsheng.yang@linux.dev> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
show more ...
|