diff options
author | Vivek Goyal <vgoyal@redhat.com> | 2018-05-11 11:49:28 -0400 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2018-07-20 03:56:08 -0400 |
commit | 027065b726434d2a95a5cc516129be765e27ecf8 (patch) | |
tree | 5f8c3aa847bf0eceab9c4cf9e384d46e4909378f | |
parent | 0c2888749363645d62cc48852d0af98d5ceef332 (diff) |
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: Vivek Goyal <vgoyal@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
-rw-r--r-- | fs/overlayfs/inode.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index a30cbd754bf2..e46f26ee6e21 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c | |||
@@ -782,6 +782,7 @@ struct inode *ovl_get_inode(struct super_block *sb, | |||
782 | int fsid = bylower ? oip->lowerpath->layer->fsid : 0; | 782 | int fsid = bylower ? oip->lowerpath->layer->fsid : 0; |
783 | bool is_dir; | 783 | bool is_dir; |
784 | unsigned long ino = 0; | 784 | unsigned long ino = 0; |
785 | int err = -ENOMEM; | ||
785 | 786 | ||
786 | if (!realinode) | 787 | if (!realinode) |
787 | realinode = d_inode(lowerdentry); | 788 | realinode = d_inode(lowerdentry); |
@@ -798,7 +799,7 @@ struct inode *ovl_get_inode(struct super_block *sb, | |||
798 | 799 | ||
799 | inode = ovl_iget5(sb, oip->newinode, key); | 800 | inode = ovl_iget5(sb, oip->newinode, key); |
800 | if (!inode) | 801 | if (!inode) |
801 | goto out_nomem; | 802 | goto out_err; |
802 | if (!(inode->i_state & I_NEW)) { | 803 | if (!(inode->i_state & I_NEW)) { |
803 | /* | 804 | /* |
804 | * Verify that the underlying files stored in the inode | 805 | * Verify that the underlying files stored in the inode |
@@ -807,8 +808,8 @@ struct inode *ovl_get_inode(struct super_block *sb, | |||
807 | if (!ovl_verify_inode(inode, lowerdentry, upperdentry, | 808 | if (!ovl_verify_inode(inode, lowerdentry, upperdentry, |
808 | true)) { | 809 | true)) { |
809 | iput(inode); | 810 | iput(inode); |
810 | inode = ERR_PTR(-ESTALE); | 811 | err = -ESTALE; |
811 | goto out; | 812 | goto out_err; |
812 | } | 813 | } |
813 | 814 | ||
814 | dput(upperdentry); | 815 | dput(upperdentry); |
@@ -824,8 +825,10 @@ struct inode *ovl_get_inode(struct super_block *sb, | |||
824 | } else { | 825 | } else { |
825 | /* Lower hardlink that will be broken on copy up */ | 826 | /* Lower hardlink that will be broken on copy up */ |
826 | inode = new_inode(sb); | 827 | inode = new_inode(sb); |
827 | if (!inode) | 828 | if (!inode) { |
828 | goto out_nomem; | 829 | err = -ENOMEM; |
830 | goto out_err; | ||
831 | } | ||
829 | } | 832 | } |
830 | ovl_fill_inode(inode, realinode->i_mode, realinode->i_rdev, ino, fsid); | 833 | ovl_fill_inode(inode, realinode->i_mode, realinode->i_rdev, ino, fsid); |
831 | ovl_inode_init(inode, upperdentry, lowerdentry); | 834 | ovl_inode_init(inode, upperdentry, lowerdentry); |
@@ -851,7 +854,7 @@ struct inode *ovl_get_inode(struct super_block *sb, | |||
851 | out: | 854 | out: |
852 | return inode; | 855 | return inode; |
853 | 856 | ||
854 | out_nomem: | 857 | out_err: |
855 | inode = ERR_PTR(-ENOMEM); | 858 | inode = ERR_PTR(err); |
856 | goto out; | 859 | goto out; |
857 | } | 860 | } |