diff mbox series

[SRU,Disco] UBUNTU: SAUCE: shiftfs: enable overlayfs on shiftfs

Message ID 20190801180829.26981-1-christian.brauner@ubuntu.com
State New
Headers show
Series [SRU,Disco] UBUNTU: SAUCE: shiftfs: enable overlayfs on shiftfs | expand

Commit Message

Christian Brauner Aug. 1, 2019, 6:08 p.m. UTC
From: Christian Brauner <christian.brauner@canonical.com>

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>
---
 fs/open.c            | 4 +++-
 fs/overlayfs/file.c  | 1 +
 fs/overlayfs/super.c | 5 +++--
 fs/shiftfs.c         | 4 +++-
 include/linux/fs.h   | 3 ++-
 5 files changed, 12 insertions(+), 5 deletions(-)

Comments

Seth Forshee Aug. 8, 2019, 3:21 p.m. UTC | #1
On Thu, Aug 01, 2019 at 08:08:29PM +0200, Christian Brauner wrote:
> From: Christian Brauner <christian.brauner@canonical.com>
> 
> 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>

I don't think it's appropriate for me to ack this since I helped develop
the patch. But please remember to include the development release on
patch submissions when appropriate.

Applied to unstable/master and eoan/master-next, thanks!
Stefan Bader Aug. 12, 2019, 1:14 p.m. UTC | #2
On 01.08.19 20:08, Christian Brauner wrote:
> From: Christian Brauner <christian.brauner@canonical.com>
> 
> 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: Stefan Bader <stefan.bader@canonical.com>
> ---
>  fs/open.c            | 4 +++-
>  fs/overlayfs/file.c  | 1 +
>  fs/overlayfs/super.c | 5 +++--
>  fs/shiftfs.c         | 4 +++-
>  include/linux/fs.h   | 3 ++-
>  5 files changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/open.c b/fs/open.c
> index 14502dde6403..b8268a334dc9 100644
> --- 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);
> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
> index 6f6eb638a320..fe61b86c843b 100644
> --- a/fs/overlayfs/file.c
> +++ b/fs/overlayfs/file.c
> @@ -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);
>  
> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
> index bb2a6f80ffd0..46def89a3664 100644
> --- a/fs/overlayfs/super.c
> +++ b/fs/overlayfs/super.c
> @@ -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;
> diff --git a/fs/shiftfs.c b/fs/shiftfs.c
> index 49f6714e9f95..400c3062365c 100644
> --- a/fs/shiftfs.c
> +++ b/fs/shiftfs.c
> @@ -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;
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 5dd548c73f8d..4cb7a1124c5f 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -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);
>
Kleber Sacilotto de Souza Aug. 12, 2019, 2:02 p.m. UTC | #3
On 8/1/19 8:08 PM, Christian Brauner wrote:
> From: Christian Brauner <christian.brauner@canonical.com>
> 
> 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>

Hi Christian,

The LP bug states:

> Target kernels: All LTS kernels that do support shiftfs, if possible.

Will this patch be submitted for Bionic and Xenial as well?


Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>

Thanks,
Kleber

> ---
>  fs/open.c            | 4 +++-
>  fs/overlayfs/file.c  | 1 +
>  fs/overlayfs/super.c | 5 +++--
>  fs/shiftfs.c         | 4 +++-
>  include/linux/fs.h   | 3 ++-
>  5 files changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/open.c b/fs/open.c
> index 14502dde6403..b8268a334dc9 100644
> --- 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);
> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
> index 6f6eb638a320..fe61b86c843b 100644
> --- a/fs/overlayfs/file.c
> +++ b/fs/overlayfs/file.c
> @@ -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);
>  
> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
> index bb2a6f80ffd0..46def89a3664 100644
> --- a/fs/overlayfs/super.c
> +++ b/fs/overlayfs/super.c
> @@ -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;
> diff --git a/fs/shiftfs.c b/fs/shiftfs.c
> index 49f6714e9f95..400c3062365c 100644
> --- a/fs/shiftfs.c
> +++ b/fs/shiftfs.c
> @@ -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;
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 5dd548c73f8d..4cb7a1124c5f 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -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);
>
Khalid Elmously Aug. 13, 2019, 5:18 a.m. UTC | #4
On 2019-08-01 20:08:29 , Christian Brauner wrote:
> From: Christian Brauner <christian.brauner@canonical.com>
> 
> 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>
> ---
>  fs/open.c            | 4 +++-
>  fs/overlayfs/file.c  | 1 +
>  fs/overlayfs/super.c | 5 +++--
>  fs/shiftfs.c         | 4 +++-
>  include/linux/fs.h   | 3 ++-
>  5 files changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/open.c b/fs/open.c
> index 14502dde6403..b8268a334dc9 100644
> --- 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);
> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
> index 6f6eb638a320..fe61b86c843b 100644
> --- a/fs/overlayfs/file.c
> +++ b/fs/overlayfs/file.c
> @@ -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);
>  
> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
> index bb2a6f80ffd0..46def89a3664 100644
> --- a/fs/overlayfs/super.c
> +++ b/fs/overlayfs/super.c
> @@ -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;
> diff --git a/fs/shiftfs.c b/fs/shiftfs.c
> index 49f6714e9f95..400c3062365c 100644
> --- a/fs/shiftfs.c
> +++ b/fs/shiftfs.c
> @@ -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;
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 5dd548c73f8d..4cb7a1124c5f 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -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);
> -- 
> 2.22.0
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
Christian Brauner Aug. 13, 2019, 5:57 a.m. UTC | #5
On August 12, 2019 4:02:33 PM GMT+02:00, Kleber Souza <kleber.souza@canonical.com> wrote:
>On 8/1/19 8:08 PM, Christian Brauner wrote:
>> From: Christian Brauner <christian.brauner@canonical.com>
>> 
>> 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>
>
>Hi Christian,
>
>The LP bug states:
>
>> Target kernels: All LTS kernels that do support shiftfs, if possible.
>
>Will this patch be submitted for Bionic and Xenial as well?

