From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.6 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C29C8C433E2 for ; Wed, 2 Sep 2020 04:22:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7D23F20709 for ; Wed, 2 Sep 2020 04:22:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="c88WkDd9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D23F20709 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0B4FB6B0003; Wed, 2 Sep 2020 00:22:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 03E2D6B005A; Wed, 2 Sep 2020 00:22:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E48436B005C; Wed, 2 Sep 2020 00:22:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0106.hostedemail.com [216.40.44.106]) by kanga.kvack.org (Postfix) with ESMTP id C95866B0003 for ; Wed, 2 Sep 2020 00:22:33 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7F3EC8248047 for ; Wed, 2 Sep 2020 04:22:33 +0000 (UTC) X-FDA: 77216824986.12.food67_39108832709e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 51BB218013E38 for ; Wed, 2 Sep 2020 04:22:33 +0000 (UTC) X-HE-Tag: food67_39108832709e X-Filterd-Recvd-Size: 5040 Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Wed, 2 Sep 2020 04:22:32 +0000 (UTC) Received: by mail-qt1-f194.google.com with SMTP id z2so2686788qtv.12 for ; Tue, 01 Sep 2020 21:22:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=l6CoZr0F56z7vGGkZxHqFEtyYx6mlMWzZpAv9vqAiw4=; b=c88WkDd917M/cYNeWf6xj5kM/aoxt59h5QaRarY1afOxjFbA0eX22XVA1VEXfl+YrU thRAmHc27PJHXMbo8K+BLvv1punKWheQh8saPbtzDwSc+KBpmJOnFh7RaD8gp8AvVRbe 0aTjWL9rQHFK6+dHFunm1JSGcAR3UofL7UOg7wZYQC0LzYnvKAzuPwFRsCSVGhmwhGMQ HDWW4O4ertLL+H1dJ7mJ1+e96L4RGYn+WbNsGTvX08jPsFkgpVYO0r0S1aizowMwYrq3 98RkENlEz7pz4ZIHuceXZzejLdMk2YW8xuzIDXiV9XWUrB7wa6coMsv/OvT5iTGCVs9a etcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=l6CoZr0F56z7vGGkZxHqFEtyYx6mlMWzZpAv9vqAiw4=; b=ZNrEfDQt+DtR+klg2/XfUZ9x7KA5zLCnFtGcceiIdXrEFAHtoaOysOaBqq5oghTW2P +VkuT2rLN9uq/UyqBKfReDkvv+jZFLsyxpMKTfEWTCuGN9upHvG6cHz0mHDZkdbaAekO 86YMUno1k7P6j+C9LBDkDfVUEuGbf5+W9PrJC+gEuy7odD/Aq791uo6/fiHAtIB+dkGH 82uM42Eh3p/nM3tnHbQusa+UEtCZbTb/0wWl0TsOE3XaBTBuqDMwY/1K6Vunk50ze1e4 VW1GEnyvfptMmkdJglqq3YZSIhTpfVbR8pUQYnHKENQK5sUkL/i33+j5XVPOSBPeicnL P1sw== X-Gm-Message-State: AOAM533GyfwK3K1h7Oi50uxoUDStOFsulErzmyIvCVAaZ76/sQxaHNC3 wRLQk5B1XEn+vp9G0Aw2plkMgA== X-Google-Smtp-Source: ABdhPJzO5rHQSMIPY+MB7qZqgOe07fSWudlq7dmfuf95lwRcrcmvio431Y34HI57agV+U+pSvrMCgA== X-Received: by 2002:ac8:6f0d:: with SMTP id g13mr5321304qtv.236.1599020551923; Tue, 01 Sep 2020 21:22:31 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id k185sm3916005qkd.94.2020.09.01.21.22.29 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Tue, 01 Sep 2020 21:22:30 -0700 (PDT) Date: Tue, 1 Sep 2020 21:22:09 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Byron Stanoszek cc: Hugh Dickins , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chris Down Subject: Re: [PATCH] tmpfs: Restore functionality of nr_inodes=0 In-Reply-To: <20200902035715.16414-1-gandalf@winds.org> Message-ID: References: <20200902035715.16414-1-gandalf@winds.org> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Rspamd-Queue-Id: 51BB218013E38 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 1 Sep 2020, Byron Stanoszek wrote: > Commit e809d5f0b5c9 ("tmpfs: per-superblock i_ino support") made changes to > shmem_reserve_inode() in mm/shmem.c, however the original test for > (sbinfo->max_inodes) got dropped. This causes mounting tmpfs with option > nr_inodes=0 to fail: > > # mount -ttmpfs -onr_inodes=0 none /ext0 > mount: /ext0: mount(2) system call failed: Cannot allocate memory. > > This patch restores the nr_inodes=0 functionality. > > Fixes: e809d5f0b5c9 ("tmpfs: per-superblock i_ino support") > Cc: Chris Down > Signed-off-by: Byron Stanoszek Yikes, thank you Byron, very bad of me not to have spotted that: Acked-by: Hugh Dickins I've taken a quick look to see how I missed it: yes, I'd compared against my own tree, knew I had to come back here sometime to replace the SB_KERNMOUNT test by a max_inodes test like I had, to restore the performance of nr_inodes=0; but thought the SB_KERNMOUNT test was good enough for now - without realizing the effect on the code below it. The error does seem to be localized just to this block, yes. Many thanks. > --- > mm/shmem.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/mm/shmem.c b/mm/shmem.c > index 271548ca20f3..8e2b35ba93ad 100644 > --- a/mm/shmem.c > +++ b/mm/shmem.c > @@ -279,11 +279,13 @@ static int shmem_reserve_inode(struct super_block *sb, ino_t *inop) > > if (!(sb->s_flags & SB_KERNMOUNT)) { > spin_lock(&sbinfo->stat_lock); > - if (!sbinfo->free_inodes) { > - spin_unlock(&sbinfo->stat_lock); > - return -ENOSPC; > + if (sbinfo->max_inodes) { > + if (!sbinfo->free_inodes) { > + spin_unlock(&sbinfo->stat_lock); > + return -ENOSPC; > + } > + sbinfo->free_inodes--; > } > - sbinfo->free_inodes--; > if (inop) { > ino = sbinfo->next_ino++; > if (unlikely(is_zero_ino(ino))) > -- > 2.28.0