From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=79.135.106.112 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795996542; b=b6FW16wB8ncyXEVlWvwk4gV6eVdWDpavAHwqtBslW5oOFTIkPXjEUcvJmUpZbK+6XAHE 5OBdffWG5+Ouor3fPB0Xs7Aqybvtj60GFstmtGeiMyD5PB4xIqA+JhI+wO3TK1cK/x+9g s4P/1zWWaE6qtcz1QtkWgqQlfCUtBILNBVxJ/ctTcd+4VR5HVEmfbx9yyPQYPOB7Mukbq YWNNGPWvh1VLFJV+2HGwoLhV3nJnxIm0IVtwuzSkLvGZQPuiosU9lt70bThIjlZ+nEBwh xVyaTo6LqSha7fHMH1kxrCp8OdtgcN6wgEKH/00Z/OBMdBqMfcPujACYM9MEAt37wtg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795996542; h=DMARC-Filter:DKIM-Signature:X-Pm-Submission-Id:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=ALKu72hGpwsIvVy1jiErLmS1E0BoEy1DyZREUV2NNIE=; b=b7Qcrz6GAq8iJUxVz0y91+7ope876vHwRNDnFwUAcKl9ZxYHgdUReVUjLXKyRf54uhq8 R3V47R14e9j4ghlmy1GuaFRA9lZKsu4BR9VmxKq5rGalUydVpHnN2xTtHehCSYywSkpId 3YehcjmXahymnhGgziFG3NxMTGEDCnx53OgZu8RVD0+xAUN80243SF2qwKex71g991Ppy KihM2QHHulAeuZcM3gRXLlFUSxESad+6J/5f+AKcWZeeaVfsYgb65TtCrBEvlZIXu+KlJ 50mG0uZ2UMo3wdSHNbDweZVOhnexHsOCzA2OGqmSspqSgFCtYXuA3VxPM3JiDrFFjtw== 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=qQscRCCl; arc=none smtp.remote-ip=79.135.106.112 Received: from mail-106112.protonmail.ch (mail-106112.protonmail.ch [79.135.106.112]) (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 79FE1606A325 for ; Sun, 29 Nov 2026 23:55:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 79FE1606A325 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=qQscRCCl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raidlab.org; s=protonmail; t=1795996538; x=1796255738; bh=ALKu72hGpwsIvVy1jiErLmS1E0BoEy1DyZREUV2NNIE=; h=From:To:Cc:Subject:Date:Message-ID:From:To:Cc:Date:Subject: Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=qQscRCClrx4xmWUKrgOwVR1TH9ynvt127oTSyZ+m0uqs9kW+ouev0XqqfSrN1E3az rRXphD3FldmK6ZMtToatvMGBhAaRCUxmqWDcz7IVSgfF7BpmOLe2ZrNI7hXwHzIbBs ZcPEVecMZJopvZ2Cd54lnKeR6+akCtU0iReTjyjEGO2sW91MOuq6FQSkCKnMp6Bh0O bQSrzFU0cGfAnfhoMNGT4IoMmQiKl/OP/ofLCo1RfO8Av84n5EPDXsgs2HM42gEeRj 0SrMDRDXXttXyJnuVdxjZvwK9gfd39Q0ODJil8JhS82UFl1waU4UZRsZPHteLTZzfE zpf7BJygBgMYQ== X-Pm-Submission-Id: 4jd3tv5Kbyz2ScP5 From: Miroslav Cimerman To: linux-btrfs@vger.kernel.org Cc: David Sterba , Chris Mason , Naohiro Aota , Johannes Thumshirn , Qu Wenruo , linux-kernel@vger.kernel.org Subject: [PATCH v2 0/3] btrfs: zoned: unwritten copies of mirrored data writes Date: Sun, 29 Nov 2026 23:52:23 +0000 Message-ID: <20261129235226.459661-1-mc@raidlab.org> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-kernel@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. 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 1adb6f14ca90 as in v1 [1], with 8 active zones per device. With 1/3 alone, zone append writes failed in 10 of 10 runs with 8 direct writers. With the series, 31 runs showed no failed write. A test-only print showed the work waiting for other writes before 82 of 160 zone finishes. With a test-only delay in the work, an unmount right after the writes hit an assertion in 9 of 9 runs without 2/3 and in none of 6 runs with it. 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] https://lore.kernel.org/linux-btrfs/20261122034826.2333981-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 unmount btrfs: zoned: finish raid stripe tree zones once all data is written fs/btrfs/bio.c | 1 + fs/btrfs/block-group.c | 16 ++++++++-- fs/btrfs/disk-io.c | 7 +++++ fs/btrfs/inode.c | 3 ++ fs/btrfs/zoned.c | 71 ++++++++++++++++++++++++++++++++++++++++-- fs/btrfs/zoned.h | 3 ++ 6 files changed, 96 insertions(+), 5 deletions(-) base-commit: 1adb6f14ca90851ae4a8279ee90442589c312ba3 -- 2.53.0