Skip to content

Commit 0379508

Browse files
mschiu77gregkh
authored andcommitted
block: clear GD_NEED_PART_SCAN later in bdev_disk_changed
[ Upstream commit 5116784 ] The GD_NEED_PART_SCAN is set by bdev_check_media_change to initiate a partition scan while removing a block device. It should be cleared after blk_drop_paritions because blk_drop_paritions could return -EBUSY and then the consequence __blkdev_get has no chance to do delete_partition if GD_NEED_PART_SCAN already cleared. It causes some problems on some card readers. Ex. Realtek card reader 0bda:0328 and 0bda:0158. The device node of the partition will not disappear after the memory card removed. Thus the user applications can not update the device mapping correctly. BugLink: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1920874 Signed-off-by: Chris Chiu <chris.chiu@canonical.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20210323085219.24428-1-chris.chiu@canonical.com Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 7c73059 commit 0379508

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎fs/block_dev.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,13 +1404,13 @@ int bdev_disk_changed(struct block_device *bdev, bool invalidate)
14041404

14051405
lockdep_assert_held(&bdev->bd_mutex);
14061406

1407-
clear_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state);
1408-
14091407
rescan:
14101408
ret = blk_drop_partitions(bdev);
14111409
if (ret)
14121410
return ret;
14131411

1412+
clear_bit(GD_NEED_PART_SCAN, &disk->state);
1413+
14141414
/*
14151415
* Historically we only set the capacity to zero for devices that
14161416
* support partitions (independ of actually having partitions created).

0 commit comments

Comments
 (0)