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.j...@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

Reply via email to