ovl: Initialize ovl_inode->redirect in ovl_get_inode()

ovl_inode->redirect is an inode property and should be initialized in
ovl_get_inode() only when we are adding a new inode to cache.  If inode is
already in cache, it is already initialized and we should not be touching
ovl_inode->redirect field.

As of now this is not a problem as redirects are used only for directories
which don't share inode.  But soon I want to use redirects for regular
files also and there it can become an issue.

Hence, move ->redirect initialization in ovl_get_inode().

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
Vivek Goyal
2018-05-11 11:49:27 -04:00
committed by Miklos Szeredi
parent 0c31d675aa
commit 9cec54c83a
3 changed files with 5 additions and 7 deletions

View File

@@ -844,6 +844,7 @@ struct inode *ovl_get_inode(struct super_block *sb,
}
dput(upperdentry);
kfree(oip->redirect);
goto out;
}
@@ -867,6 +868,8 @@ struct inode *ovl_get_inode(struct super_block *sb,
if (oip->index)
ovl_set_flag(OVL_INDEX, inode);
OVL_I(inode)->redirect = oip->redirect;
/* Check for non-merge dir that may have whiteouts */
if (is_dir) {
if (((upperdentry && lowerdentry) || oip->numlower > 1) ||