[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOQ4uxjm_106b-KDS09MEa9tUdzywh2P5HCCfWxRZMuy3XM8xw@mail.gmail.com>
Date: Tue, 19 Oct 2021 09:07:04 +0300
From: Amir Goldstein <amir73il@...il.com>
To: Gabriel Krisman Bertazi <krisman@...labora.com>
Cc: Jan Kara <jack@...e.com>, "Darrick J. Wong" <djwong@...nel.org>,
Theodore Tso <tytso@....edu>,
Dave Chinner <david@...morbit.com>,
David Howells <dhowells@...hat.com>,
Khazhismel Kumykov <khazhy@...gle.com>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Ext4 <linux-ext4@...r.kernel.org>,
Linux API <linux-api@...r.kernel.org>, kernel@...labora.com
Subject: Re: [PATCH v8 27/32] fanotify: Report fid info for file related file
system errors
On Tue, Oct 19, 2021 at 3:04 AM Gabriel Krisman Bertazi
<krisman@...labora.com> wrote:
>
> Plumb the pieces to add a FID report to error records. Since all error
> event memory must be pre-allocated, we pre-allocate the maximum file
> handle size possible, such that it should always fit.
>
> For errors that don't expose a file handle report it with an invalid
> FID.
>
> Signed-off-by: Gabriel Krisman Bertazi <krisman@...labora.com>
>
Reviewed-by: Amir Goldstein <amir73il@...il.com>
with minor nit below..
> ---
> Changes since v7:
> - Move WARN_ON to separate patch (Amir)
> - Avoid duplication in the structure definition (Amir)
> Changes since v6:
> - pass fsid from handle_events
> Changes since v5:
> - Use preallocated MAX_HANDLE_SZ FH buffer
> - Report superblock errors with a zerolength INVALID FID (jan, amir)
> ---
> fs/notify/fanotify/fanotify.c | 10 ++++++++++
> fs/notify/fanotify/fanotify.h | 11 +++++++++++
> 2 files changed, 21 insertions(+)
>
> diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
> index 45df610debbe..335ce8f88eb8 100644
> --- a/fs/notify/fanotify/fanotify.c
> +++ b/fs/notify/fanotify/fanotify.c
> @@ -609,7 +609,9 @@ static struct fanotify_event *fanotify_alloc_error_event(
> {
> struct fs_error_report *report =
> fsnotify_data_error_report(data, data_type);
> + struct inode *inode = report->inode;
> struct fanotify_error_event *fee;
> + int fh_len;
>
> if (WARN_ON_ONCE(!report))
> return NULL;
> @@ -622,6 +624,14 @@ static struct fanotify_event *fanotify_alloc_error_event(
> fee->err_count = 1;
> fee->fsid = *fsid;
>
> + fh_len = fanotify_encode_fh_len(inode);
> +
> + /* Bad fh_len. Fallback to using an invalid fh. Should never happen. */
> + if (!fh_len && inode)
> + inode = NULL;
> +
> + fanotify_encode_fh(&fee->object_fh, inode, fh_len, NULL, 0);
> +
> *hash ^= fanotify_hash_fsid(fsid);
>
> return &fee->fae;
> diff --git a/fs/notify/fanotify/fanotify.h b/fs/notify/fanotify/fanotify.h
> index bdf01ad4f9bf..4246a34667b5 100644
> --- a/fs/notify/fanotify/fanotify.h
> +++ b/fs/notify/fanotify/fanotify.h
> @@ -209,6 +209,9 @@ struct fanotify_error_event {
> u32 err_count; /* Suppressed errors count */
>
> __kernel_fsid_t fsid; /* FSID this error refers to. */
> +
> + /* This must be the last element of the structure. */
> + FANOTIFY_INLINE_FH(MAX_HANDLE_SZ);
Does not really have to be last but certainly doesn't hurt
Thanks,
Amir.
Powered by blists - more mailing lists