logo       

flushing the write-buffer when saving inhibit hd spin down: msg#00174

linux.debian.packages.vim.devel

Subject: flushing the write-buffer when saving inhibit hd spin down

Hi Bram,
a debian user reported that each save with vim makes his hard drive
spin up even if using laptop-mode. Indeed, in buf_write of fileio.c
there's the following code:

#if defined(UNIX) && defined(HAVE_FSYNC)
/* On many journalling file systems there is a bug that causes both the
* original and the backup file to be lost when halting the system right
* after writing the file. That's because only the meta-data is
* journalled. Syncing the file slows down the system, but assures it has
* been written to disk and we don't lose it.
* For a device do try the fsync() but don't complain if it does not work
* (could be a pipe). */
if (fsync(fd) != 0 && !device)
{
errmsg = (char_u *)_("E667: Fsync failed");
end = 0;
}
#endif

I understand that this behaviour could be annoying for laptop users,
moreover it is forced even for people not running journalling file
systems.

Do you think a boolean option could be added for enabling per-user
configuring of this behaviour?

Complete bug report follows.
TIA,
Cheers.

> Package: vim
> Version: 6.3-058+1

> Every time, I save my file in vim (with ':w'), my harddrive is flushed:

> Jan 28 11:43:10 sybille kernel: vim(3283): dirtied inode 3702891
> (vim.flush.swp) on hde1
> Jan 28 11:43:55 sybille kernel: vim(3283): dirtied inode 10569207 (?) on
> hde1
> Jan 28 11:43:55 sybille kernel: vim(3283): dirtied inode 10567874 (tmp) on
> hde1
> Jan 28 11:43:55 sybille kernel: vim(3283): dirtied inode 10567874 (tmp) on
> hde1
> Jan 28 11:43:55 sybille kernel: vim(3283): READ block 169082880 on hde1
> Jan 28 11:43:55 sybille kernel: vim(3283): WRITE block 169168416 on hde1
> Jan 28 11:43:55 sybille kernel: vim(3283): WRITE block 169083272 on hde1
> Jan 28 11:43:55 sybille kernel: vim(3283): dirtied inode 10569207
> (vim.flush) on hde1

> Since I use 'laptop_mode', I want my harddrive to spin down, but
> saving with vim prevents this. In the changelog
> (/usr/share/doc/vim/html/version6.html) I have found the following
> entry:

> Patch 6.2.499
> Problem: When writing a file and halting the system, the file might be
> lost
> when using a journalling file system.
> Solution: Use fsync() to flush the file data to disk after writing a file.
> (Radim Kolar)
> Files: src/fileio.c

> First I think this is not something vim has to bother about, but the
> bdflush-daemon. Second I use ext2, so since I use no journaling file
> system the fsync() command is not necessary.

> I have also searched for an option to turn the flushing off, but I
> have found only 'swapsync' for the swapfile, nothing for the normal
> file.

> Greetings
> Diether Knof

> P.S.
> Part of my vimrc:

> set swapsync=
> set updatecount=200
> set updatetime=6000
> set backupdir=~/.vim/tmp/
> set directory=~/.vim/tmp/
> set hidden
> set nobackup

--
Stefano Zacchiroli -*- Computer Science PhD student @ Uny Bologna, Italy
zack@{cs.unibo.it,debian.org,bononia.it} -%- http://www.bononia.it/zack/
If there's any real truth it's that the entire multidimensional infinity
of the Universe is almost certainly being run by a bunch of maniacs. -!-




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise