Skip to contentSkip to conversation

btrfs: zoned: Put block group after final usage

PATCH In review Nikolay Borisov 3 participants 3 messages Mar 7, 2022 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: zoned: Put block group after final usage

It's counter-intuitive (and wrong) to put the block group _before_ the final usage in submit_eb_page. Fix it by re-ordering the call to btrfs_put_block_group after its final reference. Also fix a minor typo in 'implies'

Fixes be1a1d7a5d24 ("btrfs: zoned: finish fully written block group")
---
 fs/btrfs/extent_io.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
fs/btrfs/extent_io.c +6 -3
index 3f13ff0affdb..ebda09c207f1 100644
@@ -4786,11 +4786,14 @@ static int submit_eb_page(struct page *page, struct writeback_control *wbc,
 		return ret;
 	}
 	if (cache) {
-		/* Impiles write in zoned mode */
-		btrfs_put_block_group(cache);
-		/* Mark the last eb in a block group */
+		/*
+		 * Implies write in zoned mode.
+		 *
+		 * Mark the last eb in a block group
+		 */
 		if (cache->seq_zone && eb->start + eb->len == cache->zone_capacity)
 			set_bit(EXTENT_BUFFER_ZONE_FINISH, &eb->bflags);
+		btrfs_put_block_group(cache);
 	}
 	ret = write_one_eb(eb, wbc, epd);
 	free_extent_buffer(eb);

--
2.25.1

#2 lore raw
In reply to Nikolay Borisov
Quoted 8 lines · Nikolay Borisov

It's counter-intuitive (and wrong) to put the block group _before_ the final usage in submit_eb_page. Fix it by re-ordering the call to btrfs_put_block_group after its final reference. Also fix a minor typo in 'implies'

Fixes be1a1d7a5d24 ("btrfs: zoned: finish fully written block group")

Added to misc-next, thanks.