]> www.infradead.org Git - users/jedix/linux-maple.git/commit
btrfs: zoned: handle broken write pointer on zones
authorNaohiro Aota <naohiro.aota@wdc.com>
Fri, 30 Aug 2024 16:32:49 +0000 (01:32 +0900)
committerDavid Sterba <dsterba@suse.com>
Mon, 2 Sep 2024 21:39:34 +0000 (23:39 +0200)
commitb1934cd6069538db2255dc94ba573771ecf3b560
tree0b991905c81388a53e1b294767c53dfad1cd8bcc
parentc346c629765ab982967017e2ae859156d0e235cf
btrfs: zoned: handle broken write pointer on zones

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: 265f7237dd25 ("btrfs: zoned: allow DUP on meta-data block groups")
Fixes: 568220fa9657 ("btrfs: zoned: support RAID0/1/10 on top of raid stripe tree")
CC: stable@vger.kernel.org # 6.1+
Reported-by: HAN Yuwei <hrx@bupt.moe>
Cc: Xuefer <xuefer@gmail.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/zoned.c