KDE fixes 15-year-old bug in copy completion notifications for USB drives
KDE is fixing a bug first reported in 2011 that made its desktop show inaccurate notifications when copying files to a removable USB flash drive, with the fix set to arrive in next month's KDE Frameworks 6.32 release. The copy progress and the completion notification only reflected writing to the local cache, not the actual writing of the data to the removable storage, so the desktop implied files were already on the drive when they had not necessarily been written out. KDE developer Méven Car described the history of the 15-year-old bug report in a blog post; it gathered 77+ comments and 17+ duplicate bug reports.
Two days after the report, Christoph Feck asked whether there was a way to learn when the data is really on the disk without the massive slowdowns sync-type calls would cause; two weeks later the reporter passed along Alan Stern's answer, the sync_file_range()[1] system call, which Christoph said looked like "exactly what we need". That September 2011 call is what KIO[2] now uses. Little happened for years beyond user confirmations and seventeen duplicates; in 2021 Nate Graham raised the bug to the highest priority because a move deletes the source files while the copies are still in memory, and in 2022 he changed the Disks & Devices applet so that ejecting a device explains that it is still writing. In 2024, Christoph tested the cachestat() call of Linux 6.5, which reports how much of a file is still in memory and not yet written to disk, but only for one file at a time.
Méven Car, who has contributed to KIO since 2018, tried twice in 2024 without getting sync_file_range() right: in KIO MR 1764 and Dolphin MR 862, the worker waited for the writeback[3] of the chunk it had just written, which had not started, so it never waited at all — waiting for the window before the one just written is what makes it work, and neither he nor any reviewer spotted the issue. In MR 1718[4], the sync_file_range() path stayed commented out, and another contributor's proposal to turn off the cache for copies, MR 2162, was closed. With KDE Frameworks 6.32, the completion dialog will accurately reflect when the data is copied to the USB storage by making use of sync_file_range().
Read the original phoronix.comDiscussion
Discussion
Commenters recall corrupted or lost files caused by the bug, and several say they have run the sync command manually after every USB transfer for years or always eject drives before unplugging them. Some call the fix important for making Linux friendly to average users, while one has mixed feelings about the rejected idea of disabling the cache, since the cache made batches of files copy instantly. Another calls it absurd that the underlying solution was apparently identified within two weeks of the 2011 report yet took 15 years to ship.
Sources
-
phoronix.com
KDE Fixes 15 Year Old Bug Over Inaccurate Notifications When Copying Files To USB Drives



