Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2579638pxa; Fri, 7 Aug 2020 15:02:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWZP2PMaceeEg7oThJACDNksqR3UOPXHN/rf4IZuVE/za3l156qjd4sl1IGurmR4EHpJYD X-Received: by 2002:a17:906:6bda:: with SMTP id t26mr11723312ejs.214.1596837765175; Fri, 07 Aug 2020 15:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596837765; cv=none; d=google.com; s=arc-20160816; b=ODwcgThU5tR30PYUPQaYXUk6dnw456+Ia4cC41j1mKsSA2NxiITlcJp+3xqERa4Xp0 W7BuWBabycYmAvDbpFFwwyH+LUux8VY7upUq1THv5qAT9on58acMfJfuYNc3GHugbScQ gQ+YxSBosyMN51UovPCSmyQ149Lw27susEJQEClbUxG/JSTwJdBew80jGloP++4Y3Fqg aqO25fy0WCsJLzWzFfqX0V+uDIYorhmFJ7a5iy2cVIEngPOcVBdS1pbKdKbSWoRbZiUQ M1YC+EphoGu7NAGqh8BT3oxW2P/7yR689uheu8e8CMP31ErRdcLxRLpsdSemeTOk6eiV HGgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:to:cc:in-reply-to:date:subject :mime-version:message-id:from:dkim-signature; bh=hs3HY7g7iInOHSIqlAQOKkHaLJM+XTGFYI2JrFlwSao=; b=wTbee/qh76/HcPn9fRF9hvzlQmPhrZtJanP+1E8gSA8VS3wzcrvyFPx+wfZBHY0fV/ rxEl9CGL0fBiWPAbzWK/LKHezneM/J9UQ+zoRtk6HnLXVmBPEmzneBpYklQYpCnfoKXE o6j6Y3UBbfLzOxZizMUotpQebDnQVsggujYKYqPwTddKGnyy0ouIxDOZBLlUr6NYF9bI fGMrMn9Me6h7cyPlko1Zhh2YNC9Yb1h9J3Dck9awyE1VrU+thYRm1xH2Pkw2cx8Qhfq8 Ata0zZyuAdbuH5f0vSox0k8fxNEfW3AHj43feqj5JFKDS2IDoV9zUeBckf0ZzTXCBt77 o1KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dilger-ca.20150623.gappssmtp.com header.s=20150623 header.b=KYkemN3w; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a24si6388070edj.502.2020.08.07.15.02.09; Fri, 07 Aug 2020 15:02:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@dilger-ca.20150623.gappssmtp.com header.s=20150623 header.b=KYkemN3w; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726766AbgHGWBi (ORCPT + 99 others); Fri, 7 Aug 2020 18:01:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbgHGWBg (ORCPT ); Fri, 7 Aug 2020 18:01:36 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 917D9C061A27 for ; Fri, 7 Aug 2020 15:01:36 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id f9so1659258pju.4 for ; Fri, 07 Aug 2020 15:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dilger-ca.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=hs3HY7g7iInOHSIqlAQOKkHaLJM+XTGFYI2JrFlwSao=; b=KYkemN3wBNlYDhhXvoWTtxkp87n/L1OvrCWlndyuEBoUjl6bk34DFVxYJL4b55g9xJ lpv37WwWkemyIThrNYa4CMAh2RoW2z/aUnNeeU3/IxMNI0Aqls51tIS7Zv9ZFeII2/SQ fNSdGdByo75xXLs1dxQkgPG+U9E+br6Y38HhhGUJZ2/d45wwzwQSLicDqdn7RLaM/1yM v0fKGN88M0uJbg11r+YY6HcC2xg/Oof1oDql8NHHvi5czh2f+V69rmOImdkBS5PESulX 9xic0OyQB+WJhST3ajFx37Ax+kCEw99S7oaPEZMTl+QU/XPJcLdv9fhiEAF+iWIYBopM m4og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=hs3HY7g7iInOHSIqlAQOKkHaLJM+XTGFYI2JrFlwSao=; b=WL3Omffwhbf4gFgf/8YAMezvV/TmUZhnjRaBdO+UrbbM8r7fzcIIiINnJDLBW68zhs 7xLsNMSEDK2qcoazyyvix9TX8f/qOfIkB8KmK7R8v+GbissAXYzlBpRWAi/wUIuGTpAo lM25YrTmt7xerxy7fu5C1/P/CxWJufHSvJ7YSk6rGsuNer4CmSegQuu9/fnG9g7Ow09P JOqSdDG84IzR7itz5zRaT+hfPX2cLWbb4LtFjw5mHAnFeFgZotAFQjR6W5UCUd9tMufz NYro2mWS9bb8V+n0d3yAjV3d9duofETrKg3is6vREZAasSJNnpZQjQJVhm/9wLd9s0tp f2BA== X-Gm-Message-State: AOAM531ghRVbSouYTd+mC7CecGXR8WyOraHJJl3fUx76VuQA4GrJI4dJ yNbg5lV/5h/puPkQhGsprv09iA== X-Received: by 2002:a17:90a:628b:: with SMTP id d11mr14776004pjj.167.1596837695527; Fri, 07 Aug 2020 15:01:35 -0700 (PDT) Received: from [192.168.10.160] (S01061cabc081bf83.cg.shawcable.net. [70.77.221.9]) by smtp.gmail.com with ESMTPSA id f13sm13925917pfd.215.2020.08.07.15.01.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Aug 2020 15:01:34 -0700 (PDT) From: Andreas Dilger Message-Id: <1E54BAC3-43E0-4908-97A1-6F33D9F353C3@dilger.ca> Content-Type: multipart/signed; boundary="Apple-Mail=_713A9422-50CF-4793-BBFA-A646EEB0262C"; protocol="application/pgp-signature"; micalg=pgp-sha256 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH] ext4: move buffer_mapped() to proper position Date: Fri, 7 Aug 2020 16:01:42 -0600 In-Reply-To: <20200807200254.GY7657@mit.edu> Cc: Xianting Tian , Al Viro , linux-fsdevel , Linux Kernel Mailing List , Ext4 Developers List To: Theodore Ts'o References: <1596211825-8750-1-git-send-email-xianting_tian@126.com> <20200807200254.GY7657@mit.edu> X-Mailer: Apple Mail (2.3273) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org --Apple-Mail=_713A9422-50CF-4793-BBFA-A646EEB0262C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On Aug 7, 2020, at 2:02 PM, tytso@mit.edu wrote: >=20 > Thanks, applied, although I rewrote the commit description to make it > be a bit more clearer: >=20 > fs: prevent BUG_ON in submit_bh_wbc() >=20 > If a device is hot-removed --- for example, when a physical device = is > unplugged from pcie slot or a nbd device's network is shutdown --- > this can result in a BUG_ON() crash in submit_bh_wbc(). This is > because the when the block device dies, the buffer heads will have > their Buffer_Mapped flag get cleared, leading to the crash in > submit_bh_wbc. >=20 > We had attempted to work around this problem in commit a17712c8 Should this get a "Fixes:" label with this info, rather than embedding it in the commit message, so that it could be picked up by stable? Cheers, Andreas > ("ext4: check superblock mapped prior to committing"). = Unfortunately, > it's still possible to hit the BUG_ON(!buffer_mapped(bh)) if the > device dies between when the work-around check in = ext4_commit_super() > and when submit_bh_wbh() is finally called: >=20 > Code path: > ext4_commit_super > judge if 'buffer_mapped(sbh)' is false, return <=3D=3D commit = a17712c8 > lock_buffer(sbh) > ... > unlock_buffer(sbh) > __sync_dirty_buffer(sbh,... > lock_buffer(sbh) > judge if 'buffer_mapped(sbh))' is false, = return <=3D=3D added by this patch > submit_bh(...,sbh) > submit_bh_wbc(...,sbh,...) >=20 > [100722.966497] kernel BUG at fs/buffer.c:3095! <=3D=3D = BUG_ON(!buffer_mapped(bh))' in submit_bh_wbc() > [100722.966503] invalid opcode: 0000 [#1] SMP > [100722.966566] task: ffff8817e15a9e40 task.stack: ffffc90024744000 > [100722.966574] RIP: 0010:submit_bh_wbc+0x180/0x190 > [100722.966575] RSP: 0018:ffffc90024747a90 EFLAGS: 00010246 > [100722.966576] RAX: 0000000000620005 RBX: ffff8818a80603a8 RCX: = 0000000000000000 > [100722.966576] RDX: ffff8818a80603a8 RSI: 0000000000020800 RDI: = 0000000000000001 > [100722.966577] RBP: ffffc90024747ac0 R08: 0000000000000000 R09: = ffff88207f94170d > [100722.966578] R10: 00000000000437c8 R11: 0000000000000001 R12: = 0000000000020800 > [100722.966578] R13: 0000000000000001 R14: 000000000bf9a438 R15: = ffff88195f333000 > [100722.966580] FS: 00007fa2eee27700(0000) = GS:ffff88203d840000(0000) knlGS:0000000000000000 > [100722.966580] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > [100722.966581] CR2: 0000000000f0b008 CR3: 000000201a622003 CR4: = 00000000007606e0 > [100722.966582] DR0: 0000000000000000 DR1: 0000000000000000 DR2: = 0000000000000000 > [100722.966583] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: = 0000000000000400 > [100722.966583] PKRU: 55555554 > [100722.966583] Call Trace: > [100722.966588] __sync_dirty_buffer+0x6e/0xd0 > [100722.966614] ext4_commit_super+0x1d8/0x290 [ext4] > [100722.966626] __ext4_std_error+0x78/0x100 [ext4] > [100722.966635] ? __ext4_journal_get_write_access+0xca/0x120 = [ext4] > [100722.966646] ext4_reserve_inode_write+0x58/0xb0 [ext4] > [100722.966655] ? ext4_dirty_inode+0x48/0x70 [ext4] > [100722.966663] ext4_mark_inode_dirty+0x53/0x1e0 [ext4] > [100722.966671] ? __ext4_journal_start_sb+0x6d/0xf0 [ext4] > [100722.966679] ext4_dirty_inode+0x48/0x70 [ext4] > [100722.966682] __mark_inode_dirty+0x17f/0x350 > [100722.966686] generic_update_time+0x87/0xd0 > [100722.966687] touch_atime+0xa9/0xd0 > [100722.966690] generic_file_read_iter+0xa09/0xcd0 > [100722.966694] ? page_cache_tree_insert+0xb0/0xb0 > [100722.966704] ext4_file_read_iter+0x4a/0x100 [ext4] > [100722.966707] ? __inode_security_revalidate+0x4f/0x60 > [100722.966709] __vfs_read+0xec/0x160 > [100722.966711] vfs_read+0x8c/0x130 > [100722.966712] SyS_pread64+0x87/0xb0 > [100722.966716] do_syscall_64+0x67/0x1b0 > [100722.966719] entry_SYSCALL64_slow_path+0x25/0x25 >=20 > To address this, add the check of 'buffer_mapped(bh)' to > __sync_dirty_buffer(). This also has the benefit of fixing this = for > other file systems. >=20 > With this addition, we can drop the workaround in = ext4_commit_supper(). >=20 > [ Commit description rewritten by tytso. ] >=20 > Signed-off-by: Xianting Tian > Link: = https://lore.kernel.org/r/1596211825-8750-1-git-send-email-xianting_tian@1= 26.com > Signed-off-by: Theodore Ts'o >=20 > - Ted Cheers, Andreas --Apple-Mail=_713A9422-50CF-4793-BBFA-A646EEB0262C Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org iQIzBAEBCAAdFiEEDb73u6ZejP5ZMprvcqXauRfMH+AFAl8tz0YACgkQcqXauRfM H+Ct9w//USImy+Og8ALzibs973+iX2GUBoGOsZGwszW8GFptFk8/my3ltdbeU0xs rXakgWy55lpnEzs+u2o1wOuUkaz+PX2OfOdwKyqAuLFQ2jVstOFGyajsLPh5WJV/ N7eLyTlOzfVPnTQhJEA9HBe8YwocS35V8qVGYoO1W9C+ofSlj3qbQPGieX+JMwWK iJMgGCwelvYv6zFxJhIGbBKMiApy5+uCeLBRCyjC2jCAdPJ3Zglq4WYcfocqX+EV bPSId5yESJFvhZU3dxtnK/isPpjIV8vhukBJ7Q+dewTFVaxfE0QrTV4RCx4j7ZZY COdiQ7rpGhvKxtNydZL3LGAPe6Ti9PXjpVnSvo6IHqTimzeSliWq35GndHxmROLt 2dSO2+gaEDFXvW8H2GxEj7Qbaft3iUpBK+GSbCJf0hGgxgVJRLQiFOyDlG0ViGPx aj3YQrmxmYBevKxm9VuR1Z9AqlphSeTmpBqiSEWyzqUD6TPZDSfanBYGvmpMJSY0 W25whFy3a32Fjzf0AG5aG/UBbRCcpJ49kcOTxguVTtsIgZ8mZDKg0ymz6Ha6Kgmh z/EY/HkVK+sCbKRyszVUbYcgUlomzn4dgF9F1s8hbt9UjyQJ02bm7C1p1aehkvRI DHvsU98nDXOh8FUzrJnqC4frNkWYYUld0QjXvGiS8eRXndgXSyI= =f2Bs -----END PGP SIGNATURE----- --Apple-Mail=_713A9422-50CF-4793-BBFA-A646EEB0262C--