APPLIED/Cmnt (hirsute/5.11): [PATCH 1/1][SRU][OEM-5.10/H/U] block: clear GD_NEED_PART_SCAN later in bdev_disk_changed

Andrea Righi andrea.righi at canonical.com
Mon Mar 29 13:27:00 UTC 2021


On Wed, Mar 24, 2021 at 02:49:54PM +0800, chris.chiu at canonical.com wrote:
> From: Chris Chiu <chris.chiu at canonical.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1920874
> 
> 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/bugs/1920874
> Signed-off-by: Chris Chiu <chris.chiu at canonical.com>
> Reviewed-by: Christoph Hellwig <hch at lst.de>
> Link: https://lore.kernel.org/r/20210323085219.24428-1-chris.chiu@canonical.com
> Signed-off-by: Jens Axboe <axboe at kernel.dk>
> (cherry picked from commit 5116784039f0421e9a619023cfba3e302c3d9adci
>  https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git/log/?h=block-5.12)

This is now upstream, so I updated the "cherry picked ..." line dropping
the block-5.12 URL. BTW the sha1 is not correct, there's an "i" at the
end that shouldn't be there, maybe an extra vim insert typo? :)

Anyway, applied to hirsute/5.11.

Thanks,
-Andrea

> Signed-off-by: Chris Chiu <chris.chiu at canonical.com>
> ---
>  fs/block_dev.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index 2ea189c1b4ff..12836b1fbd60 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -1395,13 +1395,13 @@ int bdev_disk_changed(struct block_device *bdev, bool invalidate)
>  
>  	lockdep_assert_held(&bdev->bd_mutex);
>  
> -	clear_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state);
> -
>  rescan:
>  	ret = blk_drop_partitions(bdev);
>  	if (ret)
>  		return ret;
>  
> +	clear_bit(GD_NEED_PART_SCAN, &disk->state);
> +
>  	/*
>  	 * Historically we only set the capacity to zero for devices that
>  	 * support partitions (independ of actually having partitions created).
> -- 
> 2.17.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team at lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team



More information about the kernel-team mailing list