linux/fs/f2fs
Jaegeuk Kim 13981b0555 f2fs: fix wrong block mapping for multi-devices
[ Upstream commit 9d5c4f5c7a ]

Assuming the disk layout as below,

disk0: 0            --- 0x00035abfff
disk1: 0x00035ac000 --- 0x00037abfff
disk2: 0x00037ac000 --- 0x00037ebfff

and we want to read data from offset=13568 having len=128 across the block
devices, we can illustrate the block addresses like below.

0 .. 0x00037ac000 ------------------- 0x00037ebfff, 0x00037ec000 -------
          |          ^            ^                                ^
          |   fofs   0            13568                            13568+128
          |       ------------------------------------------------------
          |   LBA    0x37e8aa9    0x37ebfa9                        0x37ec029
          --- map    0x3caa9      0x3ffa9

In this example, we should give the relative map of the target block device
ranging from 0x3caa9 to 0x3ffa9 where the length should be calculated by
0x37ebfff + 1 - 0x37ebfa9.

In the below equation, however, map->m_pblk was supposed to be the original
address instead of the one from the target block address.

 - map->m_len = min(map->m_len, dev->end_blk + 1 - map->m_pblk);

Cc: stable@vger.kernel.org
Fixes: 71f2c82062 ("f2fs: multidevice: support direct IO")
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
[ applied fix to f2fs_map_blocks() instead of f2fs_map_blocks_cached() ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2025-10-29 14:03:15 +01:00
..
acl.c vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
acl.h vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
checkpoint.c f2fs: fix typos in comments 2024-06-16 13:39:36 +02:00
compress.c f2fs: fix typos in comments 2024-06-16 13:39:36 +02:00
data.c f2fs: fix wrong block mapping for multi-devices 2025-10-29 14:03:15 +01:00
debug.c f2fs: use spin_lock to avoid hang 2022-04-08 14:23:58 +02:00
dir.c f2fs: Introduce linear search for dentries 2025-03-13 12:50:14 +01:00
extent_cache.c f2fs: fix KMSAN uninit-value in extent_info usage 2025-08-28 16:24:12 +02:00
f2fs.h f2fs: fix to avoid out-of-boundary access in devs.path 2025-08-28 16:24:12 +02:00
file.c f2fs: fix to wait dio completion 2025-03-13 12:50:46 +01:00
gc.c f2fs: reduce stack memory cost by using bitfield in struct f2fs_io_info 2024-03-26 18:21:32 -04:00
gc.h f2fs: introduce gc_merge mount option 2021-03-30 18:48:56 -07:00
hash.c f2fs: don't use casefolded comparison for "." and ".." 2022-06-09 10:23:17 +02:00
inline.c f2fs: Introduce linear search for dentries 2025-03-13 12:50:14 +01:00
inode.c f2fs: fix to do sanity check on ino and xnid 2025-08-28 16:24:31 +02:00
iostat.c f2fs: fix to avoid potential memory corruption in __update_iostat_latency() 2023-03-11 13:57:26 +01:00
iostat.h f2fs: introduce periodic iostat io latency traces 2021-08-23 10:25:51 -07:00
Kconfig f2fs: separate out iostat feature 2021-08-23 10:25:51 -07:00
Makefile f2fs: separate out iostat feature 2021-08-23 10:25:51 -07:00
namei.c f2fs: prevent kernel warning due to negative i_nlink from corrupted image 2025-06-27 11:05:25 +01:00
node.c f2fs: fix to avoid out-of-boundary access in dnode page 2025-08-28 16:24:36 +02:00
node.h f2fs: swap: support migrating swapfile in aligned write mode 2021-06-23 01:09:35 -07:00
recovery.c f2fs: fix write pointers on zoned device after roll forward 2024-02-23 08:54:46 +01:00
segment.c f2fs: check curseg->inited before write_sum_page in change_curseg 2024-12-14 19:51:05 +01:00
segment.h f2fs: remove struct segment_allocation default_salloc_ops 2024-12-14 19:51:05 +01:00
shrinker.c f2fs: avoid race condition for shrinker count 2020-12-03 00:59:26 -08:00
super.c f2fs: don't over-report free space or inodes in statvfs 2025-07-10 15:57:35 +02:00
sysfs.c f2fs: check validation of fault attrs in f2fs_build_fault_attr() 2025-05-02 07:44:24 +02:00
verity.c fs: f2fs: initialize fsdata in pagecache_write() 2023-03-11 13:57:23 +01:00
xattr.c f2fs: reduce expensive checkpoint trigger frequency 2024-10-17 15:11:04 +02:00
xattr.h f2fs: code cleanup by removing ifdef macro surrounding 2020-05-26 18:56:10 -07:00