mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-25 03:46:17 +00:00
f2fs: don't rely on F2FS_MAP_* in f2fs_iomap_begin
[ Upstream commit8d3c1fa3fa
] When testing with a mixed zoned / convention device combination, there are regular but not 100% reproducible failures in xfstests generic/113 where the __is_valid_data_blkaddr assert hits due to finding a hole. This seems to be because f2fs_map_blocks can set this flag on a hole when it was found in the extent cache. Rework f2fs_iomap_begin to just check the special block numbers directly. This has the added benefits of the WARN_ON showing which invalid block address we found, and being properly error out on delalloc blocks that are confusingly called unwritten but not actually suitable for direct I/O. Fixes:1517c1a7a4
("f2fs: implement iomap operations") Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
d35290addc
commit
14b3742f34
1 changed files with 14 additions and 10 deletions
|
@ -4138,20 +4138,24 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
|
||||||
*/
|
*/
|
||||||
map.m_len = fscrypt_limit_io_blocks(inode, map.m_lblk, map.m_len);
|
map.m_len = fscrypt_limit_io_blocks(inode, map.m_lblk, map.m_len);
|
||||||
|
|
||||||
if (map.m_flags & (F2FS_MAP_MAPPED | F2FS_MAP_UNWRITTEN)) {
|
/*
|
||||||
iomap->length = blks_to_bytes(inode, map.m_len);
|
* We should never see delalloc or compressed extents here based on
|
||||||
if (map.m_flags & F2FS_MAP_MAPPED) {
|
* prior flushing and checks.
|
||||||
iomap->type = IOMAP_MAPPED;
|
*/
|
||||||
iomap->flags |= IOMAP_F_MERGED;
|
if (WARN_ON_ONCE(map.m_pblk == NEW_ADDR))
|
||||||
} else {
|
return -EINVAL;
|
||||||
iomap->type = IOMAP_UNWRITTEN;
|
if (WARN_ON_ONCE(map.m_pblk == COMPRESS_ADDR))
|
||||||
}
|
return -EINVAL;
|
||||||
if (WARN_ON_ONCE(!__is_valid_data_blkaddr(map.m_pblk)))
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
|
if (map.m_pblk != NULL_ADDR) {
|
||||||
|
iomap->length = blks_to_bytes(inode, map.m_len);
|
||||||
|
iomap->type = IOMAP_MAPPED;
|
||||||
|
iomap->flags |= IOMAP_F_MERGED;
|
||||||
iomap->bdev = map.m_bdev;
|
iomap->bdev = map.m_bdev;
|
||||||
iomap->addr = blks_to_bytes(inode, map.m_pblk);
|
iomap->addr = blks_to_bytes(inode, map.m_pblk);
|
||||||
} else {
|
} else {
|
||||||
|
if (flags & IOMAP_WRITE)
|
||||||
|
return -ENOTBLK;
|
||||||
iomap->length = blks_to_bytes(inode, next_pgofs) -
|
iomap->length = blks_to_bytes(inode, next_pgofs) -
|
||||||
iomap->offset;
|
iomap->offset;
|
||||||
iomap->type = IOMAP_HOLE;
|
iomap->type = IOMAP_HOLE;
|
||||||
|
|
Loading…
Reference in a new issue