Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3469154imu; Sun, 11 Nov 2018 15:49:19 -0800 (PST) X-Google-Smtp-Source: AJdET5fHMnp2M5pd6GHbM8pVthayWT+ur2knS5v/shaplQcvIoTy+7hoLZpt1Z+OUqwJqaSOdsWe X-Received: by 2002:a63:8043:: with SMTP id j64mr15735127pgd.405.1541980159314; Sun, 11 Nov 2018 15:49:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980159; cv=none; d=google.com; s=arc-20160816; b=KfHe8qv69KNz3QJ6dLnQmheuAl0Y1pr4FxJRVGdrLqGSeejRgczukY3dBRhgH2h2Op tiNetJ9IsTwXgFAawKGsfj18dmNJY9dJbcl4uO+Gf1M3liX+lU80YBdDuVNlOCrcrxU9 ADtXrsiE+YhAHj1p+D0QYfwoSsqyzBCFqzM4oBVdgDMeUvxmqJY6U34Q4LQtt5aZewO9 S0wcgZLE/rHUOh0rDQ+aqIVykCkHF6BcWhijlmfRupeIo9lrgRJgVo5a8wr1XG3YVMFm XqieBoASjnMFOK2IH9Uw+QEZQYr2Ye8mIb/3d0Ut2DTeeB62kpwrp3DOLjYnBOF8QBRO 4+jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XxZtCMAlytonxrD8oFakfEdCHy6GVkFEF7F1v4ElMPo=; b=IO/zfsk/PlEiD0bsvMwEH/+PjzqBe6PJjPfEwuuxmXgiNzdLimW0+BAbQxRP6v6Pf4 Cl6l9c0wxjX2y/ZWXAjTgScPsoJBrn2OHsCuhqlxQjIMFdtruaxLEb3zDbTCRij098Il ldEPiNMs40N58RVk/NAw9R8nyMp337Hs8iyL23ks5ncx2BzQ24YOQYJlCM8Qrwoyztvq BOTrVDSTkgi7GbHoPH+S2XeDMTCDTh8/GgSLYVRmPoIGqzouL46C7IERO2ak2OqI7jT0 z9EMhdYMnFWxQnOeLQ0iia0MIhVT/fC5a3arLRKp6RbUmI0/GGGZRr15xklFhnfpX8dS C4mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cl4sH0ez; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si15560641plu.228.2018.11.11.15.49.04; Sun, 11 Nov 2018 15:49:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cl4sH0ez; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733155AbeKLISr (ORCPT + 99 others); Mon, 12 Nov 2018 03:18:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:39134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733142AbeKLISq (ORCPT ); Mon, 12 Nov 2018 03:18:46 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A30B121582; Sun, 11 Nov 2018 22:28:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975329; bh=7HmDRDomSlsZaQm9+bwr4Jr0skygfogHoghTtHvXttg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cl4sH0ez+/fUVJK5A4Zmovx2c65oSOM59ysQr0TJR4AQ4SjzpFJ6kxmVPoZxJ3L/X yZm7FUw02FgKNTEamfgIO4J0VI28g2t/Lc8hAPhOaTmPI3hm79aHjGh+lMZTBdqQKE ZYeG0r1Ubh0SMuhzP8n7+bkCu0M2mZFQQLggu0w8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Omar Sandoval , Liu Bo , Josef Bacik , David Sterba Subject: [PATCH 4.19 341/361] btrfs: make sure we create all new block groups Date: Sun, 11 Nov 2018 14:21:28 -0800 Message-Id: <20181111221700.742041688@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josef Bacik commit 545e3366db823dc3342ca9d7fea803f829c9062f upstream. Allocating new chunks modifies both the extent and chunk tree, which can trigger new chunk allocations. So instead of doing list_for_each_safe, just do while (!list_empty()) so we make sure we don't exit with other pending bg's still on our list. CC: stable@vger.kernel.org # 4.4+ Reviewed-by: Omar Sandoval Reviewed-by: Liu Bo Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/extent-tree.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -10094,7 +10094,7 @@ error: void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans) { struct btrfs_fs_info *fs_info = trans->fs_info; - struct btrfs_block_group_cache *block_group, *tmp; + struct btrfs_block_group_cache *block_group; struct btrfs_root *extent_root = fs_info->extent_root; struct btrfs_block_group_item item; struct btrfs_key key; @@ -10102,7 +10102,10 @@ void btrfs_create_pending_block_groups(s bool can_flush_pending_bgs = trans->can_flush_pending_bgs; trans->can_flush_pending_bgs = false; - list_for_each_entry_safe(block_group, tmp, &trans->new_bgs, bg_list) { + while (!list_empty(&trans->new_bgs)) { + block_group = list_first_entry(&trans->new_bgs, + struct btrfs_block_group_cache, + bg_list); if (ret) goto next;