From 0f2bc221507fa1e787b87c783f4c699e5feb8957 Mon Sep 17 00:00:00 2001 From: Filipe Manana Date: Sat, 10 May 2025 14:08:39 +0100 Subject: [PATCH] btrfs: simplify error return logic when getting folio at prepare_one_folio() There's no need to have special logic to return -EAGAIN in case the call to __filemap_get_folio() fails, because when FGP_NOWAIT is passed to __filemap_get_folio() it returns ERR_PTR(-EAGAIN) if it needs to do something that would imply blocking. The reason we have this logic is from the days before we migrated to the folio interface, when we called pagecache_get_page() which would return NULL instead of an error pointer. So remove this special casing and always return the error that the call to __filemap_get_folio() returned. Reviewed-by: Johannes Thumshirn Reviewed-by: Qu Wenruo Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba --- fs/btrfs/file.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index c1b350fd3bb7..660a73b6af90 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -866,13 +866,9 @@ static noinline int prepare_one_folio(struct inode *inode, struct folio **folio_ again: folio = __filemap_get_folio(inode->i_mapping, index, fgp_flags, mask); - if (IS_ERR(folio)) { - if (nowait) - ret = -EAGAIN; - else - ret = PTR_ERR(folio); - return ret; - } + if (IS_ERR(folio)) + return PTR_ERR(folio); + ret = set_folio_extent_mapped(folio); if (ret < 0) { folio_unlock(folio); -- 2.50.1