emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Making fsync() optional


From: Romain Francoise
Subject: Making fsync() optional
Date: Mon, 12 Sep 2005 21:27:02 +0200

Would people be conceptually opposed to making the fsync() call optional
in Fwrite_region?  Calling it after each write defeats the kernel's
ability to commit consecutive buffers to disk in one go, which can be
beneficial in a lot of cases (like nnml files in an nnml directory).  It
also means that the user has to wait for the file to hit the disk when
saving files interactively (under heavy system load, this can take a
while).  It also forces the disk to spin up on laptops (even with laptop
mode and friends).

Of course calling fsync() is safer if the system goes down right after
saving the file, but for systems with uninterruptible power, it doesn't
matter.

Tentative patch:

Index: src/fileio.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/fileio.c,v
retrieving revision 1.553
diff -c -r1.553 fileio.c
*** src/fileio.c        12 Sep 2005 13:42:49 -0000      1.553
--- src/fileio.c        12 Sep 2005 18:49:20 -0000
***************
*** 225,230 ****
--- 225,236 ----
     expanding file names.  This can be bound to / or \. */
  Lisp_Object Vdirectory_sep_char;
  
+ #ifdef HAVE_FSYNC
+ /* Nonzero means avoid calling fsync() after each write in
+    Fwrite-region.  */
+ int inhibit_fsync;
+ #endif
+ 
  extern Lisp_Object Vuser_login_name;
  
  #ifdef WINDOWSNT
***************
*** 5298,5304 ****
       Disk full in NFS may be reported here.  */
    /* mib says that closing the file will try to write as fast as NFS can do
       it, and that means the fsync here is not crucial for autosave files.  */
!   if (!auto_saving && fsync (desc) < 0)
      {
        /* If fsync fails with EINTR, don't treat that as serious.  */
        if (errno != EINTR)
--- 5304,5310 ----
       Disk full in NFS may be reported here.  */
    /* mib says that closing the file will try to write as fast as NFS can do
       it, and that means the fsync here is not crucial for autosave files.  */
!   if (!auto_saving && !inhibit_fsync && fsync (desc) < 0)
      {
        /* If fsync fails with EINTR, don't treat that as serious.  */
        if (errno != EINTR)
***************
*** 6743,6748 ****
--- 6749,6760 ----
  shortly after Emacs reads your `.emacs' file, if you have not yet given it
  a non-nil value.  */);
    Vauto_save_list_file_name = Qnil;
+ 
+ #ifdef HAVE_FSYNC
+   DEFVAR_BOOL ("inhibit-fsync", &inhibit_fsync,
+              doc: /* Non-nil means avoid calling fsync() after each save.  
*/);
+   inhibit_fsync = 0;
+ #endif
  
    defsubr (&Sfind_file_name_handler);
    defsubr (&Sfile_name_directory);

-- 
Romain Francoise <address@hidden> | I've become someone else's
it's a miracle -- http://orebokech.com/ | nightmare...





reply via email to

[Prev in Thread] Current Thread [Next in Thread]