Commit 027065b7 authored by Vivek Goyal's avatar Vivek Goyal Committed by Miklos Szeredi

ovl: Use out_err instead of out_nomem

Right now we use goto out_nomem which assumes error code is -ENOMEM.  But
there are other errors returned like -ESTALE as well.  So instead of
out_nomem, use out_err which will do ERR_PTR(err).  That way one can put
error code in err and jump to out_err.

This just code reorganization and no change of functionality.

I am about to add more code and this organization helps laying more code
and error paths on top of it.
Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
Reviewed-by: default avatarAmir Goldstein <amir73il@gmail.com>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent 0c288874
...@@ -782,6 +782,7 @@ struct inode *ovl_get_inode(struct super_block *sb, ...@@ -782,6 +782,7 @@ struct inode *ovl_get_inode(struct super_block *sb,
int fsid = bylower ? oip->lowerpath->layer->fsid : 0; int fsid = bylower ? oip->lowerpath->layer->fsid : 0;
bool is_dir; bool is_dir;
unsigned long ino = 0; unsigned long ino = 0;
int err = -ENOMEM;
if (!realinode) if (!realinode)
realinode = d_inode(lowerdentry); realinode = d_inode(lowerdentry);
...@@ -798,7 +799,7 @@ struct inode *ovl_get_inode(struct super_block *sb, ...@@ -798,7 +799,7 @@ struct inode *ovl_get_inode(struct super_block *sb,
inode = ovl_iget5(sb, oip->newinode, key); inode = ovl_iget5(sb, oip->newinode, key);
if (!inode) if (!inode)
goto out_nomem; goto out_err;
if (!(inode->i_state & I_NEW)) { if (!(inode->i_state & I_NEW)) {
/* /*
* Verify that the underlying files stored in the inode * Verify that the underlying files stored in the inode
...@@ -807,8 +808,8 @@ struct inode *ovl_get_inode(struct super_block *sb, ...@@ -807,8 +808,8 @@ struct inode *ovl_get_inode(struct super_block *sb,
if (!ovl_verify_inode(inode, lowerdentry, upperdentry, if (!ovl_verify_inode(inode, lowerdentry, upperdentry,
true)) { true)) {
iput(inode); iput(inode);
inode = ERR_PTR(-ESTALE); err = -ESTALE;
goto out; goto out_err;
} }
dput(upperdentry); dput(upperdentry);
...@@ -824,8 +825,10 @@ struct inode *ovl_get_inode(struct super_block *sb, ...@@ -824,8 +825,10 @@ struct inode *ovl_get_inode(struct super_block *sb,
} else { } else {
/* Lower hardlink that will be broken on copy up */ /* Lower hardlink that will be broken on copy up */
inode = new_inode(sb); inode = new_inode(sb);
if (!inode) if (!inode) {
goto out_nomem; err = -ENOMEM;
goto out_err;
}
} }
ovl_fill_inode(inode, realinode->i_mode, realinode->i_rdev, ino, fsid); ovl_fill_inode(inode, realinode->i_mode, realinode->i_rdev, ino, fsid);
ovl_inode_init(inode, upperdentry, lowerdentry); ovl_inode_init(inode, upperdentry, lowerdentry);
...@@ -851,7 +854,7 @@ struct inode *ovl_get_inode(struct super_block *sb, ...@@ -851,7 +854,7 @@ struct inode *ovl_get_inode(struct super_block *sb,
out: out:
return inode; return inode;
out_nomem: out_err:
inode = ERR_PTR(-ENOMEM); inode = ERR_PTR(err);
goto out; goto out;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment