summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2023-04-01 09:29:19 +0200
committerAmir Goldstein <amir73il@gmail.com>2023-06-19 13:01:13 +0200
commitac900ed4f253434e099a025fc1da3d04bc741bd3 (patch)
tree10d864c508b597705743dfb9d08257354eb6d06e
parentovl: move ovl_entry into ovl_inode (diff)
downloadlinux-ac900ed4f253434e099a025fc1da3d04bc741bd3.tar.xz
linux-ac900ed4f253434e099a025fc1da3d04bc741bd3.zip
ovl: deduplicate lowerpath and lowerstack[]
The ovl_inode contains a copy of lowerpath in lowerstack[0], so the lowerpath member can be removed. Use accessor ovl_lowerpath() to get the lowerpath whereever the member was accessed directly. Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
-rw-r--r--fs/overlayfs/export.c2
-rw-r--r--fs/overlayfs/inode.c8
-rw-r--r--fs/overlayfs/namei.c2
-rw-r--r--fs/overlayfs/overlayfs.h2
-rw-r--r--fs/overlayfs/ovl_entry.h6
-rw-r--r--fs/overlayfs/super.c4
-rw-r--r--fs/overlayfs/util.c10
7 files changed, 13 insertions, 21 deletions
diff --git a/fs/overlayfs/export.c b/fs/overlayfs/export.c
index be142ea73fad..35680b6e175b 100644
--- a/fs/overlayfs/export.c
+++ b/fs/overlayfs/export.c
@@ -289,9 +289,7 @@ static struct dentry *ovl_obtain_alias(struct super_block *sb,
struct inode *inode = NULL;
struct ovl_entry *oe;
struct ovl_inode_params oip = {
- .lowerpath = lowerpath,
.index = index,
- .numlower = !!lower
};
/* We get overlay directory dentries with ovl_lookup_real() */
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 995135ffec98..4dbf8d880c0f 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -1005,10 +1005,6 @@ void ovl_inode_init(struct inode *inode, struct ovl_inode_params *oip,
oi->__upperdentry = oip->upperdentry;
oi->oe = oip->oe;
oi->redirect = oip->redirect;
- if (oip->lowerpath && oip->lowerpath->dentry) {
- oi->lowerpath.dentry = dget(oip->lowerpath->dentry);
- oi->lowerpath.layer = oip->lowerpath->layer;
- }
if (oip->lowerdata)
oi->lowerdata = igrab(d_inode(oip->lowerdata));
@@ -1325,7 +1321,7 @@ struct inode *ovl_get_inode(struct super_block *sb,
{
struct ovl_fs *ofs = OVL_FS(sb);
struct dentry *upperdentry = oip->upperdentry;
- struct ovl_path *lowerpath = oip->lowerpath;
+ struct ovl_path *lowerpath = ovl_lowerpath(oip->oe);
struct inode *realinode = upperdentry ? d_inode(upperdentry) : NULL;
struct inode *inode;
struct dentry *lowerdentry = lowerpath ? lowerpath->dentry : NULL;
@@ -1404,7 +1400,7 @@ struct inode *ovl_get_inode(struct super_block *sb,
/* Check for non-merge dir that may have whiteouts */
if (is_dir) {
- if (((upperdentry && lowerdentry) || oip->numlower > 1) ||
+ if (((upperdentry && lowerdentry) || ovl_numlower(oip->oe) > 1) ||
ovl_path_check_origin_xattr(ofs, &realpath)) {
ovl_set_flag(OVL_WHITEOUTS, inode);
}
diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index a7d975bf9e48..317ab1efc236 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -1107,10 +1107,8 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
if (upperdentry || ctr) {
struct ovl_inode_params oip = {
.upperdentry = upperdentry,
- .lowerpath = stack,
.oe = oe,
.index = index,
- .numlower = ctr,
.redirect = upperredirect,
.lowerdata = (ctr > 1 && !d.is_dir) ?
stack[ctr - 1].dentry : NULL,
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index cd74d7466a58..8b38844ae341 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -653,10 +653,8 @@ bool ovl_is_private_xattr(struct super_block *sb, const char *name);
struct ovl_inode_params {
struct inode *newinode;
struct dentry *upperdentry;
- struct ovl_path *lowerpath;
struct ovl_entry *oe;
bool index;
- unsigned int numlower;
char *redirect;
struct dentry *lowerdata;
};
diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h
index f511ac78c5bd..0bb8ab3aa8a7 100644
--- a/fs/overlayfs/ovl_entry.h
+++ b/fs/overlayfs/ovl_entry.h
@@ -120,6 +120,11 @@ static inline struct ovl_path *ovl_lowerstack(struct ovl_entry *oe)
return ovl_numlower(oe) ? oe->__lowerstack : NULL;
}
+static inline struct ovl_path *ovl_lowerpath(struct ovl_entry *oe)
+{
+ return ovl_lowerstack(oe);
+}
+
/* private information held for every overlayfs dentry */
static inline unsigned long *OVL_E_FLAGS(struct dentry *dentry)
{
@@ -136,7 +141,6 @@ struct ovl_inode {
unsigned long flags;
struct inode vfs_inode;
struct dentry *__upperdentry;
- struct ovl_path lowerpath;
struct ovl_entry *oe;
/* synchronize copy up and more */
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index bb4a062ab0d5..1efc4f252561 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -172,8 +172,6 @@ static struct inode *ovl_alloc_inode(struct super_block *sb)
oi->flags = 0;
oi->__upperdentry = NULL;
oi->oe = NULL;
- oi->lowerpath.dentry = NULL;
- oi->lowerpath.layer = NULL;
oi->lowerdata = NULL;
mutex_init(&oi->lock);
@@ -194,7 +192,6 @@ static void ovl_destroy_inode(struct inode *inode)
struct ovl_inode *oi = OVL_I(inode);
dput(oi->__upperdentry);
- dput(oi->lowerpath.dentry);
ovl_free_entry(oi->oe);
if (S_ISDIR(inode->i_mode))
ovl_dir_cache_free(inode);
@@ -1839,7 +1836,6 @@ static struct dentry *ovl_get_root(struct super_block *sb,
int fsid = lowerpath->layer->fsid;
struct ovl_inode_params oip = {
.upperdentry = upperdentry,
- .lowerpath = lowerpath,
.oe = oe,
};
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
index c4bd901f3bda..143e6898f50d 100644
--- a/fs/overlayfs/util.c
+++ b/fs/overlayfs/util.c
@@ -306,10 +306,12 @@ struct dentry *ovl_i_dentry_upper(struct inode *inode)
struct inode *ovl_i_path_real(struct inode *inode, struct path *path)
{
+ struct ovl_path *lowerpath = ovl_lowerpath(OVL_I_E(inode));
+
path->dentry = ovl_i_dentry_upper(inode);
if (!path->dentry) {
- path->dentry = OVL_I(inode)->lowerpath.dentry;
- path->mnt = OVL_I(inode)->lowerpath.layer->mnt;
+ path->dentry = lowerpath->dentry;
+ path->mnt = lowerpath->layer->mnt;
} else {
path->mnt = ovl_upper_mnt(OVL_FS(inode->i_sb));
}
@@ -326,9 +328,9 @@ struct inode *ovl_inode_upper(struct inode *inode)
struct inode *ovl_inode_lower(struct inode *inode)
{
- struct dentry *lowerdentry = OVL_I(inode)->lowerpath.dentry;
+ struct ovl_path *lowerpath = ovl_lowerpath(OVL_I_E(inode));
- return lowerdentry ? d_inode(lowerdentry) : NULL;
+ return lowerpath ? d_inode(lowerpath->dentry) : NULL;
}
struct inode *ovl_inode_real(struct inode *inode)