Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3426933imu; Sun, 11 Nov 2018 14:51:10 -0800 (PST) X-Google-Smtp-Source: AJdET5co3IFn/CMUZqeDvrsou1bTo2M9JU2HlUCDmjOFCL8lX0SfaI8lmvaWV2lyxKVmyi7xUElo X-Received: by 2002:a17:902:201:: with SMTP id 1-v6mr17805461plc.307.1541976670545; Sun, 11 Nov 2018 14:51:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541976670; cv=none; d=google.com; s=arc-20160816; b=S3vxjM3Z8V57+OBmtQu9DDEqU/hpckTNRdr7TBRljWe9jCX0nQ8qVFTGVFgwVw+ZSc gkYNkI9eNnt9CKUyfOIMSvma80ePG6+mSDrqK/01ZNnpvP5BMnjRTfhICwiD+emI1Tob Ardx6ytKt/uCL0uDxR/fCkJ4JybIVs6rZqchPdQSvORNrsbzp6pYZmAsFFPgOgnMxydi F56qYk4Wjm8Px816YWNBYx8N0WeYldXz1Tps9Dm5/Ghh38TUB4duz10d/941yx5lg4ZE WloUGFMkF1qrIS+4H1+QS75yEK0hLZvub+9xoaw2MVbSraNXzU1DRo0qmSZCU9J78u1d 07+Q== 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=kyp5n5GLJ0NE7IZxmin6WZAPCPa+C5NpqRKoigQIJ8k=; b=BaaHkJ6moCO+7lR+69mP4Gsz8TeCNSb1uX1F5LuRUm3Ykp6xV3dV/S7skitpSQsS/5 mRyRAg1Av+7bncY+YCDs7HFo1WNY1tb19kiDajRkRi77XmTs33ABHBIdHqZztdaRttqh 7ReGO/AnzrvPVTP/1s6IMX/n6Z23Q1lTzVppudNqz2rl45fn/f25BmDceCXRJxHqLiPa 7zQIMXF7dohsi5BSzkrlUe2khKaZvZwE76fKIemDyPsYwxh2BBYr8joPeTUUpUR2DTLB xSTbNmGkNiC3v4a3i5DqIvJEkIOprr46/Oe8IYZwGd+8AbsjK5nWZ/esT64zr9Ysu8/m KF8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vcGPAO66; 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 cf14-v6si15630151plb.422.2018.11.11.14.50.55; Sun, 11 Nov 2018 14:51:10 -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=vcGPAO66; 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 S2390882AbeKLIki (ORCPT + 99 others); Mon, 12 Nov 2018 03:40:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:54672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404213AbeKLIXJ (ORCPT ); Mon, 12 Nov 2018 03:23:09 -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 98ACB21707; Sun, 11 Nov 2018 22:33:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975592; bh=1xn4qlqTwNjUyVxJb9o3ZcmM9/0isxahHsT29qc9Bqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vcGPAO66mTJf5+CORLRfAw6osYx9ueszJ7C1vmDHfb4DqlVhCKDnd+E0EurjnoNqc Yhn6XsPTWWguptnmgGo184tmOWl9OKCe/U9BZTxRGjFUTHCk71A6Sb2I9YAU/6rTTT QCKtn3s36FrQdNbQCUjMZSbjdXJNY7jwb0/gbZAM= 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.14 207/222] btrfs: make sure we create all new block groups Date: Sun, 11 Nov 2018 14:25:04 -0800 Message-Id: <20181111221705.168613970@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@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.14-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 @@ -10270,7 +10270,7 @@ error: void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans, struct btrfs_fs_info *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; @@ -10278,7 +10278,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;