diff options
author | Theodore Ts'o <tytso@mit.edu> | 2019-02-14 16:28:14 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2019-02-14 16:28:14 -0500 |
commit | a58ca992661a4bc6a1dfa60e9d6f606e97784149 (patch) | |
tree | 5d8aaa6130161f42ef85a226beba4e22be0a340d | |
parent | 538bcaa6261b77e71d37f5596c33127c1a3ec3f7 (diff) |
jbd2: fold jbd2_superblock_csum_{verify,set} into their callers
The functions jbd2_superblock_csum_verify() and
jbd2_superblock_csum_set() only get called from one location, so to
simplify things, fold them into their callers.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r-- | fs/jbd2/journal.c | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 67ac91b53050..382c030cc78b 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c | |||
@@ -142,22 +142,6 @@ static __be32 jbd2_superblock_csum(journal_t *j, journal_superblock_t *sb) | |||
142 | return cpu_to_be32(csum); | 142 | return cpu_to_be32(csum); |
143 | } | 143 | } |
144 | 144 | ||
145 | static int jbd2_superblock_csum_verify(journal_t *j, journal_superblock_t *sb) | ||
146 | { | ||
147 | if (!jbd2_journal_has_csum_v2or3(j)) | ||
148 | return 1; | ||
149 | |||
150 | return sb->s_checksum == jbd2_superblock_csum(j, sb); | ||
151 | } | ||
152 | |||
153 | static void jbd2_superblock_csum_set(journal_t *j, journal_superblock_t *sb) | ||
154 | { | ||
155 | if (!jbd2_journal_has_csum_v2or3(j)) | ||
156 | return; | ||
157 | |||
158 | sb->s_checksum = jbd2_superblock_csum(j, sb); | ||
159 | } | ||
160 | |||
161 | /* | 145 | /* |
162 | * Helper function used to manage commit timeouts | 146 | * Helper function used to manage commit timeouts |
163 | */ | 147 | */ |
@@ -1384,7 +1368,8 @@ static int jbd2_write_superblock(journal_t *journal, int write_flags) | |||
1384 | clear_buffer_write_io_error(bh); | 1368 | clear_buffer_write_io_error(bh); |
1385 | set_buffer_uptodate(bh); | 1369 | set_buffer_uptodate(bh); |
1386 | } | 1370 | } |
1387 | jbd2_superblock_csum_set(journal, sb); | 1371 | if (jbd2_journal_has_csum_v2or3(journal)) |
1372 | sb->s_checksum = jbd2_superblock_csum(journal, sb); | ||
1388 | get_bh(bh); | 1373 | get_bh(bh); |
1389 | bh->b_end_io = end_buffer_write_sync; | 1374 | bh->b_end_io = end_buffer_write_sync; |
1390 | ret = submit_bh(REQ_OP_WRITE, write_flags, bh); | 1375 | ret = submit_bh(REQ_OP_WRITE, write_flags, bh); |
@@ -1597,17 +1582,18 @@ static int journal_get_superblock(journal_t *journal) | |||
1597 | } | 1582 | } |
1598 | } | 1583 | } |
1599 | 1584 | ||
1600 | /* Check superblock checksum */ | 1585 | if (jbd2_journal_has_csum_v2or3(journal)) { |
1601 | if (!jbd2_superblock_csum_verify(journal, sb)) { | 1586 | /* Check superblock checksum */ |
1602 | printk(KERN_ERR "JBD2: journal checksum error\n"); | 1587 | if (sb->s_checksum != jbd2_superblock_csum(journal, sb)) { |
1603 | err = -EFSBADCRC; | 1588 | printk(KERN_ERR "JBD2: journal checksum error\n"); |
1604 | goto out; | 1589 | err = -EFSBADCRC; |
1605 | } | 1590 | goto out; |
1591 | } | ||
1606 | 1592 | ||
1607 | /* Precompute checksum seed for all metadata */ | 1593 | /* Precompute checksum seed for all metadata */ |
1608 | if (jbd2_journal_has_csum_v2or3(journal)) | ||
1609 | journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid, | 1594 | journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid, |
1610 | sizeof(sb->s_uuid)); | 1595 | sizeof(sb->s_uuid)); |
1596 | } | ||
1611 | 1597 | ||
1612 | set_buffer_verified(bh); | 1598 | set_buffer_verified(bh); |
1613 | 1599 | ||