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=-13.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 C3BDEC433E2 for ; Wed, 2 Sep 2020 03:58:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 306A2206EB for ; Wed, 2 Sep 2020 03:58:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 306A2206EB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=winds.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 90BCF6B0003; Tue, 1 Sep 2020 23:58:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 895AF6B005A; Tue, 1 Sep 2020 23:58:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 735686B005C; Tue, 1 Sep 2020 23:58:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0120.hostedemail.com [216.40.44.120]) by kanga.kvack.org (Postfix) with ESMTP id 5A46F6B0003 for ; Tue, 1 Sep 2020 23:58:23 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id F2E27824934B for ; Wed, 2 Sep 2020 03:58:22 +0000 (UTC) X-FDA: 77216764086.17.laugh03_3d186092709d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id BED6B180D0180 for ; Wed, 2 Sep 2020 03:58:22 +0000 (UTC) X-HE-Tag: laugh03_3d186092709d X-Filterd-Recvd-Size: 2090 Received: from winds.org (winds.org [68.75.195.9]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Wed, 2 Sep 2020 03:58:22 +0000 (UTC) Received: by winds.org (Postfix, from userid 0) id 4775C13BC8FD; Tue, 1 Sep 2020 23:58:21 -0400 (EDT) From: Byron Stanoszek To: Hugh Dickins , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Byron Stanoszek , Chris Down Subject: [PATCH] tmpfs: Restore functionality of nr_inodes=0 Date: Tue, 1 Sep 2020 23:57:15 -0400 Message-Id: <20200902035715.16414-1-gandalf@winds.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: BED6B180D0180 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 Content-Transfer-Encoding: quoted-printable 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: 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=3D0 to fail: # mount -ttmpfs -onr_inodes=3D0 none /ext0 mount: /ext0: mount(2) system call failed: Cannot allocate memory. This patch restores the nr_inodes=3D0 functionality. Fixes: e809d5f0b5c9 ("tmpfs: per-superblock i_ino support") Cc: Chris Down Signed-off-by: Byron Stanoszek --- 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) =20 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 =3D sbinfo->next_ino++; if (unlikely(is_zero_ino(ino))) --=20 2.28.0