Bug 581585

Summary: plasma desktop (KDE4) freezes during the free cluster scan on vfat removable partitions
Product: [openSUSE] openSUSE 11.2 Reporter: Rolf F. Buser-Kennedy <rfb>
Component: KDE4 WorkspaceAssignee: Danny Al-Gaaf <dalgaaf>
Status: RESOLVED WONTFIX QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: caf4926, cuisineconcepts, david.sura, puzel, rfb, stefan.burnicki, tschmidt, zaloha
Version: Final   
Target Milestone: ---   
Hardware: i586   
OS: openSUSE 11.2   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: workaround to set mount option "usefree" for device notifier mounting vfat devices

Description Rolf F. Buser-Kennedy 2010-02-20 13:16:31 UTC
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091222 SUSE/3.5.7-1.1.1 Firefox/3.5.7

Unless a removable device with a vfat file system is mounted with the "usefree" option the system performs a scan of the whole vfat filesystem to determine the actual free cluster value immediately after the actual mounting of the device. This is done, because Windows might not update the value correctly. By using the "usefree" option the scan is not performed and the free cluster value from the file systems meta data is trusted.

During the scan, which is done by default, the KDE4 desktop (panel and "click activity" on the background) freeze. The applications work normal if by change they have the focus. Also, the window manager allows to change focus between the applications on a given virtual desktop, but switching to another desktop is typically not possible, because all panel activity is blocked.

The freeze doesn't start immediately at the moment the mount is performed and the free cluster scanning is started. There is some kind of "buildup" (see below). If then the freeze sets in and by coincidance a desktop component like the device notifier panel or the background context menu is up, which grabs the focus completely, the freeze is total an lasts until the disk scanning is over.

There are strong indications, that the phenomenon has to do with the kernel based filesystem event notification mechanism (inotify). It seems that the scanning of the vfat partition generates an event storm which after a few seconds floods KDEs event handling system completely, which then leads to the starvation of the corresponding mouse events. It is not clear whether the problem is that KDE4 is not protecting itself enough against event flooding or whether the vfat scanning is violating principles with respect to inotify. All attemps to produce equally bad event storms with various forms of filesystem activities on ext3 and ext4 filesystems have failed and it looks as if the bad behavior might be attributed to the vfat software.

The problem can easily be reproduced. All it takes is a removable vfat device with enough data on it such that the partition scan lasts long enough. The problem is avoided by mounting the partition with "-o usefree". One solution is to mount the device by hand. Because mount options for removable devices when mounted through the device notifier cannot be set by configuration means anymore in the installation in question, a workaround is attached, such that a vfat device again can be mounted in the usual comfortable way but with the usefree option set. It consist of replacing /usr/lib/hal/hal-storage-mount (which is called by hald upon mounting) by a bash scripts wich adds the usefree option when the binary hal-storage-mount is called.

The phenomen has been observed by other users, too as discussed in a german forum:

http://www.linuxforen.de/forums/showthread.php?p=1740911#post1740911

At least one of the users has applied the workaround successfully. Probably many users know about the phenomenon but can live with it, because the freeze only takes a few seconds. On the other hand, on vfat devices with several hundred directories and files, freezes that last more than a minute have been observed.


The behavior was present in opensuse 11.1, too.



Reproducible: Always

Steps to Reproduce:
Assuming the vfat usb disk (or stick) with enough data gets /dev/sdb1 assigned, do this:

mount -t vfat -o usefree /dev/sdb1 /mnt
umount /mnt
mount -t vfat /dev/sdb1 /mnt
umount /mnt
.
.
.
After each mount change to a different virtual desktop once every second.
Actual Results:  
Each time the device is mounted without -o usefree, the destop switching gets blocked until the disk scan is over.

To find out how long the disk scan lasts, keep the focus on the shell you issue the mount command and do the umount immediately. The filesystem will be "busy" as long as the scan takes place. By the way, the device is accessible for reading during the scanning.

Expected Results:  
The desktop switching should not be hindered by the disk scan. The desktop switching stands for any mouse activities involving the plasma desktop, especially the panel, but not mouse events which belong to the applications or the window manager.
Comment 1 Rolf F. Buser-Kennedy 2010-02-20 13:24:17 UTC
Created attachment 343649 [details]
workaround to set mount option "usefree" for device notifier mounting vfat devices
Comment 2 Stefan Burnicki 2010-07-09 16:38:11 UTC
The same here with x86_64 openSUSE 11.2 with different KDE versions and on diverse computers.
Comment 3 G J 2010-07-19 12:52:30 UTC
I experience the same with openSUSE 11.2 on both 32 and 64 bit machines. The same problem is also being discussed here Bug 566614 although under a different bug title.
Comment 4 Petr Uzel 2010-07-20 13:19:42 UTC
*** Bug 566614 has been marked as a duplicate of this bug. ***
Comment 5 Petr Uzel 2010-07-20 13:23:24 UTC
Assigning to HAL maintainer to decide what to do.
Comment 6 Rolf F. Buser-Kennedy 2010-07-20 17:24:38 UTC
It is only a HAL issue if by default the usefree option should be set or if HAL should be modified such that one could configure the default mount options. But the question remains, why can the free cluster scan stress some KDE components that much? Probably users would like to stick to the scan. As long as it just behaving like heavy io in the background and the desktop just responds a little slower, things would be fine. I have already mentioned in the bug report that the disk can actually be read during the scan - only writing is delayed until the scan is finished.

