Skip to contentSkip to conversation

btrfs: a small cleanup in attach_eb_folio_to_filemap()

PATCH In review Daniel Vacek 2 participants 2 messages Apr 23, 2025 – Apr 24, 2025 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: a small cleanup in attach_eb_folio_to_filemap()

This is just a trivial change. The code looks a bit more readable this way, IMO.

---
 fs/btrfs/extent_io.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
fs/btrfs/extent_io.c +3 -4
index 7023dd527d3e7..cab4cc5583400 100644
@@ -3139,7 +3139,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);
@@ -3148,6 +3148,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)
@@ -3155,10 +3156,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);
Signature · 1 line
2.47.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 1 line · Daniel Vacek

This is just a trivial change. The code looks a bit more readable this way, IMO.

Please be more descriptive in the changelogs, the subject and text is too generic. Something like "move the initializations of folio to the beginning of the retry loop". Otherwise agreed taht it's better this way. I'll update the changelog when adding it to for-next. Thanks.

Quoted 1 line