From: Christoph Hellwig <hch@lst.de>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: cem@kernel.org, linux-xfs@vger.kernel.org, hch@lst.de,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 03/11] xfs: create event queuing, formatting, and discovery infrastructure
Date: Wed, 7 Jan 2026 10:32:45 +0100 [thread overview]
Message-ID: <20260107093245.GA24264@lst.de> (raw)
In-Reply-To: <176766637311.774337.2635132516714726157.stgit@frogsfrogsfrogs>
On Mon, Jan 05, 2026 at 11:11:24PM -0800, Darrick J. Wong wrote:
> diff --git a/fs/xfs/xfs_healthmon.c b/fs/xfs/xfs_healthmon.c
> index 3fdac72b478f3f..799e0687ae3263 100644
> --- a/fs/xfs/xfs_healthmon.c
> +++ b/fs/xfs/xfs_healthmon.c
> @@ -45,6 +45,13 @@
> /* sign of a detached health monitor */
> #define DETACHED_MOUNT_COOKIE ((uintptr_t)0)
>
> +/* Constrain the number of event objects that can build up in memory. */
> +#define XFS_HEALTHMON_MAX_EVENTS \
> + (SZ_32K / sizeof(struct xfs_healthmon_event))
The double tab indent here looks a bit weird.
> +/* Free all events */
> +STATIC void
> +xfs_healthmon_free_events(
> + struct xfs_healthmon *hm)
> +{
> + struct xfs_healthmon_event *event, *next;
> +
> + event = hm->first_event;
> + while (event != NULL) {
> + trace_xfs_healthmon_drop(hm, event);
> + next = event->next;
> + kfree(event);
> + event = next;
> + }
This could be simplified a bit to:
struct xfs_healthmon_event *event = hm->first_event;
while (event) {
struct xfs_healthmon_event *next = event->next;
trace_xfs_healthmon_drop(hm, event);
kfree(event);
event = next;
}
or alternatively:
struct xfs_healthmon_event *event, *next = hm->first_event;
while ((event = next) != NULL) {
trace_xfs_healthmon_drop(hm, event);
next = event->next;
kfree(event);
}
> + hm->first_event = hm->last_event = NULL;
Always personal preference, but I always hate decoding double assignments
like this vs the more verbose:
hm->first_event = NULL;
hm->last_event = NULL;
that beeing said, do we even need to zero these given that hm gets freed
right after?
> + return false;
> +
> + switch (existing->type) {
> + case XFS_HEALTHMON_RUNNING:
> + /* should only ever be one of these events anyway */
> + return false;
> +
> + case XFS_HEALTHMON_LOST:
> + existing->lostcount += new->lostcount;
> + return true;
> + }
> +
> + return false;
I think the XFS_HEALTHMON_RUNNING check here is redundant, so you could
just special case XFS_HEALTHMON_LOST with an if instead of the switch
statement.
> +/* Make a stack event dynamic so we can put it on the list. */
> +static inline struct xfs_healthmon_event *
> +xfs_healthmon_event_dup(
> + const struct xfs_healthmon_event *event)
> +{
> + return kmemdup(event, sizeof(struct xfs_healthmon_event), GFP_NOFS);
> +}
The callers of this and and xfs_healthmon_merge_events seem to share
the same logic. Maybe add a helper for the two calls and the
XFS_HEALTHMON_MAX_EVENTS check, and fold at least xfs_healthmon_event_dup
(and maybe xfs_healthmon_merge_events if it works out) into that?
> + if (file->f_flags & O_NONBLOCK) {
> + if (!xfs_healthmon_has_eventdata(hm))
> + return -EAGAIN;
> + } else {
> + ret = wait_event_interruptible(hm->wait,
> + xfs_healthmon_has_eventdata(hm));
> + if (ret)
> + return ret;
> + }
> +
> + inode_lock(inode);
should this be a trylock + -EAGAIN for O_NONBLOCK?
next prev parent reply other threads:[~2026-01-07 9:32 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-06 7:10 [PATCHSET V4] xfs: autonomous self healing of filesystems Darrick J. Wong
2026-01-06 7:10 ` [PATCH 01/11] docs: discuss autonomous self healing in the xfs online repair design doc Darrick J. Wong
2026-01-07 9:08 ` Christoph Hellwig
2026-01-07 19:15 ` Darrick J. Wong
2026-01-06 7:11 ` [PATCH 02/11] xfs: start creating infrastructure for health monitoring Darrick J. Wong
2026-01-07 9:17 ` Christoph Hellwig
2026-01-07 18:50 ` Darrick J. Wong
2026-01-08 10:21 ` Christoph Hellwig
2026-01-06 7:11 ` [PATCH 03/11] xfs: create event queuing, formatting, and discovery infrastructure Darrick J. Wong
2026-01-07 9:32 ` Christoph Hellwig [this message]
2026-01-07 19:01 ` Darrick J. Wong
2026-01-06 7:11 ` [PATCH 04/11] xfs: convey filesystem unmount events to the health monitor Darrick J. Wong
2026-01-06 7:11 ` [PATCH 05/11] xfs: convey metadata health " Darrick J. Wong
2026-01-06 7:12 ` [PATCH 06/11] xfs: convey filesystem shutdown " Darrick J. Wong
2026-01-06 7:12 ` [PATCH 07/11] xfs: convey externally discovered fsdax media errors " Darrick J. Wong
2026-01-06 7:12 ` [PATCH 08/11] xfs: convey file I/O " Darrick J. Wong
2026-01-06 7:12 ` [PATCH 09/11] xfs: allow reconfiguration of the health monitoring device Darrick J. Wong
2026-01-06 7:13 ` [PATCH 10/11] xfs: check if an open file is on the health monitored fs Darrick J. Wong
2026-01-06 7:13 ` [PATCH 11/11] xfs: add media error reporting ioctl Darrick J. Wong
2026-01-07 9:36 ` Christoph Hellwig
2026-01-07 16:30 ` Darrick J. Wong
2026-01-08 10:25 ` Christoph Hellwig
2026-01-08 16:09 ` Darrick J. Wong
2026-01-08 16:14 ` Christoph Hellwig
2026-01-08 16:18 ` Darrick J. Wong
2026-01-08 16:20 ` Christoph Hellwig
2026-01-08 16:53 ` Darrick J. Wong
2026-01-12 5:24 ` Darrick J. Wong
-- strict thread matches above, loose matches on Subject: below --
2026-01-13 0:32 [PATCHSET v5] xfs: autonomous self healing of filesystems Darrick J. Wong
2026-01-13 0:33 ` [PATCH 03/11] xfs: create event queuing, formatting, and discovery infrastructure Darrick J. Wong
2026-01-13 16:05 ` Christoph Hellwig
2026-01-16 5:42 [PATCHSET v6] xfs: autonomous self healing of filesystems Darrick J. Wong
2026-01-16 5:42 ` [PATCH 03/11] xfs: create event queuing, formatting, and discovery infrastructure Darrick J. Wong
2026-01-21 6:34 [PATCHSET v7 1/3] xfs: autonomous self healing of filesystems Darrick J. Wong
2026-01-21 6:35 ` [PATCH 03/11] xfs: create event queuing, formatting, and discovery infrastructure Darrick J. Wong
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=20260107093245.GA24264@lst.de \
--to=hch@lst.de \
--cc=cem@kernel.org \
--cc=djwong@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/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