1 jbd2: fold jbd2_superblock_csum_{verify,set} into their callers
3 The functions jbd2_superblock_csum_verify() and
4 jbd2_superblock_csum_set() only get called from one location, so to
5 simplify things, fold them into their callers.
7 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 fs/jbd2/journal.c | 36 +++++++++++-------------------------
10 1 file changed, 11 insertions(+), 25 deletions(-)
12 diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
13 index 88d8f22d2cba..3892f4070aff 100644
14 --- a/fs/jbd2/journal.c
15 +++ b/fs/jbd2/journal.c
16 @@ -142,22 +142,6 @@ static __be32 jbd2_superblock_csum(journal_t *j, journal_superblock_t *sb)
17 return cpu_to_be32(csum);
20 -static int jbd2_superblock_csum_verify(journal_t *j, journal_superblock_t *sb)
22 - if (!jbd2_journal_has_csum_v2or3(j))
25 - return sb->s_checksum == jbd2_superblock_csum(j, sb);
28 -static void jbd2_superblock_csum_set(journal_t *j, journal_superblock_t *sb)
30 - if (!jbd2_journal_has_csum_v2or3(j))
33 - sb->s_checksum = jbd2_superblock_csum(j, sb);
37 * Helper function used to manage commit timeouts
39 @@ -1381,7 +1365,8 @@ static int jbd2_write_superblock(journal_t *journal, int write_flags)
40 clear_buffer_write_io_error(bh);
41 set_buffer_uptodate(bh);
43 - jbd2_superblock_csum_set(journal, sb);
44 + if (jbd2_journal_has_csum_v2or3(journal))
45 + sb->s_checksum = jbd2_superblock_csum(journal, sb);
47 bh->b_end_io = end_buffer_write_sync;
48 ret = submit_bh(REQ_OP_WRITE, write_flags, bh);
49 @@ -1595,17 +1580,18 @@ static int journal_get_superblock(journal_t *journal)
53 - /* Check superblock checksum */
54 - if (!jbd2_superblock_csum_verify(journal, sb)) {
55 - printk(KERN_ERR "JBD2: journal checksum error\n");
59 + if (jbd2_journal_has_csum_v2or3(journal)) {
60 + /* Check superblock checksum */
61 + if (sb->s_checksum != jbd2_superblock_csum(journal, sb)) {
62 + printk(KERN_ERR "JBD2: journal checksum error\n");
67 - /* Precompute checksum seed for all metadata */
68 - if (jbd2_journal_has_csum_v2or3(journal))
69 + /* Precompute checksum seed for all metadata */
70 journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid,
74 set_buffer_verified(bh);