Messages in this thread Patch in this message | | | From | Denis Efremov <> | Subject | [PATCH] gfs2: Use kvmalloc instead of opencoded kmalloc/vmalloc | Date | Sat, 1 Aug 2020 00:28:18 +0300 |
| |
Use kvmalloc instead of opencoded kmalloc/vmalloc condition.
Signed-off-by: Denis Efremov <efremov@linux.com> --- fs/gfs2/dir.c | 23 ++++------------------- fs/gfs2/quota.c | 5 +---- 2 files changed, 5 insertions(+), 23 deletions(-)
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index c0f2875c946c..5d2a708fae9c 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c @@ -352,9 +352,7 @@ static __be64 *gfs2_dir_get_hash_table(struct gfs2_inode *ip) return ERR_PTR(-EIO); } - hc = kmalloc(hsize, GFP_NOFS | __GFP_NOWARN); - if (hc == NULL) - hc = __vmalloc(hsize, GFP_NOFS); + hc = kvmalloc(hsize, GFP_NOFS); if (hc == NULL) return ERR_PTR(-ENOMEM); @@ -1320,18 +1318,6 @@ static int do_filldir_main(struct gfs2_inode *dip, struct dir_context *ctx, return 0; } -static void *gfs2_alloc_sort_buffer(unsigned size) -{ - void *ptr = NULL; - - if (size < KMALLOC_MAX_SIZE) - ptr = kmalloc(size, GFP_NOFS | __GFP_NOWARN); - if (!ptr) - ptr = __vmalloc(size, GFP_NOFS); - return ptr; -} - - static int gfs2_set_cookies(struct gfs2_sbd *sdp, struct buffer_head *bh, unsigned leaf_nr, struct gfs2_dirent **darr, unsigned entries) @@ -1409,7 +1395,8 @@ static int gfs2_dir_read_leaf(struct inode *inode, struct dir_context *ctx, * 99 is the maximum number of entries that can fit in a single * leaf block. */ - larr = gfs2_alloc_sort_buffer((leaves + entries + 99) * sizeof(void *)); + larr = kvmalloc_array(leaves + entries + 99, + sizeof(void *), GFP_NOFS); if (!larr) goto out; darr = (struct gfs2_dirent **)(larr + leaves); @@ -1985,9 +1972,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len, memset(&rlist, 0, sizeof(struct gfs2_rgrp_list)); - ht = kzalloc(size, GFP_NOFS | __GFP_NOWARN); - if (ht == NULL) - ht = __vmalloc(size, GFP_NOFS | __GFP_NOWARN | __GFP_ZERO); + ht = kvzalloc(size, GFP_NOFS); if (!ht) return -ENOMEM; diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 4b67d47a7e00..204b34f38e5c 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -1362,10 +1362,7 @@ int gfs2_quota_init(struct gfs2_sbd *sdp) bm_size = DIV_ROUND_UP(sdp->sd_quota_slots, 8 * sizeof(unsigned long)); bm_size *= sizeof(unsigned long); error = -ENOMEM; - sdp->sd_quota_bitmap = kzalloc(bm_size, GFP_NOFS | __GFP_NOWARN); - if (sdp->sd_quota_bitmap == NULL) - sdp->sd_quota_bitmap = __vmalloc(bm_size, GFP_NOFS | - __GFP_ZERO); + sdp->sd_quota_bitmap = kvzalloc(bm_size, GFP_NOFS); if (!sdp->sd_quota_bitmap) return error; -- 2.26.2
| |