BugLink: https://bugs.launchpad.net/bugs/1838677
This patch enables overlayfs to use shiftfs as an underlay.
Currently it is not possible to use overlayfs on top of shiftfs. This
means Docker inside of LXD cannot make user of the overlay2 graph driver
which is blocking users such as Travis from making use of it
efficiently.
Co-Developed-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
Acked-by: Kleber Souza <kleber.souza@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
EXPORT_SYMBOL(dentry_open);
struct file *open_with_fake_path(const struct path *path, int flags,
- struct inode *inode, const struct cred *cred)
+ struct inode *inode, struct dentry *dentry,
+ const struct cred *cred)
{
struct file *f = alloc_empty_file_noaccount(flags, cred);
if (!IS_ERR(f)) {
int error;
f->f_path = *path;
+ f->f_path.dentry = dentry;
error = do_dentry_open(f, inode, NULL);
if (error) {
fput(f);
old_cred = ovl_override_creds(inode->i_sb);
realfile = open_with_fake_path(&file->f_path, flags, realinode,
+ ovl_dentry_real(file->f_path.dentry),
current_cred());
revert_creds(old_cred);
ovl_unescape(tmp);
err = ovl_mount_dir_noesc(tmp, path);
- if (!err)
- if (ovl_dentry_remote(path->dentry)) {
+ if (!err) {
+ if ((path->dentry->d_sb->s_magic != SHIFTFS_MAGIC) && ovl_dentry_remote(path->dentry)) {
pr_err("overlayfs: filesystem on '%s' not supported as upperdir\n",
tmp);
path_put_init(path);
err = -EINVAL;
}
+ }
kfree(tmp);
}
return err;
oldcred = shiftfs_override_creds(inode->i_sb);
/* XXX: open_with_fake_path() not gauranteed to stay around, if
* removed use dentry_open() */
- lowerf = open_with_fake_path(realpath, file->f_flags, loweri, info->creator_cred);
+ lowerf = open_with_fake_path(realpath, file->f_flags, loweri,
+ realpath->dentry,
+ info->creator_cred);
revert_creds(oldcred);
return lowerf;
const char *, int, umode_t);
extern struct file * dentry_open(const struct path *, int, const struct cred *);
extern struct file * open_with_fake_path(const struct path *, int,
- struct inode*, const struct cred *);
+ struct inode*, struct dentry *dentry,
+ const struct cred *);
static inline struct file *file_clone_open(struct file *file)
{
return dentry_open(&file->f_path, file->f_flags, file->f_cred);