diff options
author | David Sterba <dsterba@suse.com> | 2020-05-29 15:54:41 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-07-27 12:55:23 +0200 |
commit | 771aba0d12dd945132e2c3bbb512f96edc0efbaa (patch) | |
tree | 75755dccb363f3100e71ded1bd652466a7b9966e /fs/btrfs/scrub.c | |
parent | c7460541093494f108adb6388351636d353715fb (diff) |
btrfs: scrub: simplify data block checksum calculation
We have sectorsize same as PAGE_SIZE, the checksum can be calculated in
one go.
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/scrub.c')
-rw-r--r-- | fs/btrfs/scrub.c | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index aecaf5c7f655..16c83130d884 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -1789,37 +1789,19 @@ static int scrub_checksum_data(struct scrub_block *sblock) u8 *on_disk_csum; struct page *page; char *kaddr; - u64 len; - int index; BUG_ON(sblock->page_count < 1); if (!sblock->pagev[0]->have_csum) return 0; - shash->tfm = fs_info->csum_shash; - crypto_shash_init(shash); - on_disk_csum = sblock->pagev[0]->csum; page = sblock->pagev[0]->page; kaddr = page_address(page); - len = sctx->fs_info->sectorsize; - index = 0; - for (;;) { - u64 l = min_t(u64, len, PAGE_SIZE); - - crypto_shash_update(shash, kaddr, l); - len -= l; - if (len == 0) - break; - index++; - BUG_ON(index >= sblock->page_count); - BUG_ON(!sblock->pagev[index]->page); - page = sblock->pagev[index]->page; - kaddr = page_address(page); - } + shash->tfm = fs_info->csum_shash; + crypto_shash_init(shash); + crypto_shash_digest(shash, kaddr, PAGE_SIZE, csum); - crypto_shash_final(shash, csum); if (memcmp(csum, on_disk_csum, sctx->csum_size)) sblock->checksum_error = 1; |