btrfs: move folio initialization to one place in attach_eb_folio_to_filemap()
authorDaniel Vacek <neelx@suse.com>
Wed, 23 Apr 2025 08:51:22 +0000 (10:51 +0200)
committerDavid Sterba <dsterba@suse.com>
Thu, 15 May 2025 12:30:49 +0000 (14:30 +0200)
This is just a trivial change. The code looks a bit more readable this way, IMO.

Move initialization of existing_folio to the beginning of the retry loop
so it's set to NULL at one place.

Signed-off-by: Daniel Vacek <neelx@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c

index da836fc32f24a26943350197c5daec44cb711824..a231d03d51c7e134de884849c0550292ce09449b 100644 (file)
@@ -3107,7 +3107,7 @@ static int attach_eb_folio_to_filemap(struct extent_buffer *eb, int i,
        struct btrfs_fs_info *fs_info = eb->fs_info;
        struct address_space *mapping = fs_info->btree_inode->i_mapping;
        const unsigned long index = eb->start >> PAGE_SHIFT;
-       struct folio *existing_folio = NULL;
+       struct folio *existing_folio;
        int ret;
 
        ASSERT(found_eb_ret);
@@ -3116,6 +3116,7 @@ static int attach_eb_folio_to_filemap(struct extent_buffer *eb, int i,
        ASSERT(eb->folios[i]);
 
 retry:
+       existing_folio = NULL;
        ret = filemap_add_folio(mapping, eb->folios[i], index + i,
                                GFP_NOFS | __GFP_NOFAIL);
        if (!ret)
@@ -3123,10 +3124,8 @@ retry:
 
        existing_folio = filemap_lock_folio(mapping, index + i);
        /* The page cache only exists for a very short time, just retry. */
-       if (IS_ERR(existing_folio)) {
-               existing_folio = NULL;
+       if (IS_ERR(existing_folio))
                goto retry;
-       }
 
        /* For now, we should only have single-page folios for btree inode. */
        ASSERT(folio_nr_pages(existing_folio) == 1);