• Naohiro Aota's avatar
    btrfs: zoned: properly finish block group on metadata write · 56fbb0a4
    Naohiro Aota authored
    Commit be1a1d7a ("btrfs: zoned: finish fully written block group")
    introduced zone finishing code both for data and metadata end_io path.
    However, the metadata side is not working as it should. First, it
    compares logical address (eb->start + eb->len) with offset within a
    block group (cache->zone_capacity) in submit_eb_page(). That essentially
    disabled zone finishing on metadata end_io path.
    
    Furthermore, fixing the issue above revealed we cannot call
    btrfs_zone_finish_endio() in end_extent_buffer_writeback(). We cannot
    call btrfs_lookup_block_group() which require spin lock inside end_io
    context.
    
    Introduce btrfs_schedule_zone_finish_bg() to wait for the extent buffer
    writeback and do the zone finish IO in a workqueue.
    
    Also, drop EXTENT_BUFFER_ZONE_FINISH as it is no longer used.
    
    Fixes: be1a1d7a ("btrfs: zoned: finish fully written block group")
    CC: stable@vger.kernel.org # 5.16+
    Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
    Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    56fbb0a4
zoned.c 53.2 KB