From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-fsdevel@vger.kernel.org
Cc: jack@suse.cz, hch@infradead.org, Dmitry Monakhov <dmonakhov@openvz.org>
Subject: [PATCH 08/12] ocfs2: add error handling for dquot_initialize
Date: Wed, 19 May 2010 10:02:04 +0400 [thread overview]
Message-ID: <1274248928-5113-9-git-send-email-dmonakhov@openvz.org> (raw)
In-Reply-To: <1274248928-5113-8-git-send-email-dmonakhov@openvz.org>
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
fs/ocfs2/file.c | 16 ++++++++---
fs/ocfs2/inode.c | 5 +++-
fs/ocfs2/namei.c | 64 ++++++++++++++++++++++++++++++++++++----------
fs/ocfs2/refcounttree.c | 5 ++-
4 files changed, 68 insertions(+), 22 deletions(-)
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 92d91a1..02003c0 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -107,9 +107,11 @@ static int ocfs2_file_open(struct inode *inode, struct file *file)
mlog_entry("(0x%p, 0x%p, '%.*s')\n", inode, file,
file->f_path.dentry->d_name.len, file->f_path.dentry->d_name.name);
- if (file->f_mode & FMODE_WRITE)
- dquot_initialize(inode);
-
+ if (file->f_mode & FMODE_WRITE) {
+ status = dquot_initialize(inode);
+ if (status)
+ goto leave;
+ }
spin_lock(&oi->ip_lock);
/* Check that the inode hasn't been wiped from disk by another
@@ -978,8 +980,12 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
if (status)
return status;
- if (is_quota_modification(inode, attr))
- dquot_initialize(inode);
+ if (is_quota_modification(inode, attr)) {
+ status = dquot_initialize(inode);
+ if (status)
+ return status;
+ }
+
size_change = S_ISREG(inode->i_mode) && attr->ia_valid & ATTR_SIZE;
if (size_change) {
status = ocfs2_rw_lock(inode, 1);
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index af18988..605a12a 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -993,7 +993,10 @@ void ocfs2_delete_inode(struct inode *inode)
goto bail;
}
- dquot_initialize(inode);
+ status = dquot_initialize(inode);
+ /* Even when quota wasn't initialized we can't faile the operation */
+ if (status)
+ mlog_errno(status);
if (!ocfs2_inode_is_valid_to_delete(inode)) {
/* It's probably not necessary to truncate_inode_pages
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 4cbb18f..e955b8a 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -190,11 +190,12 @@ bail:
static struct inode *ocfs2_get_init_inode(struct inode *dir, int mode)
{
struct inode *inode;
+ int status;
inode = new_inode(dir->i_sb);
if (!inode) {
mlog(ML_ERROR, "new_inode failed!\n");
- return NULL;
+ return ERR_PTR(-ENOMEM);
}
/* populate as many fields early on as possible - many of
@@ -212,7 +213,14 @@ static struct inode *ocfs2_get_init_inode(struct inode *dir, int mode)
} else
inode->i_gid = current_fsgid();
inode->i_mode = mode;
- dquot_initialize(inode);
+ status = dquot_initialize(inode);
+ if (status) {
+ clear_nlink(inode);
+ iput(inode);
+ inode = ERR_PTR(status);
+ mlog(ML_ERROR, "new_inode failed!\n");
+ }
+
return inode;
}
@@ -244,7 +252,11 @@ static int ocfs2_mknod(struct inode *dir,
(unsigned long)dev, dentry->d_name.len,
dentry->d_name.name);
- dquot_initialize(dir);
+ status = dquot_initialize(dir);
+ if (status) {
+ mlog_errno(status);
+ return status;
+ }
/* get our super block */
osb = OCFS2_SB(dir->i_sb);
@@ -291,9 +303,10 @@ static int ocfs2_mknod(struct inode *dir,
}
inode = ocfs2_get_init_inode(dir, mode);
- if (!inode) {
- status = -ENOMEM;
+ if (IS_ERR(inode)) {
+ status = PTR_ERR(inode);
mlog_errno(status);
+ inode = NULL;
goto leave;
}
@@ -645,7 +658,11 @@ static int ocfs2_link(struct dentry *old_dentry,
if (S_ISDIR(inode->i_mode))
return -EPERM;
- dquot_initialize(dir);
+ err = dquot_initialize(dir);
+ if (err) {
+ mlog_errno(err);
+ return err;
+ }
err = ocfs2_inode_lock_nested(dir, &parent_fe_bh, 1, OI_LS_PARENT);
if (err < 0) {
@@ -802,7 +819,11 @@ static int ocfs2_unlink(struct inode *dir,
mlog_entry("(0x%p, 0x%p, '%.*s')\n", dir, dentry,
dentry->d_name.len, dentry->d_name.name);
- dquot_initialize(dir);
+ status = dquot_initialize(dir);
+ if (status) {
+ mlog_errno(status);
+ return status;
+ }
BUG_ON(dentry->d_parent->d_inode != dir);
@@ -1064,8 +1085,17 @@ static int ocfs2_rename(struct inode *old_dir,
old_dentry->d_name.len, old_dentry->d_name.name,
new_dentry->d_name.len, new_dentry->d_name.name);
- dquot_initialize(old_dir);
- dquot_initialize(new_dir);
+ status = dquot_initialize(old_dir);
+ if (status) {
+ mlog_errno(status);
+ return status;
+ }
+ status = dquot_initialize(new_dir);
+ if (status) {
+ mlog_errno(status);
+ return status;
+ }
+
osb = OCFS2_SB(old_dir->i_sb);
@@ -1615,7 +1645,11 @@ static int ocfs2_symlink(struct inode *dir,
mlog_entry("(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir,
dentry, symname, dentry->d_name.len, dentry->d_name.name);
- dquot_initialize(dir);
+ status = dquot_initialize(dir);
+ if (status) {
+ mlog_errno(status);
+ return status;
+ }
sb = dir->i_sb;
osb = OCFS2_SB(sb);
@@ -1660,9 +1694,10 @@ static int ocfs2_symlink(struct inode *dir,
}
inode = ocfs2_get_init_inode(dir, S_IFLNK | S_IRWXUGO);
- if (!inode) {
- status = -ENOMEM;
+ if (IS_ERR(inode)) {
+ status = PTR_ERR(inode);
mlog_errno(status);
+ inode = NULL;
goto bail;
}
@@ -2123,9 +2158,10 @@ int ocfs2_create_inode_in_orphan(struct inode *dir,
}
inode = ocfs2_get_init_inode(dir, mode);
- if (!inode) {
- status = -ENOMEM;
+ if (IS_ERR(inode)) {
+ status = PTR_ERR(inode);
mlog_errno(status);
+ inode = NULL;
goto leave;
}
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 5cbcd0f..7b4151c 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -4393,8 +4393,9 @@ static int ocfs2_vfs_reflink(struct dentry *old_dentry, struct inode *dir,
}
mutex_lock(&inode->i_mutex);
- dquot_initialize(dir);
- error = ocfs2_reflink(old_dentry, dir, new_dentry, preserve);
+ error = dquot_initialize(dir);
+ if (!error)
+ error = ocfs2_reflink(old_dentry, dir, new_dentry, preserve);
mutex_unlock(&inode->i_mutex);
if (!error)
fsnotify_create(dir, new_dentry);
--
1.6.6.1
next prev parent reply other threads:[~2010-05-19 6:02 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-19 6:01 [PATCH 00/12] quota: Redesign IO error handling interface V2 Dmitry Monakhov
2010-05-19 6:01 ` [PATCH 01/12] quota: Add proper error handling on quota initialization Dmitry Monakhov
2010-05-19 6:01 ` [PATCH 02/12] quota: Check what quota is properly initialized for inode before charge Dmitry Monakhov
2010-05-19 6:01 ` [PATCH 03/12] ext3: handle errors in orphan_cleanup Dmitry Monakhov
2010-05-19 6:02 ` [PATCH 04/12] ext4: " Dmitry Monakhov
2010-05-19 6:02 ` [PATCH 05/12] ufs: add error handling for dquot_initialize Dmitry Monakhov
2010-05-19 6:02 ` [PATCH 06/12] udf: " Dmitry Monakhov
2010-05-19 6:02 ` [PATCH 07/12] reiserfs: " Dmitry Monakhov
2010-05-19 6:02 ` Dmitry Monakhov [this message]
2010-05-19 6:02 ` [PATCH 09/12] jfs: " Dmitry Monakhov
2010-05-19 6:02 ` [PATCH 10/12] ext4: " Dmitry Monakhov
2010-05-19 6:02 ` [PATCH 11/12] ext3: " Dmitry Monakhov
2010-05-19 6:02 ` [PATCH 12/12] ext2: " Dmitry Monakhov
2010-05-20 17:30 ` Jan Kara
2010-05-20 17:32 ` [PATCH 11/12] ext3: " Jan Kara
2010-05-20 17:34 ` [PATCH 06/12] udf: " Jan Kara
2010-05-20 17:33 ` [PATCH 05/12] ufs: " Jan Kara
2010-05-20 17:35 ` [PATCH 03/12] ext3: handle errors in orphan_cleanup Jan Kara
2010-05-20 18:13 ` [PATCH 02/12] quota: Check what quota is properly initialized for inode before charge Jan Kara
2010-05-20 18:05 ` [PATCH 01/12] quota: Add proper error handling on quota initialization Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1274248928-5113-9-git-send-email-dmonakhov@openvz.org \
--to=dmonakhov@openvz.org \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).