linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: clear GD_NEED_PART_SCAN later in bdev_disk_changed
@ 2021-03-23  8:52 chris.chiu
  2021-03-23 15:51 ` Christoph Hellwig
  2021-03-23 15:58 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: chris.chiu @ 2021-03-23  8:52 UTC (permalink / raw)
  To: viro, hch, axboe; +Cc: linux-fsdevel, linux-kernel, Chris Chiu

From: Chris Chiu <chris.chiu@canonical.com>

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>
---
 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 92ed7d5df677..28d583fcdc2c 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1240,13 +1240,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.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: clear GD_NEED_PART_SCAN later in bdev_disk_changed
  2021-03-23  8:52 [PATCH] block: clear GD_NEED_PART_SCAN later in bdev_disk_changed chris.chiu
@ 2021-03-23 15:51 ` Christoph Hellwig
  2021-03-23 15:58 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2021-03-23 15:51 UTC (permalink / raw)
  To: chris.chiu; +Cc: viro, hch, axboe, linux-fsdevel, linux-kernel

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: clear GD_NEED_PART_SCAN later in bdev_disk_changed
  2021-03-23  8:52 [PATCH] block: clear GD_NEED_PART_SCAN later in bdev_disk_changed chris.chiu
  2021-03-23 15:51 ` Christoph Hellwig
@ 2021-03-23 15:58 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2021-03-23 15:58 UTC (permalink / raw)
  To: chris.chiu, viro, hch; +Cc: linux-fsdevel, linux-kernel

On 3/23/21 2:52 AM, chris.chiu@canonical.com wrote:
> From: Chris Chiu <chris.chiu@canonical.com>
> 
> 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.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-23 15:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23  8:52 [PATCH] block: clear GD_NEED_PART_SCAN later in bdev_disk_changed chris.chiu
2021-03-23 15:51 ` Christoph Hellwig
2021-03-23 15:58 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).