Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3090029rwb; Mon, 15 Aug 2022 17:53:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR4ULsF0n5pdYygiE4hWA43Ko8YlFU/QKdDhMr1pwMSAmpx9ZwIi2587O/U64AZxHdTktxlP X-Received: by 2002:a05:6402:3201:b0:43d:47ee:4ae2 with SMTP id g1-20020a056402320100b0043d47ee4ae2mr16458707eda.235.1660611186977; Mon, 15 Aug 2022 17:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611186; cv=none; d=google.com; s=arc-20160816; b=0OkRX1X9we4gCcsCpnmGs+NMXq+/2auJzKUH1KJ2owP3hbd5rCzd4wVMfnWiALH9q3 VIr3aJ9WV0y2/yswkK2JfsF1daIYBewh91P9qd3GItTweYWTuVc+n+gimgSeir5mhG/C Jbio1h7Z5ST1RODn9tD7oWVCWnco082qEkttbxiLNiL3SxZt4Eyikiu7ry15LRPYoBgz u6A0BzbrstvtbRZ6eGkG92Lww6JVbC2ANFdXp5EX6p7R/sh02DVo7G7y/6uotZ5rgGYH aApaU7ubGgUl2jiA/2bnTVZ+sUEMaNwCgYCrLM18STl2hGrPDeXQRRsr94LRt0uLEh0q jx8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zYmhbnMhXrofG/oDnQhJKfm3dkUOlKgVaU6xbVqSq04=; b=rY0xvUheVaoS8foAcVSJAhf+aECCP1CwPLOkWoU8h+tz77rR5erx3rjbjilawh/QFi i8EAzrl+L5KpcfgWjQMpPCbZxOPbWqUwDglNhHUTBba8P9Sz1JCR9ij5pMI0ZJQ5yh+r ci3zoPPZHDNNIHq/RDNer2gipzWuir/Zw4v6REoU3d5ysHIX6prE6GfCqNj1i4OEHekt y0G8XE3ew0rS/qAuE0lWXf5KAeXegEmSn2/Kn9Jp/Eco8Ke7MzEHxQIhdGO9eLL0WL8g f8j9xBFz68jPAAPqLgsNJTfU8A5bUaE4wnT5wDE+7j0OZF7m40nGDJLO/mHMkmhdtbA2 B1PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Q+sDy9Hv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l11-20020a170906794b00b00730f07ead67si9911262ejo.929.2022.08.15.17.52.41; Mon, 15 Aug 2022 17:53:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Q+sDy9Hv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353440AbiHOXbk (ORCPT + 99 others); Mon, 15 Aug 2022 19:31:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343985AbiHOX0K (ORCPT ); Mon, 15 Aug 2022 19:26:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 685947FE5C; Mon, 15 Aug 2022 13:06:31 -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 04AA86069E; Mon, 15 Aug 2022 20:06:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB8C9C433D6; Mon, 15 Aug 2022 20:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593990; bh=OoFLweGMGU3hs6aXiOhf2CsOVzv7McoV0UwXcZHxGHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q+sDy9HvSIhcil2q8gyBgRI7qul0gwlFoJ7Y5vS/yd3dFHSeaMcJLGuYybdKzCXhK 6DYuTGFxhk+MsVVAela91Wr0CA8JTvUMI7yeTKS40gXpCN4bW1t/K1mlXsOEBNaIB0 wso/UoUNt5gNeF8q315N+XHWKz98ZpKiCp1SSLT4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Thumshirn , Naohiro Aota , David Sterba , Sasha Levin Subject: [PATCH 5.18 1021/1095] btrfs: let can_allocate_chunk return error Date: Mon, 15 Aug 2022 20:07:00 +0200 Message-Id: <20220815180511.327770468@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Naohiro Aota [ Upstream commit bb9950d3df7169a673c594d38fb74e241ed4fb2a ] For the later patch, convert the return type from bool to int and return errors. No functional changes. Reviewed-by: Johannes Thumshirn Signed-off-by: Naohiro Aota Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/extent-tree.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index f45ecd939a2c..8bdcbc0c6d60 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3985,12 +3985,12 @@ static void found_extent(struct find_free_extent_ctl *ffe_ctl, } } -static bool can_allocate_chunk(struct btrfs_fs_info *fs_info, - struct find_free_extent_ctl *ffe_ctl) +static int can_allocate_chunk(struct btrfs_fs_info *fs_info, + struct find_free_extent_ctl *ffe_ctl) { switch (ffe_ctl->policy) { case BTRFS_EXTENT_ALLOC_CLUSTERED: - return true; + return 0; case BTRFS_EXTENT_ALLOC_ZONED: /* * If we have enough free space left in an already @@ -4000,8 +4000,8 @@ static bool can_allocate_chunk(struct btrfs_fs_info *fs_info, */ if (ffe_ctl->max_extent_size >= ffe_ctl->min_alloc_size && !btrfs_can_activate_zone(fs_info->fs_devices, ffe_ctl->flags)) - return false; - return true; + return -ENOSPC; + return 0; default: BUG(); } @@ -4083,8 +4083,9 @@ static int find_free_extent_update_loop(struct btrfs_fs_info *fs_info, int exist = 0; /*Check if allocation policy allows to create a new chunk */ - if (!can_allocate_chunk(fs_info, ffe_ctl)) - return -ENOSPC; + ret = can_allocate_chunk(fs_info, ffe_ctl); + if (ret) + return ret; trans = current->journal_info; if (trans) -- 2.35.1