From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH 1/9] btrfs: scrub: remove kmap/kunmap of pages
Date: Mon, 1 Jun 2020 17:23:03 +0200 [thread overview]
Message-ID: <d2f0d8e604efa1908b86cac6dd6670e63a0a9a62.1591024792.git.dsterba@suse.com> (raw)
In-Reply-To: <cover.1591024792.git.dsterba@suse.com>
All pages that scrub uses in the scrub_block::pagev array are allocated
with GFP_KERNEL and never part of any mapping, so kmap is not necessary,
we only need to know the page address.
In scrub_write_page_to_dev_replace we don't even need to call
flush_dcache_page because of the same reason as above.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/scrub.c | 23 ++++++++---------------
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 016a025e36c7..368791b17bac 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -1616,13 +1616,9 @@ static int scrub_write_page_to_dev_replace(struct scrub_block *sblock,
struct scrub_page *spage = sblock->pagev[page_num];
BUG_ON(spage->page == NULL);
- if (spage->io_error) {
- void *mapped_buffer = kmap_atomic(spage->page);
+ if (spage->io_error)
+ clear_page(page_address(spage->page));
- clear_page(mapped_buffer);
- flush_dcache_page(spage->page);
- kunmap_atomic(mapped_buffer);
- }
return scrub_add_page_to_wr_bio(sblock->sctx, spage);
}
@@ -1805,7 +1801,7 @@ static int scrub_checksum_data(struct scrub_block *sblock)
on_disk_csum = sblock->pagev[0]->csum;
page = sblock->pagev[0]->page;
- buffer = kmap_atomic(page);
+ buffer = page_address(page);
len = sctx->fs_info->sectorsize;
index = 0;
@@ -1813,7 +1809,6 @@ static int scrub_checksum_data(struct scrub_block *sblock)
u64 l = min_t(u64, len, PAGE_SIZE);
crypto_shash_update(shash, buffer, l);
- kunmap_atomic(buffer);
len -= l;
if (len == 0)
break;
@@ -1821,7 +1816,7 @@ static int scrub_checksum_data(struct scrub_block *sblock)
BUG_ON(index >= sblock->page_count);
BUG_ON(!sblock->pagev[index]->page);
page = sblock->pagev[index]->page;
- buffer = kmap_atomic(page);
+ buffer = page_address(page);
}
crypto_shash_final(shash, csum);
@@ -1851,7 +1846,7 @@ static int scrub_checksum_tree_block(struct scrub_block *sblock)
BUG_ON(sblock->page_count < 1);
page = sblock->pagev[0]->page;
- mapped_buffer = kmap_atomic(page);
+ mapped_buffer = page_address(page);
h = (struct btrfs_header *)mapped_buffer;
memcpy(on_disk_csum, h->csum, sctx->csum_size);
@@ -1883,7 +1878,6 @@ static int scrub_checksum_tree_block(struct scrub_block *sblock)
u64 l = min_t(u64, len, mapped_size);
crypto_shash_update(shash, p, l);
- kunmap_atomic(mapped_buffer);
len -= l;
if (len == 0)
break;
@@ -1891,7 +1885,7 @@ static int scrub_checksum_tree_block(struct scrub_block *sblock)
BUG_ON(index >= sblock->page_count);
BUG_ON(!sblock->pagev[index]->page);
page = sblock->pagev[index]->page;
- mapped_buffer = kmap_atomic(page);
+ mapped_buffer = page_address(page);
mapped_size = PAGE_SIZE;
p = mapped_buffer;
}
@@ -1925,7 +1919,7 @@ static int scrub_checksum_super(struct scrub_block *sblock)
BUG_ON(sblock->page_count < 1);
page = sblock->pagev[0]->page;
- mapped_buffer = kmap_atomic(page);
+ mapped_buffer = page_address(page);
s = (struct btrfs_super_block *)mapped_buffer;
memcpy(on_disk_csum, s->csum, sctx->csum_size);
@@ -1946,7 +1940,6 @@ static int scrub_checksum_super(struct scrub_block *sblock)
u64 l = min_t(u64, len, mapped_size);
crypto_shash_update(shash, p, l);
- kunmap_atomic(mapped_buffer);
len -= l;
if (len == 0)
break;
@@ -1954,7 +1947,7 @@ static int scrub_checksum_super(struct scrub_block *sblock)
BUG_ON(index >= sblock->page_count);
BUG_ON(!sblock->pagev[index]->page);
page = sblock->pagev[index]->page;
- mapped_buffer = kmap_atomic(page);
+ mapped_buffer = page_address(page);
mapped_size = PAGE_SIZE;
p = mapped_buffer;
}
--
2.25.0
next prev parent reply other threads:[~2020-06-01 15:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-01 15:23 [PATCH 0/9] Scrub cleanups David Sterba
2020-06-01 15:23 ` David Sterba [this message]
2020-06-01 15:23 ` [PATCH 2/9] btrfs: scrub: unify naming of page address variables David Sterba
2020-06-01 15:23 ` [PATCH 3/9] btrfs: scrub: simplify superblock checksum calculation David Sterba
2020-06-01 15:23 ` [PATCH 4/9] btrfs: scrub: remove temporary csum array in scrub_checksum_super David Sterba
2020-06-01 15:23 ` [PATCH 5/9] btrfs: scrub: clean up temporary page variables " David Sterba
2020-06-01 15:23 ` [PATCH 6/9] btrfs: scrub: simplify data block checksum calculation David Sterba
2020-06-01 15:23 ` [PATCH 7/9] btrfs: scrub: clean up temporary page variables in scrub_checksum_data David Sterba
2020-06-01 15:23 ` [PATCH 8/9] btrfs: scrub: simplify tree block checksum calculation David Sterba
2020-06-01 15:23 ` [PATCH 9/9] btrfs: scrub: clean up temporary page variables in scrub_checksum_tree_block David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d2f0d8e604efa1908b86cac6dd6670e63a0a9a62.1591024792.git.dsterba@suse.com \
--to=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).