add patch jbd2_get_transaction-does-not-need-to-return-a-value
[ext4-patch-queue.git] / fold-jbd2_superblock_csum_foo-into-their-callers
blob98d3f7f65ad1aea83e748ebdfb7ffdb3356ea644
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>
8 ---
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);
18  }
20 -static int jbd2_superblock_csum_verify(journal_t *j, journal_superblock_t *sb)
22 -       if (!jbd2_journal_has_csum_v2or3(j))
23 -               return 1;
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))
31 -               return;
33 -       sb->s_checksum = jbd2_superblock_csum(j, sb);
36  /*
37   * Helper function used to manage commit timeouts
38   */
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);
42         }
43 -       jbd2_superblock_csum_set(journal, sb);
44 +       if (jbd2_journal_has_csum_v2or3(journal))
45 +               sb->s_checksum = jbd2_superblock_csum(journal, sb);
46         get_bh(bh);
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)
50                 }
51         }
53 -       /* Check superblock checksum */
54 -       if (!jbd2_superblock_csum_verify(journal, sb)) {
55 -               printk(KERN_ERR "JBD2: journal checksum error\n");
56 -               err = -EFSBADCRC;
57 -               goto out;
58 -       }
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");
63 +                       err = -EFSBADCRC;
64 +                       goto out;
65 +               }
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,
71                                                    sizeof(sb->s_uuid));
72 +       }
74         set_buffer_verified(bh);