]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
UBUNTU: SAUCE: shiftfs: enable overlayfs on shiftfs
authorChristian Brauner <christian.brauner@canonical.com>
Thu, 1 Aug 2019 18:08:29 +0000 (20:08 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 13 Aug 2019 12:18:20 +0000 (14:18 +0200)
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>
fs/open.c
fs/overlayfs/file.c
fs/overlayfs/super.c
fs/shiftfs.c
include/linux/fs.h

index 14502dde64038116fe4de4c16c2e1a46758e84be..b8268a334dc95c6b44bdc1ddb9a3d525cb729a8d 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -914,13 +914,15 @@ struct file *dentry_open(const struct path *path, int flags,
 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);
index 7129dcd78b6b9baa62fb48a5f6ffb50eae61b51a..8b5a861d81b6b82234865abfb947c37fe7fa9184 100644 (file)
@@ -33,6 +33,7 @@ static struct file *ovl_open_realfile(const struct file *file,
 
        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);
 
index bb2a6f80ffd098fe54e4b2c954b0ef2a458e8dcc..46def89a36646bb3626485a1100ae1d3432bc053 100644 (file)
@@ -748,13 +748,14 @@ static int ovl_mount_dir(const char *name, struct path *path)
                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;
index 49f6714e9f95233aa4cf30d42d63cc031f39519b..400c3062365c18a22bc7e200af71201c5bafcff2 100644 (file)
@@ -1048,7 +1048,9 @@ static struct file *shiftfs_open_realfile(const struct file *file,
        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;
index 5dd548c73f8d3c220fe71e638f98803e60dda960..4cb7a1124c5fe392381cc01aa343e00ebab80aee 100644 (file)
@@ -2524,7 +2524,8 @@ extern struct file *file_open_root(struct dentry *, struct vfsmount *,
                                   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);