From: Jan Kara <jack@suse.cz>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Miklos Szeredi <miklos@szeredi.hu>,
Christoph Hellwig <hch@lst.de>,
David Howells <dhowells@redhat.com>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org
Subject: Re: [PATCH v4 2/2] ovl: enable fsnotify events on underlying real files
Date: Wed, 14 Jun 2023 11:54:05 +0200 [thread overview]
Message-ID: <20230614095405.e22qzktue4igcula@quack3> (raw)
In-Reply-To: <20230614074907.1943007-3-amir73il@gmail.com>
On Wed 14-06-23 10:49:07, Amir Goldstein wrote:
> Overlayfs creates the real underlying files with fake f_path, whose
> f_inode is on the underlying fs and f_path on overlayfs.
>
> Those real files were open with FMODE_NONOTIFY, because fsnotify code was
> not prapared to handle fsnotify hooks on files with fake path correctly
> and fanotify would report unexpected event->fd with fake overlayfs path,
> when the underlying fs was being watched.
>
> Teach fsnotify to handle events on the real files, and do not set real
> files to FMODE_NONOTIFY to allow operations on real file (e.g. open,
> access, modify, close) to generate async and permission events.
>
> Because fsnotify does not have notifications on address space
> operations, we do not need to worry about ->vm_file not reporting
> events to a watched overlayfs when users are accessing a mapped
> overlayfs file.
>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Looks good to me. Feel free to add:
Acked-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/overlayfs/file.c | 4 ++--
> include/linux/fsnotify.h | 3 ++-
> 2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
> index 8cf099aa97de..1fdfc53f1207 100644
> --- a/fs/overlayfs/file.c
> +++ b/fs/overlayfs/file.c
> @@ -34,8 +34,8 @@ static char ovl_whatisit(struct inode *inode, struct inode *realinode)
> return 'm';
> }
>
> -/* No atime modification nor notify on underlying */
> -#define OVL_OPEN_FLAGS (O_NOATIME | FMODE_NONOTIFY)
> +/* No atime modification on underlying */
> +#define OVL_OPEN_FLAGS (O_NOATIME)
>
> static struct file *ovl_open_realfile(const struct file *file,
> const struct path *realpath)
> diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
> index bb8467cd11ae..6f6cbc2dc49b 100644
> --- a/include/linux/fsnotify.h
> +++ b/include/linux/fsnotify.h
> @@ -91,7 +91,8 @@ static inline void fsnotify_dentry(struct dentry *dentry, __u32 mask)
>
> static inline int fsnotify_file(struct file *file, __u32 mask)
> {
> - const struct path *path = &file->f_path;
> + /* Overlayfs internal files have fake f_path */
> + const struct path *path = f_real_path(file);
>
> if (file->f_mode & FMODE_NONOTIFY)
> return 0;
> --
> 2.34.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
prev parent reply other threads:[~2023-06-14 9:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-14 7:49 [PATCH v4 0/2] Handle notifications on overlayfs fake path files Amir Goldstein
2023-06-14 7:49 ` [PATCH v4 1/2] fs: use backing_file container for internal files with "fake" f_path Amir Goldstein
2023-06-14 13:26 ` Christian Brauner
2023-06-14 13:48 ` Amir Goldstein
2023-06-15 11:32 ` Amir Goldstein
2023-06-15 4:24 ` Christoph Hellwig
2023-06-14 7:49 ` [PATCH v4 2/2] ovl: enable fsnotify events on underlying real files Amir Goldstein
2023-06-14 9:54 ` Jan Kara [this message]
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=20230614095405.e22qzktue4igcula@quack3 \
--to=jack@suse.cz \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=dhowells@redhat.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--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).