From: Jeff Mahoney <jeffm@suse.com>
Subject: Make reiserfs default to barrier=flush
Patch-mainline: not yet

Change the default reiserfs mount option to barrier=flush

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---

 fs/reiserfs/Kconfig |   22 ++++++++++++++++++++++
 fs/reiserfs/super.c |    3 +++
 2 files changed, 25 insertions(+)

--- a/fs/reiserfs/Kconfig
+++ b/fs/reiserfs/Kconfig
@@ -50,6 +50,28 @@ config REISERFS_PROC_INFO
 	  Almost everyone but ReiserFS developers and people fine-tuning
 	  reiserfs or tracing problems should say N.
 
+config REISERFS_DEFAULTS_TO_BARRIERS_ENABLED
+	bool "Default to 'barrier=flush' in reiserfs"
+	depends on REISERFS_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 REISERFS_FS_XATTR
 	bool "ReiserFS extended attributes"
 	depends on REISERFS_FS
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -1626,6 +1626,9 @@ static int reiserfs_fill_super(struct su
 	/* Set default values for options: non-aggressive tails, RO on errors */
 	REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_SMALLTAIL);
 	REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_ERROR_RO);
+#ifdef CONFIG_REISERFS_DEFAULTS_TO_BARRIERS_ENABLED
+	REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_BARRIER_FLUSH);
+#endif
 	/* no preallocation minimum, be smart in
 	   reiserfs_file_write instead */
 	REISERFS_SB(s)->s_alloc_options.preallocmin = 0;
