From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9AD3C433EF for ; Tue, 7 Jun 2022 20:22:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359391AbiFGUW2 (ORCPT ); Tue, 7 Jun 2022 16:22:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355735AbiFGTam (ORCPT ); Tue, 7 Jun 2022 15:30:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 299611A448B; Tue, 7 Jun 2022 11:12:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7F25D61985; Tue, 7 Jun 2022 18:11:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CAE4C385A2; Tue, 7 Jun 2022 18:11:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654625518; bh=fu3hKi6Rwo9Qxne+luvdh8GJfotUrWq3TWXXU4Nq7uU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dot78FOvlmv/ilVTXJx+yRl/MTbo521Jd4kTlLm+aYv2P/iXQ2AE4rym02BrMantN 72nvX9WN9pWGklRBD337HrVdr4EYHuYHd+kKRySShbPX9OlRlTacdYkqrCQzFLPCXt x64bTZmhP/6GPmrvLbNc4947Ehhkl3B8jVjSkOxI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pankaj Raghav , Johannes Thumshirn , Naohiro Aota , David Sterba Subject: [PATCH 5.17 048/772] btrfs: zoned: finish block group when there are no more allocatable bytes left Date: Tue, 7 Jun 2022 18:54:00 +0200 Message-Id: <20220607164950.451573343@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164948.980838585@linuxfoundation.org> References: <20220607164948.980838585@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Naohiro Aota commit 8b8a53998caefebfe5c8da7a74c2b601caf5dd48 upstream. Currently, btrfs_zone_finish_endio() finishes a block group only when the written region reaches the end of the block group. We can also finish the block group when no more allocation is possible. Fixes: be1a1d7a5d24 ("btrfs: zoned: finish fully written block group") CC: stable@vger.kernel.org # 5.16+ Reviewed-by: Pankaj Raghav Reviewed-by: Johannes Thumshirn Signed-off-by: Naohiro Aota Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/zoned.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1961,6 +1961,7 @@ void btrfs_zone_finish_endio(struct btrf struct btrfs_block_group *block_group; struct map_lookup *map; struct btrfs_device *device; + u64 min_alloc_bytes; u64 physical; if (!btrfs_is_zoned(fs_info)) @@ -1969,7 +1970,15 @@ void btrfs_zone_finish_endio(struct btrf block_group = btrfs_lookup_block_group(fs_info, logical); ASSERT(block_group); - if (logical + length < block_group->start + block_group->zone_capacity) + /* No MIXED_BG on zoned btrfs. */ + if (block_group->flags & BTRFS_BLOCK_GROUP_DATA) + min_alloc_bytes = fs_info->sectorsize; + else + min_alloc_bytes = fs_info->nodesize; + + /* Bail out if we can allocate more data from this block group. */ + if (logical + length + min_alloc_bytes <= + block_group->start + block_group->zone_capacity) goto out; spin_lock(&block_group->lock);