Commit bb3e96d6 authored by Byron Stanoszek's avatar Byron Stanoszek Committed by Linus Torvalds

tmpfs: restore functionality of nr_inodes=0

Commit e809d5f0 ("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: e809d5f0 ("tmpfs: per-superblock i_ino support")
Signed-off-by: default avatarByron Stanoszek <gandalf@winds.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Acked-by: default avatarHugh Dickins <hughd@google.com>
Acked-by: default avatarChris Down <chris@chrisdown.name>
Link: https://lkml.kernel.org/r/20200902035715.16414-1-gandalf@winds.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0964730b
...@@ -279,11 +279,13 @@ static int shmem_reserve_inode(struct super_block *sb, ino_t *inop) ...@@ -279,11 +279,13 @@ static int shmem_reserve_inode(struct super_block *sb, ino_t *inop)
if (!(sb->s_flags & SB_KERNMOUNT)) { if (!(sb->s_flags & SB_KERNMOUNT)) {
spin_lock(&sbinfo->stat_lock); spin_lock(&sbinfo->stat_lock);
if (!sbinfo->free_inodes) { if (sbinfo->max_inodes) {
spin_unlock(&sbinfo->stat_lock); if (!sbinfo->free_inodes) {
return -ENOSPC; spin_unlock(&sbinfo->stat_lock);
return -ENOSPC;
}
sbinfo->free_inodes--;
} }
sbinfo->free_inodes--;
if (inop) { if (inop) {
ino = sbinfo->next_ino++; ino = sbinfo->next_ino++;
if (unlikely(is_zero_ino(ino))) if (unlikely(is_zero_ino(ino)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment