Re: [PATCH] btrfs: Use kvzalloc instead of kzalloc/vmalloc in alloc_bitmap

2017-05-26 Thread David Sterba
On Thu, May 25, 2017 at 02:27:21PM -0700, Omar Sandoval wrote:
> On Thu, May 25, 2017 at 12:18:02PM -0700, Vinnie Magro wrote:
> > Replace alloc_bitmap with call to kvzalloc. kvzalloc preserves the
> > same fallback heuristic.
> 
> Looks good, thanks.
> 
> Reviewed-by: Omar Sandoval 

Added to queue, thanks.


Re: [PATCH] btrfs: Use kvzalloc instead of kzalloc/vmalloc in alloc_bitmap

2017-05-26 Thread David Sterba
On Thu, May 25, 2017 at 02:27:21PM -0700, Omar Sandoval wrote:
> On Thu, May 25, 2017 at 12:18:02PM -0700, Vinnie Magro wrote:
> > Replace alloc_bitmap with call to kvzalloc. kvzalloc preserves the
> > same fallback heuristic.
> 
> Looks good, thanks.
> 
> Reviewed-by: Omar Sandoval 

Added to queue, thanks.


Re: [PATCH] btrfs: Use kvzalloc instead of kzalloc/vmalloc in alloc_bitmap

2017-05-25 Thread Omar Sandoval
On Thu, May 25, 2017 at 12:18:02PM -0700, Vinnie Magro wrote:
> Replace alloc_bitmap with call to kvzalloc. kvzalloc preserves the
> same fallback heuristic.

Looks good, thanks.

Reviewed-by: Omar Sandoval 

