linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Miklos Szeredi <mszeredi@redhat.com>, linux-unionfs@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH v2 32/35] Partially revert "locks: fix file locking on overlayfs"
Date: Tue, 08 May 2018 11:15:47 -0400	[thread overview]
Message-ID: <129bf5c889e3317d6372a2f251cbd56458347224.camel@kernel.org> (raw)
In-Reply-To: <20180507083807.28792-33-mszeredi@redhat.com>

On Mon, 2018-05-07 at 10:38 +0200, Miklos Szeredi wrote:
> This partially reverts commit c568d68341be7030f5647def68851e469b21ca11.
> 
> Overlayfs files will now automatically get the correct locks, no need to
> hack overlay support in VFS.
> 
> It is a partial revert, because it leaves the locks_inode() calls in place
> and defines locks_inode() to file_inode().  We could revert those as well,
> but it would be unnecessary code churn and it makes sense to document that
> we are getting the inode for locking purposes.
> 
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
> ---
>  fs/locks.c              | 17 ++++++-----------
>  fs/overlayfs/super.c    |  2 +-
>  include/linux/fs.h      | 13 +------------
>  include/uapi/linux/fs.h |  1 -
>  4 files changed, 8 insertions(+), 25 deletions(-)
> 
> diff --git a/fs/locks.c b/fs/locks.c
> index 9c0e5f3da66c..40bcbaaa3f52 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -139,11 +139,6 @@
>  #define IS_OFDLCK(fl)	(fl->fl_flags & FL_OFDLCK)
>  #define IS_REMOTELCK(fl)	(fl->fl_pid <= 0)
>  
> -static inline bool is_remote_lock(struct file *filp)
> -{
> -	return likely(!(filp->f_path.dentry->d_sb->s_flags & SB_NOREMOTELOCK));
> -}
> -
>  static bool lease_breaking(struct file_lock *fl)
>  {
>  	return fl->fl_flags & (FL_UNLOCK_PENDING | FL_DOWNGRADE_PENDING);
> @@ -1875,7 +1870,7 @@ EXPORT_SYMBOL(generic_setlease);
>  int
>  vfs_setlease(struct file *filp, long arg, struct file_lock **lease, void **priv)
>  {
> -	if (filp->f_op->setlease && is_remote_lock(filp))
> +	if (filp->f_op->setlease)
>  		return filp->f_op->setlease(filp, arg, lease, priv);
>  	else
>  		return generic_setlease(filp, arg, lease, priv);
> @@ -2022,7 +2017,7 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd)
>  	if (error)
>  		goto out_free;
>  
> -	if (f.file->f_op->flock && is_remote_lock(f.file))
> +	if (f.file->f_op->flock)
>  		error = f.file->f_op->flock(f.file,
>  					  (can_sleep) ? F_SETLKW : F_SETLK,
>  					  lock);
> @@ -2048,7 +2043,7 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd)
>   */
>  int vfs_test_lock(struct file *filp, struct file_lock *fl)
>  {
> -	if (filp->f_op->lock && is_remote_lock(filp))
> +	if (filp->f_op->lock)
>  		return filp->f_op->lock(filp, F_GETLK, fl);
>  	posix_test_lock(filp, fl);
>  	return 0;
> @@ -2191,7 +2186,7 @@ int fcntl_getlk(struct file *filp, unsigned int cmd, struct flock *flock)
>   */
>  int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf)
>  {
> -	if (filp->f_op->lock && is_remote_lock(filp))
> +	if (filp->f_op->lock)
>  		return filp->f_op->lock(filp, cmd, fl);
>  	else
>  		return posix_lock_file(filp, fl, conf);
> @@ -2513,7 +2508,7 @@ locks_remove_flock(struct file *filp, struct file_lock_context *flctx)
>  	if (list_empty(&flctx->flc_flock))
>  		return;
>  
> -	if (filp->f_op->flock && is_remote_lock(filp))
> +	if (filp->f_op->flock)
>  		filp->f_op->flock(filp, F_SETLKW, &fl);
>  	else
>  		flock_lock_inode(inode, &fl);
> @@ -2600,7 +2595,7 @@ EXPORT_SYMBOL(posix_unblock_lock);
>   */
>  int vfs_cancel_lock(struct file *filp, struct file_lock *fl)
>  {
> -	if (filp->f_op->lock && is_remote_lock(filp))
> +	if (filp->f_op->lock)
>  		return filp->f_op->lock(filp, F_CANCELLK, fl);
>  	return 0;
>  }
> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
> index 7779fc610767..f2a83fabe2eb 100644
> --- a/fs/overlayfs/super.c
> +++ b/fs/overlayfs/super.c
> @@ -1479,7 +1479,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
>  	sb->s_op = &ovl_super_operations;
>  	sb->s_xattr = ovl_xattr_handlers;
>  	sb->s_fs_info = ofs;
> -	sb->s_flags |= SB_POSIXACL | SB_NOREMOTELOCK;
> +	sb->s_flags |= SB_POSIXACL;
>  
>  	err = -ENOMEM;
>  	root_dentry = d_make_root(ovl_new_inode(sb, S_IFDIR, 0));
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index ba3078693d4a..417e692a606a 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1050,17 +1050,7 @@ struct file_lock_context {
>  
>  extern void send_sigio(struct fown_struct *fown, int fd, int band);
>  
> -/*
> - * Return the inode to use for locking
> - *
> - * For overlayfs this should be the overlay inode, not the real inode returned
> - * by file_inode().  For any other fs file_inode(filp) and locks_inode(filp) are
> - * equal.
> - */
> -static inline struct inode *locks_inode(const struct file *f)
> -{
> -	return f->f_path.dentry->d_inode;
> -}
> +#define locks_inode(f) file_inode(f)
>  
>  #ifdef CONFIG_FILE_LOCKING
>  extern int fcntl_getlk(struct file *, unsigned int, struct flock *);
> @@ -1300,7 +1290,6 @@ extern int send_sigurg(struct fown_struct *fown);
>  
>  /* These sb flags are internal to the kernel */
>  #define SB_SUBMOUNT     (1<<26)
> -#define SB_NOREMOTELOCK	(1<<27)
>  #define SB_NOSEC	(1<<28)
>  #define SB_BORN		(1<<29)
>  #define SB_ACTIVE	(1<<30)
> diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
> index d2a8313fabd7..2840ddcece73 100644
> --- a/include/uapi/linux/fs.h
> +++ b/include/uapi/linux/fs.h
> @@ -134,7 +134,6 @@ struct inodes_stat_t {
>  
>  /* These sb flags are internal to the kernel */
>  #define MS_SUBMOUNT     (1<<26)
> -#define MS_NOREMOTELOCK	(1<<27)
>  #define MS_NOSEC	(1<<28)
>  #define MS_BORN		(1<<29)
>  #define MS_ACTIVE	(1<<30)

Acked-by: Jeff Layton <jlayton@kernel.org>

  reply	other threads:[~2018-05-08 15:15 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-07  8:37 [PATCH v2 00/35] overlayfs: stack file operations Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 01/35] vfs: add path_open() Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 02/35] vfs: optionally don't account file in nr_files Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 03/35] vfs: add f_op->pre_mmap() Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 04/35] vfs: export vfs_ioctl() to modules Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 05/35] vfs: export vfs_dedupe_file_range_one() " Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 06/35] ovl: copy up times Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 07/35] ovl: copy up inode flags Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 08/35] Revert "Revert "ovl: get_write_access() in truncate"" Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 09/35] ovl: copy up file size as well Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 10/35] ovl: deal with overlay files in ovl_d_real() Miklos Szeredi
2018-05-07 13:17   ` Vivek Goyal
2018-05-07  8:37 ` [PATCH v2 11/35] ovl: stack file ops Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 12/35] ovl: add helper to return real file Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 13/35] ovl: add ovl_read_iter() Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 14/35] ovl: add ovl_write_iter() Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 15/35] ovl: add ovl_fsync() Miklos Szeredi
2018-05-08  5:14   ` Amir Goldstein
2018-05-08 14:57     ` Miklos Szeredi
2018-05-08 15:02       ` Amir Goldstein
2018-05-07  8:37 ` [PATCH v2 16/35] ovl: add ovl_mmap() Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 17/35] ovl: add ovl_fallocate() Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 18/35] ovl: add lsattr/chattr support Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 19/35] ovl: add ovl_fiemap() Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 20/35] ovl: add O_DIRECT support Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 21/35] ovl: add reflink/copyfile/dedup support Miklos Szeredi
2018-05-07 20:43   ` Darrick J. Wong
2018-05-08 14:13     ` Miklos Szeredi
2018-05-08 14:38       ` Darrick J. Wong
2018-05-07  8:37 ` [PATCH v2 22/35] vfs: don't open real Miklos Szeredi
2018-05-07 10:27   ` Amir Goldstein
2018-05-07 10:29     ` Miklos Szeredi
2018-05-11 18:54   ` Vivek Goyal
2018-05-11 19:42     ` Vivek Goyal
2018-05-14 13:58       ` Vivek Goyal
2018-05-15 20:42         ` Vivek Goyal
2018-05-14 14:03       ` Daniel Walsh
2018-05-07  8:37 ` [PATCH v2 23/35] ovl: copy-up on MAP_SHARED Miklos Szeredi
2018-05-07 19:28   ` Randy Dunlap
2018-05-08 15:03     ` Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 24/35] vfs: simplify dentry_open() Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 25/35] Revert "ovl: fix may_write_real() for overlayfs directories" Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 26/35] Revert "ovl: don't allow writing ioctl on lower layer" Miklos Szeredi
2018-05-07  8:37 ` [PATCH v2 27/35] vfs: fix freeze protection in mnt_want_write_file() for overlayfs Miklos Szeredi
2018-05-07  8:38 ` [PATCH v2 28/35] Revert "ovl: fix relatime for directories" Miklos Szeredi
2018-05-07  8:38 ` [PATCH v2 29/35] Revert "vfs: update ovl inode before relatime check" Miklos Szeredi
2018-05-07  8:38 ` [PATCH v2 30/35] Revert "vfs: add flags to d_real()" Miklos Szeredi
2018-05-07  8:38 ` [PATCH v2 31/35] Revert "vfs: do get_write_access() on upper layer of overlayfs" Miklos Szeredi
2018-05-07  8:38 ` [PATCH v2 32/35] Partially revert "locks: fix file locking on overlayfs" Miklos Szeredi
2018-05-08 15:15   ` Jeff Layton [this message]
2018-05-07  8:38 ` [PATCH v2 33/35] Revert "fsnotify: support overlayfs" Miklos Szeredi
2018-05-07  8:38 ` [PATCH v2 34/35] vfs: remove open_flags from d_real() Miklos Szeredi
2018-05-07  8:38 ` [PATCH v2 35/35] ovl: fix documentation of non-standard behavior Miklos Szeredi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=129bf5c889e3317d6372a2f251cbd56458347224.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=mszeredi@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).