aboutsummaryrefslogtreecommitdiffstats
path: root/src/fileio.c
diff options
context:
space:
mode:
authorEli Zaretskii <[email protected]>2013-12-07 19:21:57 +0200
committerEli Zaretskii <[email protected]>2013-12-07 19:21:57 +0200
commitce1d7b61f12dcc1b67535b68d9b0655b45fcadb6 (patch)
tree881d03f4f486933482cd2e3851184cd3b172ef1b /src/fileio.c
parent6630df25238c5a1efa2bc6a0fa7889782e8c91b5 (diff)
parentfa6fa1a1773f255b5efbe52a743b017f4908a6cb (diff)
Merge from trunk.
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c49
1 files changed, 31 insertions, 18 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 7b4bd7f196..2ef3f1fe0f 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3878,6 +3878,9 @@ by calling `format-decode', which see. */)
beg_offset += same_at_start - BEGV_BYTE;
end_offset -= ZV_BYTE - same_at_end;
+ invalidate_buffer_caches (current_buffer,
+ BYTE_TO_CHAR (same_at_start),
+ BYTE_TO_CHAR (same_at_end));
del_range_byte (same_at_start, same_at_end, 0);
/* Insert from the file at the proper position. */
temp = BYTE_TO_CHAR (same_at_start);
@@ -3988,7 +3991,12 @@ by calling `format-decode', which see. */)
{
/* Truncate the buffer to the size of the file. */
if (same_at_start != same_at_end)
- del_range_byte (same_at_start, same_at_end, 0);
+ {
+ invalidate_buffer_caches (current_buffer,
+ BYTE_TO_CHAR (same_at_start),
+ BYTE_TO_CHAR (same_at_end));
+ del_range_byte (same_at_start, same_at_end, 0);
+ }
inserted = 0;
unbind_to (this_count, Qnil);
@@ -4036,6 +4044,9 @@ by calling `format-decode', which see. */)
if (same_at_end != same_at_start)
{
+ invalidate_buffer_caches (current_buffer,
+ BYTE_TO_CHAR (same_at_start),
+ BYTE_TO_CHAR (same_at_end));
del_range_byte (same_at_start, same_at_end, 0);
temp = GPT;
eassert (same_at_start == GPT_BYTE);
@@ -5793,6 +5804,24 @@ void
init_fileio (void)
{
valid_timestamp_file_system = 0;
+
+ /* fsync can be a significant performance hit. Often it doesn't
+ suffice to make the file-save operation survive a crash. For
+ batch scripts, which are typically part of larger shell commands
+ that don't fsync other files, its effect on performance can be
+ significant so its utility is particularly questionable.
+ Hence, for now by default fsync is used only when interactive.
+
+ For more on why fsync often fails to work on today's hardware, see:
+ Zheng M et al. Understanding the robustness of SSDs under power fault.
+ 11th USENIX Conf. on File and Storage Technologies, 2013 (FAST '13), 271-84
+ http://www.usenix.org/system/files/conference/fast13/fast13-final80.pdf
+
+ For more on why fsync does not suffice even if it works properly, see:
+ Roche X. Necessary step(s) to synchronize filename operations on disk.
+ Austin Group Defect 672, 2013-03-19
+ http://austingroupbugs.net/view.php?id=672 */
+ write_region_inhibit_fsync = noninteractive;
}
void
@@ -6013,28 +6042,12 @@ in the buffer; this is the default behavior, because the auto-save
file is usually more useful if it contains the deleted text. */);
Vauto_save_include_big_deletions = Qnil;
- /* fsync can be a significant performance hit. Often it doesn't
- suffice to make the file-save operation survive a crash. For
- batch scripts, which are typically part of larger shell commands
- that don't fsync other files, its effect on performance can be
- significant so its utility is particularly questionable.
- Hence, for now by default fsync is used only when interactive.
-
- For more on why fsync often fails to work on today's hardware, see:
- Zheng M et al. Understanding the robustness of SSDs under power fault.
- 11th USENIX Conf. on File and Storage Technologies, 2013 (FAST '13), 271-84
- http://www.usenix.org/system/files/conference/fast13/fast13-final80.pdf
-
- For more on why fsync does not suffice even if it works properly, see:
- Roche X. Necessary step(s) to synchronize filename operations on disk.
- Austin Group Defect 672, 2013-03-19
- http://austingroupbugs.net/view.php?id=672 */
DEFVAR_BOOL ("write-region-inhibit-fsync", write_region_inhibit_fsync,
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. */);
- write_region_inhibit_fsync = noninteractive;
+ write_region_inhibit_fsync = 0; /* See also `init_fileio' above. */
DEFVAR_BOOL ("delete-by-moving-to-trash", delete_by_moving_to_trash,
doc: /* Specifies whether to use the system's trash can.