[Devel] [PATCH rh7] Port diff-bc-shmem-fix-accounting-on-error-path

Vladimir Davydov vdavydov at parallels.com
Wed Jun 3 02:15:13 PDT 2015


Author: Konstantin Khlebnikov
Email: khlebnikov at openvz.org
Subject: ubc: fix shmem accounting on error path
Date: Thu, 12 Sep 2013 17:26:03 +0400

shmem inode holds memory precharge and releases it in shmem_delete_inode().
Thus we shouldn't uncharge that precharge after inode creation if in following
alloc_file hits into kmemsize memory limit.

https://jira.sw.ru/browse/PSBM-22198

Signed-off-by: Konstantin Khlebnikov <khlebnikov at openvz.org>
=============================================================================

Related to https://jira.sw.ru/browse/PSBM-33637

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 mm/shmem.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index de8f0c3e5b4b..0c8d6aec7f07 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2919,16 +2919,16 @@ static struct file *__shmem_file_setup(const char *name, loff_t size,
 	this.len = strlen(name);
 	this.hash = 0; /* will go */
 	sb = shm_mnt->mnt_sb;
+	path.mnt = mntget(shm_mnt);
 	path.dentry = d_alloc_pseudo(sb, &this);
 	if (!path.dentry)
 		goto put_memory;
 	d_set_d_op(path.dentry, &anon_ops);
-	path.mnt = mntget(shm_mnt);
 
 	res = ERR_PTR(-ENOSPC);
 	inode = shmem_get_inode(sb, NULL, S_IFREG | S_IRWXUGO, 0, flags);
 	if (!inode)
-		goto put_dentry;
+		goto put_memory;
 
 	inode->i_flags |= i_flags;
 	d_instantiate(path.dentry, inode);
@@ -2945,10 +2945,10 @@ static struct file *__shmem_file_setup(const char *name, loff_t size,
 
 	return res;
 
-put_dentry:
-	path_put(&path);
 put_memory:
 	shmem_unacct_size(flags, size, get_exec_ub());
+put_dentry:
+	path_put(&path);
 	return res;
 }
 
-- 
2.1.4




More information about the Devel mailing list