diff options
author | Darrick J. Wong <djwong@us.ibm.com> | 2012-05-27 07:48:56 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2012-05-27 07:48:56 -0400 |
commit | 25ed6e8a54df904c875365eebedbd19138a47328 (patch) | |
tree | ac16e78f0d8e0376f40d9259b1095f356d395165 /fs/ext4 | |
parent | 8f888ef846d4481e24c74b4a91ece771d2bcbcb5 (diff) |
jbd2: enable journal clients to enable v2 checksumming
Add in the necessary code so that journal clients can enable the new
journal checksumming features.
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/super.c | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 88c2054fb938..8dfb42e380ea 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -3013,6 +3013,44 @@ static void ext4_destroy_lazyinit_thread(void) | |||
3013 | kthread_stop(ext4_lazyinit_task); | 3013 | kthread_stop(ext4_lazyinit_task); |
3014 | } | 3014 | } |
3015 | 3015 | ||
3016 | static int set_journal_csum_feature_set(struct super_block *sb) | ||
3017 | { | ||
3018 | int ret = 1; | ||
3019 | int compat, incompat; | ||
3020 | struct ext4_sb_info *sbi = EXT4_SB(sb); | ||
3021 | |||
3022 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, | ||
3023 | EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) { | ||
3024 | /* journal checksum v2 */ | ||
3025 | compat = 0; | ||
3026 | incompat = JBD2_FEATURE_INCOMPAT_CSUM_V2; | ||
3027 | } else { | ||
3028 | /* journal checksum v1 */ | ||
3029 | compat = JBD2_FEATURE_COMPAT_CHECKSUM; | ||
3030 | incompat = 0; | ||
3031 | } | ||
3032 | |||
3033 | if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { | ||
3034 | ret = jbd2_journal_set_features(sbi->s_journal, | ||
3035 | compat, 0, | ||
3036 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT | | ||
3037 | incompat); | ||
3038 | } else if (test_opt(sb, JOURNAL_CHECKSUM)) { | ||
3039 | ret = jbd2_journal_set_features(sbi->s_journal, | ||
3040 | compat, 0, | ||
3041 | incompat); | ||
3042 | jbd2_journal_clear_features(sbi->s_journal, 0, 0, | ||
3043 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT); | ||
3044 | } else { | ||
3045 | jbd2_journal_clear_features(sbi->s_journal, | ||
3046 | JBD2_FEATURE_COMPAT_CHECKSUM, 0, | ||
3047 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT | | ||
3048 | JBD2_FEATURE_INCOMPAT_CSUM_V2); | ||
3049 | } | ||
3050 | |||
3051 | return ret; | ||
3052 | } | ||
3053 | |||
3016 | static int ext4_fill_super(struct super_block *sb, void *data, int silent) | 3054 | static int ext4_fill_super(struct super_block *sb, void *data, int silent) |
3017 | { | 3055 | { |
3018 | char *orig_data = kstrdup(data, GFP_KERNEL); | 3056 | char *orig_data = kstrdup(data, GFP_KERNEL); |
@@ -3610,19 +3648,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3610 | goto failed_mount_wq; | 3648 | goto failed_mount_wq; |
3611 | } | 3649 | } |
3612 | 3650 | ||
3613 | if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { | 3651 | if (!set_journal_csum_feature_set(sb)) { |
3614 | jbd2_journal_set_features(sbi->s_journal, | 3652 | ext4_msg(sb, KERN_ERR, "Failed to set journal checksum " |
3615 | JBD2_FEATURE_COMPAT_CHECKSUM, 0, | 3653 | "feature set"); |
3616 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT); | 3654 | goto failed_mount_wq; |
3617 | } else if (test_opt(sb, JOURNAL_CHECKSUM)) { | ||
3618 | jbd2_journal_set_features(sbi->s_journal, | ||
3619 | JBD2_FEATURE_COMPAT_CHECKSUM, 0, 0); | ||
3620 | jbd2_journal_clear_features(sbi->s_journal, 0, 0, | ||
3621 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT); | ||
3622 | } else { | ||
3623 | jbd2_journal_clear_features(sbi->s_journal, | ||
3624 | JBD2_FEATURE_COMPAT_CHECKSUM, 0, | ||
3625 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT); | ||
3626 | } | 3655 | } |
3627 | 3656 | ||
3628 | /* We have now updated the journal if required, so we can | 3657 | /* We have now updated the journal if required, so we can |