From patchwork Fri Mar 15 13:16:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 2277251 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 7C38DE00E6 for ; Fri, 15 Mar 2013 13:16:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754763Ab3CONQh (ORCPT ); Fri, 15 Mar 2013 09:16:37 -0400 Received: from mail-oa0-f49.google.com ([209.85.219.49]:53373 "EHLO mail-oa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754793Ab3CONQf (ORCPT ); Fri, 15 Mar 2013 09:16:35 -0400 Received: by mail-oa0-f49.google.com with SMTP id j6so3307336oag.8 for ; Fri, 15 Mar 2013 06:16:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=vko8VERt3eZD+PSx37/IL2XcQO0uuI5u4qnLHFI1ptI=; b=AKZUQyEdTI0bLrFz6uZwBcQcNauzFmTzwREsvjoOQ4071HGnAIUkDpPEaH690yuGPK pFJT5oSmzjAltFZ7mzb4XXkizU5EZmgqdChnk6FMS372FrubA6auyHGTnYQ7SJiLZFcH kov/I+i/s8D0EitjHHDUMfAA0fiAmUeU8VVAkKU0Iudzv1tLTMMNM7/LZ1WdQctINOMQ UaGsnHjfmImqVpi3J8dMhh6MPlFVfDSlp73lCOFSl6/g2YNcwgnftVAmiX/Mu3oOz4ZN ww3edsI0rjRf/LRFc09ReoMMOio9nAQZtqbieP6tH/BNZFdS9lqtg4fAAeSgoHvJnnwI xUVA== X-Received: by 10.60.21.38 with SMTP id s6mr2920644oee.3.1363353395483; Fri, 15 Mar 2013 06:16:35 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-107-015-113-143.nc.res.rr.com. [107.15.113.143]) by mx.google.com with ESMTPS id be1sm1517890obb.11.2013.03.15.06.16.33 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 15 Mar 2013 06:16:34 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH] nfsd: fix startup order in nfsd_reply_cache_init Date: Fri, 15 Mar 2013 09:16:29 -0400 Message-Id: <1363353389-11659-1-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.7 X-Gm-Message-State: ALoCoQk+537YMgW8gak0xPqkmBd43Cfvmg4SQ67GiZLJ8LTLgBn0cfHi1htB0baUFSDryR4WLjdF Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If we end up doing "goto out_nomem" in this function, we'll call nfsd_reply_cache_shutdown. That will attempt to walk the LRU list and free entries, but that list may not be initialized yet if the server is starting up for the first time. It's also possible for the shrinker to kick in before we've initialized the LRU list. Rearrange the initialization so that the LRU list_head and cache size are initialized before doing any of the allocations that might fail. Signed-off-by: Jeff Layton --- fs/nfsd/nfscache.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c index 62c1ee1..f5ad28e 100644 --- a/fs/nfsd/nfscache.c +++ b/fs/nfsd/nfscache.c @@ -118,6 +118,10 @@ nfsd_reply_cache_free(struct svc_cacherep *rp) int nfsd_reply_cache_init(void) { + INIT_LIST_HEAD(&lru_head); + max_drc_entries = nfsd_cache_size_limit(); + num_drc_entries = 0; + register_shrinker(&nfsd_reply_cache_shrinker); drc_slab = kmem_cache_create("nfsd_drc", sizeof(struct svc_cacherep), 0, 0, NULL); @@ -128,10 +132,6 @@ int nfsd_reply_cache_init(void) if (!cache_hash) goto out_nomem; - INIT_LIST_HEAD(&lru_head); - max_drc_entries = nfsd_cache_size_limit(); - num_drc_entries = 0; - return 0; out_nomem: printk(KERN_ERR "nfsd: failed to allocate reply cache\n");