From 9eac9c02df6f35028ef8065038e5b1ca92e1a2c5 Mon Sep 17 00:00:00 2001
From: girish <girish>
Date: Mon, 20 Aug 2007 10:25:23 +0000
Subject: [PATCH] Add ext3 part of Journal Checksum feature. b=10657 i=adilger
 i=kalpak

---
 ldiskfs/ChangeLog                             | 13 +++
 .../ext3-journal-chksum-2.6.18-vanilla.patch  | 81 +++++++++++++++++++
 .../series/ldiskfs-2.6-rhel5.series           |  1 +
 .../series/ldiskfs-2.6-sles10.series          |  1 +
 .../series/ldiskfs-2.6.18-vanilla.series      |  1 +
 5 files changed, 97 insertions(+)
 create mode 100644 ldiskfs/kernel_patches/patches/ext3-journal-chksum-2.6.18-vanilla.patch

diff --git a/ldiskfs/ChangeLog b/ldiskfs/ChangeLog
index 1be5fe8237..f05706a433 100644
--- a/ldiskfs/ChangeLog
+++ b/ldiskfs/ChangeLog
@@ -18,3 +18,16 @@ Details    : This feature will protect the filesystem from being mounted more
 	     to the filesystem if it is mounted. This assumes high importance
 	     in a shared storage environment where multiple mounts can severely
 	     corrupt the filesystem.
