Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp370520pxa; Fri, 31 Jul 2020 14:30:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxR4KKvdqGGk+kpP0W5L+W5Tlcj+vblG2A1nRgLho4yrKBftuLfOLOjWFUU6o945J2XNB3j X-Received: by 2002:a05:6402:1d0a:: with SMTP id dg10mr5587217edb.110.1596231055883; Fri, 31 Jul 2020 14:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596231055; cv=none; d=google.com; s=arc-20160816; b=duR1fkEMloUX2LF2I3u3Oo7Elyg4zZ1z8O9alxSWMws03D0jVmgPGrCR2YZHT95cMu HCTuBZY5qDJHfK43OGb9CPI0q6fNs4YlOfhljkextzVHtpGjIBzO4RSaxly0T8PUUHCQ tXE6OQxt0UCyMmecv2wpQ7cehNiv+YDeXkT9M8Hj5AuJys2eZDZDulhkTKrtxNQN6Go8 xF4IBbzvcFdrW8QkJ4d7sHbnFw+yoSQaVIqv/Xl0AfGyWpL5kpM/0mKAZ2lIhy1fg8Ea dKf5PJNFSZLaMJsLrfC5bZq8QesIkrwi+WkWHvmMGAA0TwXohWPDB8Abvx0rBMUUQXxk Q73w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=2LM9wmlkgT4PsRWE1wCcqgQWCXbjCWE/5JCh3nJ0oCA=; b=wFxLJ5oDWI+n65E8a1CnufuUa8e2+XZTmv9WgsM0afRPO+DkfJltrzj44SGzkYoIRl V0uR3Szq/31eTmfulycguOjOUzUnye78AwBeSJ26fIgwnVRO3BWSkOpJMgccijwIZV1W nH/zNJ75j4Hx/Rujos087brFxJ1TrAJrcmJ0ptr7wAKWYFJWwhbt2Ud/hfuUjEdEi5So DGsFEMoutCPXl7y/zdqIiU9VhHgW1QDNVcsXx5qolry0LJKkLO2WrUWZtgndPsro2V06 05iYwsdcyARmxN/sGPxn1+P2xtsWLJ7TVE2mfyuT/nFdzg86wEuLC/c6cD6lzQ5IIVkB s+ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t2si5773073eje.689.2020.07.31.14.30.33; Fri, 31 Jul 2020 14:30:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728000AbgGaV2Y (ORCPT + 99 others); Fri, 31 Jul 2020 17:28:24 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:35412 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726806AbgGaV2Y (ORCPT ); Fri, 31 Jul 2020 17:28:24 -0400 Received: by mail-lf1-f67.google.com with SMTP id j22so11683172lfm.2 for ; Fri, 31 Jul 2020 14:28:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2LM9wmlkgT4PsRWE1wCcqgQWCXbjCWE/5JCh3nJ0oCA=; b=FdGu0jzP55VSvuvrqU/RWMTfZf6fu1vgUm4hY4m2jV580ml9lYmmqQghBcSlrhkTzR KpxaKRwYqtEiHep/ODjxcaE7THQkaLucc2GCXxjXsJsVtnQTgd8bvVRU4w8XJBxVZ9oz pO9JiEnhcOJYxekCkwE8+mC7SxU/T+Anm9ZZ24ExsU/i+DEtjDgRvgQ6qLa+V0UiqQMG +xGUxtHyHVb2EcC+SM7IZ9IC7VwVL5ZfMzMarvsCX6yjZa3RhwYp7I3hT3Gz8kZgZjbK ozxSMOrZzTHgL6opmfEW94tFLtwNvwFPC4MQFZo3L3DFRNH9Ie36zo+o3izmHEj9J0HF ZAWA== X-Gm-Message-State: AOAM533VrlBiLAoM6bG9Rsub5oiZPqOmj2bDgagNNcoiEtCEaznJ2h5y GqsWq6Btfs0K+sb6vBrr6VoUbNvVljg= X-Received: by 2002:a19:e50:: with SMTP id 77mr2864709lfo.188.1596230902010; Fri, 31 Jul 2020 14:28:22 -0700 (PDT) Received: from localhost.localdomain (broadband-37-110-38-130.ip.moscow.rt.ru. [37.110.38.130]) by smtp.googlemail.com with ESMTPSA id y1sm2643326lfb.45.2020.07.31.14.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 14:28:21 -0700 (PDT) From: Denis Efremov To: Bob Peterson , Andreas Gruenbacher Cc: Denis Efremov , cluster-devel@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCH] gfs2: Use kvmalloc instead of opencoded kmalloc/vmalloc Date: Sat, 1 Aug 2020 00:28:18 +0300 Message-Id: <20200731212818.10782-1-efremov@linux.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use kvmalloc instead of opencoded kmalloc/vmalloc condition. Signed-off-by: Denis Efremov --- 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