($INBOX_DIR/description missing)
 help / color / Atom feed
* [PATCH] ovl: fix unneeded call to ovl_change_flags()
@ 2020-06-18 15:43 Amir Goldstein
  2020-07-16  4:55 ` Amir Goldstein
  0 siblings, 1 reply; 2+ messages in thread
From: Amir Goldstein @ 2020-06-18 15:43 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: linux-unionfs

The check if user has changed the overlay file was wrong, causing unneeded
call to ovl_change_flags() including taking f_lock on every file access.

Fixes: d989903058a8 ("ovl: do not generate duplicate fsnotify events...")
Cc: <stable@vger.kernel.org> # v4.19+
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 fs/overlayfs/file.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
index 01820e654a21..0d940e29d62b 100644
--- a/fs/overlayfs/file.c
+++ b/fs/overlayfs/file.c
@@ -33,13 +33,16 @@ static char ovl_whatisit(struct inode *inode, struct inode *realinode)
 		return 'm';
 }
 
+/* No atime modificaton nor notify on underlying */
+#define OVL_OPEN_FLAGS (O_NOATIME | FMODE_NONOTIFY)
+
 static struct file *ovl_open_realfile(const struct file *file,
 				      struct inode *realinode)
 {
 	struct inode *inode = file_inode(file);
 	struct file *realfile;
 	const struct cred *old_cred;
-	int flags = file->f_flags | O_NOATIME | FMODE_NONOTIFY;
+	int flags = file->f_flags | OVL_OPEN_FLAGS;
 	int acc_mode = ACC_MODE(flags);
 	int err;
 
@@ -72,8 +75,7 @@ static int ovl_change_flags(struct file *file, unsigned int flags)
 	struct inode *inode = file_inode(file);
 	int err;
 
-	/* No atime modificaton on underlying */
-	flags |= O_NOATIME | FMODE_NONOTIFY;
+	flags |= OVL_OPEN_FLAGS;
 
 	/* If some flag changed that cannot be changed then something's amiss */
 	if (WARN_ON((file->f_flags ^ flags) & ~OVL_SETFL_MASK))
@@ -126,7 +128,7 @@ static int ovl_real_fdget_meta(const struct file *file, struct fd *real,
 	}
 
 	/* Did the flags change since open? */
-	if (unlikely((file->f_flags ^ real->file->f_flags) & ~O_NOATIME))
+	if (unlikely((file->f_flags ^ real->file->f_flags) & ~OVL_OPEN_FLAGS))
 		return ovl_change_flags(real->file, file->f_flags);
 
 	return 0;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ovl: fix unneeded call to ovl_change_flags()
  2020-06-18 15:43 [PATCH] ovl: fix unneeded call to ovl_change_flags() Amir Goldstein
@ 2020-07-16  4:55 ` Amir Goldstein
  0 siblings, 0 replies; 2+ messages in thread
From: Amir Goldstein @ 2020-07-16  4:55 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: overlayfs

On Thu, Jun 18, 2020 at 6:44 PM Amir Goldstein <amir73il@gmail.com> wrote:
>
> The check if user has changed the overlay file was wrong, causing unneeded
> call to ovl_change_flags() including taking f_lock on every file access.
>
> Fixes: d989903058a8 ("ovl: do not generate duplicate fsnotify events...")
> Cc: <stable@vger.kernel.org> # v4.19+
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
>  fs/overlayfs/file.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
> index 01820e654a21..0d940e29d62b 100644
> --- a/fs/overlayfs/file.c
> +++ b/fs/overlayfs/file.c
> @@ -33,13 +33,16 @@ static char ovl_whatisit(struct inode *inode, struct inode *realinode)
>                 return 'm';
>  }
>
> +/* No atime modificaton nor notify on underlying */
> +#define OVL_OPEN_FLAGS (O_NOATIME | FMODE_NONOTIFY)
> +
>  static struct file *ovl_open_realfile(const struct file *file,
>                                       struct inode *realinode)
>  {
>         struct inode *inode = file_inode(file);
>         struct file *realfile;
>         const struct cred *old_cred;
> -       int flags = file->f_flags | O_NOATIME | FMODE_NONOTIFY;
> +       int flags = file->f_flags | OVL_OPEN_FLAGS;
>         int acc_mode = ACC_MODE(flags);
>         int err;
>
> @@ -72,8 +75,7 @@ static int ovl_change_flags(struct file *file, unsigned int flags)
>         struct inode *inode = file_inode(file);
>         int err;
>
> -       /* No atime modificaton on underlying */
> -       flags |= O_NOATIME | FMODE_NONOTIFY;
> +       flags |= OVL_OPEN_FLAGS;
>
>         /* If some flag changed that cannot be changed then something's amiss */
>         if (WARN_ON((file->f_flags ^ flags) & ~OVL_SETFL_MASK))
> @@ -126,7 +128,7 @@ static int ovl_real_fdget_meta(const struct file *file, struct fd *real,
>         }
>
>         /* Did the flags change since open? */
> -       if (unlikely((file->f_flags ^ real->file->f_flags) & ~O_NOATIME))
> +       if (unlikely((file->f_flags ^ real->file->f_flags) & ~OVL_OPEN_FLAGS))
>                 return ovl_change_flags(real->file, file->f_flags);
>
>         return 0;
> --
> 2.17.1
>

Miklos,

Was this patch left out intentionally?

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-18 15:43 [PATCH] ovl: fix unneeded call to ovl_change_flags() Amir Goldstein
2020-07-16  4:55 ` Amir Goldstein

($INBOX_DIR/description missing)

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-unionfs/0 linux-unionfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-unionfs linux-unionfs/ https://lore.kernel.org/linux-unionfs \
		linux-unionfs@vger.kernel.org
	public-inbox-index linux-unionfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-unionfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git