Commit 40669862 authored by Daniel Vacek's avatar Daniel Vacek Committed by David Sterba
Browse files

btrfs: move folio initialization to one place in attach_eb_folio_to_filemap()



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: default avatarDaniel Vacek <neelx@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent c779b798
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -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 @@ static int attach_eb_folio_to_filemap(struct extent_buffer *eb, int i,

	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);