summaryrefslogtreecommitdiff
path: root/fs/overlayfs/super.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/super.c
parent163db0da3515d1d32343906a2fb7854492191d19 (diff)
downloadlwn-0af950f57fefabab628f1963af881e6b9bfe7f38.tar.gz
lwn-0af950f57fefabab628f1963af881e6b9bfe7f38.zip
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/super.c')
-rw-r--r--fs/overlayfs/super.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 35ecea4b60b0..bb4a062ab0d5 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -59,16 +59,6 @@ module_param_named(metacopy, ovl_metacopy_def, bool, 0644);
MODULE_PARM_DESC(metacopy,
"Default to on or off for the metadata only copy up feature");
-static void ovl_dentry_release(struct dentry *dentry)
-{
- struct ovl_entry *oe = dentry->d_fsdata;
-
- if (oe) {
- ovl_stack_put(ovl_lowerstack(oe), ovl_numlower(oe));
- kfree_rcu(oe, rcu);
- }
-}
-
static struct dentry *ovl_d_real(struct dentry *dentry,
const struct inode *inode)
{
@@ -162,7 +152,6 @@ static int ovl_dentry_weak_revalidate(struct dentry *dentry, unsigned int flags)
}
static const struct dentry_operations ovl_dentry_operations = {
- .d_release = ovl_dentry_release,
.d_real = ovl_d_real,
.d_revalidate = ovl_dentry_revalidate,
.d_weak_revalidate = ovl_dentry_weak_revalidate,
@@ -182,6 +171,7 @@ static struct inode *ovl_alloc_inode(struct super_block *sb)
oi->version = 0;
oi->flags = 0;
oi->__upperdentry = NULL;
+ oi->oe = NULL;
oi->lowerpath.dentry = NULL;
oi->lowerpath.layer = NULL;
oi->lowerdata = NULL;
@@ -205,6 +195,7 @@ static void ovl_destroy_inode(struct inode *inode)
dput(oi->__upperdentry);
dput(oi->lowerpath.dentry);
+ ovl_free_entry(oi->oe);
if (S_ISDIR(inode->i_mode))
ovl_dir_cache_free(inode);
else
@@ -1849,14 +1840,13 @@ static struct dentry *ovl_get_root(struct super_block *sb,
struct ovl_inode_params oip = {
.upperdentry = upperdentry,
.lowerpath = lowerpath,
+ .oe = oe,
};
root = d_make_root(ovl_new_inode(sb, S_IFDIR, 0));
if (!root)
return NULL;
- root->d_fsdata = oe;
-
if (upperdentry) {
/* Root inode uses upper st_ino/i_ino */
ino = d_inode(upperdentry)->i_ino;
@@ -1871,7 +1861,7 @@ static struct dentry *ovl_get_root(struct super_block *sb,
ovl_dentry_set_flag(OVL_E_CONNECTED, root);
ovl_set_upperdata(d_inode(root));
ovl_inode_init(d_inode(root), &oip, ino, fsid);
- ovl_dentry_init_flags(root, upperdentry, DCACHE_OP_WEAK_REVALIDATE);
+ ovl_dentry_init_flags(root, upperdentry, oe, DCACHE_OP_WEAK_REVALIDATE);
return root;
}