oi->__upperdentry = oip->upperdentry;
oi->oe = oip->oe;
oi->redirect = oip->redirect;
+ oi->lowerdata_redirect = oip->lowerdata_redirect;
realinode = ovl_inode_real(inode);
ovl_copyattr(inode);
dput(upperdentry);
ovl_free_entry(oip->oe);
kfree(oip->redirect);
+ kfree(oip->lowerdata_redirect);
goto out;
}
.redirect = upperredirect,
};
+ /* Store lowerdata redirect for lazy lookup */
+ if (ctr > 1 && !d.is_dir && !stack[ctr - 1].dentry) {
+ oip.lowerdata_redirect = d.redirect;
+ d.redirect = NULL;
+ }
inode = ovl_get_inode(dentry->d_sb, &oip);
err = PTR_ERR(inode);
if (IS_ERR(inode))
struct inode *ovl_inode_lowerdata(struct inode *inode);
struct inode *ovl_inode_real(struct inode *inode);
struct inode *ovl_inode_realdata(struct inode *inode);
+const char *ovl_lowerdata_redirect(struct inode *inode);
struct ovl_dir_cache *ovl_dir_cache(struct inode *inode);
void ovl_set_dir_cache(struct inode *inode, struct ovl_dir_cache *cache);
void ovl_dentry_set_flag(unsigned long flag, struct dentry *dentry);
struct ovl_entry *oe;
bool index;
char *redirect;
+ char *lowerdata_redirect;
};
void ovl_inode_init(struct inode *inode, struct ovl_inode_params *oip,
unsigned long ino, int fsid);
return lowerstack ? &lowerstack[oe->__numlower - 1] : NULL;
}
+/* May return NULL if lazy lookup of lowerdata is needed */
static inline struct dentry *ovl_lowerdata_dentry(struct ovl_entry *oe)
{
struct ovl_path *lowerdata = ovl_lowerdata(oe);
struct ovl_inode {
union {
struct ovl_dir_cache *cache; /* directory */
- /* place holder for non-dir */ /* regular file */
+ const char *lowerdata_redirect; /* regular file */
};
const char *redirect;
u64 version;
oi->version = 0;
oi->flags = 0;
oi->__upperdentry = NULL;
+ oi->lowerdata_redirect = NULL;
oi->oe = NULL;
mutex_init(&oi->lock);
ovl_free_entry(oi->oe);
if (S_ISDIR(inode->i_mode))
ovl_dir_cache_free(inode);
+ else
+ kfree(oi->lowerdata_redirect);
}
static void ovl_free_fs(struct ovl_fs *ofs)
{
struct ovl_entry *oe = OVL_E(dentry);
struct ovl_path *lowerdata = ovl_lowerdata(oe);
+ struct dentry *lowerdata_dentry = ovl_lowerdata_dentry(oe);
- if (ovl_numlower(oe)) {
+ if (lowerdata_dentry) {
path->mnt = lowerdata->layer->mnt;
- path->dentry = lowerdata->dentry;
+ path->dentry = lowerdata_dentry;
} else {
*path = (struct path) { };
}
return ovl_inode_lowerdata(inode);
}
+const char *ovl_lowerdata_redirect(struct inode *inode)
+{
+ return inode && S_ISREG(inode->i_mode) ?
+ OVL_I(inode)->lowerdata_redirect : NULL;
+}
+
struct ovl_dir_cache *ovl_dir_cache(struct inode *inode)
{
- return OVL_I(inode)->cache;
+ return inode && S_ISDIR(inode->i_mode) ? OVL_I(inode)->cache : NULL;
}
void ovl_set_dir_cache(struct inode *inode, struct ovl_dir_cache *cache)