Skip to content

Commit a17712c

Browse files
Jon Derricktytso
authored andcommitted
ext4: check superblock mapped prior to committing
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 <jonathan.derrick@intel.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org
1 parent bfe0a5f commit a17712c

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎fs/ext4/super.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4808,6 +4808,14 @@ static int ext4_commit_super(struct super_block *sb, int sync)
48084808

48094809
if (!sbh || block_device_ejected(sb))
48104810
return error;
4811+
4812+
/*
4813+
* The superblock bh should be mapped, but it might not be if the
4814+
* device was hot-removed. Not much we can do but fail the I/O.
4815+
*/
4816+
if (!buffer_mapped(sbh))
4817+
return error;
4818+
48114819
/*
48124820
* If the file system is mounted read-only, don't update the
48134821
* superblock write time. This avoids updating the superblock

0 commit comments

Comments
 (0)