aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jbd2
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@us.ibm.com>2012-05-27 07:50:56 -0400
committerTheodore Ts'o <tytso@mit.edu>2012-05-27 07:50:56 -0400
commit01b5adcebb977bc61b64167adce6d8260c9da33c (patch)
tree2d17de43723163d40ada0d8f51faf1061c324f5f /fs/jbd2
parent25ed6e8a54df904c875365eebedbd19138a47328 (diff)
jbd2: Grab a reference to the crc32c driver if necessary
Obtain a reference to the crc32c driver if needed for the v2 checksum. Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/jbd2')
-rw-r--r--fs/jbd2/Kconfig2
-rw-r--r--fs/jbd2/journal.c25
2 files changed, 27 insertions, 0 deletions
diff --git a/fs/jbd2/Kconfig b/fs/jbd2/Kconfig
index f32f346f4b0a..69a48c2944da 100644
--- a/fs/jbd2/Kconfig
+++ b/fs/jbd2/Kconfig
@@ -1,6 +1,8 @@
1config JBD2 1config JBD2
2 tristate 2 tristate
3 select CRC32 3 select CRC32
4 select CRYPTO
5 select CRYPTO_CRC32C
4 help 6 help
5 This is a generic journaling layer for block devices that support 7 This is a generic journaling layer for block devices that support
6 both 32-bit and 64-bit block numbers. It is currently used by 8 both 32-bit and 64-bit block numbers. It is currently used by
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 63175f9391ab..f04ab6c4b428 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -1438,6 +1438,17 @@ static int journal_get_superblock(journal_t *journal)
1438 goto out; 1438 goto out;
1439 } 1439 }
1440 1440
1441 /* Load the checksum driver */
1442 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) {
1443 journal->j_chksum_driver = crypto_alloc_shash("crc32c", 0, 0);
1444 if (IS_ERR(journal->j_chksum_driver)) {
1445 printk(KERN_ERR "JBD: Cannot load crc32c driver.\n");
1446 err = PTR_ERR(journal->j_chksum_driver);
1447 journal->j_chksum_driver = NULL;
1448 goto out;
1449 }
1450 }
1451
1441 set_buffer_verified(bh); 1452 set_buffer_verified(bh);
1442 1453
1443 return 0; 1454 return 0;
@@ -1591,6 +1602,8 @@ int jbd2_journal_destroy(journal_t *journal)
1591 iput(journal->j_inode); 1602 iput(journal->j_inode);
1592 if (journal->j_revoke) 1603 if (journal->j_revoke)
1593 jbd2_journal_destroy_revoke(journal); 1604 jbd2_journal_destroy_revoke(journal);
1605 if (journal->j_chksum_driver)
1606 crypto_free_shash(journal->j_chksum_driver);
1594 kfree(journal->j_wbuf); 1607 kfree(journal->j_wbuf);
1595 kfree(journal); 1608 kfree(journal);
1596 1609
@@ -1707,6 +1720,18 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
1707 sb->s_checksum_type = JBD2_CRC32C_CHKSUM; 1720 sb->s_checksum_type = JBD2_CRC32C_CHKSUM;
1708 sb->s_feature_compat &= 1721 sb->s_feature_compat &=
1709 ~cpu_to_be32(JBD2_FEATURE_COMPAT_CHECKSUM); 1722 ~cpu_to_be32(JBD2_FEATURE_COMPAT_CHECKSUM);
1723
1724 /* Load the checksum driver */
1725 if (journal->j_chksum_driver == NULL) {
1726 journal->j_chksum_driver = crypto_alloc_shash("crc32c",
1727 0, 0);
1728 if (IS_ERR(journal->j_chksum_driver)) {
1729 printk(KERN_ERR "JBD: Cannot load crc32c "
1730 "driver.\n");
1731 journal->j_chksum_driver = NULL;
1732 return 0;
1733 }
1734 }
1710 } 1735 }
1711 1736
1712 /* If enabling v1 checksums, downgrade superblock */ 1737 /* If enabling v1 checksums, downgrade superblock */