f2fs: fix to handle filemap_fdatawrite() error in f2fs_ioc_decompress_file/f2fs_ioc_compress_file

It seems inappropriate that the current logic does not handle
filemap_fdatawrite() errors, so let's fix it.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Yangtao Li 2023-03-02 17:55:09 +08:00 committed by Jaegeuk Kim
parent 5bb9c111cd
commit b822dc9149
1 changed files with 10 additions and 4 deletions

View File

@ -4063,8 +4063,11 @@ static int f2fs_ioc_decompress_file(struct file *filp)
if (ret < 0)
break;
if (get_dirty_pages(inode) >= blk_per_seg)
filemap_fdatawrite(inode->i_mapping);
if (get_dirty_pages(inode) >= blk_per_seg) {
ret = filemap_fdatawrite(inode->i_mapping);
if (ret < 0)
break;
}
count -= len;
page_idx += len;
@ -4134,8 +4137,11 @@ static int f2fs_ioc_compress_file(struct file *filp)
if (ret < 0)
break;
if (get_dirty_pages(inode) >= blk_per_seg)
filemap_fdatawrite(inode->i_mapping);
if (get_dirty_pages(inode) >= blk_per_seg) {
ret = filemap_fdatawrite(inode->i_mapping);
if (ret < 0)
break;
}
count -= len;
page_idx += len;