From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: josef@toxicpanda.com
Subject: [PATCH 4/5] btrfs: scrub_checksum_tree_block() drop its function declaration
Date: Wed, 10 Feb 2021 21:25:18 -0800 [thread overview]
Message-ID: <b19539f16f4292749e201032459f5b2686709f0a.1613019838.git.anand.jain@oracle.com> (raw)
In-Reply-To: <cover.1613019838.git.anand.jain@oracle.com>
Move the static function scrub_checksum_tree_block() before its use in
the scrub.c, and drop its declaration.
No functional changes.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/scrub.c | 133 +++++++++++++++++++++++------------------------
1 file changed, 66 insertions(+), 67 deletions(-)
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 029477dd77de..bc335dd6a54f 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -221,7 +221,6 @@ static void scrub_write_block_to_dev_replace(struct scrub_block *sblock);
static int scrub_write_page_to_dev_replace(struct scrub_block *sblock,
int page_num);
static int scrub_checksum_data(struct scrub_block *sblock);
-static int scrub_checksum_tree_block(struct scrub_block *sblock);
static int scrub_checksum_super(struct scrub_block *sblock);
static void scrub_block_put(struct scrub_block *sblock);
static void scrub_page_get(struct scrub_page *spage);
@@ -1506,6 +1505,72 @@ static inline int scrub_check_fsid(u8 fsid[],
return !ret;
}
+static int scrub_checksum_tree_block(struct scrub_block *sblock)
+{
+ struct scrub_ctx *sctx = sblock->sctx;
+ struct btrfs_header *h;
+ struct btrfs_fs_info *fs_info = sctx->fs_info;
+ SHASH_DESC_ON_STACK(shash, fs_info->csum_shash);
+ u8 calculated_csum[BTRFS_CSUM_SIZE];
+ u8 on_disk_csum[BTRFS_CSUM_SIZE];
+ /*
+ * This is done in sectorsize steps even for metadata as there's a
+ * constraint for nodesize to be aligned to sectorsize. This will need
+ * to change so we don't misuse data and metadata units like that.
+ */
+ const u32 sectorsize = sctx->fs_info->sectorsize;
+ const int num_sectors = fs_info->nodesize >> fs_info->sectorsize_bits;
+ int i;
+ struct scrub_page *spage;
+ char *kaddr;
+
+ BUG_ON(sblock->page_count < 1);
+
+ /* Each member in pagev is just one block, not a full page */
+ ASSERT(sblock->page_count == num_sectors);
+
+ spage = sblock->pagev[0];
+ kaddr = page_address(spage->page);
+ h = (struct btrfs_header *)kaddr;
+ memcpy(on_disk_csum, h->csum, sctx->fs_info->csum_size);
+
+ /*
+ * we don't use the getter functions here, as we
+ * a) don't have an extent buffer and
+ * b) the page is already kmapped
+ */
+ if (spage->logical != btrfs_stack_header_bytenr(h))
+ sblock->header_error = 1;
+
+ if (spage->generation != btrfs_stack_header_generation(h)) {
+ sblock->header_error = 1;
+ sblock->generation_error = 1;
+ }
+
+ if (!scrub_check_fsid(h->fsid, spage))
+ sblock->header_error = 1;
+
+ if (memcmp(h->chunk_tree_uuid, fs_info->chunk_tree_uuid,
+ BTRFS_UUID_SIZE))
+ sblock->header_error = 1;
+
+ shash->tfm = fs_info->csum_shash;
+ crypto_shash_init(shash);
+ crypto_shash_update(shash, kaddr + BTRFS_CSUM_SIZE,
+ sectorsize - BTRFS_CSUM_SIZE);
+
+ for (i = 1; i < num_sectors; i++) {
+ kaddr = page_address(sblock->pagev[i]->page);
+ crypto_shash_update(shash, kaddr, sectorsize);
+ }
+
+ crypto_shash_final(shash, calculated_csum);
+ if (memcmp(calculated_csum, on_disk_csum, sctx->fs_info->csum_size))
+ sblock->checksum_error = 1;
+
+ return sblock->header_error || sblock->checksum_error;
+}
+
static void scrub_recheck_block_checksum(struct scrub_block *sblock)
{
sblock->header_error = 0;
@@ -1835,72 +1900,6 @@ static int scrub_checksum_data(struct scrub_block *sblock)
return sblock->checksum_error;
}
-static int scrub_checksum_tree_block(struct scrub_block *sblock)
-{
- struct scrub_ctx *sctx = sblock->sctx;
- struct btrfs_header *h;
- struct btrfs_fs_info *fs_info = sctx->fs_info;
- SHASH_DESC_ON_STACK(shash, fs_info->csum_shash);
- u8 calculated_csum[BTRFS_CSUM_SIZE];
- u8 on_disk_csum[BTRFS_CSUM_SIZE];
- /*
- * This is done in sectorsize steps even for metadata as there's a
- * constraint for nodesize to be aligned to sectorsize. This will need
- * to change so we don't misuse data and metadata units like that.
- */
- const u32 sectorsize = sctx->fs_info->sectorsize;
- const int num_sectors = fs_info->nodesize >> fs_info->sectorsize_bits;
- int i;
- struct scrub_page *spage;
- char *kaddr;
-
- BUG_ON(sblock->page_count < 1);
-
- /* Each member in pagev is just one block, not a full page */
- ASSERT(sblock->page_count == num_sectors);
-
- spage = sblock->pagev[0];
- kaddr = page_address(spage->page);
- h = (struct btrfs_header *)kaddr;
- memcpy(on_disk_csum, h->csum, sctx->fs_info->csum_size);
-
- /*
- * we don't use the getter functions here, as we
- * a) don't have an extent buffer and
- * b) the page is already kmapped
- */
- if (spage->logical != btrfs_stack_header_bytenr(h))
- sblock->header_error = 1;
-
- if (spage->generation != btrfs_stack_header_generation(h)) {
- sblock->header_error = 1;
- sblock->generation_error = 1;
- }
-
- if (!scrub_check_fsid(h->fsid, spage))
- sblock->header_error = 1;
-
- if (memcmp(h->chunk_tree_uuid, fs_info->chunk_tree_uuid,
- BTRFS_UUID_SIZE))
- sblock->header_error = 1;
-
- shash->tfm = fs_info->csum_shash;
- crypto_shash_init(shash);
- crypto_shash_update(shash, kaddr + BTRFS_CSUM_SIZE,
- sectorsize - BTRFS_CSUM_SIZE);
-
- for (i = 1; i < num_sectors; i++) {
- kaddr = page_address(sblock->pagev[i]->page);
- crypto_shash_update(shash, kaddr, sectorsize);
- }
-
- crypto_shash_final(shash, calculated_csum);
- if (memcmp(calculated_csum, on_disk_csum, sctx->fs_info->csum_size))
- sblock->checksum_error = 1;
-
- return sblock->header_error || sblock->checksum_error;
-}
-
static int scrub_checksum_super(struct scrub_block *sblock)
{
struct btrfs_super_block *s;
--
2.27.0
next prev parent reply other threads:[~2021-02-11 5:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-11 5:25 [PATCH 0/5] cleanups btrfs_extent_readonly() and scrub, part1 Anand Jain
2021-02-11 5:25 ` [PATCH 1/5] btrfs: make btrfs_extent_readonly() static Anand Jain
2021-02-11 5:25 ` [PATCH 2/5] btrfs: btrfs_extent_readonly() change return type to bool Anand Jain
2021-02-11 13:00 ` Johannes Thumshirn
2021-02-11 5:25 ` [PATCH 3/5] btrfs: scrub drop few function declarations Anand Jain
2021-02-11 13:27 ` Johannes Thumshirn
2021-02-11 5:25 ` Anand Jain [this message]
2021-02-11 13:28 ` [PATCH 4/5] btrfs: scrub_checksum_tree_block() drop its function declaration Johannes Thumshirn
2021-02-12 14:36 ` David Sterba
2021-02-25 1:21 ` Anand Jain
2021-02-25 16:16 ` David Sterba
2021-02-11 5:25 ` [PATCH 5/5] btrfs: scrub_checksum_data() " Anand Jain
2021-02-11 13:30 ` Johannes Thumshirn
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=b19539f16f4292749e201032459f5b2686709f0a.1613019838.git.anand.jain@oracle.com \
--to=anand.jain@oracle.com \
--cc=josef@toxicpanda.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).