]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: allow toggling verbose logging on the health monitoring file
authorDarrick J. Wong <djwong@kernel.org>
Wed, 21 Jan 2026 02:06:51 +0000 (18:06 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 21 Jan 2026 02:06:51 +0000 (18:06 -0800)
Make it so that we can reconfigure the health monitoring device by
calling the XFS_IOC_HEALTH_MONITOR ioctl on it.  As of right now we can
only toggle the verbose flag, but this is less annoying than having to
closing the monitor fd and reopen it.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_healthmon.c

index 1bb4b0adf2470e75dc618a05129834fef08c36e7..4a8cbd87932201a753d03ffe16991c255a738306 100644 (file)
@@ -23,6 +23,7 @@
 #include "xfs_fsops.h"
 #include "xfs_notify_failure.h"
 #include "xfs_file.h"
+#include "xfs_ioctl.h"
 
 #include <linux/anon_inodes.h>
 #include <linux/eventpoll.h>
@@ -1066,12 +1067,55 @@ xfs_healthmon_show_fdinfo(
        mutex_unlock(&hm->lock);
 }
 
+/* Reconfigure the health monitor. */
+STATIC long
+xfs_healthmon_reconfigure(
+       struct file                     *file,
+       unsigned int                    cmd,
+       void __user                     *arg)
+{
+       struct xfs_health_monitor       hmo;
+       struct xfs_healthmon            *hm = file->private_data;
+
+       if (copy_from_user(&hmo, arg, sizeof(hmo)))
+               return -EFAULT;
+
+       if (!xfs_healthmon_validate(&hmo))
+               return -EINVAL;
+
+       mutex_lock(&hm->lock);
+       hm->verbose = !!(hmo.flags & XFS_HEALTH_MONITOR_VERBOSE);
+       mutex_unlock(&hm->lock);
+
+       return 0;
+}
+
+/* Handle ioctls for the health monitoring thread. */
+STATIC long
+xfs_healthmon_ioctl(
+       struct file                     *file,
+       unsigned int                    cmd,
+       unsigned long                   p)
+{
+       void __user                     *arg = (void __user *)p;
+
+       switch (cmd) {
+       case XFS_IOC_HEALTH_MONITOR:
+               return xfs_healthmon_reconfigure(file, cmd, arg);
+       default:
+               break;
+       }
+
+       return -ENOTTY;
+}
+
 static const struct file_operations xfs_healthmon_fops = {
        .owner          = THIS_MODULE,
        .show_fdinfo    = xfs_healthmon_show_fdinfo,
        .read_iter      = xfs_healthmon_read_iter,
        .poll           = xfs_healthmon_poll,
        .release        = xfs_healthmon_release,
+       .unlocked_ioctl = xfs_healthmon_ioctl,
 };
 
 /*