Source: kf6-kio
Version: 6.13.0-6
Severity: important
Tags: patch fixed-upstream trixie

Dear Maintainer,

In trixie, the whole Plasma panel (task manager, launcher, tray, clock) can freeze for as long as a network or FUSE mount stays unreachable. That can be forever: the usual case is an sshfs mount whose ssh connection died during
suspend. The only way out is to kill the mount.


Cause
-----

Since KF 6.11 (upstream commit 35e575eb, for KDE bug 494129),
KMountPoint::currentMountPoints() calls lstat() on every mount point to get its device id. If one of those mounts is a network/FUSE mount that no longer
answers, that lstat() blocks until the server replies.

currentMountPoints() is called on the GUI thread in plasmashell.
KFilePlacesItem calls it for every fuse.sshfs device, to hide KDE Connect's own mounts. Any KFilePlacesModel in plasmashell therefore freezes the shell
whenever a new sshfs mount appears while another mount is dead.

plasma-workspace's job notifications create a KFilePlacesModel on the first
file transfer, and it lives for the whole session
(libnotificationmanager/job_p.cpp). From then on, any new sshfs mount (KDE Connect mounting a phone, for example) while another mount is unreachable
freezes the panel. Here it happened right after a resume, when the
connection behind an sshfs mount had died during suspend.

Upstream fixed this in KF 6.23 with commit 4709688a, "kmountpoint: use statx
to get device id":
  https://invent.kde.org/frameworks/kio/-/commit/4709688a

Its message: "using stat on every mountpoint could lead to serious
performance issues when it comes to network mounts ... we use statx which
allows us to ask the kernel for only a cached value ... This saves us a
network roundtrip and avoids blocking."

KF 6.24 then added AT_NO_AUTOMOUNT to the same call (part of 089402fe).
Without it, the new statx() would trigger autofs/systemd automounts, which lstat() never did. On a machine with automounted NFS, that brings back the same freeze whenever the NFS server is down. The attached backport includes
that flag.

forky (6.30.0-1) and sid (6.32.0-1) already contain both changes. Only
trixie is affected.


Observed
--------

On the frozen plasmashell, the main thread was in request_wait_answer
(FUSE), in newfstatat(AT_FDCWD, "<sshfs mount point>", ...,
AT_SYMLINK_NOFOLLOW), i.e. an lstat() of the mount root. The ssh child of
sshfs had died during suspend; sshfs itself was still running.


Reproduce (plain trixie, Plasma 6.3.6, KF 6.13.0-6)
---------------------------------------------------

1. Mount something with sshfs: sshfs host:/tmp ~/a
2. Copy any file with a KIO tool, e.g. kioclient copy of a few hundred MB,
   so that plasmashell shows a job and creates its places model.
3. Make the connection dead without unmounting:
   kill -STOP <pid of the "ssh ... host sftp" process for ~/a>
4. Wait more than 20 s. sshfs answers from its own attribute cache until
   then.
5. Mount another sshfs, e.g. sshfs host:/tmp ~/b
6. The panel freezes. cat /proc/$(pidof plasmashell)/wchan shows
   request_wait_answer. It recovers on kill -CONT of the ssh process.


Tested
------

A/B run of the steps above, on the same machine, with the same trigger each
time:

- long-running plasmashell, libKF6KIOCore 6.13.0-6: frozen
  (lstat of the dead mount root)
- freshly started plasmashell, 6.13.0-6: frozen
  (lstat of the dead mount root)
- freshly started plasmashell, 6.13.0-6 + attached patch only: no freeze

The patched library was built from the Debian 6.13.0-6 source with only
this patch added. It exports the same 1104 symbols.


Request
-------

Please consider the attached patch (a DEP-3 backport of 4709688a plus the
AT_NO_AUTOMOUNT flag from 089402fe) for a trixie stable update.


-- System Information:
Debian Release: 13 (trixie)
Kernel: Linux 6.12.116+deb13-amd64
Versions: libkf6kiocore6 6.13.0-6, plasma-workspace 4:6.3.6-2, sshfs 3.7.3



--
Emmanuel Revah
Description: kmountpoint: use statx to get device id
 Since 6.11 (upstream 35e575eb), KMountPoint::currentMountPoints() lstat()s every
 mount point to get its device id. On a network/FUSE mount whose server or
 connection is gone, that lstat() blocks until the server answers, i.e. possibly
 forever, and it blocks the calling thread. In plasmashell that is the GUI thread
 (KFilePlacesItem calls currentMountPoints() for every fuse.sshfs device), so the
 whole panel freezes.
 .
 statx(AT_STATX_DONT_SYNC) takes the device id from the kernel's cached
 attributes instead. AT_NO_AUTOMOUNT keeps it from triggering automounts, which
 lstat() never did. Upstream added that flag one release later (089402fe).
 .
 Backported to 6.13: the context differs (no HAVE_STATX_MNT_ID block yet).
Author: Oliver Schramm
Origin: backport, https://invent.kde.org/frameworks/kio/-/commit/4709688a
 and the AT_NO_AUTOMOUNT part of https://invent.kde.org/frameworks/kio/-/commit/089402fe
Applied-Upstream: 6.23 (4709688a), 6.24 (089402fe)
Last-Update: 2026-11-13
---
--- a/src/core/kmountpoint.cpp
+++ b/src/core/kmountpoint.cpp
@@ -48,6 +48,9 @@
 // Linux
 #if HAVE_LIB_MOUNT
 #include <libmount/libmount.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
 #endif
 
 static bool isNetfs(const QString &mountType)
@@ -360,13 +363,8 @@
                 mp->d->m_mountType = QFile::decodeName(mnt_fs_get_fstype(fs));
                 mp->d->m_isNetFs = mnt_fs_is_netfs(fs) == 1;
 
-                // handle bind mounts
-                if (mp->d->m_mountedFrom != mp->d->m_mountPoint) {
-                    if (QT_STATBUF buff; QT_LSTAT(mp->d->m_mountPoint.toLatin1().constData(), &buff) == 0) {
-                        mp->d->m_deviceId = buff.st_dev;
-                    }
-                } else {
-                    mp->d->m_deviceId = mnt_fs_get_devno(fs);
+                if (struct statx buff; statx(AT_FDCWD, mnt_fs_get_target(fs), AT_STATX_DONT_SYNC | AT_NO_AUTOMOUNT, STATX_INO, &buff) == 0) {
+                    mp->d->m_deviceId = makedev(buff.stx_dev_major, buff.stx_dev_minor);
                 }
 
                 if (infoNeeded & NeedMountOptions) {

Reply via email to