diff mbox series

[4/5] btrfs: scrub_checksum_tree_block() drop its function declaration

Message ID b19539f16f4292749e201032459f5b2686709f0a.1613019838.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series cleanups btrfs_extent_readonly() and scrub, part1 | expand

Commit Message

Anand Jain Feb. 11, 2021, 5:25 a.m. UTC
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(-)

Comments

Johannes Thumshirn Feb. 11, 2021, 1:28 p.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
David Sterba Feb. 12, 2021, 2:36 p.m. UTC | #2
On Wed, Feb 10, 2021 at 09:25:18PM -0800, Anand Jain wrote:
> Move the static function scrub_checksum_tree_block() before its use in
> the scrub.c, and drop its declaration.
> 
> No functional changes.

We've rejected patches that move static function within one file unless
there's another reason for it other than removing the prototype.
Anand Jain Feb. 25, 2021, 1:21 a.m. UTC | #3
On 12/02/2021 22:36, David Sterba wrote:
> On Wed, Feb 10, 2021 at 09:25:18PM -0800, Anand Jain wrote:
>> Move the static function scrub_checksum_tree_block() before its use in
>> the scrub.c, and drop its declaration.
>>
>> No functional changes.
> 

> We've rejected patches that move static function within one file unless
> there's another reason for it other than removing the prototype.

Ok.
Patches 1-3 aren't of this type. I suppose they will be integrated?

Thanks, Anand
David Sterba Feb. 25, 2021, 4:16 p.m. UTC | #4
On Thu, Feb 25, 2021 at 09:21:31AM +0800, Anand Jain wrote:
> On 12/02/2021 22:36, David Sterba wrote:
> > On Wed, Feb 10, 2021 at 09:25:18PM -0800, Anand Jain wrote:
> >> Move the static function scrub_checksum_tree_block() before its use in
> >> the scrub.c, and drop its declaration.
> >>
> >> No functional changes.
> > 
> 
> > We've rejected patches that move static function within one file unless
> > there's another reason for it other than removing the prototype.
> 
> Ok.
> Patches 1-3 aren't of this type. I suppose they will be integrated?

Yes, they're good cleanups and now in misc-next, thanks.
diff mbox series

Patch

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;