Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp760145pxb; Tue, 5 Apr 2022 22:07:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4Yprds0YF5EyvD6DsviRSKj5Fjo/4G1eqwlOuxM/ktX1QkMomZ2QiB8HsygOxq/qErY3z X-Received: by 2002:a17:902:e193:b0:156:a04a:40d0 with SMTP id y19-20020a170902e19300b00156a04a40d0mr6784715pla.125.1649221656174; Tue, 05 Apr 2022 22:07:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649221656; cv=none; d=google.com; s=arc-20160816; b=JT+Fl8cgaBREykzxUFesqOyIi4lsywOq9oP8+o5GE9DSLWZPaC3nPm2S8ylg9co6UY QudHLYLBUfowDya8M0daG3hmPWg5P6xAAU1uMB1N59bnW7MNNVVWI8DjtVC7yNOvN9Ck utZ4L6r7/B0Xi/JjcfTKw+6VukQ4vax5zQTL74Ufidx4MEYHtaljDx/M6N9DHn7cTEz3 0PM9FvW9oUGw+4ShVK6RmKB2Irv33O6Schc+ayp2KCrJhjP+OvtuGUpn5cQ//EWdjsdd a5XkDVlG8zyJiTpwfst/KPVX6BcZU364q8Ncpf0+M9/zGMlDcBTI2WGFONIX/MYXowAt wNvQ== 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=ncpQigwHMXYY56OiejWmHZjBZXAT6Ns3PnEYcROCfVw=; b=iiv9n7HuBdAswVIXRcxfODjSjXizMir/Xzi346+3RwlQLM95QTiQxL1FHiBSrg+RGe 6q+ebF+UgNztCB1GxZ6mGyu5/VjnonRH8tgDcPIpiH+1qdu/H2AAXJkji992bulp3WXb PSJS5JnIC/X6EiJ3LTpB64VoTQ6cM+mxF+HxZxSwz+2BjL9S6XPYeW+kbeHVf0uhcqxr 13+SNYX5DLpgzezQ1fTRrtlkg/QijJYK/B+1VKi1W/UZZHvOfWUVQQTdwWOmkCYNHNtz CYzMktdGptPTCLs+TK1u9uvJEBzsf8hDl6b+qudR2ia5y85rb3VHzRk9TpQFMEcz80JE 68Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XreuLiQ4; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s4-20020a056a00194400b004fa3b635a94si15513756pfk.111.2022.04.05.22.07.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 22:07:36 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XreuLiQ4; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 730CD3E4C3C; Tue, 5 Apr 2022 20:31:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233420AbiDEH5H (ORCPT + 99 others); Tue, 5 Apr 2022 03:57:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233629AbiDEHsP (ORCPT ); Tue, 5 Apr 2022 03:48:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C930CBB; Tue, 5 Apr 2022 00:46:17 -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 64DDD615E7; Tue, 5 Apr 2022 07:46:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71FF7C340EE; Tue, 5 Apr 2022 07:46:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649144776; bh=kCiBLdnFzD0QRDANYJYIktkcCTP1oE4zBfsCsX8qP78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XreuLiQ4KkaYNUP0IKig6vs7M0c2IVnY6XxZAoJAXrL/fUSB6aQ6IPg+eZ17GEGUh GJ/mrNgYUi2OYD3OEGV8sVv7QE9jnHCdFqlCy8aHMmDm1qK+erTSSUTcME+eocBkLe efYfCSyzxdDMwZKmR0Zrbagq5QqQZSCRGgSwNYXA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Thumshirn , Nikolay Borisov , David Sterba Subject: [PATCH 5.17 0140/1126] btrfs: zoned: put block group after final usage Date: Tue, 5 Apr 2022 09:14:47 +0200 Message-Id: <20220405070411.688381132@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: Nikolay Borisov commit d3e29967079c522ce1c5cab0e9fab2c280b977eb upstream. It's counter-intuitive (and wrong) to put the block group _before_ the final usage in submit_eb_page. Fix it by re-ordering the call to btrfs_put_block_group after its final reference. Also fix a minor typo in 'implies' Fixes: be1a1d7a5d24 ("btrfs: zoned: finish fully written block group") CC: stable@vger.kernel.org # 5.16+ Reviewed-by: Johannes Thumshirn Signed-off-by: Nikolay Borisov Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/extent_io.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -4780,11 +4780,12 @@ static int submit_eb_page(struct page *p return ret; } if (cache) { - /* Impiles write in zoned mode */ - btrfs_put_block_group(cache); - /* Mark the last eb in a block group */ + /* + * Implies write in zoned mode. Mark the last eb in a block group. + */ if (cache->seq_zone && eb->start + eb->len == cache->zone_capacity) set_bit(EXTENT_BUFFER_ZONE_FINISH, &eb->bflags); + btrfs_put_block_group(cache); } ret = write_one_eb(eb, wbc, epd); free_extent_buffer(eb);