Skip to content

Commit 443e4d0

Browse files
fdmananakdave
authored andcommitted
btrfs: return real error from __filemap_get_folio() calls
We have a few places that always assume a -ENOMEM error happened in case a call to __filemap_get_folio() returns an error, which is just too much of an assumption and even if it would be the case at some point in time, it's not future proof and there's nothing in the documentation that guarantees that only ERR_PTR(-ENOMEM) can be returned with the flags we are passing to it. So use the exact error returned by __filemap_get_folio() instead. Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent ca84913 commit 443e4d0

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

fs/btrfs/free-space-cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
457457
mask);
458458
if (IS_ERR(folio)) {
459459
io_ctl_drop_pages(io_ctl);
460-
return -ENOMEM;
460+
return PTR_ERR(folio);
461461
}
462462

463463
ret = set_folio_extent_mapped(folio);

fs/btrfs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4937,7 +4937,7 @@ int btrfs_truncate_block(struct btrfs_inode *inode, u64 offset, u64 start, u64 e
49374937
btrfs_delalloc_release_space(inode, data_reserved,
49384938
block_start, blocksize, true);
49394939
btrfs_delalloc_release_extents(inode, blocksize);
4940-
ret = -ENOMEM;
4940+
ret = PTR_ERR(folio);
49414941
goto out;
49424942
}
49434943

fs/btrfs/reflink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static int copy_inline_to_page(struct btrfs_inode *inode,
8787
FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
8888
btrfs_alloc_write_mask(mapping));
8989
if (IS_ERR(folio)) {
90-
ret = -ENOMEM;
90+
ret = PTR_ERR(folio);
9191
goto out_unlock;
9292
}
9393

0 commit comments

Comments
 (0)