mirror of https://gitee.com/openkylin/linux.git
btrfs: scrub: clean up temporary page variables in scrub_checksum_data
Add proper variable for the scrub page and use it instead of repeatedly dereferencing the other structures. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
771aba0d12
commit
d41ebef200
|
@ -1786,23 +1786,21 @@ static int scrub_checksum_data(struct scrub_block *sblock)
|
||||||
struct btrfs_fs_info *fs_info = sctx->fs_info;
|
struct btrfs_fs_info *fs_info = sctx->fs_info;
|
||||||
SHASH_DESC_ON_STACK(shash, fs_info->csum_shash);
|
SHASH_DESC_ON_STACK(shash, fs_info->csum_shash);
|
||||||
u8 csum[BTRFS_CSUM_SIZE];
|
u8 csum[BTRFS_CSUM_SIZE];
|
||||||
u8 *on_disk_csum;
|
struct scrub_page *spage;
|
||||||
struct page *page;
|
|
||||||
char *kaddr;
|
char *kaddr;
|
||||||
|
|
||||||
BUG_ON(sblock->page_count < 1);
|
BUG_ON(sblock->page_count < 1);
|
||||||
if (!sblock->pagev[0]->have_csum)
|
spage = sblock->pagev[0];
|
||||||
|
if (!spage->have_csum)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
on_disk_csum = sblock->pagev[0]->csum;
|
kaddr = page_address(spage->page);
|
||||||
page = sblock->pagev[0]->page;
|
|
||||||
kaddr = page_address(page);
|
|
||||||
|
|
||||||
shash->tfm = fs_info->csum_shash;
|
shash->tfm = fs_info->csum_shash;
|
||||||
crypto_shash_init(shash);
|
crypto_shash_init(shash);
|
||||||
crypto_shash_digest(shash, kaddr, PAGE_SIZE, csum);
|
crypto_shash_digest(shash, kaddr, PAGE_SIZE, csum);
|
||||||
|
|
||||||
if (memcmp(csum, on_disk_csum, sctx->csum_size))
|
if (memcmp(csum, spage->csum, sctx->csum_size))
|
||||||
sblock->checksum_error = 1;
|
sblock->checksum_error = 1;
|
||||||
|
|
||||||
return sblock->checksum_error;
|
return sblock->checksum_error;
|
||||||
|
|
Loading…
Reference in New Issue