Re: [PATCH 2/2] Btrfs: check-int: don't complain about balanced blocks

2014-10-17 Thread Miao Xie
On Thu, 16 Oct 2014 17:48:49 +0200, Stefan Behrens wrote:
> The xfstest btrfs/014 which tests the balance operation caused that the
> check_int module complained that known blocks changed their physical
> location. Since this is not an error in this case, only print such
> message if the verbose mode was enabled.
> 
> Reported-by: Wang Shilong 
> Signed-off-by: Stefan Behrens 
> ---
>  fs/btrfs/check-integrity.c | 87 
> ++
>  1 file changed, 49 insertions(+), 38 deletions(-)
> 
> diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
> index 65fc2e0bbc4a..65226d7c9fe0 100644
> --- a/fs/btrfs/check-integrity.c
> +++ b/fs/btrfs/check-integrity.c
> @@ -1325,24 +1325,28 @@ static int btrfsic_create_link_to_next_block(
>   l = NULL;
>   next_block->generation = BTRFSIC_GENERATION_UNKNOWN;
>   } else {
> - if (next_block->logical_bytenr != next_bytenr &&
> - !(!next_block->is_metadata &&
> -   0 == next_block->logical_bytenr)) {
> - printk(KERN_INFO
> -"Referenced block @%llu (%s/%llu/%d)"
> -" found in hash table, %c,"
> -" bytenr mismatch (!= stored %llu).\n",
> -next_bytenr, next_block_ctx->dev->name,
> -next_block_ctx->dev_bytenr, *mirror_nump,
> -btrfsic_get_block_type(state, next_block),
> -next_block->logical_bytenr);
> - } else if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE)
> - printk(KERN_INFO
> -"Referenced block @%llu (%s/%llu/%d)"
> -" found in hash table, %c.\n",
> -next_bytenr, next_block_ctx->dev->name,
> -next_block_ctx->dev_bytenr, *mirror_nump,
> -btrfsic_get_block_type(state, next_block));
> + if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) {
> + if (next_block->logical_bytenr != next_bytenr &&
> + !(!next_block->is_metadata &&
> +   0 == next_block->logical_bytenr))
> + printk(KERN_INFO
> +"Referenced block @%llu (%s/%llu/%d)"
> +" found in hash table, %c,"
> +" bytenr mismatch (!= stored %llu).\n",

According to the coding style, we don't expect the user-visible strings are 
broken.

Thanks
Miao

> +next_bytenr, next_block_ctx->dev->name,
> +next_block_ctx->dev_bytenr, *mirror_nump,
> +btrfsic_get_block_type(state,
> +   next_block),
> +next_block->logical_bytenr);
> + else
> + printk(KERN_INFO
> +"Referenced block @%llu (%s/%llu/%d)"
> +" found in hash table, %c.\n",
> +next_bytenr, next_block_ctx->dev->name,
> +next_block_ctx->dev_bytenr, *mirror_nump,
> +btrfsic_get_block_type(state,
> +   next_block));
> + }
>   next_block->logical_bytenr = next_bytenr;
>  
>   next_block->mirror_num = *mirror_nump;
> @@ -1528,7 +1532,9 @@ static int btrfsic_handle_extent_data(
>   return -1;
>   }
>   if (!block_was_created) {
> - if (next_block->logical_bytenr != next_bytenr &&
> + if ((state->print_mask &
> +  BTRFSIC_PRINT_MASK_VERBOSE) &&
> + next_block->logical_bytenr != next_bytenr &&
>   !(!next_block->is_metadata &&
> 0 == next_block->logical_bytenr)) {
>   printk(KERN_INFO
> @@ -1881,25 +1887,30 @@ again:
>  dev_state,
>  dev_bytenr);
>   }
> - if (block->logical_bytenr != bytenr &&
> - !(!block->is_metadata &&
> -   block->logical_bytenr == 0))
> - printk(KERN_INFO
> -"Written block @%llu (%s/%llu/%d)"
> -" found in hash table, %c,"
> -   

Re: [PATCH 2/2] Btrfs: check-int: don't complain about balanced blocks

2014-10-17 Thread Wang Shilong
 The xfstest btrfs/014 which tests the balance operation caused that the
> check_int module complained that known blocks changed their physical
> location. Since this is not an error in this case, only print such
> message if the verbose mode was enabled.
> 
> Reported-by: Wang Shilong 
> Signed-off-by: Stefan Behrens 

This passed my Tests after applying both patches.

Tested-by: Wang Shilong 

> ---
> fs/btrfs/check-integrity.c | 87 ++
> 1 file changed, 49 insertions(+), 38 deletions(-)
> 
> diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
> index 65fc2e0bbc4a..65226d7c9fe0 100644
> --- a/fs/btrfs/check-integrity.c
> +++ b/fs/btrfs/check-integrity.c
> @@ -1325,24 +1325,28 @@ static int btrfsic_create_link_to_next_block(
>   l = NULL;
>   next_block->generation = BTRFSIC_GENERATION_UNKNOWN;
>   } else {
> - if (next_block->logical_bytenr != next_bytenr &&
> - !(!next_block->is_metadata &&
> -   0 == next_block->logical_bytenr)) {
> - printk(KERN_INFO
> -"Referenced block @%llu (%s/%llu/%d)"
> -" found in hash table, %c,"
> -" bytenr mismatch (!= stored %llu).\n",
> -next_bytenr, next_block_ctx->dev->name,
> -next_block_ctx->dev_bytenr, *mirror_nump,
> -btrfsic_get_block_type(state, next_block),
> -next_block->logical_bytenr);
> - } else if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE)
> - printk(KERN_INFO
> -"Referenced block @%llu (%s/%llu/%d)"
> -" found in hash table, %c.\n",
> -next_bytenr, next_block_ctx->dev->name,
> -next_block_ctx->dev_bytenr, *mirror_nump,
> -btrfsic_get_block_type(state, next_block));
> + if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) {
> + if (next_block->logical_bytenr != next_bytenr &&
> + !(!next_block->is_metadata &&
> +   0 == next_block->logical_bytenr))
> + printk(KERN_INFO
> +"Referenced block @%llu (%s/%llu/%d)"
> +" found in hash table, %c,"
> +" bytenr mismatch (!= stored %llu).\n",
> +next_bytenr, next_block_ctx->dev->name,
> +next_block_ctx->dev_bytenr, *mirror_nump,
> +btrfsic_get_block_type(state,
> +   next_block),
> +next_block->logical_bytenr);
> + else
> + printk(KERN_INFO
> +"Referenced block @%llu (%s/%llu/%d)"
> +" found in hash table, %c.\n",
> +next_bytenr, next_block_ctx->dev->name,
> +next_block_ctx->dev_bytenr, *mirror_nump,
> +btrfsic_get_block_type(state,
> +   next_block));
> + }
>   next_block->logical_bytenr = next_bytenr;
> 
>   next_block->mirror_num = *mirror_nump;
> @@ -1528,7 +1532,9 @@ static int btrfsic_handle_extent_data(
>   return -1;
>   }
>   if (!block_was_created) {
> - if (next_block->logical_bytenr != next_bytenr &&
> + if ((state->print_mask &
> +  BTRFSIC_PRINT_MASK_VERBOSE) &&
> + next_block->logical_bytenr != next_bytenr &&
>   !(!next_block->is_metadata &&
> 0 == next_block->logical_bytenr)) {
>   printk(KERN_INFO
> @@ -1881,25 +1887,30 @@ again:
>  dev_state,
>  dev_bytenr);
>   }
> - if (block->logical_bytenr != bytenr &&
> - !(!block->is_metadata &&
> -   block->logical_bytenr == 0))
> - printk(KERN_INFO
> -"Written block @%llu (%s/%llu/%d)"
> -" found in hash table, %c,"
> -" bytenr mismatch"
> -" (!= stored %llu).\n",

[PATCH 2/2] Btrfs: check-int: don't complain about balanced blocks

2014-10-16 Thread Stefan Behrens
The xfstest btrfs/014 which tests the balance operation caused that the
check_int module complained that known blocks changed their physical
location. Since this is not an error in this case, only print such
message if the verbose mode was enabled.

Reported-by: Wang Shilong 
Signed-off-by: Stefan Behrens 
---
 fs/btrfs/check-integrity.c | 87 ++
 1 file changed, 49 insertions(+), 38 deletions(-)

diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 65fc2e0bbc4a..65226d7c9fe0 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -1325,24 +1325,28 @@ static int btrfsic_create_link_to_next_block(
l = NULL;
next_block->generation = BTRFSIC_GENERATION_UNKNOWN;
} else {
-   if (next_block->logical_bytenr != next_bytenr &&
-   !(!next_block->is_metadata &&
- 0 == next_block->logical_bytenr)) {
-   printk(KERN_INFO
-  "Referenced block @%llu (%s/%llu/%d)"
-  " found in hash table, %c,"
-  " bytenr mismatch (!= stored %llu).\n",
-  next_bytenr, next_block_ctx->dev->name,
-  next_block_ctx->dev_bytenr, *mirror_nump,
-  btrfsic_get_block_type(state, next_block),
-  next_block->logical_bytenr);
-   } else if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE)
-   printk(KERN_INFO
-  "Referenced block @%llu (%s/%llu/%d)"
-  " found in hash table, %c.\n",
-  next_bytenr, next_block_ctx->dev->name,
-  next_block_ctx->dev_bytenr, *mirror_nump,
-  btrfsic_get_block_type(state, next_block));
+   if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) {
+   if (next_block->logical_bytenr != next_bytenr &&
+   !(!next_block->is_metadata &&
+ 0 == next_block->logical_bytenr))
+   printk(KERN_INFO
+  "Referenced block @%llu (%s/%llu/%d)"
+  " found in hash table, %c,"
+  " bytenr mismatch (!= stored %llu).\n",
+  next_bytenr, next_block_ctx->dev->name,
+  next_block_ctx->dev_bytenr, *mirror_nump,
+  btrfsic_get_block_type(state,
+ next_block),
+  next_block->logical_bytenr);
+   else
+   printk(KERN_INFO
+  "Referenced block @%llu (%s/%llu/%d)"
+  " found in hash table, %c.\n",
+  next_bytenr, next_block_ctx->dev->name,
+  next_block_ctx->dev_bytenr, *mirror_nump,
+  btrfsic_get_block_type(state,
+ next_block));
+   }
next_block->logical_bytenr = next_bytenr;
 
next_block->mirror_num = *mirror_nump;
@@ -1528,7 +1532,9 @@ static int btrfsic_handle_extent_data(
return -1;
}
if (!block_was_created) {
-   if (next_block->logical_bytenr != next_bytenr &&
+   if ((state->print_mask &
+BTRFSIC_PRINT_MASK_VERBOSE) &&
+   next_block->logical_bytenr != next_bytenr &&
!(!next_block->is_metadata &&
  0 == next_block->logical_bytenr)) {
printk(KERN_INFO
@@ -1881,25 +1887,30 @@ again:
   dev_state,
   dev_bytenr);
}
-   if (block->logical_bytenr != bytenr &&
-   !(!block->is_metadata &&
- block->logical_bytenr == 0))
-   printk(KERN_INFO
-  "Written block @%llu (%s/%llu/%d)"
-  " found in hash table, %c,"
-  " bytenr mismatch"
-  " (!= stored %llu).\n",
-  bytenr, dev_state->name, dev_bytenr,
-