The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.47.x-ovz" and will 
appear at
after rh7-3.10.0-693.21.1.vz7.47.6
commit ae090f2a94c81548c6bb456eb9fd888b4a8e7d74
Author: Jeff Layton <>
Date:   Wed May 16 11:18:12 2018 +0300

    ms/nfsd: more robust allocation failure handling in nfsd_reply_cache_init
    Currently, we try to allocate the cache as a single, large chunk, which
    can fail if no big chunks of memory are available. We _do_ try to size
    it according to the amount of memory in the box, but if the server is
    started well after boot time, then the allocation can fail due to memory
    Fall back to doing a vzalloc if the kcalloc fails, and switch the
    shutdown code to do a kvfree to handle freeing correctly.
    Reported-by: Olaf Hering <>
    Cc: Linus Torvalds <>
    Signed-off-by: Jeff Layton <>
    Signed-off-by: J. Bruce Fields <>
    ms commit 8f97514b423a0983e4c600099882a9c6613142d2
    Signed-off-by: Oleg Babin <>
    Patchset description:
    nfsd: use kvzalloc() to allocate memory for drc_hashtbl
    The size of drc_hashtbl depends on totalram_pages and totalhigh_pages
    mm variables and limited to 96k which means 5th memory order.
    Use kvzalloc() for drc_hashtbl allocation to fallback to vmalloc()
    in case of high order page is not available at the moment.
    v2: Make use of the mainstream patch which partially fixes the problem.
    Jeff Layton (1):
      nfsd: more robust allocation failure handling in nfsd_reply_cache_init
    Oleg Babin (1):
      nfsd: use kvzalloc() to allocate memory for drc_hashtbl
 fs/nfsd/nfscache.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
index a4fa08e6acd3..b5c25eaeaae2 100644
--- a/fs/nfsd/nfscache.c
+++ b/fs/nfsd/nfscache.c
@@ -9,6 +9,7 @@
 #include <linux/slab.h>
+#include <linux/vmalloc.h>
 #include <linux/sunrpc/addr.h>
 #include <linux/highmem.h>
 #include <linux/log2.h>
@@ -178,8 +179,12 @@ int nfsd_reply_cache_init(void)
                goto out_nomem;
        drc_hashtbl = kcalloc(hashsize, sizeof(*drc_hashtbl), GFP_KERNEL);
-       if (!drc_hashtbl)
-               goto out_nomem;
+       if (!drc_hashtbl) {
+               drc_hashtbl = vzalloc(hashsize * sizeof(*drc_hashtbl));
+               if (!drc_hashtbl)
+                       goto out_nomem;
+       }
        for (i = 0; i < hashsize; i++) {
@@ -209,7 +214,7 @@ void nfsd_reply_cache_shutdown(void)
-       kfree (drc_hashtbl);
+       kvfree(drc_hashtbl);
        drc_hashtbl = NULL;
        drc_hashsize = 0;
Devel mailing list

Reply via email to