[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: fsync() madness
From:       "Bart Van Assche" <bart.vanassche () gmail ! com>
Date:       2008-04-20 17:08:13
Message-ID: e2e108260804201008y3972f153gc8e9232a023c86ac () mail ! gmail ! com
[Download RAW message or body]

On Sun, Apr 20, 2008 at 12:45 PM, Oswald Buddenhagen <ossi@kde.org> wrote:
>
>  hmm, it was on kde-devel, in fact.
>  http://lists.kde.org/?l=kde-devel&m=119255926531628&w=2
>  i think this is the second one i had in mind:
>  http://lists.kde.org/?l=kde-core-devel&m=108971672603299&w=2

What I learned from these threads is that KDE config files are written
first to a temporary file and this file gets renamed to the original
name. In this case it is indeed necessary to call fdatasync() in order
to avoid data corruption in case of a power failure on a filesystem
with metadata journaling only (the default option for ext3).

According to the above thread Konqueror is using KSaveFile for saving
the browser history, which triggers fdatasync()'s, and this is
unfortunate. At least with ext3, appending data to a file is
guaranteed not to corrupt the contents of that file in case of a power
failure. The new contents is either appended or lost. Would it be a
good idea to modify Konqueror such that appending a new URL to the
browser history only involves appending data to a file, and previously
written data is not modified ? The interval at which data is written
to disk (filesystem journal) can be controlled via the commit=...
parameter of journaling filesystems (defaults to 5 s, I always change
this to 300 s on any system for which I have sufficient privileges).

The source code of the class KSaveFile can be found here:
* http://developer.kde.org/documentation/library/3.1-api/kdecore/html/ksavefile_8h-source.html
* http://developer.kde.org/documentation/library/3.1-api/kdecore/html/ksavefile_8cpp-source.html

Bart.
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic