|
@@ -97,6 +97,15 @@ EXPORT_SYMBOL(jbd2_inode_cache);
|
|
static void __journal_abort_soft (journal_t *journal, int errno);
|
|
static void __journal_abort_soft (journal_t *journal, int errno);
|
|
static int jbd2_journal_create_slab(size_t slab_size);
|
|
static int jbd2_journal_create_slab(size_t slab_size);
|
|
|
|
|
|
|
|
+/* Checksumming functions */
|
|
|
|
+int jbd2_verify_csum_type(journal_t *j, journal_superblock_t *sb)
|
|
|
|
+{
|
|
|
|
+ if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
|
|
|
|
+ return 1;
|
|
|
|
+
|
|
|
|
+ return sb->s_checksum_type == JBD2_CRC32C_CHKSUM;
|
|
|
|
+}
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* Helper function used to manage commit timeouts
|
|
* Helper function used to manage commit timeouts
|
|
*/
|
|
*/
|
|
@@ -1376,6 +1385,9 @@ static int journal_get_superblock(journal_t *journal)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (buffer_verified(bh))
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
sb = journal->j_superblock;
|
|
sb = journal->j_superblock;
|
|
|
|
|
|
err = -EINVAL;
|
|
err = -EINVAL;
|
|
@@ -1413,6 +1425,21 @@ static int journal_get_superblock(journal_t *journal)
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM) &&
|
|
|
|
+ JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) {
|
|
|
|
+ /* Can't have checksum v1 and v2 on at the same time! */
|
|
|
|
+ printk(KERN_ERR "JBD: Can't enable checksumming v1 and v2 "
|
|
|
|
+ "at the same time!\n");
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!jbd2_verify_csum_type(journal, sb)) {
|
|
|
|
+ printk(KERN_ERR "JBD: Unknown checksum type\n");
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ set_buffer_verified(bh);
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
out:
|
|
out:
|
|
@@ -1653,6 +1680,10 @@ int jbd2_journal_check_available_features (journal_t *journal, unsigned long com
|
|
int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
|
|
int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
|
|
unsigned long ro, unsigned long incompat)
|
|
unsigned long ro, unsigned long incompat)
|
|
{
|
|
{
|
|
|
|
+#define INCOMPAT_FEATURE_ON(f) \
|
|
|
|
+ ((incompat & (f)) && !(sb->s_feature_incompat & cpu_to_be32(f)))
|
|
|
|
+#define COMPAT_FEATURE_ON(f) \
|
|
|
|
+ ((compat & (f)) && !(sb->s_feature_compat & cpu_to_be32(f)))
|
|
journal_superblock_t *sb;
|
|
journal_superblock_t *sb;
|
|
|
|
|
|
if (jbd2_journal_check_used_features(journal, compat, ro, incompat))
|
|
if (jbd2_journal_check_used_features(journal, compat, ro, incompat))
|
|
@@ -1661,16 +1692,35 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
|
|
if (!jbd2_journal_check_available_features(journal, compat, ro, incompat))
|
|
if (!jbd2_journal_check_available_features(journal, compat, ro, incompat))
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
|
|
+ /* Asking for checksumming v2 and v1? Only give them v2. */
|
|
|
|
+ if (incompat & JBD2_FEATURE_INCOMPAT_CSUM_V2 &&
|
|
|
|
+ compat & JBD2_FEATURE_COMPAT_CHECKSUM)
|
|
|
|
+ compat &= ~JBD2_FEATURE_COMPAT_CHECKSUM;
|
|
|
|
+
|
|
jbd_debug(1, "Setting new features 0x%lx/0x%lx/0x%lx\n",
|
|
jbd_debug(1, "Setting new features 0x%lx/0x%lx/0x%lx\n",
|
|
compat, ro, incompat);
|
|
compat, ro, incompat);
|
|
|
|
|
|
sb = journal->j_superblock;
|
|
sb = journal->j_superblock;
|
|
|
|
|
|
|
|
+ /* If enabling v2 checksums, update superblock */
|
|
|
|
+ if (INCOMPAT_FEATURE_ON(JBD2_FEATURE_INCOMPAT_CSUM_V2)) {
|
|
|
|
+ sb->s_checksum_type = JBD2_CRC32C_CHKSUM;
|
|
|
|
+ sb->s_feature_compat &=
|
|
|
|
+ ~cpu_to_be32(JBD2_FEATURE_COMPAT_CHECKSUM);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* If enabling v1 checksums, downgrade superblock */
|
|
|
|
+ if (COMPAT_FEATURE_ON(JBD2_FEATURE_COMPAT_CHECKSUM))
|
|
|
|
+ sb->s_feature_incompat &=
|
|
|
|
+ ~cpu_to_be32(JBD2_FEATURE_INCOMPAT_CSUM_V2);
|
|
|
|
+
|
|
sb->s_feature_compat |= cpu_to_be32(compat);
|
|
sb->s_feature_compat |= cpu_to_be32(compat);
|
|
sb->s_feature_ro_compat |= cpu_to_be32(ro);
|
|
sb->s_feature_ro_compat |= cpu_to_be32(ro);
|
|
sb->s_feature_incompat |= cpu_to_be32(incompat);
|
|
sb->s_feature_incompat |= cpu_to_be32(incompat);
|
|
|
|
|
|
return 1;
|
|
return 1;
|
|
|
|
+#undef COMPAT_FEATURE_ON
|
|
|
|
+#undef INCOMPAT_FEATURE_ON
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|