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 B9E0B494A13; Sat, 28 Feb 2026 17:44:55 +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=1772300695; cv=none; b=eh3OKwB32bPO6gJgd096xY7qadABYdZ1sXv7QaqbxvCXzsKKcklpzc1oBPTUniE+gSSAg/vVSEut2UnE0DlSMPrhkCyBuSD1uza/j3E7YGitlsj1SFQ6ysVr2BVfbH9N8LLSuow4K+9TFfHX6D6y+9VuCi+xn5B9XggSGfCnZHs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772300695; c=relaxed/simple; bh=xXjaISQWB5K+hLOvfvyVDRNcW/9pv1KrNdhC60jFPYI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nAVKhBA5Mhvvst/ami+ZIldJXWpqTlXmwuXLHjLniEeGHdOWbCupeqLxc2IMwtmxmqg8JP1gD3xOdhTaA50MSZhQJTcSERl2ysq+86QEkf2z1pfkdBI/NoAlVj3zc6p1sm6bcgPf2BASQgacMGfbXixSdeR9Vc9OZB2eGXQc/eI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IXHErwXH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IXHErwXH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB952C19425; Sat, 28 Feb 2026 17:44:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772300695; bh=xXjaISQWB5K+hLOvfvyVDRNcW/9pv1KrNdhC60jFPYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IXHErwXHgDFLtOvEfWKXcBcR24b3daU6A5Gg9ks1vxJMMZz1Kg3kwCf2Jviyw1M1H lK96WQHedzKGn9tqXpj96zBHXHkJ/uKuk9fFG6kAdcbz09hFOsgR5BnoVSCxz5opDE KjUCVmn4LbuX+md54mRYZyIIhAGrDzHeIP8MtqItUOs5QiaMVXHVXYqc12dogwhgiI JUJaMDtFfUZETiS5cno/ZjchfP5UVoyVbY0dYH4KE4X5drJjqGi1xs6RjxmYWePxGj Hveu5CRl739O2dWdk2jwt149TeUga/IMmRpj34QdzR9O8t5Nu20HoecbQ5wmAuBUYP kMn4YBDK5pk0w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Naohiro Aota , Johannes Thumshirn , David Sterba , Sasha Levin Subject: [PATCH 6.19 731/844] btrfs: zoned: fixup last alloc pointer after extent removal for DUP Date: Sat, 28 Feb 2026 12:30:44 -0500 Message-ID: <20260228173244.1509663-732-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260228173244.1509663-1-sashal@kernel.org> References: <20260228173244.1509663-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Naohiro Aota [ Upstream commit e2d848649e64de39fc1b9c64002629b4daa1105d ] 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: c0d90a79e8e6 ("btrfs: zoned: fix alloc_offset calculation for partly conventional block groups") CC: stable@vger.kernel.org # 6.16+ Reviewed-by: Johannes Thumshirn Signed-off-by: Naohiro Aota Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/zoned.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index f27ba6e9b47d5..6c06581954181 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1449,6 +1449,20 @@ static int btrfs_load_block_group_dup(struct btrfs_block_group *bg, return -EIO; } + /* + * 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 (int i = 0; i < map->num_stripes; i++) { + if (zone_info[i].alloc_offset == WP_CONVENTIONAL) + continue; + if (last_alloc <= zone_info[i].alloc_offset) { + last_alloc = zone_info[i].alloc_offset; + break; + } + } + if (zone_info[0].alloc_offset == WP_CONVENTIONAL) zone_info[0].alloc_offset = last_alloc; -- 2.51.0