Linux XFS filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: cem@kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 04/11] xfs: convey filesystem unmount events to the health monitor
Date: Tue, 13 Jan 2026 10:48:12 -0800	[thread overview]
Message-ID: <20260113184812.GB15551@frogsfrogsfrogs> (raw)
In-Reply-To: <20260113161105.GC4208@lst.de>

On Tue, Jan 13, 2026 at 05:11:05PM +0100, Christoph Hellwig wrote:
> > +	event = kzalloc(sizeof(struct xfs_healthmon_event), GFP_NOFS);
> > +	mutex_lock(&hm->lock);
> > +
> > +	trace_xfs_healthmon_report_unmount(hm);
> > +
> > +	if (event) {
> > +		/*
> > +		 * Insert the unmount notification at the start of the event
> > +		 * queue so that userspace knows the filesystem went away as
> > +		 * soon as possible.  There's nothing actionable for userspace
> > +		 * after an unmount.
> > +		 */
> > +		event->type = XFS_HEALTHMON_UNMOUNT;
> > +		event->domain = XFS_HEALTHMON_MOUNT;
> > +
> > +		__xfs_healthmon_insert(hm, event);
> 
> The allocation (and locking) could move into __xfs_healthmon_insert
> sharing this code with xfs_ioc_health_monitor().  That means the wake_up
> would not be covered by the lock, but I can't see how that would need
> it.
> 
> > +	} else {
> > +		/*
> > +		 * Wake up the reader directly in case we didn't have enough
> > +		 * memory to queue the unmount event.  The filesystem is about
> > +		 * to go away so we don't care about reporting previously lost
> > +		 * events.
> > +		 */
> > +		wake_up(&hm->wait);
> > +	}
> 
> And then even after reading this many times I'm still not understanding
> it.  Yes, this wakes up the reader direct, but why is waking it up
> without an even ok?

I think that was an artifact from an earlier stage in development where
it was necessary to wake up the reader to get it to drain the event
queue no matter what.  At this point I'd much rather preallocate the
unmount event because...

> And if it is ok, why do we even bother with the
> unmount even?  If OTOH the unmount event is actually important, should
> we preallocate the event?  (and render my above suggestion impractical).

...the unmount is important, because the userspace daemon uses that as
the signal to quit immediately.  If userspace misses the event then
it'll just keep running forever with a dead healthmon fd.

xfs_healer_start will restart the whole service if someone mounts
another xfs filesystem at the same mountpoint, but if nobody does that
then we'll be stuck with a defunct daemon forever.

Let's preallocate the unmount event, and then this whole thing becomes:

	/*
	 * Insert the unmount notification at the start of the event
	 * queue so that userspace knows the filesystem went away as
	 * soon as possible.  There's nothing actionable for userspace
	 * after an unmount.  Once we've inserted unmount_event, hm no
	 * longer owns that event.
	 */
	mutex_lock(&hm->lock);
	__xfs_healthmon_insert(hm, hm->unmount_event);
	hm->unmount_event = NULL;
	mutex_unlock(&hm->lock);

--D

  reply	other threads:[~2026-01-13 18:48 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-13  0:32 [PATCHSET v5] xfs: autonomous self healing of filesystems Darrick J. Wong
2026-01-13  0:32 ` [PATCH 01/11] docs: discuss autonomous self healing in the xfs online repair design doc Darrick J. Wong
2026-01-13 16:00   ` Christoph Hellwig
2026-01-13  0:33 ` [PATCH 02/11] xfs: start creating infrastructure for health monitoring Darrick J. Wong
2026-01-13 16:03   ` Christoph Hellwig
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-13  0:33 ` [PATCH 04/11] xfs: convey filesystem unmount events to the health monitor Darrick J. Wong
2026-01-13 16:11   ` Christoph Hellwig
2026-01-13 18:48     ` Darrick J. Wong [this message]
2026-01-13  0:33 ` [PATCH 05/11] xfs: convey metadata health " Darrick J. Wong
2026-01-13 16:11   ` Christoph Hellwig
2026-01-13  0:34 ` [PATCH 06/11] xfs: convey filesystem shutdown " Darrick J. Wong
2026-01-13 16:14   ` Christoph Hellwig
2026-01-13 19:01     ` Darrick J. Wong
2026-01-13  0:34 ` [PATCH 07/11] xfs: convey externally discovered fsdax media errors " Darrick J. Wong
2026-01-13 16:15   ` Christoph Hellwig
2026-01-13  0:34 ` [PATCH 08/11] xfs: convey file I/O " Darrick J. Wong
2026-01-13 16:15   ` Christoph Hellwig
2026-01-13  0:34 ` [PATCH 09/11] xfs: allow reconfiguration of the health monitoring device Darrick J. Wong
2026-01-13 16:17   ` Christoph Hellwig
2026-01-13 18:28     ` Darrick J. Wong
2026-01-13  0:35 ` [PATCH 10/11] xfs: check if an open file is on the health monitored fs Darrick J. Wong
2026-01-13 16:17   ` Christoph Hellwig
2026-01-13  0:35 ` [PATCH 11/11] xfs: add media verification ioctl Darrick J. Wong
2026-01-13 15:57   ` Christoph Hellwig
2026-01-13 23:21     ` Darrick J. Wong
2026-01-14  5:40       ` Darrick J. Wong
2026-01-14  6:02       ` Christoph Hellwig
2026-01-14  6:07         ` Darrick J. Wong
2026-01-14  6:15           ` Christoph Hellwig
2026-01-14  6:19             ` Darrick J. Wong
  -- strict thread matches above, loose matches on Subject: below --
2026-01-21  6:34 [PATCHSET v7 1/3] xfs: autonomous self healing of filesystems Darrick J. Wong
2026-01-21  6:35 ` [PATCH 04/11] xfs: convey filesystem unmount events to the health monitor Darrick J. Wong
2026-01-16  5:42 [PATCHSET v6] xfs: autonomous self healing of filesystems Darrick J. Wong
2026-01-16  5:43 ` [PATCH 04/11] xfs: convey filesystem unmount events to the health monitor Darrick J. Wong
2026-01-19 15:44   ` Christoph Hellwig
2026-01-06  7:10 [PATCHSET V4] xfs: autonomous self healing of filesystems Darrick J. Wong
2026-01-06  7:11 ` [PATCH 04/11] xfs: convey filesystem unmount events to the health monitor 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=20260113184812.GB15551@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=cem@kernel.org \
    --cc=hch@lst.de \
    --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