Re: Syncing a file's metadata in a portable way

From: Andrew Morton
Date: Sat Jul 10 2004 - 15:18:18 EST


bert hubert <ahu@xxxxxxx> wrote:
>
> On Fri, Jul 09, 2004 at 02:39:48AM -0700, Andrew Morton wrote:
>
> > It depends on the Linux filesystem. On ext3, for example, fsync() will
> > sync all of the filesytem's metadata (and data in journalled and ordered
> > data mode).
>
> I've noticed that on ext3, SQLite transactions are nearly useless, with the
> smallest transactions causing 5 megabyte/s writout activity based on
> relatively small writes. kjournald bore a large part of that according to
> laptop_mode's block dump.

If only the one file has been written to, an fsync on ext3 shouldn't
produce any more writeout than an fsync on ext2.

If there are other files on the same fs which have been written to then
they will be accidentally fsynced too, unless you're using data=writeback.

Either that, or SQLite is broken.

> Do we actually need to flush the journal on fsync? I'm no fs theorist but I
> wonder if having data in the journal isn't good enough - in case of failure,
> the data will be there on recovery?

fsync in ordered data mode will sync file data to the main fs and will sync
metadata tothe journal. It will not sync previously-journalled metadata
back to the main fs, because that's not required for a succesful recovery.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/