linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: Use DIV_ROUND_UP rathen than opencoding it
@ 2017-09-28 13:48 Nikolay Borisov
  2017-10-04 14:49 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Nikolay Borisov @ 2017-09-28 13:48 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/extent-tree.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index e2d7e86b51d1..9e67616892cd 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2896,9 +2896,8 @@ u64 btrfs_csum_bytes_to_leaves(struct btrfs_fs_info *fs_info, u64 csum_bytes)
 	num_csums_per_leaf = div64_u64(csum_size,
 			(u64)btrfs_super_csum_size(fs_info->super_copy));
 	num_csums = div64_u64(csum_bytes, fs_info->sectorsize);
-	num_csums += num_csums_per_leaf - 1;
-	num_csums = div64_u64(num_csums, num_csums_per_leaf);
-	return num_csums;
+
+	return DIV_ROUND_UP(num_csums, num_csums_per_leaf);
 }
 
 int btrfs_check_space_for_delayed_refs(struct btrfs_trans_handle *trans,
-- 
2.7.4


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

* Re: [PATCH] btrfs: Use DIV_ROUND_UP rathen than opencoding it
  2017-09-28 13:48 [PATCH] btrfs: Use DIV_ROUND_UP rathen than opencoding it Nikolay Borisov
@ 2017-10-04 14:49 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2017-10-04 14:49 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: linux-btrfs

On Thu, Sep 28, 2017 at 04:48:19PM +0300, Nikolay Borisov wrote:
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>  fs/btrfs/extent-tree.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index e2d7e86b51d1..9e67616892cd 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -2896,9 +2896,8 @@ u64 btrfs_csum_bytes_to_leaves(struct btrfs_fs_info *fs_info, u64 csum_bytes)
>  	num_csums_per_leaf = div64_u64(csum_size,
>  			(u64)btrfs_super_csum_size(fs_info->super_copy));
>  	num_csums = div64_u64(csum_bytes, fs_info->sectorsize);
> -	num_csums += num_csums_per_leaf - 1;
> -	num_csums = div64_u64(num_csums, num_csums_per_leaf);
> -	return num_csums;
> +
> +	return DIV_ROUND_UP(num_csums, num_csums_per_leaf);

DIV_ROUND_UP ends up as plain division (/) so this will not work on
32bit. We need to keep it opencoded, or convert all the relevant
variabless to 32bit first.

#define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP
#define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))

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

end of thread, other threads:[~2017-10-04 14:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-28 13:48 [PATCH] btrfs: Use DIV_ROUND_UP rathen than opencoding it Nikolay Borisov
2017-10-04 14:49 ` David Sterba

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