+
+Severity   : normal
+Bugzilla   : 10657
+Description: Add journal checksum support. (ext3 part)
+Details    : The journal checksum feature adds two new flags i.e 
+             JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT and 
+	     JBD2_FEATURE_COMPAT_CHECKSUM. JBD2_FEATURE_CHECKSUM flag
+   	     indicates that the commit block contains the checksum for
+    	     the blocks described by the descriptor blocks. Now commit
+      	     record can be sent to disk without waiting for descriptor
+    	     blocks to be written to disk. This behavior is controlled
+     	     using JBD2_FEATURE_ASYNC_COMMIT flag.
+
diff --git a/ldiskfs/kernel_patches/patches/ext3-journal-chksum-2.6.18-vanilla.patch b/ldiskfs/kernel_patches/patches/ext3-journal-chksum-2.6.18-vanilla.patch
new file mode 100644
index 0000000000..1d8f299bdd
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext3-journal-chksum-2.6.18-vanilla.patch
@@ -0,0 +1,81 @@
+Index: linux-2.6.18/fs/ext3/super.c
+===================================================================
+--- linux-2.6.18.orig/fs/ext3/super.c
++++ linux-2.6.18/fs/ext3/super.c
+@@ -688,6 +688,9 @@ enum {
+ 	Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl,
+ 	Opt_reservation, Opt_noreservation, Opt_noload, Opt_nobh, Opt_bh,
+ 	Opt_commit, Opt_journal_update, Opt_journal_inum, Opt_journal_dev,
++#ifdef JFS_FEATURE_COMPAT_CHECKSUM
++	Opt_journal_checksum, Opt_journal_async_commit,
++#endif
+ 	Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback,
+ 	Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
+ 	Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
+@@ -730,6 +733,10 @@ static match_table_t tokens = {
+ 	{Opt_journal_update, "journal=update"},
+ 	{Opt_journal_inum, "journal=%u"},
+ 	{Opt_journal_dev, "journal_dev=%u"},
++#ifdef JFS_FEATURE_COMPAT_CHECKSUM
++	{Opt_journal_checksum, "journal_checksum"},
++	{Opt_journal_async_commit, "journal_async_commit"},
++#endif
+ 	{Opt_abort, "abort"},
+ 	{Opt_data_journal, "data=journal"},
+ 	{Opt_data_ordered, "data=ordered"},
+@@ -924,6 +931,15 @@ static int parse_options (char *options,
+ 				return 0;
+ 			*journal_devnum = option;
+ 			break;
++#ifdef JFS_FEATURE_COMPAT_CHECKSUM
++		case Opt_journal_checksum:
++			set_opt (sbi->s_mount_opt, JOURNAL_CHECKSUM);
++			break;
++		case Opt_journal_async_commit:
++			set_opt (sbi->s_mount_opt, JOURNAL_ASYNC_COMMIT);
++			set_opt (sbi->s_mount_opt, JOURNAL_CHECKSUM);
++			break;
++#endif
+ 		case Opt_noload:
+ 			set_opt (sbi->s_mount_opt, NOLOAD);
+ 			break;
+@@ -2180,6 +2196,23 @@ static int ext3_fill_super (struct super
+ 		goto failed_mount3;
+ 	}
+ 
++#ifdef JFS_FEATURE_COMPAT_CHECKSUM
++	if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) {
++		journal_set_features(sbi->s_journal,
++				JFS_FEATURE_COMPAT_CHECKSUM, 0,
++				JFS_FEATURE_INCOMPAT_ASYNC_COMMIT);
++	} else if (test_opt(sb, JOURNAL_CHECKSUM)) {
++		journal_set_features(sbi->s_journal,
++				JFS_FEATURE_COMPAT_CHECKSUM, 0, 0);
++		journal_clear_features(sbi->s_journal, 0, 0,
++				JFS_FEATURE_INCOMPAT_ASYNC_COMMIT);
++	} else {
++		journal_clear_features(sbi->s_journal,
++				JFS_FEATURE_COMPAT_CHECKSUM, 0,
++				JFS_FEATURE_INCOMPAT_ASYNC_COMMIT);
++	}
++#endif
++
+ 	/* We have now updated the journal if required, so we can
+ 	 * validate the data journaling mode. */
+ 	switch (test_opt(sb, DATA_FLAGS)) {
+Index: linux-2.6.18/include/linux/ext3_fs.h
+===================================================================
+--- linux-2.6.18.orig/include/linux/ext3_fs.h
++++ linux-2.6.18/include/linux/ext3_fs.h
+@@ -476,6 +476,11 @@ do {									       \
+ #define EXT3_MOUNT_EXTDEBUG             0x4000000/* Extents debug */
+ #define EXT3_MOUNT_MBALLOC		0x8000000/* Buddy allocation support */
+ 
++#ifdef JFS_FEATURE_COMPAT_CHECKSUM
++#define EXT3_MOUNT_JOURNAL_CHECKSUM     0x10000000 /* Journal checksums */
++#define EXT3_MOUNT_JOURNAL_ASYNC_COMMIT 0x20000000 /* Journal Async Commit */
++#endif
++
+ /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
+ #ifndef clear_opt
+ #define clear_opt(o, opt)		o &= ~EXT3_MOUNT_##opt
diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel5.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel5.series
index 24698be842..9225438289 100644
--- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel5.series
+++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel5.series
@@ -15,3 +15,4 @@ ext3-nanosecond-2.6.18-vanilla.patch
 ext3-inode-version-2.6.18-vanilla.patch
 ext3-mmp-2.6.18-vanilla.patch
 ext3-unlink-race.patch
+ext3-journal-chksum-2.6.18-vanilla.patch
diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles10.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles10.series
index 213fff30ed..9096d2e79f 100644
--- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles10.series
+++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles10.series
@@ -19,3 +19,4 @@ ext3-uninit-2.6-sles10.patch
 ext3-nanosecond-2.6-sles10.patch
 ext3-inode-version-2.6-sles10.patch
 ext3-mmp-2.6-sles10.patch
+ext3-journal-chksum-2.6.18-vanilla.patch
diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6.18-vanilla.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6.18-vanilla.series
index 94bc6ad61f..60d9a23ea5 100644
--- a/ldiskfs/kernel_patches/series/ldiskfs-2.6.18-vanilla.series
+++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6.18-vanilla.series
@@ -16,3 +16,4 @@ ext3-nanosecond-2.6.18-vanilla.patch
 ext3-inode-version-2.6.18-vanilla.patch
 ext3-mmp-2.6.18-vanilla.patch
 ext3-handle-directory-corruption-better.patch
+ext3-journal-chksum-2.6.18-vanilla.patch
-- 
GitLab