Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3427659imu; Sun, 11 Nov 2018 14:52:16 -0800 (PST) X-Google-Smtp-Source: AJdET5fN4U/JdsP7daTs0Eiz2U4g1JCgrA2FV2IjATfUicKrITXeFuvII62qsOuHwrVoQ0ps0dm2 X-Received: by 2002:a62:6486:: with SMTP id y128-v6mr18304061pfb.76.1541976736001; Sun, 11 Nov 2018 14:52:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541976735; cv=none; d=google.com; s=arc-20160816; b=l+JPN/wpgk5BE1nzPBMNaBFT0FkzlOXFOevO6hnQoAzlNKL7Q1KwPdF957vzok7uK0 QXgp5pf8dPGJ+Q+Oh4Cx6pa6lBUXrdZyxgEEkQvcu/16PnRaFwylM//tEeOoOBdSqrdu A4iaKYMmWePd5Pjbchr/ByqTi3wlMYVErHRCIzSlp+5kHIaJMMJMag6/+oHxcXOp1sHm B624QJPQw5msdy28x01/Sbp534X4zZs/57NrN30kE3CsNTg1jsDCf4RBnsnsOoVrtLhC StiLMTMd/qIBzSpOITS2wWbQ9zJ773qsf/UZQS5qvvMyhhxKlgkvuL9h5Q10NqBUxjfJ KZfQ== 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=s1oB1E5pi60JpEZ7HhenkERsxC7iw+N+4qHVZobKnGI=; b=d0Xzj3U+WVuc7TdVCAHCn0ZQLTSDFmUh1A+en3FUJrD3SlgjIkvlpNnWI3xFGfX2P0 ymtr2ajA1zdWxP92RQDiF+/uGpPugdUS0DQ7bUeCuTwbY7rahPdxU91hxX/oxr5LUqSO e/s/tJ9qcuUFIt87gwtiEiEc/4QqIr02qUwY5FsgPkCB8YfxN/gswd0l+2f2nj4qe5B/ phiAtK/0BSifWdvt0JS/mi1+QTIKC0YB1UomaDaJXrX3wZVyUxh5zQ/a1e27aS3LnBki g0L5nwExbLFw1cY0yQ+c+Klf17mb4qOe/88LxeOvbZsQAhw9KkU9h1e/jf6MxiHf1QxF uUuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UzRjbQvx; 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 e1-v6si16003250ple.148.2018.11.11.14.52.01; Sun, 11 Nov 2018 14:52:15 -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=UzRjbQvx; 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 S2404227AbeKLIXJ (ORCPT + 99 others); Mon, 12 Nov 2018 03:23:09 -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 S2404173AbeKLIXI (ORCPT ); Mon, 12 Nov 2018 03:23:08 -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 4155C2243E; Sun, 11 Nov 2018 22:33:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975591; bh=5TdJhso0Pj+H2OvguW4+zXuarGsGqe5Kd8mx5jH77P4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UzRjbQvx5cdM97AWMRFMIChMN26RVXzBvRsJRBjSpM7XZyUDfpcGPdHoETb+OGN8i pYXs3l6XkMS41YJrbOqGLzrV+vbGLbjSQPnC2ree427YyHh5iECM+q4fHqUIZc+bwK CBRBRMT4WzP1yO713zM0jobBl632Y5Q0VMSzKFlE= 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.14 204/222] btrfs: wait on caching when putting the bg cache Date: Sun, 11 Nov 2018 14:25:01 -0800 Message-Id: <20181111221704.938395094@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 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 @@ -9881,6 +9881,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;