From c25d1d5dd37863206c5ff2ed01209a8cc8b39cf0 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 11 Feb 2019 20:20:27 -0500 Subject: [PATCH] add patch fold-jbd2_superblock_csum_foo-into-their-callers --- fold-jbd2_superblock_csum_foo-into-their-callers | 75 ++++++++++++++++++++++++ series | 1 + timestamps | 12 ++-- 3 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 fold-jbd2_superblock_csum_foo-into-their-callers diff --git a/fold-jbd2_superblock_csum_foo-into-their-callers b/fold-jbd2_superblock_csum_foo-into-their-callers new file mode 100644 index 00000000..98d3f7f6 --- /dev/null +++ b/fold-jbd2_superblock_csum_foo-into-their-callers @@ -0,0 +1,75 @@ +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 +--- + fs/jbd2/journal.c | 36 +++++++++++------------------------- + 1 file changed, 11 insertions(+), 25 deletions(-) + +diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c +index 88d8f22d2cba..3892f4070aff 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) + return cpu_to_be32(csum); + } + +-static int jbd2_superblock_csum_verify(journal_t *j, journal_superblock_t *sb) +-{ +- if (!jbd2_journal_has_csum_v2or3(j)) +- return 1; +- +- return sb->s_checksum == jbd2_superblock_csum(j, sb); +-} +- +-static void jbd2_superblock_csum_set(journal_t *j, journal_superblock_t *sb) +-{ +- if (!jbd2_journal_has_csum_v2or3(j)) +- return; +- +- sb->s_checksum = jbd2_superblock_csum(j, sb); +-} +- + /* + * Helper function used to manage commit timeouts + */ +@@ -1381,7 +1365,8 @@ static int jbd2_write_superblock(journal_t *journal, int write_flags) + clear_buffer_write_io_error(bh); + set_buffer_uptodate(bh); + } +- jbd2_superblock_csum_set(journal, sb); ++ if (jbd2_journal_has_csum_v2or3(journal)) ++ sb->s_checksum = jbd2_superblock_csum(journal, sb); + get_bh(bh); + bh->b_end_io = end_buffer_write_sync; + ret = submit_bh(REQ_OP_WRITE, write_flags, bh); +@@ -1595,17 +1580,18 @@ static int journal_get_superblock(journal_t *journal) + } + } + +- /* Check superblock checksum */ +- if (!jbd2_superblock_csum_verify(journal, sb)) { +- printk(KERN_ERR "JBD2: journal checksum error\n"); +- err = -EFSBADCRC; +- goto out; +- } ++ if (jbd2_journal_has_csum_v2or3(journal)) { ++ /* Check superblock checksum */ ++ if (sb->s_checksum != jbd2_superblock_csum(journal, sb)) { ++ printk(KERN_ERR "JBD2: journal checksum error\n"); ++ err = -EFSBADCRC; ++ goto out; ++ } + +- /* Precompute checksum seed for all metadata */ +- if (jbd2_journal_has_csum_v2or3(journal)) ++ /* Precompute checksum seed for all metadata */ + journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid, + sizeof(sb->s_uuid)); ++ } + + set_buffer_verified(bh); + diff --git a/series b/series index 9816fe79..4dcd8274 100644 --- a/series +++ b/series @@ -14,6 +14,7 @@ add-mask-of-ext4-flags-to-swap disallow-journal_data-files-from-EXT4_IOC_SWAP_BOOT fix-crash-during-online-resizing fix-race-while-writing-superblock +fold-jbd2_superblock_csum_foo-into-their-callers #fix-slow-writeback-under-dioread_nolock-and-nodelalloc diff --git a/timestamps b/timestamps index 68f878d8..ec3ee097 100755 --- a/timestamps +++ b/timestamps @@ -23,14 +23,14 @@ touch -d @1549859166 discard-dirty-data-when-forgetting-unjournaled-buffer touch -d @1549859527 cleanup-clean_bdev_aliases-calls touch -d @1549860801 unlock-unused-pages-more-timely-when-doing-writeback touch -d @1549861325 fix-check-of-inode-in-swap_inode_boot_loader -touch -d @1549861385 stable-boundary touch -d @1549861524 cleanup-pagecache-before-swap-i_data touch -d @1549862042 update-quota-information-while-swapping-boot-loader-inode touch -d @1549863306 add-mask-of-ext4-flags-to-swap touch -d @1549865230 disallow-journal_data-files-from-EXT4_IOC_SWAP_BOOT touch -d @1549909832 fix-crash-during-online-resizing -touch -d @1549912906 fold-jbd2_superblock_csum_foo-into-their-callers -touch -d @1549914734 fix-race-while-writing-superblock -touch -d @1549914734 status -touch -d @1549915509 series -touch -d @1549915520 timestamps +touch -d @1549915530 series +touch -d @1549933961 fix-race-while-writing-superblock +touch -d @1549934021 fold-jbd2_superblock_csum_foo-into-their-callers +touch -d @1549934081 stable-boundary +touch -d @1549934384 status +touch -d @1549934414 timestamps -- 2.11.4.GIT