From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dongsheng Yang Subject: [PATCH 18/25] ubifs: record quota information about inode in ubifs_new_inode Date: Tue, 21 Jul 2015 16:37:49 +0800 Message-ID: <1437467876-22106-19-git-send-email-yangds.fnst@cn.fujitsu.com> References: <1437467876-22106-1-git-send-email-yangds.fnst@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain Cc: , , Dongsheng Yang To: , , Return-path: Received: from cn.fujitsu.com ([59.151.112.132]:57008 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753942AbbGUInw (ORCPT ); Tue, 21 Jul 2015 04:43:52 -0400 In-Reply-To: <1437467876-22106-1-git-send-email-yangds.fnst@cn.fujitsu.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Initialize quota and alloc a inode quota information in ubifs_new_inode(). Then quota would be aware of a new inode is allocated. Signed-off-by: Dongsheng Yang --- fs/ubifs/dir.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 27060fc..01cbc8b 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -41,6 +41,7 @@ */ #include "ubifs.h" +#include /** * inherit_flags - inherit flags of the parent inode. @@ -90,12 +91,18 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir, { struct inode *inode; struct ubifs_inode *ui; + int err = 0; inode = new_inode(c->vfs_sb); - ui = ubifs_inode(inode); if (!inode) return ERR_PTR(-ENOMEM); + dquot_initialize(inode); + err = dquot_alloc_inode(inode); + if (err) + goto fail_drop; + + ui = ubifs_inode(inode); /* * Set 'S_NOCMTIME' to prevent VFS form updating [mc]time of inodes and * marking them dirty in file write path (see 'file_update_time()'). @@ -148,8 +155,8 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir, spin_unlock(&c->cnt_lock); ubifs_err(c, "out of inode numbers"); make_bad_inode(inode); - iput(inode); - return ERR_PTR(-EINVAL); + err = -EINVAL; + goto fail_free; } ubifs_warn(c, "running out of inode numbers (current %lu, max %u)", (unsigned long)c->highest_inum, INUM_WATERMARK); @@ -166,6 +173,13 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir, ui->creat_sqnum = ++c->max_sqnum; spin_unlock(&c->cnt_lock); return inode; + +fail_free: + dquot_free_inode(inode); +fail_drop: + dquot_drop(inode); + iput(inode); + return ERR_PTR(err); } static int dbg_check_name(const struct ubifs_info *c, -- 1.8.4.2