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 9F1522376E4; Fri, 31 Oct 2025 14:06:25 +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=1761919585; cv=none; b=dWqB5kWtPt/0/fG0YJQoFw0TFjQTaaiGHLc1N6E64e6nf7lwkHtc+IIdZ93qf7fKmoK6P8rkng3yl3j0kpPRDSJKaIVxDAS9k1FDfSUG3tp9eHh78B+rJC6ypY0Mc27azgSwDHk/HLQQIAsbU0m9JYjq0Es97l1O+6jhM+wQWMw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761919585; c=relaxed/simple; bh=mqHDIC14tdGX6B5h3VE/ms39LQGKt/5aYoR/WcUwJY8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s5Jm+NOT7QhJwhpo7A5xCdNYVr69Vn85ugcTvtWQnPbu2juiCaCSHLtUiPmBYLA2oa+exrLVLz3GOWejvGJ3CbNsyaht4uXzhG5yYq9RRgPjjTswi5JouwVuBVgRaeKZfnbUuORvCld4NHfsFhwr4MuTfnqDq1AKatTIjQvNTUk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=peu+63di; 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="peu+63di" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2913EC4CEE7; Fri, 31 Oct 2025 14:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761919585; bh=mqHDIC14tdGX6B5h3VE/ms39LQGKt/5aYoR/WcUwJY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=peu+63diXemvMa5j/PrWwTpqvFl7cbCrBWOztJwEIP89f8GjtryIe8rqKXXhKCQQy 5JfHCs1yYSJg3h8758KxlZ9I8nTvoaeRbMdw1EjwDmO2ztu8/96gywhDvDUc767AEE V00C7MQvLTL6LQYTDNK4twWY4wsbSNkzKNPUC2l0= 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.17 27/35] btrfs: zoned: refine extent allocator hint selection Date: Fri, 31 Oct 2025 15:01:35 +0100 Message-ID: <20251031140044.219685145@linuxfoundation.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251031140043.564670400@linuxfoundation.org> References: <20251031140043.564670400@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Naohiro Aota [ Upstream commit 0d703963d297964451783e1a0688ebdf74cd6151 ] The hint block group selection in the extent allocator is wrong in the first place, as it can select the dedicated data relocation block group for the normal data allocation. Since we separated the normal data space_info and the data relocation space_info, we can easily identify a block group is for data relocation or not. Do not choose it for the normal data allocation. Reviewed-by: Johannes Thumshirn Signed-off-by: Naohiro Aota Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/extent-tree.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 97d517cdf2df7..682d21a73a67a 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4297,7 +4297,8 @@ static int prepare_allocation_clustered(struct btrfs_fs_info *fs_info, } static int prepare_allocation_zoned(struct btrfs_fs_info *fs_info, - struct find_free_extent_ctl *ffe_ctl) + struct find_free_extent_ctl *ffe_ctl, + struct btrfs_space_info *space_info) { if (ffe_ctl->for_treelog) { spin_lock(&fs_info->treelog_bg_lock); @@ -4321,6 +4322,7 @@ static int prepare_allocation_zoned(struct btrfs_fs_info *fs_info, u64 avail = block_group->zone_capacity - block_group->alloc_offset; if (block_group_bits(block_group, ffe_ctl->flags) && + block_group->space_info == space_info && avail >= ffe_ctl->num_bytes) { ffe_ctl->hint_byte = block_group->start; break; @@ -4342,7 +4344,7 @@ static int prepare_allocation(struct btrfs_fs_info *fs_info, return prepare_allocation_clustered(fs_info, ffe_ctl, space_info, ins); case BTRFS_EXTENT_ALLOC_ZONED: - return prepare_allocation_zoned(fs_info, ffe_ctl); + return prepare_allocation_zoned(fs_info, ffe_ctl, space_info); default: BUG(); } -- 2.51.0