Sorry, was on vacation.
It should go into all kernels that have shiftfs support. :)
Seth probably knows better whether we have this in Bionic and Xenial. I reckon we do.
Seth, do I need to submit this separate patches?

Christian

>
>
>Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
>
>Thanks,
>Kleber
>
>> ---
>>  fs/open.c            | 4 +++-
>>  fs/overlayfs/file.c  | 1 +
>>  fs/overlayfs/super.c | 5 +++--
>>  fs/shiftfs.c         | 4 +++-
>>  include/linux/fs.h   | 3 ++-
>>  5 files changed, 12 insertions(+), 5 deletions(-)
>> 
>> diff --git a/fs/open.c b/fs/open.c
>> index 14502dde6403..b8268a334dc9 100644
>> --- 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);
>> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
>> index 6f6eb638a320..fe61b86c843b 100644
>> --- a/fs/overlayfs/file.c
>> +++ b/fs/overlayfs/file.c
>> @@ -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);
>>  
>> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
>> index bb2a6f80ffd0..46def89a3664 100644
>> --- a/fs/overlayfs/super.c
>> +++ b/fs/overlayfs/super.c
>> @@ -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;
>> diff --git a/fs/shiftfs.c b/fs/shiftfs.c
>> index 49f6714e9f95..400c3062365c 100644
>> --- a/fs/shiftfs.c
>> +++ b/fs/shiftfs.c
>> @@ -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;
>> diff --git a/include/linux/fs.h b/include/linux/fs.h
>> index 5dd548c73f8d..4cb7a1124c5f 100644
>> --- a/include/linux/fs.h
>> +++ b/include/linux/fs.h
>> @@ -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);
>>
Kleber Sacilotto de Souza Aug. 13, 2019, 8:27 a.m. UTC | #6
On 8/13/19 7:57 AM, Christian Brauner wrote:
> On August 12, 2019 4:02:33 PM GMT+02:00, Kleber Souza <kleber.souza@canonical.com> wrote:
>> On 8/1/19 8:08 PM, Christian Brauner wrote:
>>> From: Christian Brauner <christian.brauner@canonical.com>
>>>
>>> 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>
>>
>> Hi Christian,
>>
>> The LP bug states:
>>
>>> Target kernels: All LTS kernels that do support shiftfs, if possible.
>>
>> Will this patch be submitted for Bionic and Xenial as well?
> 
> Sorry, was on vacation.
> It should go into all kernels that have shiftfs support. :)
> Seth probably knows better whether we have this in Bionic and Xenial. I reckon we do.
> Seth, do I need to submit this separate patches?

The file 'fs/shiftfs.c' doesn't exist in B/X, so I assume
it's not needed beyond Disco.


Thanks,
Kleber

> 
> Christian
> 
>>
>>
>> Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
>>
>> Thanks,
>> Kleber
>>
>>> ---
>>>  fs/open.c            | 4 +++-
>>>  fs/overlayfs/file.c  | 1 +
>>>  fs/overlayfs/super.c | 5 +++--
>>>  fs/shiftfs.c         | 4 +++-
>>>  include/linux/fs.h   | 3 ++-
>>>  5 files changed, 12 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/fs/open.c b/fs/open.c
>>> index 14502dde6403..b8268a334dc9 100644
>>> --- 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);
>>> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
>>> index 6f6eb638a320..fe61b86c843b 100644
>>> --- a/fs/overlayfs/file.c
>>> +++ b/fs/overlayfs/file.c
>>> @@ -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);
>>>  
>>> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
>>> index bb2a6f80ffd0..46def89a3664 100644
>>> --- a/fs/overlayfs/super.c
>>> +++ b/fs/overlayfs/super.c
>>> @@ -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;
>>> diff --git a/fs/shiftfs.c b/fs/shiftfs.c
>>> index 49f6714e9f95..400c3062365c 100644
>>> --- a/fs/shiftfs.c
>>> +++ b/fs/shiftfs.c
>>> @@ -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;
>>> diff --git a/include/linux/fs.h b/include/linux/fs.h
>>> index 5dd548c73f8d..4cb7a1124c5f 100644
>>> --- a/include/linux/fs.h
>>> +++ b/include/linux/fs.h
>>> @@ -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);
>>>
>
diff mbox series

Patch

diff --git a/fs/open.c b/fs/open.c
index 14502dde6403..b8268a334dc9 100644
--- 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);
diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
index 6f6eb638a320..fe61b86c843b 100644
--- a/fs/overlayfs/file.c
+++ b/fs/overlayfs/file.c
@@ -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);
 
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index bb2a6f80ffd0..46def89a3664 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -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;
diff --git a/fs/shiftfs.c b/fs/shiftfs.c
index 49f6714e9f95..400c3062365c 100644
--- a/fs/shiftfs.c
+++ b/fs/shiftfs.c
@@ -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;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 5dd548c73f8d..4cb7a1124c5f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -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);