aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/jbd2.h
diff options
context:
space:
mode:
authorBehan Webster <behanw@converseincode.com>2012-11-08 11:24:46 -0500
committerTheodore Ts'o <tytso@mit.edu>2012-11-08 11:24:46 -0500
commitfd47d3e1c2949838e858379aaf2bc20647be2912 (patch)
tree07fc4583dbaea7110aaf112e2c298c6120f891b1 /include/linux/jbd2.h
parent37be2f59d3149b95afaeeeff94edde2c07f165d2 (diff)
jbd2: remove VLAIS usage from JBD2 code
The use of variable length arrays in structs (VLAIS) in the Linux Kernel code precludes the use of compilers which don't implement VLAIS (for instance the Clang compiler). Since ctx is always a 32-bit CRC, hard coding a size of 4 bytes accomplishes the same thing without the use of VLAIS. This is the same technique already employed in fs/ext4/ext4.h Signed-off-by: Mark Charlebois <charlebm@gmail.com> Signed-off-by: Behan Webster <behanw@converseincode.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'include/linux/jbd2.h')
-rw-r--r--include/linux/jbd2.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index de7f55682088..1be23d9fdacb 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -1302,15 +1302,21 @@ static inline int jbd_space_needed(journal_t *journal)
1302 1302
1303extern int jbd_blocks_per_page(struct inode *inode); 1303extern int jbd_blocks_per_page(struct inode *inode);
1304 1304
1305/* JBD uses a CRC32 checksum */
1306#define JBD_MAX_CHECKSUM_SIZE 4
1307
1305static inline u32 jbd2_chksum(journal_t *journal, u32 crc, 1308static inline u32 jbd2_chksum(journal_t *journal, u32 crc,
1306 const void *address, unsigned int length) 1309 const void *address, unsigned int length)
1307{ 1310{
1308 struct { 1311 struct {
1309 struct shash_desc shash; 1312 struct shash_desc shash;
1310 char ctx[crypto_shash_descsize(journal->j_chksum_driver)]; 1313 char ctx[JBD_MAX_CHECKSUM_SIZE];
1311 } desc; 1314 } desc;
1312 int err; 1315 int err;
1313 1316
1317 BUG_ON(crypto_shash_descsize(journal->j_chksum_driver) >
1318 JBD_MAX_CHECKSUM_SIZE);
1319
1314 desc.shash.tfm = journal->j_chksum_driver; 1320 desc.shash.tfm = journal->j_chksum_driver;
1315 desc.shash.flags = 0; 1321 desc.shash.flags = 0;
1316 *(u32 *)desc.ctx = crc; 1322 *(u32 *)desc.ctx = crc;