From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dmitry Monakhov Subject: [PATCH 09/12] jfs: add error handling for dquot_initialize Date: Wed, 19 May 2010 10:02:05 +0400 Message-ID: <1274248928-5113-10-git-send-email-dmonakhov@openvz.org> References: <1274248928-5113-1-git-send-email-dmonakhov@openvz.org> <1274248928-5113-2-git-send-email-dmonakhov@openvz.org> <1274248928-5113-3-git-send-email-dmonakhov@openvz.org> <1274248928-5113-4-git-send-email-dmonakhov@openvz.org> <1274248928-5113-5-git-send-email-dmonakhov@openvz.org> <1274248928-5113-6-git-send-email-dmonakhov@openvz.org> <1274248928-5113-7-git-send-email-dmonakhov@openvz.org> <1274248928-5113-8-git-send-email-dmonakhov@openvz.org> <1274248928-5113-9-git-send-email-dmonakhov@openvz.org> Cc: jack@suse.cz, hch@infradead.org, Dmitry Monakhov To: linux-fsdevel@vger.kernel.org Return-path: Received: from fg-out-1718.google.com ([72.14.220.159]:37272 "EHLO fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751591Ab0ESGC1 (ORCPT ); Wed, 19 May 2010 02:02:27 -0400 Received: by fg-out-1718.google.com with SMTP id 22so1414519fge.1 for ; Tue, 18 May 2010 23:02:26 -0700 (PDT) In-Reply-To: <1274248928-5113-9-git-send-email-dmonakhov@openvz.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Signed-off-by: Dmitry Monakhov --- fs/jfs/file.c | 7 ++++- fs/jfs/jfs_inode.c | 5 +++- fs/jfs/namei.c | 59 +++++++++++++++++++++++++++++++++++++-------------- 3 files changed, 52 insertions(+), 19 deletions(-) diff --git a/fs/jfs/file.c b/fs/jfs/file.c index 85d9ec6..cb0da27 100644 --- a/fs/jfs/file.c +++ b/fs/jfs/file.c @@ -98,8 +98,11 @@ int jfs_setattr(struct dentry *dentry, struct iattr *iattr) if (rc) return rc; - if (is_quota_modification(inode, iattr)) - dquot_initialize(inode); + if (is_quota_modification(inode, iattr)) { + rc = dquot_initialize(inode); + if (rc) + return rc; + } if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) || (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) { rc = dquot_transfer(inode, iattr); diff --git a/fs/jfs/jfs_inode.c b/fs/jfs/jfs_inode.c index 829921b..8d18c95 100644 --- a/fs/jfs/jfs_inode.c +++ b/fs/jfs/jfs_inode.c @@ -116,7 +116,10 @@ struct inode *ialloc(struct inode *parent, umode_t mode) /* * Allocate inode to quota. */ - dquot_initialize(inode); + rc = dquot_initialize(inode); + if (rc) + goto fail_unlock; + rc = dquot_alloc_inode(inode); if (rc) goto fail_drop; diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index a9cf8e8..96d40a6 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c @@ -85,7 +85,9 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode, jfs_info("jfs_create: dip:0x%p name:%s", dip, dentry->d_name.name); - dquot_initialize(dip); + rc = dquot_initialize(dip); + if (rc) + goto out1; /* * search parent directory for entry/freespace @@ -217,7 +219,9 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode) jfs_info("jfs_mkdir: dip:0x%p name:%s", dip, dentry->d_name.name); - dquot_initialize(dip); + rc = dquot_initialize(dip); + if (rc) + goto out1; /* link count overflow on parent directory ? */ if (dip->i_nlink == JFS_LINK_MAX) { @@ -360,8 +364,12 @@ static int jfs_rmdir(struct inode *dip, struct dentry *dentry) jfs_info("jfs_rmdir: dip:0x%p name:%s", dip, dentry->d_name.name); /* Init inode for quota operations. */ - dquot_initialize(dip); - dquot_initialize(ip); + rc = dquot_initialize(dip); + if (rc) + goto out; + rc = dquot_initialize(ip); + if (rc) + goto out; /* directory must be empty to be removed */ if (!dtEmpty(ip)) { @@ -488,8 +496,12 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry) jfs_info("jfs_unlink: dip:0x%p name:%s", dip, dentry->d_name.name); /* Init inode for quota operations. */ - dquot_initialize(dip); - dquot_initialize(ip); + rc = dquot_initialize(dip); + if (rc) + goto out; + rc = dquot_initialize(ip); + if (rc) + goto out; if ((rc = get_UCSname(&dname, dentry))) goto out; @@ -811,7 +823,9 @@ static int jfs_link(struct dentry *old_dentry, if (ip->i_nlink == 0) return -ENOENT; - dquot_initialize(dir); + rc = dquot_initialize(dir); + if (rc) + return rc; tid = txBegin(ip->i_sb, 0); @@ -904,7 +918,9 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry, jfs_info("jfs_symlink: dip:0x%p name:%s", dip, name); - dquot_initialize(dip); + rc = dquot_initialize(dip); + if(rc) + goto out1; ssize = strlen(name) + 1; @@ -1097,12 +1113,24 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry, jfs_info("jfs_rename: %s %s", old_dentry->d_name.name, new_dentry->d_name.name); - dquot_initialize(old_dir); - dquot_initialize(new_dir); - old_ip = old_dentry->d_inode; new_ip = new_dentry->d_inode; + /* Init inode for quota operations. */ + rc = dquot_initialize(old_dir); + if (rc) + goto out1; + + rc = dquot_initialize(new_dir); + if(rc) + goto out1; + + if (new_ip) { + rc = dquot_initialize(new_ip); + if(rc) + goto out1; + } + if ((rc = get_UCSname(&old_dname, old_dentry))) goto out1; @@ -1146,11 +1174,8 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry, rc = -EMLINK; goto out3; } - } else if (new_ip) { + } else if (new_ip) IWRITE_LOCK(new_ip, RDWRLOCK_NORMAL); - /* Init inode for quota operations. */ - dquot_initialize(new_ip); - } /* * The real work starts here @@ -1373,7 +1398,9 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry, jfs_info("jfs_mknod: %s", dentry->d_name.name); - dquot_initialize(dir); + rc = dquot_initialize(dir); + if (rc) + goto out; if ((rc = get_UCSname(&dname, dentry))) goto out; -- 1.6.6.1