GNU bug report logs - #13944
file synchronization fixes

Previous Next

Package: emacs;

Reported by: Paul Eggert <eggert <at> cs.ucla.edu>

Date: Wed, 13 Mar 2013 07:40:01 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: 13944 <at> debbugs.gnu.org
Cc: Eli Zaretskii <eliz <at> gnu.org>
Subject: bug#13944: file synchronization fixes
Date: Wed, 13 Mar 2013 00:38:00 -0700
[Message part 1 (text/plain, inline)]
Tags: patch

The new code for creating regular-file lock files has a problem if
the system crashes while the lock file is being created: due to
races inside the file system, if the crash occurs at the wrong time
the file system may end up with an empty regular-file lock file,
which after the reboot will cause Emacs to bypass locking for that
file indefinitely (unless the empty lock file is removed manually
by the user).

On a POSIX-conforming system the problem can occur only if the
system crashes just as a lock file is being created.  Fixing this
requires using a synchronization primitive such as fsync on the
newly created file, before renaming it.

While looking into this I noticed some other file synchronization
problems.  fsync is used sometimes when fdatasync will do.  Emacs
does not consistently retry fsync after being interrupted.  It
sometimes incorrectly reports an error merely because fsync isn't
supported.  And it sometimes incorrectly skips fsync merely because
we are on a non-BSD system.

Attached a patch which I'd like to install.  If MS-Windows has fdatasync
already this should build on MS-Windows; if not, the MS-Windows port
needs to compile lib/fdatasync.c or support an fdatasync substitute
in some other way.
[fsync.txt (text/plain, attachment)]

This bug report was last modified 12 years and 129 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.