From: Linus Benedict Torvalds (torvalds@klaava.Helsinki.FI)
Date: 07/14/92


From: torvalds@klaava.Helsinki.FI (Linus Benedict Torvalds)
Subject: Re: [comp.os.linux]: Re: File system issues!
Date: 14 Jul 1992 11:21:36 GMT


[ sorry if the attributions are wrong: the included file was a bit messy ]

In article <cy7uNB1w165w@ssg.com> unixsys@ssg.com (Rick Emerson) writes:
> From: davidsen@ariel.crd.GE.COM (william E Davidsen)
>>
>> Perhaps that class of user should be using fsync() to force their data
>> out.

fsync() under linux isn't implemented right now: although a fsync() that
just does a sync() is possible.

>'Splain me why a "fscache -writeback 0" (or something equivalent) is so
>distasteful? Please, let's not debate the pros and cons of write-back
>caching.

Ok, ok, ok. Here is a simple patch (not cdiff, but you can do it by
hand) that essentially implements write-through. I won't put it into
the standard kernel (unless somebody pays me $$$ - anybody? I'm /very/
corruptible.) but you might try it out if you want to..

In the function brelse(), in fs/buffer.c:

  void brelse(struct buffer_head * buf)
  {
        if (!buf)
                return;
+ ll_rw_block(WRITE,buf);
        wait_on_buffer(buf);
        if (!(buf->b_count--))
                panic("Trying to free free buffer");
        wake_up(&buffer_wait);
  }

One line to add, and voila. Magic.

I still like the fsync() and O_SYNC ideas better, but the above is so
simple anybody can try it out. DISCLAIMER: I used my usual rigorous
testing techniques on the above, ie none.

                Linus