diff options
Diffstat (limited to 'include/linux/jbd2.h')
-rw-r--r-- | include/linux/jbd2.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index 809c439066c5..71e77dddebf1 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/mutex.h> | 31 | #include <linux/mutex.h> |
32 | #include <linux/timer.h> | 32 | #include <linux/timer.h> |
33 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
34 | #include <crypto/hash.h> | ||
34 | #endif | 35 | #endif |
35 | 36 | ||
36 | #define journal_oom_retry 1 | 37 | #define journal_oom_retry 1 |
@@ -965,6 +966,9 @@ struct journal_s | |||
965 | * superblock pointer here | 966 | * superblock pointer here |
966 | */ | 967 | */ |
967 | void *j_private; | 968 | void *j_private; |
969 | |||
970 | /* Reference to checksum algorithm driver via cryptoapi */ | ||
971 | struct crypto_shash *j_chksum_driver; | ||
968 | }; | 972 | }; |
969 | 973 | ||
970 | /* | 974 | /* |
@@ -1294,6 +1298,25 @@ static inline int jbd_space_needed(journal_t *journal) | |||
1294 | 1298 | ||
1295 | extern int jbd_blocks_per_page(struct inode *inode); | 1299 | extern int jbd_blocks_per_page(struct inode *inode); |
1296 | 1300 | ||
1301 | static inline u32 jbd2_chksum(journal_t *journal, u32 crc, | ||
1302 | const void *address, unsigned int length) | ||
1303 | { | ||
1304 | struct { | ||
1305 | struct shash_desc shash; | ||
1306 | char ctx[crypto_shash_descsize(journal->j_chksum_driver)]; | ||
1307 | } desc; | ||
1308 | int err; | ||
1309 | |||
1310 | desc.shash.tfm = journal->j_chksum_driver; | ||
1311 | desc.shash.flags = 0; | ||
1312 | *(u32 *)desc.ctx = crc; | ||
1313 | |||
1314 | err = crypto_shash_update(&desc.shash, address, length); | ||
1315 | BUG_ON(err); | ||
1316 | |||
1317 | return *(u32 *)desc.ctx; | ||
1318 | } | ||
1319 | |||
1297 | #ifdef __KERNEL__ | 1320 | #ifdef __KERNEL__ |
1298 | 1321 | ||
1299 | #define buffer_trace_init(bh) do {} while (0) | 1322 | #define buffer_trace_init(bh) do {} while (0) |