Commit ab1eb5ff authored by Amir Goldstein's avatar Amir Goldstein
Browse files

ovl: deduplicate lowerdata and lowerstack[]



The ovl_inode contains a copy of lowerdata in lowerstack[], so the
lowerdata inode member can be removed.

Use accessors ovl_lowerdata*() to get the lowerdata whereever the member
was accessed directly.

Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent ac900ed4
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -1005,8 +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->lowerdata)
		oi->lowerdata = igrab(d_inode(oip->lowerdata));

	realinode = ovl_inode_real(inode);
	ovl_copyattr(inode);
+0 −2
Original line number Diff line number Diff line
@@ -1110,8 +1110,6 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
			.oe = oe,
			.index = index,
			.redirect = upperredirect,
			.lowerdata = (ctr > 1 && !d.is_dir) ?
				      stack[ctr - 1].dentry : NULL,
		};

		inode = ovl_get_inode(dentry->d_sb, &oip);
+0 −1
Original line number Diff line number Diff line
@@ -656,7 +656,6 @@ struct ovl_inode_params {
	struct ovl_entry *oe;
	bool index;
	char *redirect;
	struct dentry *lowerdata;
};
void ovl_inode_init(struct inode *inode, struct ovl_inode_params *oip,
		    unsigned long ino, int fsid);
+15 −1
Original line number Diff line number Diff line
@@ -125,6 +125,20 @@ static inline struct ovl_path *ovl_lowerpath(struct ovl_entry *oe)
	return ovl_lowerstack(oe);
}

static inline struct ovl_path *ovl_lowerdata(struct ovl_entry *oe)
{
	struct ovl_path *lowerstack = ovl_lowerstack(oe);

	return lowerstack ? &lowerstack[oe->__numlower - 1] : NULL;
}

static inline struct dentry *ovl_lowerdata_dentry(struct ovl_entry *oe)
{
	struct ovl_path *lowerdata = ovl_lowerdata(oe);

	return lowerdata ? lowerdata->dentry : NULL;
}

/* private information held for every overlayfs dentry */
static inline unsigned long *OVL_E_FLAGS(struct dentry *dentry)
{
@@ -134,7 +148,7 @@ static inline unsigned long *OVL_E_FLAGS(struct dentry *dentry)
struct ovl_inode {
	union {
		struct ovl_dir_cache *cache;	/* directory */
		struct inode *lowerdata;	/* regular file */
		/* place holder for non-dir */	/* regular file */
	};
	const char *redirect;
	u64 version;
+0 −3
Original line number Diff line number Diff line
@@ -172,7 +172,6 @@ static struct inode *ovl_alloc_inode(struct super_block *sb)
	oi->flags = 0;
	oi->__upperdentry = NULL;
	oi->oe = NULL;
	oi->lowerdata = NULL;
	mutex_init(&oi->lock);

	return &oi->vfs_inode;
@@ -195,8 +194,6 @@ static void ovl_destroy_inode(struct inode *inode)
	ovl_free_entry(oi->oe);
	if (S_ISDIR(inode->i_mode))
		ovl_dir_cache_free(inode);
	else
		iput(oi->lowerdata);
}

static void ovl_free_fs(struct ovl_fs *ofs)
Loading