I started trying this on current quantal, which uses the latest gvfs and udisks2. I can reproduce the "device is busy" race condition with the attached script sometimes (that race condition is rather hard to catch on my system). However, I never get the loop device to automount, the problem is apparently that gvfs notices the manual mount and then does its .Trash thing there.
When I exercise the steps manually, I see in "gvfs-mount -oi" that after sudo losetup /dev/loop0 /tmp/img gvfs sees the new volume: Volume added: 'Datenträger 10 MB' Volume(0): Datenträger 10 MB Type: GProxyVolume (GProxyVolumeMonitorUDisks2) ids: class: 'device' unix-device: '/dev/loop0' uuid: '6a3142af-c40d-455c-b4a3-5a7ae9456d41' themed icons: [drive-removable-media] can_mount=1 can_eject=0 should_automount=0 sort_key=gvfs.time_detected_usec.1339748763777673 should_automount is correctly at "0", i. e. it does not automount it. Once I manually mount it, it goes away: sudo mount /dev/loop0 /tmp/gvfstest Volume removed: 'Datenträger 10 MB' Volume(0): Datenträger 10 MB Type: GProxyVolume (GProxyVolumeMonitorUDisks2) ids: class: 'device' unix-device: '/dev/loop0' uuid: '6a3142af-c40d-455c-b4a3-5a7ae9456d41' themed icons: [drive-removable-media] can_mount=1 can_eject=0 should_automount=0 sort_key=gvfs.time_detected_usec.1339748763777673 That might look confusing at first, but only shows that gvfs is correctly ignoring mounts that are not in /media/ (or /run/media/ for udisks2 these days). Can you please confirm that gvfs does not actually automount the loop device? I. e. if you run the losetup/losetup -d in a loop, gvfs never automounts it? "gvfs-mount -oi" should never show "should_automount=1". If you confirm this, then we are actually seeing the same issue. I never get the "busy" problem if I only SIGSTOP gvfsd-trash. I suspect what happens is that gvfsd-trash is watching for new mounts (I can see it accessing /proc/mounts in strace), accesses new mounts to do its thing, and that races with the very quick unmount; if I put a "sleep 0.1" in between mount and unmount, I never get the "busy" either. Can you confirm this? ** Summary changed: - gvfs-gdu-volume-monitor automounts loop devices, preventing them from being unmounted + gvfsd-trash probes devices not in /run/media, keeping the device busy -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gvfs in Ubuntu. https://bugs.launchpad.net/bugs/1010141 Title: gvfsd-trash probes devices not in /run/media, keeping the device busy To manage notifications about this bug go to: https://bugs.launchpad.net/gvfs/+bug/1010141/+subscriptions -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs