all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Making fsync() optional
@ 2005-09-12 19:27 Romain Francoise
  2005-09-13 15:55 ` Richard M. Stallman
  0 siblings, 1 reply; 6+ messages in thread
From: Romain Francoise @ 2005-09-12 19:27 UTC (permalink / raw)


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 <romain@orebokech.com> | I've become someone else's
it's a miracle -- http://orebokech.com/ | nightmare...

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-09-16  1:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-12 19:27 Making fsync() optional Romain Francoise
2005-09-13 15:55 ` Richard M. Stallman
2005-09-13 18:19   ` Romain Francoise
2005-09-14 14:06     ` Richard M. Stallman
2005-09-15  8:45       ` Romain Francoise
2005-09-16  1:01         ` Richard M. Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.