Commit 00de23f4 authored by Amir Goldstein's avatar Amir Goldstein Committed by Greg Kroah-Hartman

ovl: fix unneeded call to ovl_change_flags()

commit 81a33c1e upstream.

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: d9899030 ("ovl: do not generate duplicate fsnotify events for "fake" path")
Cc: <stable@vger.kernel.org> # v4.19+
Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f03b3a03
...@@ -24,13 +24,16 @@ static char ovl_whatisit(struct inode *inode, struct inode *realinode) ...@@ -24,13 +24,16 @@ static char ovl_whatisit(struct inode *inode, struct inode *realinode)
return 'm'; 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, static struct file *ovl_open_realfile(const struct file *file,
struct inode *realinode) struct inode *realinode)
{ {
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
struct file *realfile; struct file *realfile;
const struct cred *old_cred; const struct cred *old_cred;
int flags = file->f_flags | O_NOATIME | FMODE_NONOTIFY; int flags = file->f_flags | OVL_OPEN_FLAGS;
old_cred = ovl_override_creds(inode->i_sb); old_cred = ovl_override_creds(inode->i_sb);
realfile = open_with_fake_path(&file->f_path, flags, realinode, realfile = open_with_fake_path(&file->f_path, flags, realinode,
...@@ -51,8 +54,7 @@ static int ovl_change_flags(struct file *file, unsigned int flags) ...@@ -51,8 +54,7 @@ static int ovl_change_flags(struct file *file, unsigned int flags)
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
int err; int err;
/* No atime modificaton on underlying */ flags |= OVL_OPEN_FLAGS;
flags |= O_NOATIME | FMODE_NONOTIFY;
/* If some flag changed that cannot be changed then something's amiss */ /* If some flag changed that cannot be changed then something's amiss */
if (WARN_ON((file->f_flags ^ flags) & ~OVL_SETFL_MASK)) if (WARN_ON((file->f_flags ^ flags) & ~OVL_SETFL_MASK))
...@@ -105,7 +107,7 @@ static int ovl_real_fdget_meta(const struct file *file, struct fd *real, ...@@ -105,7 +107,7 @@ static int ovl_real_fdget_meta(const struct file *file, struct fd *real,
} }
/* Did the flags change since open? */ /* 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 ovl_change_flags(real->file, file->f_flags);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment