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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13944 in the body.
You can then email your comments to 13944 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#13944; Package emacs. (Wed, 13 Mar 2013 07:40:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Paul Eggert <eggert <at> cs.ucla.edu>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 13 Mar 2013 07:40:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: bug-gnu-emacs <at> gnu.org
Cc: Eli Zaretskii <eliz <at> gnu.org>
Subject: 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)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13944; Package emacs. (Wed, 13 Mar 2013 18:05:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: bug-gnu-emacs <at> gnu.org
Subject: Re: file synchronization fixes
Date: Wed, 13 Mar 2013 20:02:57 +0200
> Date: Wed, 13 Mar 2013 00:38:00 -0700
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> CC: Eli Zaretskii <eliz <at> gnu.org>
> 
> 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.

I think all that is needed for the MS-Windows build is this one line:

--- nt/inc/ms-w32.h	2013-02-25 17:36:03 +0000
+++ nt/inc/ms-w32.h	2013-03-13 17:57:30 +0000
@@ -225,6 +225,7 @@ extern int sys_unlink (const char *);
 #define fileno	  _fileno
 #endif
 #define fsync	  _commit
+#define fdatasync _commit
 #define ftruncate _chsize
 #define getpid    _getpid
 #ifdef _MSC_VER

Thanks.




Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Wed, 13 Mar 2013 18:45:01 GMT) Full text and rfc822 format available.

Notification sent to Paul Eggert <eggert <at> cs.ucla.edu>:
bug acknowledged by developer. (Wed, 13 Mar 2013 18:45:02 GMT) Full text and rfc822 format available.

Message #13 received at 13944-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 13944-done <at> debbugs.gnu.org
Subject: Re: file synchronization fixes
Date: Wed, 13 Mar 2013 11:43:17 -0700
On 03/13/13 11:02, Eli Zaretskii wrote:
> +#define fdatasync _commit

Thanks for the quick review.  I added that line, pushed
it as trunk bzr 112039, and am marking this as done.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 11 Apr 2013 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 29 days ago.

Previous Next


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