`udevadm monitor` shows events as follows while removing memory card of
these card reader in kernel 5.8

```

KERNEL[188.377042] change 
/devices/pci0000:00/0000:00:14.0/usb2/2-9/2-9:1.0/host5/target5:0:0/5:0:0:0/block/sdc
 (block)
UDEV [188.383261] remove 
/devices/pci0000:00/0000:00:14.0/usb2/2-9/2-9:1.0/host5/target5:0:0/5:0:0:0/block/sdc
 (block)
KERNEL[188.390887] change 
/devices/pci0000:00/0000:00:14.0/usb2/2-9/2-9:1.0/host5/target5:0:0/5:0:0:0/block/sdc
 (block)
UDEV [188.396012] remove 
/devices/pci0000:00/0000:00:14.0/usb2/2-9/2-9:1.0/host5/target5:0:0/5:0:0:0/block/sdc
 (block)
```

In Kernel later then 5.9.0-rc3, the udevadm shows only `change` event
instead of `remove`.

Removing memory cards on these card readers do not trigger remove event
for scsi_disk, scsi_device, scsi_generic, or usb unbind like other card
readers do.

After kernel bisecting, I found the commit `block: don't clear
bd_invalidated in check_disk_size_change`
(https://github.com/torvalds/linux/commit/6540fbf6b634071950f01ee4e4194e2ea8ca72d1)
makes the difference.


When removing memory card on kernel 5.10, the GD_NEED_PART_SCAN bit is cleared 
in bdev_disk_changed() but the blk_drop_partitions() returns -EBUSY right 
after. It makes the consequent __blkdev_get have no chance to invoke 
bdev_disk_changed() again, thus the partitions has no chance to be removed 
until the memory card re-inserted.

Reverting the commit or clear the GD_NEED_PART_SCAN bit after
blk_drop_partitions done can fix the issue.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1920874

Title:
  [Regression] Partition not removed after removing the memory cards
  from card reader since kernel 5.9.0-rc3+

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1920874/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to