raid5: use kmalloc_array() for GFP_NOIO flag
PATCH 1/1 raid5: use kmalloc_array() for GFP_NOIO flag
Commit b330e6a49dc3 ("md: convert to kvmalloc") uses kvmalloc_array() to allocate memory with GFP_NOIO flag in resize_chunks() via function scribble_alloc(),
2269 err = scribble_alloc(percpu, new_disks,
2270 new_sectors / STRIPE_SECTORS,
2271 GFP_NOIO);
Indeed kvmalloc() inside kvmalloc_array() does not accept non GFP_KERNEL compatible flags, it means GFP_NOIO will make kvmalloc_node() call kmalloc_node() instead, which is not the above listed code wants.
For md raid1 and raid10 code, such allocation just simply calls kmalloc_array(), which is enough and works fine. This patch removes the misleading kvmalloc_array() and simply uses kmalloc_array() as md raid1 and raid10 code do.
--- drivers/md/raid5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid5.c +1 -1
@@ -2235,7 +2235,7 @@ static int scribble_alloc(struct raid5_percpu *percpu,sizeof (addr_conv_t) * (num+2 );void *scribble; - scribble =kvmalloc_array (cnt, obj_size, flags); + scribble =kmalloc_array (cnt, obj_size, flags);if (!scribble)return -ENOMEM ;
Signature · 1 line
2.25.0
Quoted 30 lines · Coly Li
Commit
b330e6a49dc3("md: convert to kvmalloc") useskvmalloc_array()to allocate memory withGFP_NOIOflag inresize_chunks()via functionscribble_alloc(),
2269 err = scribble_alloc(percpu,new_disks,
2270new_sectors/STRIPE_SECTORS,
2271GFP_NOIO);Indeed
kvmalloc()insidekvmalloc_array()does not accept nonGFP_KERNELcompatible flags, it meansGFP_NOIOwill makekvmalloc_node()callkmalloc_node()instead, which is not the above listed code wants.For md raid1 and raid10 code, such allocation just simply calls
kmalloc_array(), which is enough and works fine. This patch removes the misleadingkvmalloc_array()and simply useskmalloc_array()as md raid1 and raid10 code do.Fixes b330e6a49dc3 ("md: convert to kvmalloc")Signed-off-by Coly Li <[email protected]>Cc Kent Overstreet <[email protected]>Cc Michal Hocko <[email protected]>--- drivers/md/raid5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/md/raid5.c +0
-0
drivers/md/raid5.c static int scribble_alloc(struct raid5_percpu *percpu, · line 2241
Quoted 8 lines
drivers/md/raid5.c +1
-1@@ -2235,7 +2235,7 @@ static int scribble_alloc(struct raid5_percpu *percpu,sizeof (addr_conv_t) * (num+2 );void *scribble; - scribble =kvmalloc_array (cnt, obj_size, flags); + scribble =kmalloc_array (cnt, obj_size, flags);if (!scribble)return -ENOMEM ;
I will post another version to use memalloc_noio_save()/restore() scope APIs. Please ignore this patch.
Thanks.
Signature · 1 line
Coly Li