Skip to contentSkip to conversation

fs: Fixup bdev_mark_dead callbacks for ext4 and xfs

PATCH In review Jan Kara 2 participants 6 messages Jun 21, 2023

Subsystems (3)
lore
Share & tools
lore

Jan Kara

author reviewer
#0 lore raw

cover fs: Fixup bdev_mark_dead callbacks for ext4 and xfs

Hello,

Jens, I have found out the recently added handlers (sitting in your tree) of .bdev_mark_dead callbacks in xfs and ext4 were wrongly using bdev->bd_holder instead of bdev->bd_super and so they could never work. This series fixes them.

Honza

author reviewer
#1 lore raw

PATCH 1/2 ext4: Fix crash in ext4_bdev_mark_dead()

ext4_bdev_mark_dead() passes bdev->bd_holder to ext4_force_shutdown() instead of bdev->bd_super leading to crashes. Fix it.

Fixes dd2e31afba9e ("ext4: wire up the ->mark_dead holder operation for log devices")
---
 fs/ext4/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/super.c +1 -1
index 6f43a86ecf16..53d74144ee34 100644
@@ -1098,7 +1098,7 @@ void ext4_update_dynamic_rev(struct super_block *sb)
 
 static void ext4_bdev_mark_dead(struct block_device *bdev)
 {
-	ext4_force_shutdown(bdev->bd_holder, EXT4_GOING_FLAGS_NOLOGFLUSH);
+	ext4_force_shutdown(bdev->bd_super, EXT4_GOING_FLAGS_NOLOGFLUSH);
 }
 
 static const struct blk_holder_ops ext4_holder_ops = {
Signature · 1 line
2.35.3
#2 lore raw

Re: [PATCH 1/2] ext4: Fix crash in ext4_bdev_mark_dead()

Quoted 2 lines · Jan Kara

ext4_bdev_mark_dead() passes bdev->bd_holder to ext4_force_shutdown() instead of bdev->bd_super leading to crashes. Fix it.

How does this crash? ext4_blkdev_get passes the sb as holder, and I actually tested this code.

This is not to be confused with the blkdev_get_by_path in get_tree_bdev, but that never ends up in ext4_bdev_mark_dead.

author reviewer
#3 lore raw

Re: [PATCH 1/2] ext4: Fix crash in ext4_bdev_mark_dead()

Quoted 9 lines · Christoph Hellwig
Quoted 2 lines · Jan Kara

ext4_bdev_mark_dead() passes bdev->bd_holder to ext4_force_shutdown() instead of bdev->bd_super leading to crashes. Fix it.

How does this crash? ext4_blkdev_get passes the sb as holder, and I actually tested this code.

This is not to be confused with the blkdev_get_by_path in get_tree_bdev, but that never ends up in ext4_bdev_mark_dead.

Indeed, I have confused the method called for journal device with the method called for the main filesystem device. Both my patches are wrong and I'm sorry for the confusion!

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
author reviewer
#4 lore raw

PATCH 2/2 xfs: Fix crash in ext4_bdev_mark_dead()

In reply to Jan Kara

xfs_bdev_mark_dead() passes bdev->bd_holder to ext4_force_shutdown() instead of bdev->bd_super leading to crashes. Fix it.

Fixes 8067ca1dcdfc ("xfs: wire up the ->mark_dead holder operation for log and RT devices")
---
 fs/xfs/xfs_super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_super.c +1 -1
index d910b141d52e..3ab188a6fba1 100644
@@ -381,7 +381,7 @@ static void
 xfs_bdev_mark_dead(
 	struct block_device	*bdev)
 {
-	xfs_force_shutdown(bdev->bd_holder, SHUTDOWN_DEVICE_REMOVED);
+	xfs_force_shutdown(XFS_M(bdev->bd_super), SHUTDOWN_DEVICE_REMOVED);
 }
 
 static const struct blk_holder_ops xfs_holder_ops = {
Signature · 1 line
2.35.3
#5 lore raw

Re: [PATCH 2/2] xfs: Fix crash in ext4_bdev_mark_dead()

Quoted 2 lines · Jan Kara

xfs_bdev_mark_dead() passes bdev->bd_holder to ext4_force_shutdown() instead of bdev->bd_super leading to crashes. Fix it.

xfs_bdev_mark_dead is only called for the log and RT devices, for which the mp is passed as holder to blkdev_get_by_path. bd_super won't be set for those devices, so this patch will introduce a crash and not fix one.