Re: Disabling in-memory write cache for x86-64 in Linux II

From: NeilBrown
Date: Mon Nov 04 2013 - 21:08:38 EST


On Tue, 5 Nov 2013 09:40:55 +0800 "Figo.zhang" <figo1802@xxxxxxxxx> wrote:

> > >
> > > Of course, if you don't use Linux on the desktop you don't really care -
> > well, I do. Also
> > > not everyone in this world has an UPS - which means such a huge buffer
> > can lead to a
> > > serious data loss in case of a power blackout.
> >
> > I don't have a desk (just a lap), but I use Linux on all my computers and
> > I've never really noticed the problem. Maybe I'm just very patient, or
> > maybe
> > I don't work with large data sets and slow devices.
> >
> > However I don't think data-loss is really a related issue. Any process
> > that
> > cares about data safety *must* use fsync at appropriate places. This has
> > always been true.
> >
> > =>May i ask question that, some like ext4 filesystem, if some app motify
> the files, it create some dirty data. if some meta-data writing to the
> journal disk when a power backout,
> it will be lose some serious data and the the file will damage?

If you modify a file, then you must take care that you can recover from a
crash at any point in the process.

If the file is small, the usual approach is to create a copy of the file with
the appropriate changes made, then 'fsync' the file and rename the new file
over the old file.

If the file is large you might need some sort of update log (in a small file)
so you can replay recent updates after a crash.

The journalling that the filesystem provides only protects the filesystem
metadata. It does not protect the consistency of the data in your file.

I hope that helps.

NeilBrown

Attachment: signature.asc
Description: PGP signature