> Signed-off-by: Vinnie Magro 
> ---
>  fs/btrfs/free-space-tree.c | 23 ++-
>  1 file changed, 2 insertions(+), 21 deletions(-)
> 
> diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
> index fc0bd84..9e87129 100644
> --- a/fs/btrfs/free-space-tree.c
> +++ b/fs/btrfs/free-space-tree.c
> @@ -151,25 +151,6 @@ static inline u32 free_space_bitmap_size(u64 size, u32 
> sectorsize)
>   return DIV_ROUND_UP((u32)div_u64(size, sectorsize), BITS_PER_BYTE);
>  }
>  
> -static u8 *alloc_bitmap(u32 bitmap_size)
> -{
> - void *mem;
> -
> - /*
> -  * The allocation size varies, observed numbers were < 4K up to 16K.
> -  * Using vmalloc unconditionally would be too heavy, we'll try
> -  * contiguous allocations first.
> -  */
> - if  (bitmap_size <= PAGE_SIZE)
> - return kzalloc(bitmap_size, GFP_NOFS);
> -
> - mem = kzalloc(bitmap_size, GFP_NOFS | __GFP_NOWARN);
> - if (mem)
> - return mem;
> -
> - return __vmalloc(bitmap_size, GFP_NOFS | __GFP_ZERO, PAGE_KERNEL);
> -}
> -
>  int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
> struct btrfs_fs_info *fs_info,
> struct btrfs_block_group_cache *block_group,
> @@ -189,7 +170,7 @@ int convert_free_space_to_bitmaps(struct 
> btrfs_trans_handle *trans,
>  
>   bitmap_size = free_space_bitmap_size(block_group->key.offset,
>fs_info->sectorsize);
> - bitmap = alloc_bitmap(bitmap_size);
> + bitmap = kvzalloc(bitmap_size, GFP_NOFS);
>   if (!bitmap) {
>   ret = -ENOMEM;
>   goto out;
> @@ -330,7 +311,7 @@ int convert_free_space_to_extents(struct 
> btrfs_trans_handle *trans,
>  
>   bitmap_size = free_space_bitmap_size(block_group->key.offset,
>fs_info->sectorsize);
> - bitmap = alloc_bitmap(bitmap_size);
> + bitmap = kvzalloc(bitmap_size, GFP_NOFS);
>   if (!bitmap) {
>   ret = -ENOMEM;
>   goto out;
> -- 
> 2.9.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] btrfs: Use kvzalloc instead of kzalloc/vmalloc in alloc_bitmap

2017-05-25 Thread Omar Sandoval
On Thu, May 25, 2017 at 12:18:02PM -0700, Vinnie Magro wrote:
> Replace alloc_bitmap with call to kvzalloc. kvzalloc preserves the
> same fallback heuristic.

Looks good, thanks.

Reviewed-by: Omar Sandoval 

> Signed-off-by: Vinnie Magro 
> ---
>  fs/btrfs/free-space-tree.c | 23 ++-
>  1 file changed, 2 insertions(+), 21 deletions(-)
> 
> diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
> index fc0bd84..9e87129 100644
> --- a/fs/btrfs/free-space-tree.c
> +++ b/fs/btrfs/free-space-tree.c
> @@ -151,25 +151,6 @@ static inline u32 free_space_bitmap_size(u64 size, u32 
> sectorsize)
>   return DIV_ROUND_UP((u32)div_u64(size, sectorsize), BITS_PER_BYTE);
>  }
>  
> -static u8 *alloc_bitmap(u32 bitmap_size)
> -{
> - void *mem;
> -
> - /*
> -  * The allocation size varies, observed numbers were < 4K up to 16K.
> -  * Using vmalloc unconditionally would be too heavy, we'll try
> -  * contiguous allocations first.
> -  */
> - if  (bitmap_size <= PAGE_SIZE)
> - return kzalloc(bitmap_size, GFP_NOFS);
> -
> - mem = kzalloc(bitmap_size, GFP_NOFS | __GFP_NOWARN);
> - if (mem)
> - return mem;
> -
> - return __vmalloc(bitmap_size, GFP_NOFS | __GFP_ZERO, PAGE_KERNEL);
> -}
> -
>  int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
> struct btrfs_fs_info *fs_info,
> struct btrfs_block_group_cache *block_group,
> @@ -189,7 +170,7 @@ int convert_free_space_to_bitmaps(struct 
> btrfs_trans_handle *trans,
>  
>   bitmap_size = free_space_bitmap_size(block_group->key.offset,
>fs_info->sectorsize);
> - bitmap = alloc_bitmap(bitmap_size);
> + bitmap = kvzalloc(bitmap_size, GFP_NOFS);
>   if (!bitmap) {
>   ret = -ENOMEM;
>   goto out;
> @@ -330,7 +311,7 @@ int convert_free_space_to_extents(struct 
> btrfs_trans_handle *trans,
>  
>   bitmap_size = free_space_bitmap_size(block_group->key.offset,
>fs_info->sectorsize);
> - bitmap = alloc_bitmap(bitmap_size);
> + bitmap = kvzalloc(bitmap_size, GFP_NOFS);
>   if (!bitmap) {
>   ret = -ENOMEM;
>   goto out;
> -- 
> 2.9.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] btrfs: Use kvzalloc instead of kzalloc/vmalloc in alloc_bitmap

2017-05-25 Thread Vinnie Magro
Replace alloc_bitmap with call to kvzalloc. kvzalloc preserves the
same fallback heuristic.

Signed-off-by: Vinnie Magro 
---
 fs/btrfs/free-space-tree.c | 23 ++-
 1 file changed, 2 insertions(+), 21 deletions(-)

diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index fc0bd84..9e87129 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -151,25 +151,6 @@ static inline u32 free_space_bitmap_size(u64 size, u32 
sectorsize)
return DIV_ROUND_UP((u32)div_u64(size, sectorsize), BITS_PER_BYTE);
 }
 
-static u8 *alloc_bitmap(u32 bitmap_size)
-{
-   void *mem;
-
-   /*
-* The allocation size varies, observed numbers were < 4K up to 16K.
-* Using vmalloc unconditionally would be too heavy, we'll try
-* contiguous allocations first.
-*/
-   if  (bitmap_size <= PAGE_SIZE)
-   return kzalloc(bitmap_size, GFP_NOFS);
-
-   mem = kzalloc(bitmap_size, GFP_NOFS | __GFP_NOWARN);
-   if (mem)
-   return mem;
-
-   return __vmalloc(bitmap_size, GFP_NOFS | __GFP_ZERO, PAGE_KERNEL);
-}
-
 int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
  struct btrfs_fs_info *fs_info,
  struct btrfs_block_group_cache *block_group,
@@ -189,7 +170,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle 
*trans,
 
bitmap_size = free_space_bitmap_size(block_group->key.offset,
 fs_info->sectorsize);
-   bitmap = alloc_bitmap(bitmap_size);
+   bitmap = kvzalloc(bitmap_size, GFP_NOFS);
if (!bitmap) {
ret = -ENOMEM;
goto out;
@@ -330,7 +311,7 @@ int convert_free_space_to_extents(struct btrfs_trans_handle 
*trans,
 
bitmap_size = free_space_bitmap_size(block_group->key.offset,
 fs_info->sectorsize);
-   bitmap = alloc_bitmap(bitmap_size);
+   bitmap = kvzalloc(bitmap_size, GFP_NOFS);
if (!bitmap) {
ret = -ENOMEM;
goto out;
-- 
2.9.3



[PATCH] btrfs: Use kvzalloc instead of kzalloc/vmalloc in alloc_bitmap

2017-05-25 Thread Vinnie Magro
Replace alloc_bitmap with call to kvzalloc. kvzalloc preserves the
same fallback heuristic.

Signed-off-by: Vinnie Magro 
---
 fs/btrfs/free-space-tree.c | 23 ++-
 1 file changed, 2 insertions(+), 21 deletions(-)

diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index fc0bd84..9e87129 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -151,25 +151,6 @@ static inline u32 free_space_bitmap_size(u64 size, u32 
sectorsize)
return DIV_ROUND_UP((u32)div_u64(size, sectorsize), BITS_PER_BYTE);
 }
 
-static u8 *alloc_bitmap(u32 bitmap_size)
-{
-   void *mem;
-
-   /*
-* The allocation size varies, observed numbers were < 4K up to 16K.
-* Using vmalloc unconditionally would be too heavy, we'll try
-* contiguous allocations first.
-*/
-   if  (bitmap_size <= PAGE_SIZE)
-   return kzalloc(bitmap_size, GFP_NOFS);
-
-   mem = kzalloc(bitmap_size, GFP_NOFS | __GFP_NOWARN);
-   if (mem)
-   return mem;
-
-   return __vmalloc(bitmap_size, GFP_NOFS | __GFP_ZERO, PAGE_KERNEL);
-}
-
 int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
  struct btrfs_fs_info *fs_info,
  struct btrfs_block_group_cache *block_group,
@@ -189,7 +170,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle 
*trans,
 
bitmap_size = free_space_bitmap_size(block_group->key.offset,
 fs_info->sectorsize);
-   bitmap = alloc_bitmap(bitmap_size);
+   bitmap = kvzalloc(bitmap_size, GFP_NOFS);
if (!bitmap) {
ret = -ENOMEM;
goto out;
@@ -330,7 +311,7 @@ int convert_free_space_to_extents(struct btrfs_trans_handle 
*trans,
 
bitmap_size = free_space_bitmap_size(block_group->key.offset,
 fs_info->sectorsize);
-   bitmap = alloc_bitmap(bitmap_size);
+   bitmap = kvzalloc(bitmap_size, GFP_NOFS);
if (!bitmap) {
ret = -ENOMEM;
goto out;
-- 
2.9.3