Skip to content

Commit bbaf971

Browse files
committed
btrfs: compression: drop kmap/kunmap from zstd
As we don't use highmem pages anymore, drop the kmap/kunmap. The kmap is simply page_address and kunmap is a no-op. Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 696ab56 commit bbaf971

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

fs/btrfs/zstd.c

+9-18
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
399399

400400
/* map in the first page of input data */
401401
in_page = find_get_page(mapping, start >> PAGE_SHIFT);
402-
workspace->in_buf.src = kmap(in_page);
402+
workspace->in_buf.src = page_address(in_page);
403403
workspace->in_buf.pos = 0;
404404
workspace->in_buf.size = min_t(size_t, len, PAGE_SIZE);
405405

@@ -411,7 +411,7 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
411411
goto out;
412412
}
413413
pages[nr_pages++] = out_page;
414-
workspace->out_buf.dst = kmap(out_page);
414+
workspace->out_buf.dst = page_address(out_page);
415415
workspace->out_buf.pos = 0;
416416
workspace->out_buf.size = min_t(size_t, max_out, PAGE_SIZE);
417417

@@ -446,7 +446,6 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
446446
if (workspace->out_buf.pos == workspace->out_buf.size) {
447447
tot_out += PAGE_SIZE;
448448
max_out -= PAGE_SIZE;
449-
kunmap(out_page);
450449
if (nr_pages == nr_dest_pages) {
451450
out_page = NULL;
452451
ret = -E2BIG;
@@ -458,7 +457,7 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
458457
goto out;
459458
}
460459
pages[nr_pages++] = out_page;
461-
workspace->out_buf.dst = kmap(out_page);
460+
workspace->out_buf.dst = page_address(out_page);
462461
workspace->out_buf.pos = 0;
463462
workspace->out_buf.size = min_t(size_t, max_out,
464463
PAGE_SIZE);
@@ -473,13 +472,12 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
473472
/* Check if we need more input */
474473
if (workspace->in_buf.pos == workspace->in_buf.size) {
475474
tot_in += PAGE_SIZE;
476-
kunmap(in_page);
477475
put_page(in_page);
478476

479477
start += PAGE_SIZE;
480478
len -= PAGE_SIZE;
481479
in_page = find_get_page(mapping, start >> PAGE_SHIFT);
482-
workspace->in_buf.src = kmap(in_page);
480+
workspace->in_buf.src = page_address(in_page);
483481
workspace->in_buf.pos = 0;
484482
workspace->in_buf.size = min_t(size_t, len, PAGE_SIZE);
485483
}
@@ -506,7 +504,6 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
506504

507505
tot_out += PAGE_SIZE;
508506
max_out -= PAGE_SIZE;
509-
kunmap(out_page);
510507
if (nr_pages == nr_dest_pages) {
511508
out_page = NULL;
512509
ret = -E2BIG;
@@ -518,7 +515,7 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
518515
goto out;
519516
}
520517
pages[nr_pages++] = out_page;
521-
workspace->out_buf.dst = kmap(out_page);
518+
workspace->out_buf.dst = page_address(out_page);
522519
workspace->out_buf.pos = 0;
523520
workspace->out_buf.size = min_t(size_t, max_out, PAGE_SIZE);
524521
}
@@ -534,12 +531,8 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
534531
out:
535532
*out_pages = nr_pages;
536533
/* Cleanup */
537-
if (in_page) {
538-
kunmap(in_page);
534+
if (in_page)
539535
put_page(in_page);
540-
}
541-
if (out_page)
542-
kunmap(out_page);
543536
return ret;
544537
}
545538

@@ -565,7 +558,7 @@ int zstd_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
565558
goto done;
566559
}
567560

568-
workspace->in_buf.src = kmap(pages_in[page_in_index]);
561+
workspace->in_buf.src = page_address(pages_in[page_in_index]);
569562
workspace->in_buf.pos = 0;
570563
workspace->in_buf.size = min_t(size_t, srclen, PAGE_SIZE);
571564

@@ -601,23 +594,21 @@ int zstd_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
601594
break;
602595

603596
if (workspace->in_buf.pos == workspace->in_buf.size) {
604-
kunmap(pages_in[page_in_index++]);
597+
page_in_index++;
605598
if (page_in_index >= total_pages_in) {
606599
workspace->in_buf.src = NULL;
607600
ret = -EIO;
608601
goto done;
609602
}
610603
srclen -= PAGE_SIZE;
611-
workspace->in_buf.src = kmap(pages_in[page_in_index]);
604+
workspace->in_buf.src = page_address(pages_in[page_in_index]);
612605
workspace->in_buf.pos = 0;
613606
workspace->in_buf.size = min_t(size_t, srclen, PAGE_SIZE);
614607
}
615608
}
616609
ret = 0;
617610
zero_fill_bio(orig_bio);
618611
done:
619-
if (workspace->in_buf.src)
620-
kunmap(pages_in[page_in_index]);
621612
return ret;
622613
}
623614

0 commit comments

Comments
 (0)