• Naohiro Aota's avatar
    btrfs: zoned: drop optimization of zone finish · b3a3b025
    Naohiro Aota authored
    We have an optimization in do_zone_finish() to send REQ_OP_ZONE_FINISH only
    when necessary, i.e. we don't send REQ_OP_ZONE_FINISH when we assume we
    wrote fully into the zone.
    
    The assumption is determined by "alloc_offset == capacity". This condition
    won't work if the last ordered extent is canceled due to some errors. In
    that case, we consider the zone is deactivated without sending the finish
    command while it's still active.
    
    This inconstancy results in activating another block group while we cannot
    really activate the underlying zone, which causes the active zone exceeds
    errors like below.
    
        BTRFS error (device nvme3n2): allocation failed flags 1, wanted 520192 tree-log 0, relocation: 0
        nvme3n2: I/O Cmd(0x7d) @ LBA 160432128, 127 blocks, I/O Error (sct 0x1 / sc 0xbd) MORE DNR
        active zones exceeded error, dev nvme3n2, sector 0 op 0xd:(ZONE_APPEND) flags 0x4800 phys_seg 1 prio class 0
        nvme3n2: I/O Cmd(0x7d) @ LBA 160432128, 127 blocks, I/O Error (sct 0x1 / sc 0xbd) MORE DNR
        active zones exceeded error, dev nvme3n2, sector 0 op 0xd:(ZONE_APPEND) flags 0x4800 phys_seg 1 prio class 0
    
    Fix the issue by removing the optimization for now.
    
    Fixes: 8376d9e1 ("btrfs: zoned: finish superblock zone once no space left for new SB")
    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>
    b3a3b025
zoned.c 54.2 KB