Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3469144imu; Sun, 11 Nov 2018 15:49:19 -0800 (PST) X-Google-Smtp-Source: AJdET5cgC/PiJy+lQLIa5YnTvYHIGgCGipc7bXfNx27fvY9mBJBZNVAsM+bgtmnwjZQc25jZoCUG X-Received: by 2002:a63:c503:: with SMTP id f3mr8084266pgd.431.1541980158985; Sun, 11 Nov 2018 15:49:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980158; cv=none; d=google.com; s=arc-20160816; b=QzITn87I+u67xDdJ2AD03f3sCLfdcAKcOTPJ3lTd0nkGdwqP4Fq41P2oz8l32yRGDe /SDPSO5JewOCdtUnz4HXeeL3+VUpYDwCpH2xbISMTXzOoMtDAOzGVdsGNNC2ZRm+W7cK 8UQSOlLnfWn+lDxFtVJDNd1t4oCICy0DgyM0LbJytPIp6H2ebAxYfSBIRAtwkWx07yqU YiUngmOaH81wciwl7k5nf4kfZ7oJjpGuyoitrxcq/kLe4EItwpC87bvk/6gTkswDktC7 /BTUGQexgYIH3oQcFhYrbf8Sb/tRdQDsLHyFjwfpwdNmF29sn1bdq4qg1TTi/RzpE8XQ FsdQ== 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=Q13CVPGfu4VlaVfVGQKzQPzyz8DjzTifmj/q22and9c=; b=YgE69RqEY2o4VnbqI/+5YDSCwyz2kpRDLo0joCRfYxadQZhjtCoekCyV4bS5rPYoh4 qMJRIeeAIq/NHemvwb9mZxKYakhj0YEaXoYz/ZgeWYVBB5+JxDAtO5X89JUsDsI64odx MO5d85zeEjvyKRS2ukZJrW6Yi1d3/9VB1Y5Y56N6u/GtJeVfe1xmxW5ywwIXCRzU5TTc Mz/KTXBE8uXfo9CA550GfU1eXN8Fmg1H/gsnDp2zKK6NgmijcVN6dXRMnaT2NqhBPbJQ xftZ4CZiNKzQJlUefTsVGAcmowkHA3BuuziXSuoraa9bh5b8IQD5XC6YoJCr90qIC9mc vvSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=w738KXoc; 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 2-v6si17760395pla.223.2018.11.11.15.49.04; Sun, 11 Nov 2018 15:49:18 -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=w738KXoc; 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 S2387475AbeKLJjD (ORCPT + 99 others); Mon, 12 Nov 2018 04:39:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:38936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733071AbeKLISn (ORCPT ); Mon, 12 Nov 2018 03:18:43 -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 B0A9F2241B; Sun, 11 Nov 2018 22:28:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975326; bh=qh9ZgmbAQFcK4t+OP0J1zBPQyB+HB7ZZ/vlyKGX0xLE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w738KXocoj0Cb8fRx92TcDDVBMiRhKSHbJB6Z2WwnFiw/rCYJHUEvEm5Qpi49gGRw 46EkExHdDP+J6oPalnk97sv9R2RyyEElC/kMkwCL156r+enYnUTnhRD+/SnIMwnAb5 jPmqnEsSGmFat/8QXqSBSHqXStm4UrRKnI22yvW4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josef Bacik , Omar Sandoval , David Sterba Subject: [PATCH 4.19 336/361] btrfs: wait on caching when putting the bg cache Date: Sun, 11 Nov 2018 14:21:23 -0800 Message-Id: <20181111221700.322448431@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 3aa7c7a31c26321696b92841d5103461c6f3f517 upstream. While testing my backport I noticed there was a panic if I ran generic/416 generic/417 generic/418 all in a row. This just happened to uncover a race where we had outstanding IO after we destroy all of our workqueues, and then we'd go to queue the endio work on those free'd workqueues. This is because we aren't waiting for the caching threads to be done before freeing everything up, so to fix this make sure we wait on any outstanding caching that's being done before we free up the block group, so we're sure to be done with all IO by the time we get to btrfs_stop_all_workers(). This fixes the panic I was seeing consistently in testing. ------------[ cut here ]------------ kernel BUG at fs/btrfs/volumes.c:6112! SMP PTI Modules linked in: CPU: 1 PID: 27165 Comm: kworker/u4:7 Not tainted 4.16.0-02155-g3553e54a578d-dirty #875 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-2.el7 04/01/2014 Workqueue: btrfs-cache btrfs_cache_helper RIP: 0010:btrfs_map_bio+0x346/0x370 RSP: 0000:ffffc900061e79d0 EFLAGS: 00010202 RAX: 0000000000000000 RBX: ffff880071542e00 RCX: 0000000000533000 RDX: ffff88006bb74380 RSI: 0000000000000008 RDI: ffff880078160000 RBP: 0000000000000001 R08: ffff8800781cd200 R09: 0000000000503000 R10: ffff88006cd21200 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000000 R14: ffff8800781cd200 R15: ffff880071542e00 FS: 0000000000000000(0000) GS:ffff88007fd00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000000817ffc4 CR3: 0000000078314000 CR4: 00000000000006e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: btree_submit_bio_hook+0x8a/0xd0 submit_one_bio+0x5d/0x80 read_extent_buffer_pages+0x18a/0x320 btree_read_extent_buffer_pages+0xbc/0x200 ? alloc_extent_buffer+0x359/0x3e0 read_tree_block+0x3d/0x60 read_block_for_search.isra.30+0x1a5/0x360 btrfs_search_slot+0x41b/0xa10 btrfs_next_old_leaf+0x212/0x470 caching_thread+0x323/0x490 normal_work_helper+0xc5/0x310 process_one_work+0x141/0x340 worker_thread+0x44/0x3c0 kthread+0xf8/0x130 ? process_one_work+0x340/0x340 ? kthread_bind+0x10/0x10 ret_from_fork+0x35/0x40 RIP: btrfs_map_bio+0x346/0x370 RSP: ffffc900061e79d0 ---[ end trace 827eb13e50846033 ]--- Kernel panic - not syncing: Fatal exception Kernel Offset: disabled ---[ end Kernel panic - not syncing: Fatal exception CC: stable@vger.kernel.org # 4.4+ Signed-off-by: Josef Bacik Reviewed-by: Omar Sandoval Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/extent-tree.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -9632,6 +9632,7 @@ void btrfs_put_block_group_cache(struct block_group = btrfs_lookup_first_block_group(info, last); while (block_group) { + wait_block_group_cache_done(block_group); spin_lock(&block_group->lock); if (block_group->iref) break;