GNOME Bugzilla – Bug 673550
"free space: unknown" and CPU spins instead
Last modified: 2012-04-05 16:00:29 UTC
Opening the properties dialog on a directory in nautilus gives Free space: unknown Meanwhile, the CPU is spinning in a loop due to the dialog calling nautilus_file_get_volume_free_space() which performs an async call which causes a change signal to be emitted which causes the dialog to try to update the value again... This has been broken since 2009. This seemingly-innocent commit introduced the problem: http://git.gnome.org/browse/nautilus/commit/?id=2d61fcdf4987802441b7d9dab5364a28fb2dbd7c That commit looks like a legitimate fix, but it seems that leaking the directory was good because it caused the value to be cached and therefore not continuously refetched... This code probably needs a bit of a rethink.
Created attachment 211392 [details] [review] NautilusFile: keep free space information directly There were previously some tricks in nautilus to this effect: - when you call nautilus_file_get_volume_free_space() on a NautilusFile, the return result is NULL at first and later you get a "changed" signal on the file after the value is filled in - the value is being stored inside the NautilusDirectory equivalent for the file that is created when the call is first performed and kept around until after the change signal fires (so that the person receiving the change signal can still get the data). This is done to save space by not expanding NautilusFile. The NautilusDirectory is then unreffed after the change signal is done firing. - the nautilus properties window has a 200ms timeout after changes to files being reported before it re-queries the properties The end result is that the NautilusDirectory (which holds the information about the free space) is already freed by the time the properties window tries to update the free space display. This results in the directory being recreated and the process starting over again. The end result is that we never get the free space shown in the dialog and instead we have an infinite loop of CPU usage (fortunately repeating only every 200ms, so you get ~5% CPU usage instead of 100%). We can solve the problem by just storing the free space information directly in the NautilusFile details structure and dropping the dance with NautilusDirectory; nothing in NautilusDirectory is actually using that information anyway.
Review of attachment 211392 [details] [review]: Looks good to me.
Attachment 211392 [details] pushed as ba04ec0 - NautilusFile: keep free space information directly