I'm running plasmashell 5.4.2 on Kubuntu 15.10 with the device notifier in the system tray, and a systemd automount NFS share. The share is set to idle timeout after 60 s of inactivity. Systemd does this after 60 s, but plasmashell triggers a remount shortly after. Is there a way to set plasmashell/device notifier to ignore systemd automounts to prevent this from happening? /etc/fstab line: serverhostname:/tmp/mnt/hddname /mnt/readyshare nfs noauto,x-systemd.automount,x-systemd.device-timeout=10,x-systemd.idle-timeout=60,timeo=14,rw,hard,intr,async,nodev,nosuid,noatime,vers=3 0 0 systemd journalctl log: Nov 12 11:56:09 hostname systemd[1]: Unmounting /mnt/readyshare... Nov 12 11:56:09 hostname systemd[1]: Unmounted /mnt/readyshare. Nov 12 11:56:09 hostname systemd[1]: mnt-readyshare.automount: Got automount req uest for /mnt/readyshare, triggered by 2538 (plasmashell) Nov 12 11:56:09 hostname systemd[1]: Mounting /mnt/readyshare... Nov 12 11:56:09 hostname systemd[1]: Mounted /mnt/readyshare. Nov 12 11:57:10 hostname systemd[1]: Unmounting /mnt/readyshare... Nov 12 11:57:10 hostname systemd[1]: Unmounted /mnt/readyshare. Nov 12 11:57:10 hostname systemd[1]: mnt-readyshare.automount: Got automount request for /mnt/readyshare, triggered by 2538 (plasmashell) Nov 12 11:57:10 hostname systemd[1]: Mounting /mnt/readyshare... Nov 12 11:57:10 hostname systemd[1]: Mounted /mnt/readyshare. Nov 12 11:58:10 hostname systemd[1]: Unmounting /mnt/readyshare... Nov 12 11:58:10 hostname systemd[1]: Unmounted /mnt/readyshare. Nov 12 11:58:10 hostname systemd[1]: mnt-readyshare.automount: Got automount request for /mnt/readyshare, triggered by 2538 (plasmashell) Nov 12 11:58:10 hostname systemd[1]: Mounting /mnt/readyshare... Nov 12 11:58:11 hostname systemd[1]: Mounted /mnt/readyshare. Reproducible: Always Steps to Reproduce: 1. Add a systemd nfs automount with a noauto,x-systemd.automount,x-systemd.idle-timeout=60s. 2. Login to Plasma5 with a device notifier applet. 3. ls /mnt/mountpoint 4. Wait 1 minute, check the systemd log with journalctl. Actual Results: The mount has unmounted and remounted with plasmashell as the requester. Expected Results: The mount has unmounted, but was not accessed by plasmashell and remounted.
>2. Login to Plasma5 with a device notifier applet. You've verified that this applet is the culprit?
I did some adding/removing of different Plasma5 services. Device notifier was a red herring. It's the Free Space Notifier that's causing it. After turning that off, the automount idle unmounts without plasmashell triggering a remount.
(reassigning to General as we don't seem to have a component for Free Space Notifier) I'll try to have a look next week.
Thanks
KDialog is doing it too from a Save As dialog from Chrome: Nov 14 17:20:16 hostname systemd[1]: mnt-readyshare.automount: Got automount request for /mnt/readyshare, triggered by 18652 (kdialog) Nov 14 17:20:16 hostname systemd[1]: Mounting /mnt/readyshare... Nov 14 17:20:16 hostname systemd[1]: Mounted /mnt/readyshare. Nov 14 17:20:16 hostname systemd[1]: mnt-mythmedia.automount: Got automount request for /mnt/mythmedia, triggered by 18652 (kdialog) Nov 14 17:20:16 hostname systemd[1]: Mounting /mnt/mythmedia... The NFS server was suspended, and the dialog blocked waiting for the mount to come up. I had to send a WoL to the machine to unblock the KDialog. The KDialog shouldn't try to stat the fstab automounts until I try to access them.
KDiskFreeSpaceInfo is the culprit for KDialog. I ran it in the debugger and it blocked on a stat of the automount path. $ gdb kdialog (gdb) r --getopenfilename /home #0 0x00007ffff4d10017 in statfs64 () at ../sysdeps/unix/syscall-template.S:81 #1 0x00007ffff4d10086 in __GI_statvfs (file=0x1047e48 "/mnt/mythmedia", buf=buf@entry=0x7fffffffaa30) at ../sysdeps/unix/sysv/linux/wordsize-64/../statvfs.c:34 #2 0x00007ffff784cf9f in KDiskFreeSpaceInfo::freeSpaceInfo (path=...) at ../../kio/kfile/kdiskfreespaceinfo.cpp:135 #3 0x00007ffff7b9829d in KFilePlacesViewDelegate::paint (this=0xaee6f0, painter=0x7fffffffadb0, option=..., index=...) at ../../kfile/kfileplacesview.cpp:178 #4 0x00007ffff5a88133 in QListView::paintEvent (this=this@entry=0x911680, e=<optimized out>) at itemviews/qlistview.cpp:1044 #5 0x00007ffff7b9a3dc in KFilePlacesView::paintEvent (this=0x911680, event=<optimized out>) at ../../kfile/kfileplacesview.cpp:802 #6 0x00007ffff557de20 in QWidget::event (this=this@entry=0x911680, event=event@entry=0x7fffffffb6c0) at kernel/qwidget.cpp:8775 #7 0x00007ffff594770e in QFrame::event (this=0x911680, e=0x7fffffffb6c0) at widgets/qframe.cpp:557 #8 0x00007ffff5a6cff3 in QAbstractItemView::viewportEvent (this=0x911680, event=0x7fffffffb6c0) at itemviews/qabstractitemview.cpp:1644 #9 0x00007ffff61e09c6 in QCoreApplicationPrivate::sendThroughObjectEventFilters (this=this@entry=0x675450, receiver=receiver@entry=0x8d6560, event=event@entry=0x7fffffffb6c0) at kernel/qcoreapplication.cpp:1065
Ah so it's KDiskFreeSpaceInfo, which is also used by the Free Space Notifier and very likely by the Device Notifier, which would imo explain why in your first comment it has plasmashell as the requestor, because the Free Space Notifier lives in kded process, not plasmashell. I've looked at the code and all it does is get KMountPoint by path and then call statvfs() on the path. From [1] the recommendation is to not use "hard" in mount options as that will cause the application to block, which is what you're seeing. As for the stat causing a remount, that's unfortunately out of my knowledge. Reassigning to proper component, perhaps someone more knowledgeable will be able to help. [1] http://unix.stackexchange.com/questions/147308/system-lock-up-when-storage-go-offline-when-using-nfs-mount-options-bg-hard-noin
I'm aware of the difference between hard and soft NFS mount options. I prefer using hard mounts to prevent corruption during minor hiccups for large transfers. I've always heard hard,intr is recommended for this reason. Background services accessing the NFS mounts should do so asynchronously so that blocking doesn't freeze the whole application. stat causes a remount on autofs because of how autofs is designed. If anything tries to access that mountpoint, it causes it to automatically mount. To prevent the mount, the code needs to avoid the stat. I've worked around this on my personal machine by patching KDiskFreeSpaceInfo to skip "possiblySlow()" mount points. This prevents the free disk space info for returning values for nfs, autofs or smbfs based on the current KMountPoint code which likely has broader impact. However, for my use cases, both at home and at work, stating autofs or nfs is problematic. At work, we have hundreds of nfs mounts on the machine. Stating all of them in a background thread (Free Disk Space Notifier) or when a dialog opens (KDialog) is a major performance issue. The desktop frequently freezes on NFS blips, and opening a SaveAs KDialog takes over a minute. At home, the NFS automounts aren't always available since machines sleep. Remounting an autofs partition causes the disks to stay spun up, when the NAS should spin down the disks to save power and prevent wear. "possiblySlow()" volumes should only be accessed when a user specifically tries to access one.
This bug has reappeared for me. I had worked around it by patching KDiskFreeSpaceInfo to not call stat on "probablySlow" mount points. However, this has recently started happening again with that patch installed. I don't know what is calling stat on my automounts now, but plasmashell 5.9.4 on Ubuntu Zesty is causing my systemd automounts to remount shortly after they timeout and autounmount: May 14 22:07:34 fishasshole systemd[1]: Unmounting /mediastorage/mediastorage... -- Subject: Unit mediastorage-mediastorage.mount has begun shutting down -- Unit mediastorage-mediastorage.mount has begun shutting down. May 14 22:07:34 fishasshole systemd[1]: Unmounted /mediastorage/mediastorage. -- Subject: Unit mediastorage-mediastorage.mount has finished shutting down -- Unit mediastorage-mediastorage.mount has finished shutting down. May 14 22:07:34 fishasshole systemd[1]: mediastorage-mediastorage.automount: Got automount request for /mediastorage/mediastorage, triggered by 18881 (plasmashell) May 14 22:07:34 fishasshole systemd[1]: Mounting /mediastorage/mediastorage... -- Subject: Unit mediastorage-mediastorage.mount has begun start-up -- Unit mediastorage-mediastorage.mount has begun starting up. May 14 22:07:34 fishasshole systemd[1]: Mounted /mediastorage/mediastorage. -- Subject: Unit mediastorage-mediastorage.mount has finished start-up -- Unit mediastorage-mediastorage.mount has finished starting up. I will try to trace why it is stating those mount points.
I can confirm that Device Notifier is the culprit this time. I attached strace to plasmashell and see stat("/mediastorage/mediastorage" after every auto umount. I removed Device Notifier from the system tray, and no longer see this. I see a read of mounts around the same time, so it looks like it's reading through my mounts and doing a stat. This is problematic for automounts. I will try to pin down where Device Notifier is doing this.
I tracked the stat call down to KMountPoint::List::findByPath which is called by KDiskFreeSpaceInfo again. That is being called by Device Notifier. When systemd times out and unmounts my automounts, Device Notifier gets an event and rescans the mounts. This triggers all of my automounts to remount when it stats them. KMountPoint::List:findByPath calls QFileInfo fileinfo(path); const QString realname = fileinfo.exists() The fileinfo.exists() ends up calling stat on the mount point which retriggers the mount. This causes my automounts to constantly remount after they timeout. Is there a way to turn off the free space feature for Device Notifier?
Here is the bug: On a disconnect or connect event: Device Notifier loops over all elements in my fstab and calls KDiskFreeSpaceInfo on each of them. This triggers a stat on the mount points in KMountPoint::List::findByPath which causes every automount point in my fstab to mount. Device Notifier is set to only show removable devices. No removable devices are connected, yet it gathers free space information for devices it will never show me. This is a major performance issue. My automounts are set to timeout after 1 minute of inactivity. This bugs causes them to remount every time the time out. Device notifier should not be asking for free space information for every line in my fstab when it will never display them. Free space information should only be requested on demand when the applet needs to show it for a specific device.
I can confirm this bug on Arch Linux with plasma 5.9.5-1. Having a share with x-systemd.idle-timeout=1min in /etc/fstab results in periodic log messages from systemd every minute: systemd[1]: mnt-temp.automount: Got automount request for /mnt/temp, triggered by 856 (plasmashell) If the share is not available, plasma periodically freezes for some seconds. Is there any solution in sight?
Perhaps checking for storageaccess->isAccessible() in updateStorageSpace helps. It already does that before calling into updateStorageSpace in populateDeviceData but does not in updateSourceEvent, I'll try to come up with a patch if you can perhaps test them.
Created attachment 105780 [details] Possible patch Completely untested (other than that it compiles), please test, thanks!
Thank you very much for the patch! It looks much better now. For shares that cannot be mounted because the server is down, isAccessible() returns false, and thus prevents plasma from blocking. Great! However there still seems to be a race condition when there are multiple shares with the same idle timeout. When the shares are unmounted at the same time by systemd, plasmashell handles the event for the first share that is unmounted. It loops over all shares and checks for isAccessible(). At that time isAccessible() might still return true for the second share, although it is currently being unmounted by systemd. Therefore, the rest of updateStorageSpace() is executed, which results in the original bug where plasmashell triggers a new automount request for the second share that was just unmounted.
It's a start ;) Where do you see it looping over the list of available devices in response to a device change?
I did not check the code myself but referred to Comment 12: > On a disconnect or connect event: > Device Notifier loops over all elements in my fstab and calls KDiskFreeSpaceInfo on each of them.
Created attachment 105803 [details] Log showing the race condition for share4 The attached log illustrates the race condition for share4. I added following line to your patch before the condition you added: qDebug() << " XXX: " << udi << " isAccessible(): " << storageaccess->isAccessible();
I wonder why it does forceImmediateUpdateOfAllVisualizations() just because one device changed.
(In reply to Kai Uwe Broulik from comment #20) > I wonder why it does forceImmediateUpdateOfAllVisualizations() just because > one device changed. I'm not familiar with the kde/plasma code, but if you have any further debugging suggestions, I'm happy to try them out.
I experience a similar issue. I have three NFS mounts in fstab, with option "x-systemd.automount" set (so they should only be mounted when something tries accessing corresponding directories). After system boot none of the three shares is mounted, but then when one is mounted on demand, plasmashell triggers the mount of other two shares: Jul 31 22:41:05 hostname systemd[1]: n-media.automount: Got automount request for /n/media, triggered by 669 (mpd) Jul 31 22:41:05 hostname systemd[1]: Mounting /n/media... Jul 31 22:41:05 hostname systemd[1]: Mounted /n/media. Jul 31 22:41:05 hostname systemd[1]: n-pacman.automount: Got automount request for /n/pacman, triggered by 518 (plasmashell) Jul 31 22:41:05 hostname systemd[1]: Mounting /n/pacman... Jul 31 22:41:05 hostname systemd[1]: Mounted /n/pacman. Jul 31 22:41:05 hostname systemd[1]: n-backup.automount: Got automount request for /n/backup, triggered by 518 (plasmashell) Jul 31 22:41:05 hostname systemd[1]: Mounting /n/backup... Jul 31 22:41:05 hostname systemd[1]: Mounted /n/backup. As in original description, it's not possible to unmount any of the shares: Jul 31 22:44:14 hostname systemd[1]: Unmounting /n/backup... Jul 31 22:44:14 hostname systemd[1]: n-backup.automount: Got automount request for /n/backup, triggered by 518 (plasmashell) Jul 31 22:44:14 hostname systemd[1]: Mounting /n/backup... Jul 31 22:44:15 hostname systemd[1]: Mounted /n/backup. This only happens with Device Notifier applet active -- without it, everything works correctly. The patch from comment #15 fixes both of above issues -- plasmashell no longer triggers any unwanted mounts in those scenarios. Regarding simultaneous unmount (as described in comment #16): manually running umount with multiple targets always works (all shares are properly unmounted). It's only when doing this from systemd that sometimes shares are remounted by plasmashell: # systemctl stop n-backup.mount n-media.mount n-pacman.mount Job for n-media.mount canceled. Jul 31 23:02:53 hostname systemd[1]: Unmounting /n/backup... Jul 31 23:02:53 hostname systemd[1]: Unmounting /n/media... Jul 31 23:02:53 hostname systemd[1]: Unmounting /n/pacman... Jul 31 23:02:53 hostname systemd[1]: n-media.automount: Got automount request for /n/media, triggered by 508 (plasmashell) Jul 31 23:02:53 hostname systemd[1]: Unmounted /n/backup. Jul 31 23:02:53 hostname systemd[1]: Mounting /n/media... Jul 31 23:02:53 hostname systemd[1]: Unmounted /n/pacman. Jul 31 23:02:53 hostname systemd[1]: Mounted /n/media. Still, could the patch from comment #15 be merged regardless of this remaining issue? In my case the patch only improves the behavior, as it eliminates almost all of unwanted mounts (leaving only a specific corner-case that is simultaneous unmounting).
Git commit e29ac5c3ff38f48d8b48bddf2e308dcc68dc9ba8 by Kai Uwe Broulik. Committed on 08/08/2018 at 10:41. Pushed by broulik into branch 'Plasma/5.12'. [Solid Device Engine] Don't update free space info for inaccessible storage devices This might trigger automounting of devices. Differential Revision: https://phabricator.kde.org/D14532 M +1 -1 dataengines/soliddevice/soliddeviceengine.cpp https://commits.kde.org/plasma-workspace/e29ac5c3ff38f48d8b48bddf2e308dcc68dc9ba8
Hi, Confirming the fix works on Plasma 5.13.5. Automounts are no longer triggered by plasmashell, and it's now possible to unmount them. Thank you for a very quick reaction!
Reading through the comment, it seems fixed now.
So can this be closed then?
Seems like it!