Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1580774imm; Fri, 29 Jun 2018 23:10:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe9kN6POAa4kwReeOHPYykFOjP8VZDdJxslXFnXZL72f6ZncQOwbrAyRfam7iIK76b7uXA5 X-Received: by 2002:a62:190d:: with SMTP id 13-v6mr5095690pfz.103.1530339052152; Fri, 29 Jun 2018 23:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530339052; cv=none; d=google.com; s=arc-20160816; b=p3U2B13J0jK+twsQ8YEezVVgtRdD8GkcYah0BMGboQ1lMT3+N1w824JQT/39y9UGJa eZdSPCUMCy/d1nLJgtKJYbpldbnK5HapJXT8J9w3+hl2LSKzE4VIyzeZyQZo/tKe4ZJF zQNEv3JhmKRCKq9Ad7wg3Q5v0NC8yWX81Nf1IMUbLCsojV9LWmmnW7rP7jiH+BQL2yg0 coCXotPplU1hyxFbcdjPslz55DB7y/yFn7SpsyXw9HowMjV9tWDmfyeRuFhRu5hAck4G whQ+IqPKyFQJe7gSZjNeyz1y6h4lkz+RRRYFMvl2VI02lbKz57r/rITR1GEMMMgJjaz8 VvoA== 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 :arc-authentication-results; bh=Pb9U1/hSbMVUkgpCk/PvqbOJeWDzAE827Qt38kzByDA=; b=y2jUlaBbFGGHCGGnGKvDokaICIE+tT9GYByKy0TM6OPG8qBbhHM/TPpvJmNECatk3i 9uu1tfZe9wNWMh49i1cjeNgO67AyImhnWI0prSiCoT6Sd2IWxe9+2FO66ZavMKbfCrjH dpD13/Pp+DTt36Gh7mpXYqp9OmOPHVFYSJVey5tP/3wDzhGTvQHGF4YloPjRfh2mI5jo HB7Ls/B9YVGMPwtY8O9nkqgTztWdiLlqiRr+ZqG8/YCN+AtBk7iDjunquZwUt99s8JVW CCQVUVHPzsSg9le3lthuK1jrnF8dhoZeRuzgaTV3nViZHUqiAAEkw+oZ9QJfVK97CmuQ Y7uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dilger-ca.20150623.gappssmtp.com header.s=20150623 header.b=aqDZ1zFK; 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 b2-v6si10772102plx.88.2018.06.29.23.10.37; Fri, 29 Jun 2018 23:10:52 -0700 (PDT) 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=@dilger-ca.20150623.gappssmtp.com header.s=20150623 header.b=aqDZ1zFK; 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 S1754028AbeF3EgN (ORCPT + 99 others); Sat, 30 Jun 2018 00:36:13 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:43400 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753909AbeF3EgL (ORCPT ); Sat, 30 Jun 2018 00:36:11 -0400 Received: by mail-pg0-f65.google.com with SMTP id a14-v6so4807753pgw.10 for ; Fri, 29 Jun 2018 21:36:11 -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=Pb9U1/hSbMVUkgpCk/PvqbOJeWDzAE827Qt38kzByDA=; b=aqDZ1zFKwPB5UZ64SIvogYu5LCFWGsf0rgRkuhu4/9hLIzwC6i/4NGDJEQZoEb059k ymWfpG7mFYMkzsVZNWHVUsYulydBz/HyyTghm8faRc1VgNFELd7GwhwnpPMtWX3ZIF5W +qbE8aWQXS1Ri57hYAXvFxTW6OQg8wjf7aLcnaQbC30DFYol4Xnl9Z9ZSxQFAdxwOGzf DDDvaOUC0YemJh0XalBoSvSfdIqDX3RdWCBoXj84xEW7wKYlDQwNX6fcQsu/1ME5pwVD nAn47SMWLwBj4BMLeyQ31ixxIKWcBkTvgdlqFlwbkv2hhGG2eSrVwNvdCc3lA2dms8zh t4WQ== 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=Pb9U1/hSbMVUkgpCk/PvqbOJeWDzAE827Qt38kzByDA=; b=S16QBvO6N69y3aWvalKmr1gqptBNZf2zMlewaG/RU1CO74EL1m9wIGwV6HSzbnm3he ZeI+ZI2a+hfaV33tbqV+hiVAFE03uqsYAeUe4cUp+ZRTOpg33P7t3YIzJDmefWKmKhzk iLcK7EbVpbGoyuc+Comuqu9LLCBGCxzhrK+9hD9AojwEyXRNodHZEDJ0Sa8B0fOUAsDF yafaieStdVWTM1uTUJUFnTyX4yhAotD4EZh80pRyc0V/vHsc+k710+C2vdZI5sMeMRO8 36RFvTtmEKaMD/8Yv3pOWJVwB9nxOZOATTaoVLQKdG4TD5AhoCfWGqPXHhT/+PI6ZZcw IaXQ== X-Gm-Message-State: APt69E1Vyr0vVCyjeN6DfD7+znltWMWGdvF92BaacvpEsxuIlJcvSabi 57hoT/dHlU3puFQOLPOTV2kOcKTcZhE= X-Received: by 2002:a63:2e81:: with SMTP id u123-v6mr11352187pgu.225.1530333370871; Fri, 29 Jun 2018 21:36:10 -0700 (PDT) Received: from cabot.adilger.ext (S0106a84e3fe4b223.cg.shawcable.net. [70.77.216.213]) by smtp.gmail.com with ESMTPSA id 4-v6sm19977729pfi.78.2018.06.29.21.36.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jun 2018 21:36:09 -0700 (PDT) From: Andreas Dilger Message-Id: Content-Type: multipart/signed; boundary="Apple-Mail=_E8FFBE7E-1B06-4D58-8BBF-BAE19556F898"; protocol="application/pgp-signature"; micalg=pgp-sha256 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH] ext4: Check superblock mapped prior to committing Date: Fri, 29 Jun 2018 22:36:06 -0600 In-Reply-To: <1530300995-25583-1-git-send-email-jonathan.derrick@intel.com> Cc: Ext4 Developers List , Theodore Ts'o , Linux Kernel Mailing List To: Jon Derrick References: <1530300995-25583-1-git-send-email-jonathan.derrick@intel.com> X-Mailer: Apple Mail (2.3273) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --Apple-Mail=_E8FFBE7E-1B06-4D58-8BBF-BAE19556F898 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On Jun 29, 2018, at 1:36 PM, Jon Derrick = wrote: >=20 > This patch attempts to close a hole leading to a BUG seen with hot > removals during writes [1]. >=20 > A block device (NVME namespace in this test case) is formatted to EXT4 > without partitions. It's mounted and write I/O is run to a file, then > the device is hot removed from the slot. The superblock attempts to be > written to the drive which is no longer present. >=20 > The typical chain of events leading to the BUG: > ext4_commit_super() > __sync_dirty_buffer() > submit_bh() > submit_bh_wbc() > BUG_ON(!buffer_mapped(bh)); >=20 > This fix checks for the superblock's buffer head being mapped prior to > syncing. >=20 > [1] https://www.spinics.net/lists/linux-ext4/msg56527.html >=20 > Signed-off-by: Jon Derrick > --- > fs/ext4/super.c | 8 ++++++++ > 1 file changed, 8 insertions(+) >=20 > diff --git a/fs/ext4/super.c b/fs/ext4/super.c > index 0c4c220..ee33233 100644 > --- a/fs/ext4/super.c > +++ b/fs/ext4/super.c > @@ -4736,6 +4736,14 @@ static int ext4_commit_super(struct super_block = *sb, int sync) >=20 > if (!sbh || block_device_ejected(sb)) > return error; > + > + /* > + * The superblock bh should be mapped, but it might not be if = the > + * device was hot-removed. Not much we can do but fail the I/O. > + */ > + if (!buffer_mapped(sbh)) > + return error; This still looks a bit racy, based on the stack trace you posted. There is already a "block_device_ejected()" check a line above, which makes me think that the PCI device removal should be handled like an ejected device, so that it is also handled elsewhere. Even so, the check here in ext4_commit_super() can pass, and the PCI card can be removed on the next instruction and still trigger the BUG_ON(). That said, this is probably still an improvement on the existing situation. Cheers, Andreas --Apple-Mail=_E8FFBE7E-1B06-4D58-8BBF-BAE19556F898 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+AFAls3CLYACgkQcqXauRfM H+B1IQ/+Ivh2zNIIOCJEilXbgCSnYxWDUwDWUEX8I3q1FuDqoRC80U5Di2sx2ibK pfAF5a61IJMvinjW5VlnxIzDtc+kq//aZT/5ddLOSvY161+JHF1AysVjQIGZWEBS 5dFpOGarmjZa3HfDjDkcNGwBdolB1SSE1W8GX8V8Zlk/R8aUqHOQitYusmUQHNbf ZG6EQmZuuN0ydEyOZCnUbDm2ab9YIDQtxzhvIBqfTLSdXOhwMVnL0ftJqaiFiEn4 yt4dXo3sZEWxpAGWYmnZK+Pjwxyc6xvqAd1YlnchDZxsKlkICvicliU19NzCaVIe 2GTi5kQ84dYNtTpSsoOhOYGNfyUpE6QegF5NdL2+1o4vnqYoC7c1rMxrMVBBiGJl lazFrGvnZSFTKMt0Aqy4Ytt15w0XPZmaY17TOge4/xCCXZhZzMFv4OWav50qL4Ye ppkzTWTNFKZ1GYjYmgmmYtaHyjwaSys2O3wvws/sU+RHn768MFdjfL7vDXHAxMby MWY9M8n2PUIi7o6Am8m7aBGpwJF8d3oJGcUt40K5UMoJFalnGqHCy4vKMEEa1JdM HHqLtw3lgKml4zhSfZqY7T4/NHd4KMGuv9a6hcuppIRhCFW9qlWy74X9aU5PTNyX kKK9vW+LtgSiHjMR04IpcwvUPwEhQbV8x0NvuQFi5pw8pTeOCXE= =9q8V -----END PGP SIGNATURE----- --Apple-Mail=_E8FFBE7E-1B06-4D58-8BBF-BAE19556F898--