All of lore.kernel.org
 help / color / mirror / Atom feed
From: Byongho Lee <bhlee.kernel@gmail.com>
To: Stefan Behrens <sbehrens@giantdisaster.de>
Cc: linux-btrfs@vger.kernel.org, dsterba@suse.cz
Subject: Re: [PATCH] btrfs: simplify expression in btrfs_csum_bytes_to_leaves()
Date: Tue, 26 Jan 2016 17:46:00 +0900	[thread overview]
Message-ID: <87r3h4lodz.fsf@gmail.com> (raw)
In-Reply-To: <56A729F8.4010603@giantdisaster.de>


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;
>>  }
>>  
>>  /*
>>  


  reply	other threads:[~2016-01-26  8:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2016-01-26  9:03     ` Stefan Behrens
2016-01-26 14:58 ` Byongho Lee

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=87r3h4lodz.fsf@gmail.com \
    --to=bhlee.kernel@gmail.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=sbehrens@giantdisaster.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.