• Naohiro Aota's avatar
    btrfs: zoned: implement zoned chunk allocator · 1cd6121f
    Naohiro Aota authored
    Implement a zoned chunk and device extent allocator. One device zone
    becomes a device extent so that a zone reset affects only this device
    extent and does not change the state of blocks in the neighbor device
    extents.
    
    To implement the allocator, we need to extend the following functions for
    a zoned filesystem.
    
    - init_alloc_chunk_ctl
    - dev_extent_search_start
    - dev_extent_hole_check
    - decide_stripe_size
    
    init_alloc_chunk_ctl_zoned() is mostly the same as regular one. It always
    set the stripe_size to the zone size and aligns the parameters to the zone
    size.
    
    dev_extent_search_start() only aligns the start offset to zone boundaries.
    We don't care about the first 1MB like in regular filesystem because we
    anyway reserve the first two zones for superblock logging.
    
    dev_extent_hole_check_zoned() checks if zones in given hole are either
    conventional or empty sequential zones. Also, it skips zones reserved for
    superblock logging.
    
    With the change to the hole, the new hole may now contain pending extents.
    So, in this case, loop again to check that.
    
    Finally, decide_stripe_size_zoned() should shrink the number of devices
    instead of stripe size because we need to honor stripe_size == zone_size.
    Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
    Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    1cd6121f
volumes.c 210 KB