From: Behan Webster <behanw@converseincode.com>
To: tytso@mit.edu
Cc: linux-ext4@vger.kernel.org, Mark Charlebois <charlebm@gmail.com>,
Behan Webster <behanw@converseincode.com>
Subject: [PATCH V2] Remove VLAIS usage from JBD2 code
Date: Tue, 30 Oct 2012 17:50:08 -0400 [thread overview]
Message-ID: <1351633808-8720-1-git-send-email-behanw@converseincode.com> (raw)
From: Mark Charlebois <charlebm@gmail.com>
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>
[Used a #define to specify the fixed size of ctx]
Signed-off-by: Behan Webster <behanw@converseincode.com>
---
include/linux/jbd2.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 3efc43f..93b323f 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -1303,15 +1303,21 @@ static inline int jbd_space_needed(journal_t *journal)
extern int jbd_blocks_per_page(struct inode *inode);
+/* JBD uses a CRC32 checksum */
+#define JBD_MAX_CHECKSUM_SIZE 4
+
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)];
+ char ctx[JBD_MAX_CHECKSUM_SIZE];
} desc;
int err;
+ BUG_ON(crypto_shash_descsize(journal->j_chksum_driver) >
+ JBD_MAX_CHECKSUM_SIZE);
+
desc.shash.tfm = journal->j_chksum_driver;
desc.shash.flags = 0;
*(u32 *)desc.ctx = crc;
--
1.7.9.5
reply other threads:[~2012-10-30 21:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1351633808-8720-1-git-send-email-behanw@converseincode.com \
--to=behanw@converseincode.com \
--cc=charlebm@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).