Commit 5a6e6e7c authored by Fabio M. De Francesco's avatar Fabio M. De Francesco Committed by David Sterba

btrfs: zlib: replace kmap() with kmap_local_page() in zlib_decompress_bio()

The use of kmap() is being deprecated in favor of kmap_local_page(). With
kmap_local_page(), the mapping is per thread, CPU local and not globally
visible.

Therefore, use kmap_local_page() / kunmap_local() in zlib_decompress_bio()
because in this function the mappings are per thread and are not visible
in other contexts.

Tested with xfstests on QEMU + KVM 32-bits VM with 4GB of RAM and
HIGHMEM64G enabled. This patch passes 26/26 tests of group "compress".
Suggested-by: default avatarIra Weiny <ira.weiny@intel.com>
Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarFabio M. De Francesco <fmdefrancesco@gmail.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 718e5855
...@@ -281,7 +281,7 @@ int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb) ...@@ -281,7 +281,7 @@ int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
unsigned long buf_start; unsigned long buf_start;
struct page **pages_in = cb->compressed_pages; struct page **pages_in = cb->compressed_pages;
data_in = kmap(pages_in[page_in_index]); data_in = kmap_local_page(pages_in[page_in_index]);
workspace->strm.next_in = data_in; workspace->strm.next_in = data_in;
workspace->strm.avail_in = min_t(size_t, srclen, PAGE_SIZE); workspace->strm.avail_in = min_t(size_t, srclen, PAGE_SIZE);
workspace->strm.total_in = 0; workspace->strm.total_in = 0;
...@@ -303,7 +303,7 @@ int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb) ...@@ -303,7 +303,7 @@ int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
if (Z_OK != zlib_inflateInit2(&workspace->strm, wbits)) { if (Z_OK != zlib_inflateInit2(&workspace->strm, wbits)) {
pr_warn("BTRFS: inflateInit failed\n"); pr_warn("BTRFS: inflateInit failed\n");
kunmap(pages_in[page_in_index]); kunmap_local(data_in);
return -EIO; return -EIO;
} }
while (workspace->strm.total_in < srclen) { while (workspace->strm.total_in < srclen) {
...@@ -330,13 +330,13 @@ int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb) ...@@ -330,13 +330,13 @@ int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
if (workspace->strm.avail_in == 0) { if (workspace->strm.avail_in == 0) {
unsigned long tmp; unsigned long tmp;
kunmap(pages_in[page_in_index]); kunmap_local(data_in);
page_in_index++; page_in_index++;
if (page_in_index >= total_pages_in) { if (page_in_index >= total_pages_in) {
data_in = NULL; data_in = NULL;
break; break;
} }
data_in = kmap(pages_in[page_in_index]); data_in = kmap_local_page(pages_in[page_in_index]);
workspace->strm.next_in = data_in; workspace->strm.next_in = data_in;
tmp = srclen - workspace->strm.total_in; tmp = srclen - workspace->strm.total_in;
workspace->strm.avail_in = min(tmp, PAGE_SIZE); workspace->strm.avail_in = min(tmp, PAGE_SIZE);
...@@ -349,7 +349,7 @@ int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb) ...@@ -349,7 +349,7 @@ int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
done: done:
zlib_inflateEnd(&workspace->strm); zlib_inflateEnd(&workspace->strm);
if (data_in) if (data_in)
kunmap(pages_in[page_in_index]); kunmap_local(data_in);
if (!ret) if (!ret)
zero_fill_bio(cb->orig_bio); zero_fill_bio(cb->orig_bio);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment