ext4: check iomap type only if ext4_iomap_begin() does not fail
PATCH 1/1 ext4: check iomap type only if ext4_iomap_begin() does not fail
When ext4_iomap_overwrite_begin() calls ext4_iomap_begin() map blocks may fail for some reason (e.g. memory allocation failure, bare disk write), and later because "iomap->type ! = IOMAP_MAPPED" triggers WARN_ON(). When ext4 iomap_begin() returns an error, it is normal that the type of iomap->type may not match the expectation. Therefore, we only determine if iomap->type is as expected when ext4_iomap_begin() is executed successfully.
--- fs/ext4/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/inode.c +1 -1
@@ -3375,7 +3375,7 @@ static int ext4_iomap_overwrite_begin(struct inode *inode, loff_t offset,*/ flags &= ~IOMAP_WRITE ; ret =ext4_iomap_begin (inode, offset, length, flags, iomap, srcmap); -WARN_ON_ONCE (iomap->type !=IOMAP_MAPPED ); +WARN_ON_ONCE (!ret && iomap->type !=IOMAP_MAPPED );return ret; }
Signature · 1 line
2.31.1
Quoted 10 lines · Baokun Li
When
ext4_iomap_overwrite_begin()callsext4_iomap_begin()map blocks may fail for some reason (e.g. memory allocation failure, bare disk write), and later because "iomap->type! =IOMAP_MAPPED" triggersWARN_ON(). When ext4iomap_begin()returns an error, it is normal that the type ofiomap->typemay not match the expectation. Therefore, we only determine ifiomap->typeis as expected whenext4_iomap_begin()is executed successfully.Reported-by [email protected]Signed-off-by Baokun Li <[email protected]>
Makes sense. Feel free to add:
Honza
Quoted 16 lines
fs/ext4/inode.c +1
-1@@ -3375,7 +3375,7 @@ static int ext4_iomap_overwrite_begin(struct inode *inode, loff_t offset,*/ flags &= ~IOMAP_WRITE ; ret =ext4_iomap_begin (inode, offset, length, flags, iomap, srcmap); -WARN_ON_ONCE (iomap->type !=IOMAP_MAPPED ); +WARN_ON_ONCE (!ret && iomap->type !=IOMAP_MAPPED );return ret; }Signature · 1 line
2.31.1
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 8 lines · Baokun Li
When
ext4_iomap_overwrite_begin()callsext4_iomap_begin()map blocks may fail for some reason (e.g. memory allocation failure, bare disk write), and later because "iomap->type! =IOMAP_MAPPED" triggersWARN_ON(). When ext4iomap_begin()returns an error, it is normal that the type ofiomap->typemay not match the expectation. Therefore, we only determine ifiomap->typeis as expected whenext4_iomap_begin()is executed successfully.[...]
Applied, thanks!
[1/1] ext4: check iomap type only if ext4_iomap_begin() does not fail
commit: 705c514635a4b6fd0ee321bcf1a9bd75c3629b71
Best regards,
Signature · 1 line
Theodore Ts'o <[email protected]>