Summary: | Unmounting certain SD cards can triggers an immediate remount when using "automount on attach" setting | ||
---|---|---|---|
Product: | [Frameworks and Libraries] frameworks-solid | Reporter: | Alberto Garcia <berto> |
Component: | general | Assignee: | Unassigned bugs mailing-list <unassigned-bugs> |
Status: | ASSIGNED --- | ||
Severity: | normal | CC: | kdelibs-bugs, lukas, mr, nate, stefan.bruens |
Priority: | NOR | ||
Version: | 5.103.0 | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | strace output |
Description
Alberto Garcia
2023-03-24 13:11:10 UTC
*** Bug 446395 has been marked as a duplicate of this bug. *** Can't reproduce with my card and card reader, FWIW. So I think it depends on the hardware's adherence to the spec, which underscores the flakiness here. Perhaps Solid can grow the ability to check for whether an unmounted volume immediately gets an "add" event from udisks, and ignore it if it's under a certain timeout. Say, 100ms. In case you want to give it a try with QEMU, here's a very simple test case: 1) Boot a VM with a virtual SD card reader, like this: -device sdhci-pci -device sd-card,drive=mmc0 -drive if=none,file=card.qcow2,id=mmc0 2) Add a partition to the SD card, no need to format it (you can use GPT or DOS/MBR, it doesn't matter). 3) Run `udevadm monitor` and in a different terminal run `eject /dev/mmcblk0` This is enough to see the udev events I mentioned earlier. The check that you describe seems fine (assuming that timeout is not too small). Thanks! A possibly relevant merge request was started @ https://invent.kde.org/frameworks/solid/-/merge_requests/128 A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/1454 "eject" in this context forces the card reader/drive to flush any pending operations from its caches. The timestamp based heuristic does not work in all cases, as a card reader will have a constant "TimeDetected" timestamp, and plugging a card into it will result in a significantly later "TimeMediaDetected". @ Alberto: Can you please provide the output of "udisctl monitor", when you run "/usr/bin/eject /dev/mmcblk0; echo $? "?. (You likely have to run "eject" as root, e.g. via sudo. In case eject returns with a non-zero exit code, stracing it may reveal further information - "sudo strace -s 200 eject /dev/mmcblk0".) Created attachment 157742 [details]
strace output
The strace output is attached. Here's the output of the eject and monitor commands:
# /usr/bin/eject /dev/mmcblk0; echo $?
eject: unable to eject
1
# udisksctl monitor
Monitoring the udisks daemon. Press Ctrl+C to exit.
15:43:49.633: The udisks-daemon is running (name-owner :1.29).
15:43:50.504: Removed /org/freedesktop/UDisks2/block_devices/mmcblk0p1
15:43:50.538: /org/freedesktop/UDisks2/block_devices/mmcblk0: org.freedesktop.UDisks2.PartitionTable: Properties Changed
Partitions:
15:43:50.629: Added /org/freedesktop/UDisks2/block_devices/mmcblk0p1
org.freedesktop.UDisks2.Block:
Configuration: []
CryptoBackingDevice: '/'
Device: /dev/mmcblk0p1
DeviceNumber: 45825
Drive: '/org/freedesktop/UDisks2/drives/SL16G_0x8c9ed258'
HintAuto: true
HintIconName:
HintIgnore: false
HintName:
HintPartitionable: true
HintSymbolicIconName:
HintSystem: false
Id: by-uuid-9019398f-1e38-4f69-bca4-6feb56d98ed7
IdLabel: SD_CARD
IdType: ext4
IdUUID: 9019398f-1e38-4f69-bca4-6feb56d98ed7
IdUsage: filesystem
IdVersion: 1.0
MDRaid: '/'
MDRaidMember: '/'
PreferredDevice: /dev/mmcblk0p1
ReadOnly: false
Size: 15929966592
Symlinks: /dev/disk/by-id/mmc-SL16G_0x8c9ed258-part1
/dev/disk/by-label/SD_CARD
/dev/disk/by-partlabel/primary
/dev/disk/by-partuuid/679ecb89-c2df-4e55-ac6a-e8be61e2709d
/dev/disk/by-uuid/9019398f-1e38-4f69-bca4-6feb56d98ed7
UserspaceMountOptions:
org.freedesktop.UDisks2.Filesystem:
MountPoints:
Size: 15929966592
org.freedesktop.UDisks2.Partition:
Flags: 0
IsContained: false
IsContainer: false
Name: primary
Number: 1
Offset: 1048576
Size: 15929966592
Table: '/org/freedesktop/UDisks2/block_devices/mmcblk0'
Type: 0fc63daf-8483-4772-8e79-3d69d8477de4
UUID: 679ecb89-c2df-4e55-ac6a-e8be61e2709d
15:43:50.629: /org/freedesktop/UDisks2/block_devices/mmcblk0: org.freedesktop.UDisks2.PartitionTable: Properties Changed
Partitions: /org/freedesktop/UDisks2/block_devices/mmcblk0p1
According to the strace output, the drive supports none of the four attempted methods of eject, i.e. the ioctl's 'CDROM_LOCKDOOR', 'SG_IO(...)', 'FDEJECT' and 'MTIOCTOP'. I can confirm the behavior by issuing e.g. 'eject -f ...', as FDEJECT is not supported by my card reader (it supports the SCSI ioctl) I also get the UDEV REMOVED/CHANGED/ADDED sequence. (In reply to Stefan Brüns from comment #9) > According to the strace output, the drive supports none of the four > attempted methods of eject, i.e. the ioctl's 'CDROM_LOCKDOOR', 'SG_IO(...)', > 'FDEJECT' and 'MTIOCTOP'. FWIW the same happens with QEMU's virtual SD card reader (the strace output I attached earlier is from actual hardware). There's one more thing to take into account with the "5 seconds since plugged" heuristic: the case when the volume was present at coldplug (i.e. it was already there when the session started). Related links for the GNOME implementation: https://gitlab.gnome.org/GNOME/gvfs/-/commit/e30a67f3215d829e95ee7e358c67af7d67635fe8 https://bugzilla.redhat.com/show_bug.cgi?id=813069 Git commit 41eaa14d3375e303e68e0d2f39090f5ed4f48c82 by David Edmundson. Committed on 21/06/2023 at 10:45. Pushed by davidedmundson into branch 'master'. Expose StorageDevice timeDetected/timeMediaDetected For automounting purposes it's useful to know when a drive appeared in relation to when StorageVolumes appear. Rather than adding tracking in front-end code we can make use of udisk's existing information. M +10 -0 src/solid/devices/backends/fakehw/fakestorage.cpp M +3 -0 src/solid/devices/backends/fakehw/fakestorage.h M +20 -0 src/solid/devices/backends/udisks2/udisksstoragedrive.cpp M +3 -0 src/solid/devices/backends/udisks2/udisksstoragedrive.h M +12 -0 src/solid/devices/frontend/storagedrive.cpp M +21 -0 src/solid/devices/frontend/storagedrive.h M +10 -0 src/solid/devices/ifaces/storagedrive.cpp M +12 -0 src/solid/devices/ifaces/storagedrive.h https://invent.kde.org/frameworks/solid/-/commit/41eaa14d3375e303e68e0d2f39090f5ed4f48c82 |