summaryrefslogtreecommitdiff
path: root/fs/overlayfs/namei.c
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2023-04-08 12:31:13 +0300
committerAmir Goldstein <amir73il@gmail.com>2023-06-19 14:01:13 +0300
commit0af950f57fefabab628f1963af881e6b9bfe7f38 (patch)
treedcb63dcfdf15e4a91e33d6b46822bb2cfdc5d7b6 /fs/overlayfs/namei.c
parent163db0da3515d1d32343906a2fb7854492191d19 (diff)
downloadlinux-0af950f57fefabab628f1963af881e6b9bfe7f38.tar.xz
ovl: move ovl_entry into ovl_inode
The lower stacks of all the ovl inode aliases should be identical and there is redundant information in ovl_entry and ovl_inode. Move lowerstack into ovl_inode and keep only the OVL_E_FLAGS per overlay dentry. Following patches will deduplicate redundant ovl_inode fields. Note that for pure upper and negative dentries, OVL_E(dentry) may be NULL now, so it is imporatnt to use the ovl_numlower() accessor. Reviewed-by: Alexander Larsson <alexl@redhat.com> Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/overlayfs/namei.c')
-rw-r--r--fs/overlayfs/namei.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index c237c8dbff09..a7d975bf9e48 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -831,7 +831,7 @@ static int ovl_fix_origin(struct ovl_fs *ofs, struct dentry *dentry,
struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
unsigned int flags)
{
- struct ovl_entry *oe;
+ struct ovl_entry *oe = NULL;
const struct cred *old_cred;
struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
struct ovl_entry *poe = OVL_E(dentry->d_parent);
@@ -1067,13 +1067,14 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
}
}
- oe = ovl_alloc_entry(ctr);
- err = -ENOMEM;
- if (!oe)
- goto out_put;
+ if (ctr) {
+ oe = ovl_alloc_entry(ctr);
+ err = -ENOMEM;
+ if (!oe)
+ goto out_put;
- ovl_stack_cpy(ovl_lowerstack(oe), stack, ctr);
- dentry->d_fsdata = oe;
+ ovl_stack_cpy(ovl_lowerstack(oe), stack, ctr);
+ }
if (upperopaque)
ovl_dentry_set_opaque(dentry);
@@ -1107,6 +1108,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
struct ovl_inode_params oip = {
.upperdentry = upperdentry,
.lowerpath = stack,
+ .oe = oe,
.index = index,
.numlower = ctr,
.redirect = upperredirect,
@@ -1122,7 +1124,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
ovl_set_flag(OVL_UPPERDATA, inode);
}
- ovl_dentry_init_reval(dentry, upperdentry);
+ ovl_dentry_init_reval(dentry, upperdentry, OVL_I_E(inode));
revert_creds(old_cred);
if (origin_path) {
@@ -1135,7 +1137,6 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
return d_splice_alias(inode, dentry);
out_free_oe:
- dentry->d_fsdata = NULL;
ovl_free_entry(oe);
out_put:
dput(index);