Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp604983pxb; Tue, 5 Apr 2022 15:42:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBmW2TKo1L6DO7SySifD6QD9Aiwt3HEm8/ko6ULeYct/TpzWUbeydlwbDEl9yt3UwUaY9p X-Received: by 2002:a05:6a00:894:b0:4fe:25d7:f59e with SMTP id q20-20020a056a00089400b004fe25d7f59emr5891530pfj.58.1649198532427; Tue, 05 Apr 2022 15:42:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649198532; cv=none; d=google.com; s=arc-20160816; b=gIcbjuVskobvwYdAiVNQ54v2a2sFycGfVUg5KJwNXLAOXiiHPthEGEGd4fTOhz0Guh Wu7cOYWhN7fshZpmX3SG6D9prn+ql6OR5Ej4DrBlMjX3egn6D7cp52OGYiTc2HU0Iiq/ PSoGojUBEFR//UZrD7DtNg19QLDr98X4MHmkc2akIg6YCXo63RUd6nijXgCBL8rfOqra Aa+2L45evfYWbf9ACIo4v6b+2Ik+Qeo23VmktSsSV4xEIiCAVv9CgzGIItgeq7m2v+CR zFbkN77jdDsUZ2cAua36+oMhLhb/JFtXgoK+mOru6sTNZRcRx2U86a0UWN11fbN92QE+ 1cfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MfNMZ9eSBaDKbsZZzY7qk8M1fvuLaJylcs9cLfmNRtQ=; b=vvTitPe35Or5fALCnDlOQOUyeYjQ0280da7qMTAxkhl+JSiQtV7siu54v7N+REFuE9 bM+uNuFRGZsJAqs5+lq3EQCfrC6Ii91VQEfLXrQp5Ebt4L06XyBdtGldWAXKG8uNBmrk vCX+7qCAyBi8Qb8xf3i2C2tZo5MdrklGjlK2Lrh0Ecxa9fASNOtdwRL/y6xvRv6Bj5S4 D6q9OilqkP/Lp+TCz9gYvM88mANDbWlFdhcR67kmC1nx6NDubo/5wiHreW3fidKqfQc/ Re1d2mazSmac70m03UYCo0Bma1OI6n3fFIWmo8sRPROGRD/IcU1Haw8eaJg3yXzbNqez Hlwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pk8kbJLg; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id c2-20020a170902d48200b00153b2d16453si15264990plg.91.2022.04.05.15.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 15:42:12 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pk8kbJLg; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 26678443EB; Tue, 5 Apr 2022 15:23:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346606AbiDEPSH (ORCPT + 99 others); Tue, 5 Apr 2022 11:18:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346746AbiDEJpZ (ORCPT ); Tue, 5 Apr 2022 05:45:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11D66DB4B0; Tue, 5 Apr 2022 02:31:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A4BF8B81CBC; Tue, 5 Apr 2022 09:31:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7311FC385A2; Tue, 5 Apr 2022 09:31:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151098; bh=73W+wrV+pltzRuWYHC+jUw+ORe5Zrq6RlCWY8xI8l3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pk8kbJLg0EyT57EQ7AcGFFJcW0YES3iIQfzUznukgR0q/0wbBMrhxscZjuv+e4cwe goQ6G3YX6fq+ewaCeis6Z9juR2ClhZoWnFJwhjSl7J73Oah6+ZbH0pdGnHQcY80hgn Ma16a32O1yrYY49Id9qOmKGoJQcjciG5Ht6KDxvg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeff Layton , Amir Goldstein , Chuck Lever , Sasha Levin Subject: [PATCH 5.15 255/913] nfsd: more robust allocation failure handling in nfsd_file_cache_init Date: Tue, 5 Apr 2022 09:21:57 +0200 Message-Id: <20220405070347.499400402@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Amir Goldstein [ Upstream commit 4d2eeafecd6c83b4444db3dc0ada201c89b1aa44 ] The nfsd file cache table can be pretty large and its allocation may require as many as 80 contigious pages. Employ the same fix that was employed for similar issue that was reported for the reply cache hash table allocation several years ago by commit 8f97514b423a ("nfsd: more robust allocation failure handling in nfsd_reply_cache_init"). Fixes: 65294c1f2c5e ("nfsd: add a new struct file caching facility to nfsd") Link: https://lore.kernel.org/linux-nfs/e3cdaeec85a6cfec980e87fc294327c0381c1778.camel@kernel.org/ Suggested-by: Jeff Layton Signed-off-by: Amir Goldstein Reviewed-by: Jeff Layton Signed-off-by: Chuck Lever Tested-by: Amir Goldstein Signed-off-by: Sasha Levin --- fs/nfsd/filecache.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index be3c1aad50ea..7e23c588f484 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -641,7 +641,7 @@ nfsd_file_cache_init(void) if (!nfsd_filecache_wq) goto out; - nfsd_file_hashtbl = kcalloc(NFSD_FILE_HASH_SIZE, + nfsd_file_hashtbl = kvcalloc(NFSD_FILE_HASH_SIZE, sizeof(*nfsd_file_hashtbl), GFP_KERNEL); if (!nfsd_file_hashtbl) { pr_err("nfsd: unable to allocate nfsd_file_hashtbl\n"); @@ -709,7 +709,7 @@ nfsd_file_cache_init(void) nfsd_file_slab = NULL; kmem_cache_destroy(nfsd_file_mark_slab); nfsd_file_mark_slab = NULL; - kfree(nfsd_file_hashtbl); + kvfree(nfsd_file_hashtbl); nfsd_file_hashtbl = NULL; destroy_workqueue(nfsd_filecache_wq); nfsd_filecache_wq = NULL; @@ -855,7 +855,7 @@ nfsd_file_cache_shutdown(void) fsnotify_wait_marks_destroyed(); kmem_cache_destroy(nfsd_file_mark_slab); nfsd_file_mark_slab = NULL; - kfree(nfsd_file_hashtbl); + kvfree(nfsd_file_hashtbl); nfsd_file_hashtbl = NULL; destroy_workqueue(nfsd_filecache_wq); nfsd_filecache_wq = NULL; -- 2.34.1