mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-04-19 22:17:39 +07:00
btrfs: replace opencoded kvzalloc with the helper
The logic of kmalloc and vmalloc fallback is opencoded in several places, we can now use the existing helper. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
1e9d7291e5
commit
818e010bf9
@ -94,7 +94,7 @@
|
|||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
#include <linux/genhd.h>
|
#include <linux/genhd.h>
|
||||||
#include <linux/blkdev.h>
|
#include <linux/blkdev.h>
|
||||||
#include <linux/vmalloc.h>
|
#include <linux/mm.h>
|
||||||
#include <linux/string.h>
|
#include <linux/string.h>
|
||||||
#include "ctree.h"
|
#include "ctree.h"
|
||||||
#include "disk-io.h"
|
#include "disk-io.h"
|
||||||
@ -2920,14 +2920,11 @@ int btrfsic_mount(struct btrfs_fs_info *fs_info,
|
|||||||
fs_info->sectorsize, PAGE_SIZE);
|
fs_info->sectorsize, PAGE_SIZE);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
state = kzalloc(sizeof(*state), GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT);
|
state = kvzalloc(sizeof(*state), GFP_KERNEL);
|
||||||
if (!state) {
|
if (!state) {
|
||||||
state = vzalloc(sizeof(*state));
|
pr_info("btrfs check-integrity: allocation failed!\n");
|
||||||
if (!state) {
|
|
||||||
pr_info("btrfs check-integrity: vzalloc() failed!\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!btrfsic_is_initialized) {
|
if (!btrfsic_is_initialized) {
|
||||||
mutex_init(&btrfsic_mutex);
|
mutex_init(&btrfsic_mutex);
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include <linux/hash.h>
|
#include <linux/hash.h>
|
||||||
#include <linux/list_sort.h>
|
#include <linux/list_sort.h>
|
||||||
#include <linux/raid/xor.h>
|
#include <linux/raid/xor.h>
|
||||||
#include <linux/vmalloc.h>
|
#include <linux/mm.h>
|
||||||
#include <asm/div64.h>
|
#include <asm/div64.h>
|
||||||
#include "ctree.h"
|
#include "ctree.h"
|
||||||
#include "extent_map.h"
|
#include "extent_map.h"
|
||||||
@ -218,12 +218,9 @@ int btrfs_alloc_stripe_hash_table(struct btrfs_fs_info *info)
|
|||||||
* of a failing mount.
|
* of a failing mount.
|
||||||
*/
|
*/
|
||||||
table_size = sizeof(*table) + sizeof(*h) * num_entries;
|
table_size = sizeof(*table) + sizeof(*h) * num_entries;
|
||||||
table = kzalloc(table_size, GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT);
|
table = kvzalloc(table_size, GFP_KERNEL);
|
||||||
if (!table) {
|
|
||||||
table = vzalloc(table_size);
|
|
||||||
if (!table)
|
if (!table)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
|
||||||
|
|
||||||
spin_lock_init(&table->cache_lock);
|
spin_lock_init(&table->cache_lock);
|
||||||
INIT_LIST_HEAD(&table->stripe_cache);
|
INIT_LIST_HEAD(&table->stripe_cache);
|
||||||
|
@ -6389,14 +6389,11 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
|
|||||||
|
|
||||||
alloc_size = sizeof(struct clone_root) * (arg->clone_sources_count + 1);
|
alloc_size = sizeof(struct clone_root) * (arg->clone_sources_count + 1);
|
||||||
|
|
||||||
sctx->clone_roots = kzalloc(alloc_size, GFP_KERNEL | __GFP_NOWARN);
|
sctx->clone_roots = kzalloc(alloc_size, GFP_KERNEL);
|
||||||
if (!sctx->clone_roots) {
|
|
||||||
sctx->clone_roots = vzalloc(alloc_size);
|
|
||||||
if (!sctx->clone_roots) {
|
if (!sctx->clone_roots) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
alloc_size = arg->clone_sources_count * sizeof(*arg->clone_sources);
|
alloc_size = arg->clone_sources_count * sizeof(*arg->clone_sources);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user