From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA2DA2C15BE; Thu, 12 Mar 2026 20:18:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773346711; cv=none; b=e89gJUru7H3uNjNiXDEnz+6X/GmsmeXUour91x+ewodDpT1qa2eK4dSZ8mXChBWm7gZqIeZ4xJhZnUcGd/qd4UMypYlf2knZMxdk06PKBxT2vuNNKRX0GmVs1mzTu3HiogEzgl9MQWZXXvU/o8v/DgwwbsPjUzVUdqAsgY1GSaQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773346711; c=relaxed/simple; bh=pbNBHnYlrmPmVMFyotoOiycK9/iwc0i1/iVRdT5VrI8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=djONjhL4ZV+M24NQtkzoEjBUb2VLiz2b+6SmIxHFtH+Cz5Wh2OgKyH3nhaK6O8TYPOtZy19bJjrOUsr6Pf8WWjNqrnBu72swH25Kd508qH44L8XoGavo2FtADaD829LKSOmR4uk1uOIJdInAoqcL8yUwEIxH/bogTE/kld3Hno8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=MSHHQXbK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="MSHHQXbK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 228F3C19425; Thu, 12 Mar 2026 20:18:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1773346711; bh=pbNBHnYlrmPmVMFyotoOiycK9/iwc0i1/iVRdT5VrI8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MSHHQXbKseFxpHif9uI7gkhaQmaFEKhPR5IBQ6cJaTAR48enCG9s2imYGdINsPEQM CEuMmHSTVeV6wSLVbfCh4KzoT2VQGpkvZ76aaFxEP30dZfvbqCfdtAS5xIN2JRv4J9 d58s78bKNK1oDEFYzp2xGaxmraAOGutn+0tIJi4Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Johannes Thumshirn , Naohiro Aota , David Sterba , Sasha Levin Subject: [PATCH 6.12 105/265] btrfs: zoned: fixup last alloc pointer after extent removal for RAID1 Date: Thu, 12 Mar 2026 21:08:12 +0100 Message-ID: <20260312201022.025272974@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260312201018.128816016@linuxfoundation.org> References: <20260312201018.128816016@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Naohiro Aota [ Upstream commit dda3ec9ee6b3e120603bff1b798f25b51e54ac5d ] When a block group is composed of a sequential write zone and a conventional zone, we recover the (pseudo) write pointer of the conventional zone using the end of the last allocated position. However, if the last extent in a block group is removed, the last extent position will be smaller than the other real write pointer position. Then, that will cause an error due to mismatch of the write pointers. We can fixup this case by moving the alloc_offset to the corresponding write pointer position. Fixes: 568220fa9657 ("btrfs: zoned: support RAID0/1/10 on top of raid stripe tree") CC: stable@vger.kernel.org # 6.12+ Reviewed-by: Johannes Thumshirn Signed-off-by: Naohiro Aota Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/zoned.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index b757377d9331e..5deddb89c6197 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1452,6 +1452,21 @@ static int btrfs_load_block_group_raid1(struct btrfs_block_group *bg, /* In case a device is missing we have a cap of 0, so don't use it. */ bg->zone_capacity = min_not_zero(zone_info[0].capacity, zone_info[1].capacity); + /* + * When the last extent is removed, last_alloc can be smaller than the other write + * pointer. In that case, last_alloc should be moved to the corresponding write + * pointer position. + */ + for (i = 0; i < map->num_stripes; i++) { + if (zone_info[i].alloc_offset == WP_MISSING_DEV || + zone_info[i].alloc_offset == WP_CONVENTIONAL) + continue; + if (last_alloc <= zone_info[i].alloc_offset) { + last_alloc = zone_info[i].alloc_offset; + break; + } + } + for (i = 0; i < map->num_stripes; i++) { if (zone_info[i].alloc_offset == WP_MISSING_DEV) continue; -- 2.51.0