I think the KDE maintainers should look into this issue. If an application has the focus it behaves pretty well during the scan - why does KDE behave so badly? I still think there is an event flooding problem and it might well be, that the vfat free cluster scan reveals a problem on the KDE side.
Comment 7 Rolf F. Buser-Kennedy 2010-08-07 00:33:18 UTC
The Problem is probably solved in OpenSuse 11.3. It seems that the free cluster scan has been reworked. Timing it on both system looks promising:

On 11.2:

linux-nida:/home/rfb # mount -t vfat /dev/sdb1 /mnt;time df -h /dev/sdb1
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdb1             233G  169G   65G  73% /mnt

real    0m22.603s
user    0m0.004s
sys     0m0.492s

The same machine with 11.3 and the same disk in identical state:

linux-ioee:/home/rfb # mount -t vfat /dev/sdb1 /mnt;time df -h /dev/sdb1
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdb1             233G  169G   65G  73% /mnt

real    0m1.187s
user    0m0.000s
sys     0m0.000s

On 11.3 the scan is 19 times faster. It looks as if the old scan was behaving badly and thus might have been the cause of the problem. With a scan which only lasts a second it is not possible to check how the plasma desktop behaves. Somebody with a huge vfat partition should make a similar test. Of course the scan then lasts longer. But that's not a problem. We already know that during the scan the disk is accessible. df is probably the only type of disk access which has to wait until the scan is over. The new well behaved scan will probably not harm the plasma desktop and we can stick with it (which is good) and don't need to use the usefree option. This means, the default mount options don't need to be changed and HAL doesn't need to be touched for this.

By the way, without the scan we have this:
linux-ioee:/home/rfb # mount -t vfat -o usefree /dev/sdb1 /mnt;time df -h /dev/sdb1
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdb1             233G  169G   65G  73% /mnt

real    0m0.025s
user    0m0.000s
sys     0m0.000s
Comment 8 Jiri Novak 2010-08-07 09:51:29 UTC
Yes, I can confirm that the vfat HDD mounting in 11.3 is much more faster - it takes only several seconds (WD MyBook 500GB). Test was made via mounting applet in KDE 4.4.4.
Comment 9 David Sura 2010-08-12 20:02:09 UTC
I can also confirm that the vfat mounting in 11.3 is about 20 times faster than in 11.2. There are the same tests as in comment #7 with USB HDD Samsung G3 Station 1 TB on the same machine (11.2 installed, 11.3 live CD):

11.2 with the scan:
david@ls01:~> sudo mount -t vfat /dev/sdb1 /mnt/samsung_G3;time df -h /dev/sdb1
Souborový systém  Velikost Užito Volno Uži% Připojeno do
/dev/sdb1             932G   38G  895G   4% /mnt/samsung_G3

real    1m31.777s
user    0m0.000s
sys     0m0.004s


11.2 without the scan:
david@ls01:~> sudo mount -t vfat -o usefree /dev/sdb1 /mnt/samsung_G3;time df -h /dev/sdb1
Souborový systém  Velikost Užito Volno Uži% Připojeno do
/dev/sdb1             932G   38G  895G   4% /mnt/samsung_G3

real    0m0.004s
user    0m0.000s
sys     0m0.000s

11.3 with the scan:
linux@linux:~> sudo mount -t vfat /dev/sdb1 /mnt/samsung_g3;time df -h /dev/sdb1
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdb1             932G   38G  895G   4% /mnt/samsung_g3

real    0m4.340s
user    0m0.000s
sys     0m0.000s


11.3 without the scan:
linux@linux:~> sudo mount -t vfat -o usefree /dev/sdb1 /mnt/samsung_g3;time df -h /dev/sdb1
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdb1             932G   38G  895G   4% /mnt/samsung_g3

real    0m0.020s
user    0m0.000s
sys     0m0.000s
Comment 10 Danny Al-Gaaf 2010-11-19 14:03:19 UTC
Is there really a fix needed for openSUSE 11.2 since it's fixed in 11.3 and since there is a workaround available? Btw. it looks to me like a kernel/mount  and not a HAL bug.

Either we reassign it to Kernel or I tend to close the bug as WONTFIX.
Comment 11 Rolf F. Buser-Kennedy 2010-11-19 16:48:25 UTC
It is definitively not a HAL issue. It is not clear whether it is fixed in 11.3. What we know is that the scan has been reworked such that it goes 20 times faster. My impression is that the freeze still happens. But I have no large vfat partitions to really test that. On mine I now see 2 seconds in maximum. David sees scans of 4-5 seconds. I was hoping that somebody has partitions of a size, that even on 11.3 the scan takes that long that he/she can see whether the freeze occurs. Of course if altogether even on the largest vfat partitions the scan now only takes a few seconds, nobody gets bothered any more and it would be of pure academic interest to figure out whether the kernel generates to many events or whether the plasma desktop can't handle the event flood. Taking into account, that large vfat partitions will disappear anyway, it is OK to close the bug. If the phenomen was really pointing to a general underlying eventhandling issue, the problem will eventually show up elsewere again.
Comment 12 Danny Al-Gaaf 2010-11-19 17:18:06 UTC
Okay. I close it as WONTFIX.