Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6265997imu; Mon, 21 Jan 2019 06:05:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN60xXq50GwiriuPMDUk9WsBJGTB7/WXotopKbhNUC9p67LEun9n80zwh1Z7yhiG/eZ2ZP5B X-Received: by 2002:a63:1321:: with SMTP id i33mr28713192pgl.380.1548079554864; Mon, 21 Jan 2019 06:05:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548079554; cv=none; d=google.com; s=arc-20160816; b=PmqpmTvwVcmvn2RcnshW+gd/EtuOZNKCe6p3xpI4v3S+BGuJ666/FTn3CkKPp7Ede+ NDZVg6sgwIt3kJc2D/1VlK2VriM/N08OsYWli/p0JKrN4nXrKl5tBs68wBBvWAm4bl2O 1TA1hievR5IRaee3BAfTGCq9j1ZL8JTafz2t3f9RQw01Zms+KBDCG7NzPX/wYvTMPARi 2vkAnKAxrmNMQy3K+La46ikXP3SrsrLNTBhGUMJsKnX1mxvk8d80DoQ54/yq0SEi+DeD CjtVt/YcsbTbx9wPCbJ9+YPN07JEME45w1nm1/AeYDPREYrQM5mi6BnThbwWn0Bw0WCQ epnw== 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=5HXQAFfe00Uv0pQwyYWlqJVoxrgRxQUQzg/1tFGS8Ro=; b=auk5cKROgsqL1aeEoEHTtxsYhPevxhX7fo6J+kt7nc4iiCyN/trXB80T6Hmgm97EPi 0WrivXhF8dMTR+k3VhflcvIZx7GxmazPQuAlF8TK2cMTX3Ns/BRMCe/Vx7sVCS3EjNLz iO19X1ixfSW24kIncOgAdM3I6TfCx9SqFRWmlYOqAMpepL+FbtsWiEt+NUeEp144TIAD yxF58kgNMrXBZmyfxqVW2idi3/E+3neWC09iHbKVsqAeTXN4G9qM3ov10AvCDtgIPT8E FolP71VYJoTzNuERsNlQgk6ux2HdJ2HGQA0H8AMBKsg1C/qoPhd8llDJgjrswW7d5fAL sESg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NOkzKyGR; 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 o1si12689078pld.79.2019.01.21.06.05.38; Mon, 21 Jan 2019 06:05:54 -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=NOkzKyGR; 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 S1732694AbfAUOBt (ORCPT + 99 others); Mon, 21 Jan 2019 09:01:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:48924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729683AbfAUOBr (ORCPT ); Mon, 21 Jan 2019 09:01:47 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 EECE52089F; Mon, 21 Jan 2019 14:01:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548079305; bh=J3+/mxExVyG0bIpU+dwc77WxkvXabZdR+4h7UwNMfTM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NOkzKyGRX7HQoTwGjT2dfihr/TB/R4raWECy8zTDh/5ZDW5xnyRQhZdvZGuo4beYe AoK/WTmMunGXUmciW/XCt5QSUOlrsIYVlT77TEIWiCarE3NLq/dDPwaWgsZt1fmrgE aT7sDH7gKn0O8nzo6y+066BFwd6qBYazW8QyhVhE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , Josef Bacik , David Sterba Subject: [PATCH 4.19 41/99] btrfs: wait on ordered extents on abort cleanup Date: Mon, 21 Jan 2019 14:48:33 +0100 Message-Id: <20190121134915.480864801@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121134913.924726465@linuxfoundation.org> References: <20190121134913.924726465@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 74d5d229b1bf60f93bff244b2dfc0eb21ec32a07 upstream. If we flip read-only before we initiate writeback on all dirty pages for ordered extents we've created then we'll have ordered extents left over on umount, which results in all sorts of bad things happening. Fix this by making sure we wait on ordered extents if we have to do the aborted transaction cleanup stuff. generic/475 can produce this warning: [ 8531.177332] WARNING: CPU: 2 PID: 11997 at fs/btrfs/disk-io.c:3856 btrfs_free_fs_root+0x95/0xa0 [btrfs] [ 8531.183282] CPU: 2 PID: 11997 Comm: umount Tainted: G W 5.0.0-rc1-default+ #394 [ 8531.185164] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),BIOS rel-1.11.2-0-gf9626cc-prebuilt.qemu-project.org 04/01/2014 [ 8531.187851] RIP: 0010:btrfs_free_fs_root+0x95/0xa0 [btrfs] [ 8531.193082] RSP: 0018:ffffb1ab86163d98 EFLAGS: 00010286 [ 8531.194198] RAX: ffff9f3449494d18 RBX: ffff9f34a2695000 RCX:0000000000000000 [ 8531.195629] RDX: 0000000000000002 RSI: 0000000000000001 RDI:0000000000000000 [ 8531.197315] RBP: ffff9f344e930000 R08: 0000000000000001 R09:0000000000000000 [ 8531.199095] R10: 0000000000000000 R11: ffff9f34494d4ff8 R12:ffffb1ab86163dc0 [ 8531.200870] R13: ffff9f344e9300b0 R14: ffffb1ab86163db8 R15:0000000000000000 [ 8531.202707] FS: 00007fc68e949fc0(0000) GS:ffff9f34bd800000(0000)knlGS:0000000000000000 [ 8531.204851] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 8531.205942] CR2: 00007ffde8114dd8 CR3: 000000002dfbd000 CR4:00000000000006e0 [ 8531.207516] Call Trace: [ 8531.208175] btrfs_free_fs_roots+0xdb/0x170 [btrfs] [ 8531.210209] ? wait_for_completion+0x5b/0x190 [ 8531.211303] close_ctree+0x157/0x350 [btrfs] [ 8531.212412] generic_shutdown_super+0x64/0x100 [ 8531.213485] kill_anon_super+0x14/0x30 [ 8531.214430] btrfs_kill_super+0x12/0xa0 [btrfs] [ 8531.215539] deactivate_locked_super+0x29/0x60 [ 8531.216633] cleanup_mnt+0x3b/0x70 [ 8531.217497] task_work_run+0x98/0xc0 [ 8531.218397] exit_to_usermode_loop+0x83/0x90 [ 8531.219324] do_syscall_64+0x15b/0x180 [ 8531.220192] entry_SYSCALL_64_after_hwframe+0x49/0xbe [ 8531.221286] RIP: 0033:0x7fc68e5e4d07 [ 8531.225621] RSP: 002b:00007ffde8116608 EFLAGS: 00000246 ORIG_RAX:00000000000000a6 [ 8531.227512] RAX: 0000000000000000 RBX: 00005580c2175970 RCX:00007fc68e5e4d07 [ 8531.229098] RDX: 0000000000000001 RSI: 0000000000000000 RDI:00005580c2175b80 [ 8531.230730] RBP: 0000000000000000 R08: 00005580c2175ba0 R09:00007ffde8114e80 [ 8531.232269] R10: 0000000000000000 R11: 0000000000000246 R12:00005580c2175b80 [ 8531.233839] R13: 00007fc68eac61c4 R14: 00005580c2175a68 R15:0000000000000000 Leaving a tree in the rb-tree: 3853 void btrfs_free_fs_root(struct btrfs_root *root) 3854 { 3855 iput(root->ino_cache_inode); 3856 WARN_ON(!RB_EMPTY_ROOT(&root->inode_tree)); CC: stable@vger.kernel.org Reviewed-by: Nikolay Borisov Signed-off-by: Josef Bacik [ add stacktrace ] Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/disk-io.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -4155,6 +4155,14 @@ static void btrfs_destroy_all_ordered_ex spin_lock(&fs_info->ordered_root_lock); } spin_unlock(&fs_info->ordered_root_lock); + + /* + * We need this here because if we've been flipped read-only we won't + * get sync() from the umount, so we need to make sure any ordered + * extents that haven't had their dirty pages IO start writeout yet + * actually get run and error out properly. + */ + btrfs_wait_ordered_roots(fs_info, U64_MAX, 0, (u64)-1); } static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,