From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.70.43.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796410820; b=3QjjyrjCpVTsDDOJUN5HmXUAafLuD5zAjIDtTtxHZtg6fI1zYSYeE8OSbLfQD54aT8uO FTCRQbiPBCa+z7tEP1dWnD+dTvpDwaNK3M2rcbhNhvx0sSZAdXtXiMy8gaOApV8vBwlUt /ja0tb58e555xu7xnjrKdIOpsP0d8BOdFho3FMwkV+3/sv9Z7LQHUHzjHJ/PiKxTQLAX5 yqAs3F5Jj/RPRUW6qyDTUBRpNVT8i/caKnogveH2BpeiRNJRMMp0Q34RXgCa6wpZKO1Zm gU86m6lWkO1KJJf+srJt2zTewuyZbjIlcU4Do/nIf6wv7q1hTOmFWCzDVNA0EkY1IdA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796410820; h=DMARC-Filter:DKIM-Signature:X-Pm-Submission-Id:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=SkHkKF796DWlqVDLoRyuC6b+b0RfACJUvDzHda5ptr8=; b=HzrB5md8B8wQ7eWrodo5deAkWFrduBFtrHKeQ+uRDdPBDuWAvFWzGSA2fYS53Jtcz4Kk GomYLX8SG5d7roO6bME54hEcjjKpGzddLcCZh9DTj0z7pNiA0UDQBbJXYzHM1qgNJww46 8zKQfm0Qfpc9wyaGnlx2J4Ruvi+TvSYuFJpXnWJ6WWcb/LNnSbRJE8IiKUCPEY9g7bFbH Pt0g5iU2yZ+LFofp+xbqzLqP2fL2AoKJQ/06h9/fZw5g7i4s4Rv1hcysX6vwXXb7tklJR Zv3WfthMrpKXQ2T26Iz8og3HbXTEPoW2Pgnpb0RpWq3hypXWLx/+M7uL0JXtBy0Bdbw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=raidlab.org; spf=pass smtp.mailfrom=raidlab.org; dkim=pass header.d=raidlab.org header.i=@raidlab.org header.a=rsa-sha256 header.s=protonmail header.b=l2tijaNF; arc=none smtp.remote-ip=185.70.43.172 Received: from mail-43172.protonmail.ch (mail-43172.protonmail.ch [185.70.43.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD114606A334 for ; Fri, 4 Dec 2026 19:00:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AD114606A334 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raidlab.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raidlab.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=raidlab.org header.i=@raidlab.org header.a=rsa-sha256 header.s=protonmail header.b=l2tijaNF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raidlab.org; s=protonmail; t=1796410809; x=1796670009; bh=SkHkKF796DWlqVDLoRyuC6b+b0RfACJUvDzHda5ptr8=; h=From:To:Cc:Subject:Date:Message-ID:From:To:Cc:Date:Subject: Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=l2tijaNF3iv39w4mtiVUsD9q3U2ZocyZld5uSaIWGCk8w7Kcx7Pb16YnOimgICzy0 Mt01fmD6oznyhR97Hd3CU93ubUEtQ/UXtJ9qjSXtHraA/csXBnW7e5G/xipL7qsZ4z H1wHfHgSugQz93UBveW6DbwpVJteVN7WHGbqBIwQLHMyNWMq8JQD2wb+AqBdIhYfoB DYolA1vYnaSfhOa7n95gMiA2PaO2Up7W5hV6cILXQX2zQHy0v/BaqDTnB/uZ3V920e HcKnNGFV5aqBx9Bk+bgkYuCSdMRpgFHUf+92hoauVn25EfdhbVM4fpJqSBI/dIV9HN GrPvwFCkACLkw== X-Pm-Submission-Id: 4jh15d59RRz2Scmb From: Miroslav Cimerman To: linux-btrfs@vger.kernel.org Cc: David Sterba , Chris Mason , Johannes Thumshirn , Naohiro Aota Subject: [PATCH v3 0/3] btrfs: zoned: unwritten copies of mirrored data writes Date: Fri, 4 Dec 2026 18:59:54 +0000 Message-ID: <20261204185957.313982-1-mc@raidlab.org> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On a zoned filesystem, a mirrored data write can lose a copy, or fail, without any problem on the devices. The bugs fixed by 1/3 and 3/3 need writes to one zone to arrive out of allocation order, which parallel writers do. 1/3: since 7.0, every copy but the last is a regular write. A regular write that arrives before an earlier one fails. 2/3: since 5.19, unmount does not wait for the work that finishes the zones of a full metadata block group. 3/3 uses that work for data too. 3/3: since 6.7, with the raid stripe tree, the zones of a block group are finished when the extent at its end completes. Zone append writes of other extents that are still queued then fail. 3/3 relies on alloc_offset of a full block group not moving back. [2] fixes the zoned allocator, which could move it back. Changes in v3: - 1/3: unchanged. - 2/3: also wait in btrfs_remove_block_group(). A block group removed before unmount is no longer in the tree that unmount walks (Sashiko on v2 [1]). Reviewed-by from Johannes. - 3/3: split the assertion into ASSERT()s with messages, and assert that delalloc_bytes does not underflow (Johannes). The data relocation block group on RAID0/RAID10 has an older problem of its own (Sashiko). I will send a fix. - Rebased on for-next. Changes in v2: - 1/3: Reviewed-by from Johannes. Stable tag 6.18+: the fixed commit is in 6.18.y too. Rebased on for-next. - 2/3: new. - 3/3: no new field in btrfs_block_group (Johannes). zone_finish_work finishes the zones once every extent that zone append writes to the block group is written or freed. Rebased on for-next. Tested on for-next d7a35bfad47f with [2] applied, btrfs-progs 7.3 and 8 active zones per device. Without the series, 8 direct writers on RAID1 with the raid stripe tree hit zone append errors in 2 of 2 runs. With the series, 13 runs showed no failed write and no assertion, and unmount waited for every zone finish work. Found by an LLM while testing a fix on zoned RAID1. The analysis, the fixes and the tests were done with the help of an LLM. I reviewed everything. [1] v2: https://lore.kernel.org/linux-btrfs/20261129235226.459661-1-mc@raidlab.org/ [2] https://lore.kernel.org/linux-btrfs/20261130163800.175298-1-mc@raidlab.org/ Miroslav Cimerman (3): btrfs: zoned: use zone append for every copy of a mirrored write btrfs: zoned: wait for zone finish works at removal and unmount btrfs: zoned: finish raid stripe tree zones once all data is written fs/btrfs/bio.c | 1 + fs/btrfs/block-group.c | 30 ++++++++++++++++-- fs/btrfs/disk-io.c | 7 +++++ fs/btrfs/inode.c | 6 ++++ fs/btrfs/zoned.c | 71 ++++++++++++++++++++++++++++++++++++++++-- fs/btrfs/zoned.h | 3 ++ 6 files changed, 113 insertions(+), 5 deletions(-) base-commit: d7a35bfad47f033380f6f6d42d186adc1d9fe406 -- 2.53.0