From: Andrew Morton Cc: Hugh Dickins Cc: Pavel Emelyanov Signed-off-by: Andrew Morton --- mm/shmem.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff -puN mm/shmem.c~shmem-factor-out-sbi-free_inodes-manipulations-fix mm/shmem.c --- a/mm/shmem.c~shmem-factor-out-sbi-free_inodes-manipulations-fix +++ a/mm/shmem.c @@ -212,7 +212,7 @@ static int shmem_reserve_inode(struct su spin_lock(&sbinfo->stat_lock); if (!sbinfo->free_inodes) { spin_unlock(&sbinfo->stat_lock); - return -ENOMEM; + return -ENOSPC; } sbinfo->free_inodes--; spin_unlock(&sbinfo->stat_lock); @@ -1680,14 +1680,16 @@ static int shmem_create(struct inode *di static int shmem_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) { struct inode *inode = old_dentry->d_inode; + int ret; /* * No ordinary (disk based) filesystem counts links as inodes; * but each new link needs a new dentry, pinning lowmem, and * tmpfs dentries cannot be pruned until they are unlinked. */ - if (shmem_reserve_inode(inode->i_sb)) - return -ENOSPC; + ret = shmem_reserve_inode(inode->i_sb); + if (ret) + goto out; dir->i_size += BOGO_DIRENT_SIZE; inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME; @@ -1695,7 +1697,8 @@ static int shmem_link(struct dentry *old atomic_inc(&inode->i_count); /* New dentry reference */ dget(dentry); /* Extra pinning count for the created dentry */ d_instantiate(dentry, inode); - return 0; +out: + return ret; } static int shmem_unlink(struct inode *dir, struct dentry *dentry) _