btrfs: integrity-checker: convert block context kmap's to kmap_local_page

btrfsic_read_block() (which calls kmap()) and
btrfsic_release_block_ctx() (which calls kunmap()) are always called
within a single thread of execution.

Therefore the mappings created within these calls can be a thread local
mapping.

Convert the kmap() of bloc_ctx->pagev to kmap_local_page().  Luckily the
unmap loops backwards through the array pointer so no adjustment needs
to be made to the unmapping order.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
pull/634/merge
Ira Weiny 2021-02-16 18:48:26 -08:00 committed by David Sterba
parent 3e037efdbd
commit 9a002d531b
1 changed files with 3 additions and 2 deletions

View File

@ -1555,10 +1555,11 @@ static void btrfsic_release_block_ctx(struct btrfsic_block_data_ctx *block_ctx)
BUG_ON(!block_ctx->pagev); BUG_ON(!block_ctx->pagev);
num_pages = (block_ctx->len + (u64)PAGE_SIZE - 1) >> num_pages = (block_ctx->len + (u64)PAGE_SIZE - 1) >>
PAGE_SHIFT; PAGE_SHIFT;
/* Pages must be unmapped in reverse order */
while (num_pages > 0) { while (num_pages > 0) {
num_pages--; num_pages--;
if (block_ctx->datav[num_pages]) { if (block_ctx->datav[num_pages]) {
kunmap(block_ctx->pagev[num_pages]); kunmap_local(block_ctx->datav[num_pages]);
block_ctx->datav[num_pages] = NULL; block_ctx->datav[num_pages] = NULL;
} }
if (block_ctx->pagev[num_pages]) { if (block_ctx->pagev[num_pages]) {
@ -1637,7 +1638,7 @@ static int btrfsic_read_block(struct btrfsic_state *state,
i = j; i = j;
} }
for (i = 0; i < num_pages; i++) for (i = 0; i < num_pages; i++)
block_ctx->datav[i] = kmap(block_ctx->pagev[i]); block_ctx->datav[i] = kmap_local_page(block_ctx->pagev[i]);
return block_ctx->len; return block_ctx->len;
} }