diff options
author | David Sterba <dsterba@suse.com> | 2020-06-30 17:44:49 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-12-08 15:54:01 +0100 |
commit | 2ae0c2d80d25dae7658b64b93c271004bc8708e8 (patch) | |
tree | 76f6cab64a0c4dc953c01f1cbe5e604435a105cb /fs/btrfs/scrub.c | |
parent | 419b791ce76090aeaa598d7879579c236736e4ae (diff) | |
download | linux-2ae0c2d80d25dae7658b64b93c271004bc8708e8.tar.bz2 |
btrfs: scrub: remove local copy of csum_size from context
The context structure unnecessarily stores copy of the checksum size,
that can be now easily obtained from fs_info.
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/scrub.c')
-rw-r--r-- | fs/btrfs/scrub.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 51222534618b..58cd3278fbfe 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -161,7 +161,6 @@ struct scrub_ctx { atomic_t workers_pending; spinlock_t list_lock; wait_queue_head_t list_wait; - u16 csum_size; struct list_head csum_list; atomic_t cancel_req; int readonly; @@ -610,7 +609,6 @@ static noinline_for_stack struct scrub_ctx *scrub_setup_ctx( atomic_set(&sctx->bios_in_flight, 0); atomic_set(&sctx->workers_pending, 0); atomic_set(&sctx->cancel_req, 0); - sctx->csum_size = fs_info->csum_size; spin_lock_init(&sctx->list_lock); spin_lock_init(&sctx->stat_lock); @@ -1349,7 +1347,7 @@ leave_nomem: if (have_csum) memcpy(page->csum, original_sblock->pagev[0]->csum, - sctx->csum_size); + sctx->fs_info->csum_size); scrub_stripe_index_and_offset(logical, bbio->map_type, @@ -1800,7 +1798,7 @@ static int scrub_checksum_data(struct scrub_block *sblock) crypto_shash_init(shash); crypto_shash_digest(shash, kaddr, PAGE_SIZE, csum); - if (memcmp(csum, spage->csum, sctx->csum_size)) + if (memcmp(csum, spage->csum, sctx->fs_info->csum_size)) sblock->checksum_error = 1; return sblock->checksum_error; @@ -1823,7 +1821,7 @@ static int scrub_checksum_tree_block(struct scrub_block *sblock) spage = sblock->pagev[0]; kaddr = page_address(spage->page); h = (struct btrfs_header *)kaddr; - memcpy(on_disk_csum, h->csum, sctx->csum_size); + memcpy(on_disk_csum, h->csum, sctx->fs_info->csum_size); /* * we don't use the getter functions here, as we @@ -1856,7 +1854,7 @@ static int scrub_checksum_tree_block(struct scrub_block *sblock) } crypto_shash_final(shash, calculated_csum); - if (memcmp(calculated_csum, on_disk_csum, sctx->csum_size)) + if (memcmp(calculated_csum, on_disk_csum, sctx->fs_info->csum_size)) sblock->checksum_error = 1; return sblock->header_error || sblock->checksum_error; @@ -1893,7 +1891,7 @@ static int scrub_checksum_super(struct scrub_block *sblock) crypto_shash_digest(shash, kaddr + BTRFS_CSUM_SIZE, BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE, calculated_csum); - if (memcmp(calculated_csum, s->csum, sctx->csum_size)) + if (memcmp(calculated_csum, s->csum, sctx->fs_info->csum_size)) ++fail_cor; if (fail_cor + fail_gen) { @@ -2198,7 +2196,7 @@ leave_nomem: spage->mirror_num = mirror_num; if (csum) { spage->have_csum = 1; - memcpy(spage->csum, csum, sctx->csum_size); + memcpy(spage->csum, csum, sctx->fs_info->csum_size); } else { spage->have_csum = 0; } @@ -2390,7 +2388,8 @@ static int scrub_find_csum(struct scrub_ctx *sctx, u64 logical, u8 *csum) ASSERT(index < UINT_MAX); num_sectors = sum->len >> sctx->fs_info->sectorsize_bits; - memcpy(csum, sum->sums + index * sctx->csum_size, sctx->csum_size); + memcpy(csum, sum->sums + index * sctx->fs_info->csum_size, + sctx->fs_info->csum_size); if (index == num_sectors - 1) { list_del(&sum->list); kfree(sum); @@ -2508,7 +2507,7 @@ leave_nomem: spage->mirror_num = mirror_num; if (csum) { spage->have_csum = 1; - memcpy(spage->csum, csum, sctx->csum_size); + memcpy(spage->csum, csum, sctx->fs_info->csum_size); } else { spage->have_csum = 0; } |