linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: simplify expression in btrfs_csum_bytes_to_leaves()
@ 2016-01-26  7:13 Byongho Lee
  2016-01-26  8:10 ` Stefan Behrens
  2016-01-26 14:58 ` Byongho Lee
  0 siblings, 2 replies; 5+ messages in thread
From: Byongho Lee @ 2016-01-26  7:13 UTC (permalink / raw)
  To: linux-btrfs, dsterba

Simplify expression in btrfs_csum_bytes_to_leaves().

Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
---
 fs/btrfs/ctree.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index a9496644f47d..3ab8026280a2 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3448,8 +3448,7 @@ u64 btrfs_csum_bytes_to_leaves(struct btrfs_root *root, u64 csum_bytes);
 static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_root *root,
 						 unsigned num_items)
 {
-	return (root->nodesize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) *
-		2 * num_items;
+	return root->nodesize * BTRFS_MAX_LEVEL * 2 * num_items;
 }
 
 /*
-- 
2.7.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: simplify expression in btrfs_csum_bytes_to_leaves()
  2016-01-26  7:13 [PATCH] btrfs: simplify expression in btrfs_csum_bytes_to_leaves() Byongho Lee
@ 2016-01-26  8:10 ` Stefan Behrens
  2016-01-26  8:46   ` Byongho Lee
  2016-01-26 14:58 ` Byongho Lee
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Behrens @ 2016-01-26  8:10 UTC (permalink / raw)
  To: Byongho Lee, linux-btrfs, dsterba

The result of the calculation is different, which doesn't look right.


On Tue, 26 Jan 2016 16:13:17 +0900, Byongho Lee wrote:
> Simplify expression in btrfs_csum_bytes_to_leaves().
> 
> Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
> ---
>  fs/btrfs/ctree.h | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index a9496644f47d..3ab8026280a2 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -3448,8 +3448,7 @@ u64 btrfs_csum_bytes_to_leaves(struct btrfs_root *root, u64 csum_bytes);
>  static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_root *root,
>  						 unsigned num_items)
>  {
> -	return (root->nodesize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) *
> -		2 * num_items;
> +	return root->nodesize * BTRFS_MAX_LEVEL * 2 * num_items;
>  }
>  
>  /*
>  

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: simplify expression in btrfs_csum_bytes_to_leaves()
  2016-01-26  8:10 ` Stefan Behrens
@ 2016-01-26  8:46   ` Byongho Lee
  2016-01-26  9:03     ` Stefan Behrens
  0 siblings, 1 reply; 5+ messages in thread
From: Byongho Lee @ 2016-01-26  8:46 UTC (permalink / raw)
  To: Stefan Behrens; +Cc: linux-btrfs, dsterba


Hi Stefan,

Stefan Behrens writes:

> The result of the calculation is different, which doesn't look right.
>
The expression comes out this way.
  (root->nodesize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) * 2 * num_items
->(root->nodesize * (1 + BTRFS_MAX_LEVEL - 1)) * 2 * num_items
->(root->nodesize * (BTRFS_MAX_LEVEL)) * 2 * num_items
=>root->nodesize * BTRFS_MAX_LEVEL * 2 * num_items

Am I missing?

>
> On Tue, 26 Jan 2016 16:13:17 +0900, Byongho Lee wrote:
>> Simplify expression in btrfs_csum_bytes_to_leaves().
>> 
>> Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
>> ---
>>  fs/btrfs/ctree.h | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>> 
>> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
>> index a9496644f47d..3ab8026280a2 100644
>> --- a/fs/btrfs/ctree.h
>> +++ b/fs/btrfs/ctree.h
>> @@ -3448,8 +3448,7 @@ u64 btrfs_csum_bytes_to_leaves(struct btrfs_root *root, u64 csum_bytes);
>>  static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_root *root,
>>  						 unsigned num_items)
>>  {
>> -	return (root->nodesize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) *
>> -		2 * num_items;
>> +	return root->nodesize * BTRFS_MAX_LEVEL * 2 * num_items;
>>  }
>>  
>>  /*
>>  


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: simplify expression in btrfs_csum_bytes_to_leaves()
  2016-01-26  8:46   ` Byongho Lee
@ 2016-01-26  9:03     ` Stefan Behrens
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Behrens @ 2016-01-26  9:03 UTC (permalink / raw)
  To: Byongho Lee; +Cc: linux-btrfs, dsterba

Correction: The result of the calculation is equal, which looks right.
Sorry for overlooking the closing bracket.

Reviewed-By: Stefan Behrens <sbehrens@giantdisaster.de>


On Tue, 26 Jan 2016 17:46:00 +0900, Byongho Lee wrote:
> Stefan Behrens writes:
> 
>> The result of the calculation is different, which doesn't look right.
>>
> The expression comes out this way.
>   (root->nodesize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) * 2 * num_items
> ->(root->nodesize * (1 + BTRFS_MAX_LEVEL - 1)) * 2 * num_items
> ->(root->nodesize * (BTRFS_MAX_LEVEL)) * 2 * num_items
> =>root->nodesize * BTRFS_MAX_LEVEL * 2 * num_items
> 
> Am I missing?
> 
>>
>> On Tue, 26 Jan 2016 16:13:17 +0900, Byongho Lee wrote:
>>> Simplify expression in btrfs_csum_bytes_to_leaves().
>>>
>>> Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
>>> ---
>>>  fs/btrfs/ctree.h | 3 +--
>>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>>
>>> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
>>> index a9496644f47d..3ab8026280a2 100644
>>> --- a/fs/btrfs/ctree.h
>>> +++ b/fs/btrfs/ctree.h
>>> @@ -3448,8 +3448,7 @@ u64 btrfs_csum_bytes_to_leaves(struct btrfs_root *root, u64 csum_bytes);
>>>  static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_root *root,
>>>  						 unsigned num_items)
>>>  {
>>> -	return (root->nodesize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) *
>>> -		2 * num_items;
>>> +	return root->nodesize * BTRFS_MAX_LEVEL * 2 * num_items;
>>>  }
>>>  
>>>  /*

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: simplify expression in btrfs_csum_bytes_to_leaves()
  2016-01-26  7:13 [PATCH] btrfs: simplify expression in btrfs_csum_bytes_to_leaves() Byongho Lee
  2016-01-26  8:10 ` Stefan Behrens
@ 2016-01-26 14:58 ` Byongho Lee
  1 sibling, 0 replies; 5+ messages in thread
From: Byongho Lee @ 2016-01-26 14:58 UTC (permalink / raw)
  To: linux-btrfs, dsterba


Hi,

Please ignore this patch.  Because the function's name is wrong in the
subject line.  While I was writing the commit log, I copy & pasted the
first function's name showing in git diff result. I will prepare V2 soon.

Byongho Lee writes:

> Simplify expression in btrfs_csum_bytes_to_leaves().
>
> Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
> ---
>  fs/btrfs/ctree.h | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index a9496644f47d..3ab8026280a2 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -3448,8 +3448,7 @@ u64 btrfs_csum_bytes_to_leaves(struct btrfs_root *root, u64 csum_bytes);
>  static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_root *root,
>  						 unsigned num_items)
>  {
> -	return (root->nodesize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) *
> -		2 * num_items;
> +	return root->nodesize * BTRFS_MAX_LEVEL * 2 * num_items;
>  }
>  
>  /*


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-01-26 15:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-26  7:13 [PATCH] btrfs: simplify expression in btrfs_csum_bytes_to_leaves() Byongho Lee
2016-01-26  8:10 ` Stefan Behrens
2016-01-26  8:46   ` Byongho Lee
2016-01-26  9:03     ` Stefan Behrens
2016-01-26 14:58 ` Byongho Lee

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).