Linux EXT4 FS development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: brauner@kernel.org, djwong@kernel.org
Cc: linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org,
	hch@lst.de, linux-fsdevel@vger.kernel.org
Subject: [PATCH 2/4] xfs: send uevents when major filesystem events happen
Date: Wed, 17 Dec 2025 18:04:45 -0800	[thread overview]
Message-ID: <176602332548.688213.501157461742943815.stgit@frogsfrogsfrogs> (raw)
In-Reply-To: <176602332484.688213.11232314346072982565.stgit@frogsfrogsfrogs>

From: Darrick J. Wong <djwong@kernel.org>

Send uevents when we mount, unmount, and shut down the filesystem, so
that we can trigger systemd services when major events happen.  This
enables us to create a udev rule that will start up xfs_healer whenever
a filesystem is mounted.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
 fs/xfs/xfs_fsops.c |    2 ++
 fs/xfs/xfs_super.c |   10 ++++++++++
 2 files changed, 12 insertions(+)


diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index b7c21f68edc78d..bd1022ecd2eb4c 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -27,6 +27,7 @@
 #include "xfs_metafile.h"
 
 #include <linux/fserror.h>
+#include <linux/fsevent.h>
 
 /*
  * Write new AG headers to disk. Non-transactional, but need to be
@@ -544,6 +545,7 @@ xfs_do_force_shutdown(
 		xfs_stack_trace();
 
 	fserror_report_shutdown(mp->m_super, GFP_KERNEL);
+	fsevent_send_shutdown(mp->m_super, &mp->m_kobj.kobject);
 }
 
 /*
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index bc71aa9dcee8d6..bd078c99389bc1 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -53,6 +53,8 @@
 #include <linux/magic.h>
 #include <linux/fs_context.h>
 #include <linux/fs_parser.h>
+#include <linux/uuid.h>
+#include <linux/fsevent.h>
 
 static const struct super_operations xfs_super_operations;
 
@@ -1249,6 +1251,8 @@ xfs_fs_put_super(
 {
 	struct xfs_mount	*mp = XFS_M(sb);
 
+	fsevent_send_unmount(mp->m_super, &mp->m_kobj.kobject);
+
 	xfs_notice(mp, "Unmounting Filesystem %pU", &mp->m_sb.sb_uuid);
 	xfs_filestream_unmount(mp);
 	xfs_unmountfs(mp);
@@ -1972,6 +1976,11 @@ xfs_fs_fill_super(
 		goto out_unmount;
 	}
 
+	/*
+	 * Send a uevent signalling that the mount succeeded so we can use udev
+	 * rules to start background services.
+	 */
+	fsevent_send_mount(mp->m_super, &mp->m_kobj.kobject, fc);
 	return 0;
 
  out_filestream_unmount:
@@ -2217,6 +2226,7 @@ xfs_fs_reconfigure(
 			return error;
 	}
 
+	fsevent_send_remount(mp->m_super, &mp->m_kobj.kobject);
 	return 0;
 }
 


  parent reply	other threads:[~2025-12-18  2:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-18  2:02 [PATCHSET V4 2/2] fs: send uevents on mount and unmount Darrick J. Wong
2025-12-18  2:04 ` [PATCH 1/4] fs: send uevents for filesystem mount events Darrick J. Wong
2025-12-18  5:26   ` Christoph Hellwig
2025-12-18 19:49     ` Darrick J. Wong
2025-12-18 23:33   ` [PATCH V4.1 " Darrick J. Wong
2025-12-24 12:47   ` [PATCH " Christian Brauner
2025-12-26 23:58     ` Ian Kent
2026-01-05 17:26       ` Darrick J. Wong
2026-01-05 17:25     ` Darrick J. Wong
2025-12-18  2:04 ` Darrick J. Wong [this message]
2025-12-18  5:27   ` [PATCH 2/4] xfs: send uevents when major filesystem events happen Christoph Hellwig
2025-12-18  2:05 ` [PATCH 3/4] ext4: convert ext4_root to a kset Darrick J. Wong
2025-12-18  5:27   ` Christoph Hellwig
2025-12-18  2:05 ` [PATCH 4/4] ext4: send uevents when major filesystem events happen Darrick J. Wong
2025-12-18  5:27   ` Christoph Hellwig

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=176602332548.688213.501157461742943815.stgit@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=brauner@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-ext4@vger.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