Bug#292630: marked as forwarded (flushing the write-buffer when saving)

Debian Bug Tracking System owner@bugs.debian.org
Sun, 24 Apr 2005 14:33:14 -0700


Your message dated Sun, 24 Apr 2005 23:26:31 +0200
with message-id <20050424212629.GA2236@fistandantilus.takhisis.org>
has caused the Debian Bug report #292630,
regarding flushing the write-buffer when saving
to be marked as having been forwarded to the upstream software
author(s) Bram Moolenaar <Bram@moolenaar.net>.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

---------------------------------------
Received: (at 292630-forwarded) by bugs.debian.org; 24 Apr 2005 21:27:54 +0000
>From zack@bononia.it Sun Apr 24 14:27:54 2005
Return-path: <zack@bononia.it>
Received: from ms003msg.fastwebnet.it [213.140.2.42] 
	by spohr.debian.org with esmtp (Exim 3.35 1 (Debian))
	id 1DPodu-0005If-00; Sun, 24 Apr 2005 14:27:54 -0700
Received: from fistandantilus.takhisis.org (37.10.140.106) by ms003msg.fastwebnet.it (7.2.052.3)
        id 41FFB1A401301268; Sun, 24 Apr 2005 23:27:22 +0200
Received: by fistandantilus.takhisis.org (Postfix, from userid 3148)
	id B0D2C2745AC; Sun, 24 Apr 2005 23:26:31 +0200 (CEST)
Date: Sun, 24 Apr 2005 23:26:31 +0200
From: Stefano Zacchiroli <zack@debian.org>
To: Bram Moolenaar <Bram@moolenaar.net>
Cc: 292630-forwarded@bugs.debian.org, 292630-submitter@bugs.debian.org
Subject: flushing the write-buffer when saving inhibit hd spin down
Message-ID: <20050424212629.GA2236@fistandantilus.takhisis.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.9i
Delivered-To: 292630-forwarded@bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Status: No, hits=-3.0 required=4.0 tests=BAYES_00 autolearn=no 
	version=2.60-bugs.debian.org_2005_01_02
X-Spam-Level: 

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. -!-