summaryrefslogtreecommitdiffstats
path: root/include/linux/jbd2.h
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 /include/linux/jbd2.h
parent25ed6e8a54df904c875365eebedbd19138a47328 (diff)
downloadop-kernel-dev-01b5adcebb977bc61b64167adce6d8260c9da33c.zip
op-kernel-dev-01b5adcebb977bc61b64167adce6d8260c9da33c.tar.gz
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 'include/linux/jbd2.h')
-rw-r--r--include/linux/jbd2.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 809c439..71e77dd 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -31,6 +31,7 @@
#include <linux/mutex.h>
#include <linux/timer.h>
#include <linux/slab.h>
+#include <crypto/hash.h>
#endif
#define journal_oom_retry 1
@@ -965,6 +966,9 @@ struct journal_s
* superblock pointer here
*/
void *j_private;
+
+ /* Reference to checksum algorithm driver via cryptoapi */
+ struct crypto_shash *j_chksum_driver;
};
/*
@@ -1294,6 +1298,25 @@ static inline int jbd_space_needed(journal_t *journal)
extern int jbd_blocks_per_page(struct inode *inode);
+static inline u32 jbd2_chksum(journal_t *journal, u32 crc,
+ const void *address, unsigned int length)
+{
+ struct {
+ struct shash_desc shash;
+ char ctx[crypto_shash_descsize(journal->j_chksum_driver)];
+ } desc;
+ int err;
+
+ desc.shash.tfm = journal->j_chksum_driver;
+ desc.shash.flags = 0;
+ *(u32 *)desc.ctx = crc;
+
+ err = crypto_shash_update(&desc.shash, address, length);
+ BUG_ON(err);
+
+ return *(u32 *)desc.ctx;
+}
+
#ifdef __KERNEL__
#define buffer_trace_init(bh) do {} while (0)
OpenPOWER on IntegriCloud