From: Chris Mason Subject: make ext3 mount default to barrier=1 Patch-mainline: probably never Hello everyone, This patch turns on barriers by default for ext3. mount -o barrier=0 will turn them off. It also changes the ext3 fsync call to trigger a barrier when a commit isn't done. It should be safe, but some extra review would be appreciated. Updated Apr 13 2009 jeffm: - Added Kconfig option Acked-by: Jeff Mahoney --- fs/ext3/Kconfig | 22 ++++++++++++++++++++++ fs/ext3/fsync.c | 1 + fs/ext3/super.c | 4 ++++ 3 files changed, 27 insertions(+) --- a/fs/ext3/Kconfig +++ b/fs/ext3/Kconfig @@ -49,6 +49,28 @@ config EXT3_DEFAULTS_TO_ORDERED privacy issues of data=writeback and are willing to make that trade off, answer 'n'. +config EXT3_DEFAULTS_TO_BARRIERS_ENABLED + bool "Default to 'barrier=1' in ext3" + depends on EXT3_FS + help + Modern disk drives support write caches that can speed up writeback. + Some devices, in order to improve their performance statistics, + report that the write has been completed even when it has only + been committed to volatile cache memory. This can result in + severe corruption in the event of power loss. + + The -o barrier option enables the file system to direct the block + layer to issue a barrier, which ensures that the cache has been + flushed before proceeding. This can produce some slowdown in + certain environments, but allows higher end storage arrays with + battery-backed caches to report completes writes sooner than + would be otherwise possible. + + Without this option, disk write caches should be disabled if + you value data integrity over writeback performance. + + If unsure, say N. + config EXT3_FS_XATTR bool "Ext3 extended attributes" depends on EXT3_FS --- a/fs/ext3/fsync.c +++ b/fs/ext3/fsync.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -1688,6 +1688,10 @@ static int ext3_fill_super (struct super sbi->s_resuid = le16_to_cpu(es->s_def_resuid); sbi->s_resgid = le16_to_cpu(es->s_def_resgid); + /* enable barriers by default */ +#ifdef CONFIG_EXT3_DEFAULTS_TO_BARRIERS_ENABLED + set_opt(sbi->s_mount_opt, BARRIER); +#endif set_opt(sbi->s_mount_opt, RESERVATION); if (!parse_options ((char *) data, sb, &journal_inum, &journal_devnum,