bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#60474: 30.0.50; `write-region-inhibit-fsync' and copy-on-write file


From: Ihor Radchenko
Subject: bug#60474: 30.0.50; `write-region-inhibit-fsync' and copy-on-write file systems
Date: Mon, 02 Jan 2023 05:54:11 +0000

Paul Eggert <eggert@cs.ucla.edu> writes:

> On 2023-01-01 12:07, Eli Zaretskii wrote:
>
>> Paul, any comments?
>
> Sure, Emacs should do the reverse of what it's doing now. That is, Emacs 
> should use fsync only in special situations, instead of avoiding it only 
> in special situations. In the old days it may have made sense to use 
> fsync, but nowadays most platforms don't need fsync for the sorts of 
> things people use interactive Emacs.

What about Emacs DOS port and the likes? May be there some gotchas about
specific file systems in non-standard OS?

Also, what would be the special situations you are talking about?

> diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
> index 6d66683161..5164339c66 100644
> --- a/doc/emacs/files.texi
> +++ b/doc/emacs/files.texi
> @@ -815,8 +815,7 @@ Customize Save
>  
>    The @code{write-region-inhibit-fsync} variable controls whether
>  Emacs invokes @code{fsync} after saving a file.  The variable's
> -default value is @code{nil} when Emacs is interactive, and @code{t}
> -when Emacs runs in batch mode (@pxref{Initial Options, Batch Mode}).
> +default value is @code{t}.
>  
>    Emacs never uses @code{fsync} when writing auto-save files, as these
>  files might lose data anyway.
> diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
> index 707af6ee64..57784fb57f 100644
> --- a/doc/lispref/files.texi
> +++ b/doc/lispref/files.texi
> @@ -695,8 +695,7 @@ Writing to Files
>  @code{fsync} system call after writing a file.  Although this slows
>  Emacs down, it lessens the risk of data loss after power failure.  If
>  the value is @code{t}, Emacs does not use @code{fsync}.  The default
> -value is @code{nil} when Emacs is interactive, and @code{t} when Emacs
> -runs in batch mode.  @xref{Files and Storage}.
> +value is @code{t}.  @xref{Files and Storage}.
>  @end defvar

I think that the above pieces of the manuals are written under the
premise that fsync is executed by default. Merely changing the default
value makes the whole paragraph confusing.

> diff --git a/src/fileio.c b/src/fileio.c
> index 7fb7f5ddc5..bd4c8ec0c9 100644
> --- a/src/fileio.c
> +++ b/src/fileio.c
> @@ -6351,7 +6351,7 @@ init_fileio (void)
>       Roche X. Necessary step(s) to synchronize filename operations on disk.
>       Austin Group Defect 672, 2013-03-19
>       https://austingroupbugs.net/view.php?id=672  */
> -  write_region_inhibit_fsync = noninteractive;
> +  write_region_inhibit_fsync = true;
>  }

This change contradicts what the above comments states:

"     Hence, for now by default fsync is used only when interactive."

> @@ -6610,8 +6610,8 @@ do (file-exists-p FILENAME) and FILENAME is handled by 
> HANDLER, then
>              doc: /* Non-nil means don't call fsync in `write-region'.
>  This variable affects calls to `write-region' as well as save commands.
>  Setting this to nil may avoid data loss if the system loses power or
> -the operating system crashes.  By default, it is non-nil in batch mode.  */);
> -  write_region_inhibit_fsync = 0; /* See also `init_fileio' above.  */
> +the operating system crashes.  By default, it is non-nil.  */);
> +  write_region_inhibit_fsync = true; /* See also `init_fileio' above.  */

Will this `init_fileio' also appear in Elisp docstring?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>





reply via email to

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