btrfs: simplify expression in btrfs_csum_bytes_to_leaves()
PATCH 1/1 btrfs: simplify expression in btrfs_csum_bytes_to_leaves()
Simplify expression in btrfs_csum_bytes_to_leaves().
--- fs/btrfs/ctree.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/ctree.h +1 -2
@@ -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; }/*
Signature · 1 line
2.7.0
The result of the calculation is different, which doesn't look right.
Quoted 22 lines · Byongho Lee
Simplify expression in
btrfs_csum_bytes_to_leaves().Signed-off-by Byongho Lee <[email protected]>--- fs/btrfs/ctree.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/btrfs/ctree.h +1
-2@@ -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; }/*
Hi Stefan,
Quoted 2 lines · Stefan Behrens
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?
Quoted 24 lines · Byongho Lee
Quoted 22 lines
Simplify expression in
btrfs_csum_bytes_to_leaves().Signed-off-by Byongho Lee <[email protected]>--- fs/btrfs/ctree.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/btrfs/ctree.h +1
-2@@ -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; }/*
Stefan Behrens
Reviewed-byCorrection: The result of the calculation is equal, which looks right. Sorry for overlooking the closing bracket.
Quoted 35 lines · Byongho Lee
Quoted 2 lines · Stefan Behrens
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_itemsAm I missing?
Quoted 23 lines · Byongho Lee
Quoted 21 lines
Simplify expression in
btrfs_csum_bytes_to_leaves().Signed-off-by Byongho Lee <[email protected]>--- fs/btrfs/ctree.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/btrfs/ctree.h +1
-2@@ -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; }/*
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.
Quoted 21 lines · Byongho Lee
Simplify expression in
btrfs_csum_bytes_to_leaves().Signed-off-by Byongho Lee <[email protected]>--- fs/btrfs/ctree.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/btrfs/ctree.h +1
-2@@ -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; }/*