From: Nikolay Borisov Date: Mon, 7 Mar 2022 13:30:02 +0000 (+0200) Subject: btrfs: zoned: put block group after final usage X-Git-Tag: v5.17.2~984 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=ea1e3fbb68e6c07df9c99363ed6ab2d92627792e;p=users%2Fdwmw2%2Flinux.git btrfs: zoned: put block group after final usage commit d3e29967079c522ce1c5cab0e9fab2c280b977eb upstream. 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") CC: stable@vger.kernel.org # 5.16+ Reviewed-by: Johannes Thumshirn Signed-off-by: Nikolay Borisov Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 4c91060d103ae..f767c1164742d 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -4780,11 +4780,12 @@ 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);