Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1244958imm; Fri, 29 Jun 2018 14:14:52 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJaXg6zAzSBUatGTgyiFwfIitUAdW0LyXxvVojvIzFgQfY5xK2oi6GqkAsduVPJ5CfS93yq X-Received: by 2002:a17:902:2c83:: with SMTP id n3-v6mr16175579plb.211.1530306892826; Fri, 29 Jun 2018 14:14:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530306892; cv=none; d=google.com; s=arc-20160816; b=ZtFkgKJgNIpzVXuXmxC+pFTLWQ3kPSmahYyABjtGD2CxOe9TEEcz0sOMrMiavosfvL 562fKl+Rx+e8PduVnCvIuccmQmgisbbIx27mJMJYUz3sC6PXHLncS60z+fp8JdHYyZ9G bEtchGDo+P3zrB3JsNuYGXZodX7iBbxKUxRjF+w2Df29NF0eUQDTKMx2TfoqM8JzNi4+ IQvxTIHLJBUCuMSx7t6bqK/GWPGNBaUh2wXqhY25/lb6PqvDx/UkCHHyDH9yFvLThBTC aVYneBVjH5Hg8wde2mN+b3NaLzL6k8ZbNUAajWFrpJbm/WEiTtuQyswlxWn1pLQK+au7 OFNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=KwAk1sUafc9zLGRKMwyxM49eHh2GhisJJXt9ChHIxBs=; b=IM2/04VCRa77hPWvXDxi7HrJJRFmGmM6fsG2gUum+WF71T/G5pbWizyl/TbFeVVWrt gNABpVgR792H0FWpxt0OwTHHHff3AuRPpAuvvKfQ87hYx8TzqX0awXDBXkoNcnfoO+l3 /5ai3NIC4SWqnIssAKo6m370urfqVkwOs8AfCs/rV1x57mfn73W+DcMoPTxQcYuMj6zc iC3m9oEr/rYsjsDhxmXAW+JU0jDul5JMV4DRrIn2kjnOqPPkFg4UXEf+iEZT5xPf9T3i 86EQcC8xoWK02epkQ745rcZ4rlObtIBTybLUu6Ia4IqIrHDNLO6nTY+yEgNLq2Jkyj/u 8ROQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z4-v6si1679151pgp.580.2018.06.29.14.14.38; Fri, 29 Jun 2018 14:14: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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937276AbeF2TjW (ORCPT + 99 others); Fri, 29 Jun 2018 15:39:22 -0400 Received: from mga06.intel.com ([134.134.136.31]:57709 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932405AbeF2TjU (ORCPT ); Fri, 29 Jun 2018 15:39:20 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jun 2018 12:39:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,287,1526367600"; d="scan'208";a="63263208" Received: from unknown (HELO localhost.localdomain) ([10.232.117.195]) by orsmga003.jf.intel.com with ESMTP; 29 Jun 2018 12:38:55 -0700 From: Jon Derrick To: Cc: "Theodore Ts'o" , Andreas Dilger , , Jon Derrick Subject: [PATCH] ext4: Check superblock mapped prior to committing Date: Fri, 29 Jun 2018 13:36:35 -0600 Message-Id: <1530300995-25583-1-git-send-email-jonathan.derrick@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch attempts to close a hole leading to a BUG seen with hot removals during writes [1]. 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. 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)); This fix checks for the superblock's buffer head being mapped prior to syncing. [1] https://www.spinics.net/lists/linux-ext4/msg56527.html Signed-off-by: Jon Derrick --- fs/ext4/super.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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) 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; + /* * If the file system is mounted read-only, don't update the * superblock write time. This avoids updating the superblock -- 2.7.4