f2fs: fix 0 addr of multi devices when dio mapping
PATCH 1/1 f2fs: fix 0 addr of multi devices when dio mapping
Consider of a f2fs system with 2 devices:
Info: Device[0] : /dev/block/dm-46 blkaddr = 0--3fffff
Info: Device[1] : /dev/block/dm-47 blkaddr = 400000--67fffff
f2fs_map_blocks will return logical addr of fs when doing buffered io:f2fs_map_blocks: dev = (254,46), ino = 40020, file offset = 462865, start blkaddr = 0x400000
While dio mapping will return the addr of device:f2fs_map_blocks: dev = (254,47), ino = 40020, file offset = 462865, start blkaddr = 0x0
So the addr=0 is valid when the map.m_bdev is not s_bdev.
--- fs/f2fs/data.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/data.c +2 -1
@@ -4185,7 +4185,8 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,if (WARN_ON_ONCE (map.m_pblk ==COMPRESS_ADDR ))return -EINVAL ; -if (map.m_pblk !=NULL_ADDR ) { +if (map.m_pblk !=NULL_ADDR || + (map.m_multidev_dio && map.m_bdev != inode->i_sb->s_bdev)) { iomap->length =blks_to_bytes (inode, map.m_len); iomap->type =IOMAP_MAPPED ; iomap->flags |=IOMAP_F_MERGED ;
Signature · 1 line
2.25.1
Chao Yu
maintainerQuoted 11 lines · Wu Bo
Consider of a f2fs system with 2 devices:
Info: Device[0] :/dev/block/dm-46blkaddr = 0--3fffff
Info: Device[1] :/dev/block/dm-47blkaddr = 400000--67fffff
f2fs_map_blockswill return logical addr of fs when doing buffered io:f2fs_map_blocks: dev = (254,46), ino = 40020, file offset = 462865, start blkaddr =0x400000While dio mapping will return the addr of device:
f2fs_map_blocks: dev = (254,47), ino = 40020, file offset = 462865, start blkaddr =0x0So the addr=0 is valid when the map.m_bdev is not
s_bdev.
Thanks for catching this, there is already a formal patch as below link:
https://lore.kernel.org/linux-f2fs-devel/[email protected]
Thanks,
Quoted 21 lines
Fixes 8d3c1fa3fa5e ("f2fs: don't rely on F2FS_MAP_* in f2fs_iomap_begin")Signed-off-by Wu Bo <[email protected]>--- fs/f2fs/data.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/f2fs/data.c +2
-1@@ -4185,7 +4185,8 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,if (WARN_ON_ONCE (map.m_pblk ==COMPRESS_ADDR ))return -EINVAL ; -if (map.m_pblk !=NULL_ADDR ) { +if (map.m_pblk !=NULL_ADDR || + (map.m_multidev_dio && map.m_bdev != inode->i_sb->s_bdev)) { iomap->length =blks_to_bytes (inode, map.m_len); iomap->type =IOMAP_MAPPED ; iomap->flags |=IOMAP_F_MERGED ;