Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1876051iob; Thu, 5 May 2022 09:54:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzevPvkC5+x/nM/QBRaLpI+tOi16fpdRLwd6ufSwXtq3N6DCR9j9+44oqFY6XAWCbWShSz X-Received: by 2002:a17:902:ec83:b0:15e:b5d2:a81b with SMTP id x3-20020a170902ec8300b0015eb5d2a81bmr15154254plg.64.1651769668874; Thu, 05 May 2022 09:54:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651769668; cv=none; d=google.com; s=arc-20160816; b=ycQcqzRZ1IR5U7iSdKZF6fcRclXeeg/rAXIUNgcj5+CIZulvyJYflVLM6j86mqNgW6 rVhDn2AjLEi59BK7zu1Of8jgyUnrNxVNFad6cdTUiV/Y8Rw6ogf5whacBH524EGtf3uj awxVAbdUcbaWW5GnQ3+3xtoVB+ODopZMVuLfAuk9BfMUSMCH59RnqfsUfTXDchWhR0En mEDpu6zz18XB/kBxTRlzhPMAoawID2bD3fzX6C9tTig+n2gvMNMwJT0rY+Zp2AZs6PwC 2nFywE0XiBGmSnXmguduIqXP7k0kym4GIXBEaDnd3dx7vmubnEPzEu8AU5zbrQBZDwpP PZRw== 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=Khz0lCqgzkzKrTcaHVaCmqzyD/sSJAW+FGsDl4NbXcI=; b=cvs/V0eS96qT/WcTqLiXUudkqQ+3TFxISI1/QJbfQscyc+Z9i9zlNAKKMCPyoeeFAP fNJq3VGEhh+/qBv7JC5DO2HxB+NmNpCan+4Zb1E36bI61ULGABAocPS3Ijk/oT+M4Nqx KsOiZlu4CBeYrG0cf9vqy1FYpfwng8baMEuYlgFkfNyDUztTKRLYthR6nrR0Khq00dJQ pXkG3PYYnlxwKQKOdrUtw4PFj32WLPH1pxDRDfSgdYUAwd5z++0e2fjzObnWw7rZ+aXI KOHr5s9cURpcS5b5Fdp6K0rq2y0zxz8kAzX22kZG7xaQPb0F0KPAsMVvUf3Wefruc+Zy 2lvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MV1V50fY; 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 k7-20020a636f07000000b003a28427bff3si2033513pgc.677.2022.05.05.09.54.12; Thu, 05 May 2022 09:54:28 -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=MV1V50fY; 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 S238324AbiEDR2e (ORCPT + 99 others); Wed, 4 May 2022 13:28:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356196AbiEDRJD (ORCPT ); Wed, 4 May 2022 13:09:03 -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 9C16D52E58; Wed, 4 May 2022 09:54:58 -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 1BFC161851; Wed, 4 May 2022 16:54:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65725C385A4; Wed, 4 May 2022 16:54:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683297; bh=ekEKJfgW6dGACF/UjxglVYNmCt1DGFIUTNvzoJhvRww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MV1V50fYjhaOk65nRy/93JNITVyfjJpj9/aD+cc30FelNT7iiD5hOaeqBDdlraUEC 6kT6shrrT8/u0Mnx8IAfDFb33HySsQ7Hsftewc9NkbKIom5eIGvTnn8qmlMNpIaxLv tbm/LKtBelgO48VNh6uCSG6SXUOGPM8SGZYUUULk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Thumshirn , Filipe Manana , David Sterba Subject: [PATCH 5.15 151/177] btrfs: fix leaked plug after failure syncing log on zoned filesystems Date: Wed, 4 May 2022 18:45:44 +0200 Message-Id: <20220504153106.857561670@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@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=-7.7 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: Filipe Manana commit 50ff57888d0b13440e7f4cde05dc339ee8d0f1f8 upstream. On a zoned filesystem, if we fail to allocate the root node for the log root tree while syncing the log, we end up returning without finishing the IO plug we started before, resulting in leaking resources as we have started writeback for extent buffers of a log tree before. That allocation failure, which typically is either -ENOMEM or -ENOSPC, is not fatal and the fsync can safely fallback to a full transaction commit. So release the IO plug if we fail to allocate the extent buffer for the root of the log root tree when syncing the log on a zoned filesystem. Fixes: 3ddebf27fcd3a9 ("btrfs: zoned: reorder log node allocation on zoned filesystem") CC: stable@vger.kernel.org # 5.15+ Reviewed-by: Johannes Thumshirn Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/tree-log.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -3216,6 +3216,7 @@ int btrfs_sync_log(struct btrfs_trans_ha ret = btrfs_alloc_log_tree_node(trans, log_root_tree); if (ret) { mutex_unlock(&fs_info->tree_root->log_mutex); + blk_finish_plug(&plug); goto out; } }