• Naohiro Aota's avatar
    btrfs: zoned: handle broken write pointer on zones · b1934cd6
    Naohiro Aota authored
    Btrfs rejects to mount a FS if it finds a block group with a broken write
    pointer (e.g, unequal write pointers on two zones of RAID1 block group).
    Since such case can happen easily with a power-loss or crash of a system,
    we need to handle the case more gently.
    
    Handle such block group by making it unallocatable, so that there will be
    no writes into it. That can be done by setting the allocation pointer at
    the end of allocating region (= block_group->zone_capacity). Then, existing
    code handle zone_unusable properly.
    
    Having proper zone_capacity is necessary for the change. So, set it as fast
    as possible.
    
    We cannot handle RAID0 and RAID10 case like this. But, they are anyway
    unable to read because of a missing stripe.
    
    Fixes: 265f7237 ("btrfs: zoned: allow DUP on meta-data block groups")
    Fixes: 568220fa ("btrfs: zoned: support RAID0/1/10 on top of raid stripe tree")
    CC: stable@vger.kernel.org # 6.1+
    Reported-by: default avatarHAN Yuwei <hrx@bupt.moe>
    Cc: Xuefer <xuefer@gmail.com>
    Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    b1934cd6
zoned.c 70.2 KB