]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: stop checking for NULL return from btrfs_get_extent()
authorFilipe Manana <fdmanana@suse.com>
Thu, 3 Feb 2022 15:36:42 +0000 (15:36 +0000)
committerDavid Sterba <dsterba@suse.com>
Mon, 14 Mar 2022 12:13:50 +0000 (13:13 +0100)
At extent_io.c, in the read page and write page code paths, we are testing
if the return value from btrfs_get_extent() can be NULL. However that is
not possible, as btrfs_get_extent() always returns either an error pointer
or a (non-NULL) pointer to an extent map structure.

Everywhere else outside extent_io.c we never check for NULL, we always
treat any returned value as a non-NULL pointer if it does not encode an
error.

So check only for the IS_ERR() case at extent_io.c.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c

index 6bafdec691eb85c750908125963974bcf9749268..37589fd440b5ac94996db759ce882d7a20491a3b 100644 (file)
@@ -3534,7 +3534,7 @@ __get_extent_map(struct inode *inode, struct page *page, size_t pg_offset,
        }
 
        em = btrfs_get_extent(BTRFS_I(inode), page, pg_offset, start, len);
-       if (em_cached && !IS_ERR_OR_NULL(em)) {
+       if (em_cached && !IS_ERR(em)) {
                BUG_ON(*em_cached);
                refcount_inc(&em->refs);
                *em_cached = em;
@@ -3608,7 +3608,7 @@ int btrfs_do_readpage(struct page *page, struct extent_map **em_cached,
                }
                em = __get_extent_map(inode, page, pg_offset, cur,
                                      end - cur + 1, em_cached);
-               if (IS_ERR_OR_NULL(em)) {
+               if (IS_ERR(em)) {
                        unlock_extent(tree, cur, end);
                        end_page_read(page, false, cur, end + 1 - cur);
                        break;
@@ -3951,7 +3951,7 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode,
                }
 
                em = btrfs_get_extent(inode, NULL, 0, cur, end - cur + 1);
-               if (IS_ERR_OR_NULL(em)) {
+               if (IS_ERR(em)) {
                        btrfs_page_set_error(fs_info, page, cur, end - cur + 1);
                        ret = PTR_ERR_OR_ZERO(em);
                        break;