diff options
| author | Darrick J. Wong <djwong@kernel.org> | 2026-01-20 18:06:51 -0800 |
|---|---|---|
| committer | Darrick J. Wong <djwong@kernel.org> | 2026-01-20 18:06:51 -0800 |
| commit | c0e719cb36672b69a06da65ac4ec71e9a599dff5 (patch) | |
| tree | 1c7099b11128dea7f600897d4297adf299dd2007 | |
| parent | dfa8bad3a8796ce1ca4f1d15158e2ecfb9c5c014 (diff) | |
xfs: allow toggling verbose logging on the health monitoring file
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>
| -rw-r--r-- | fs/xfs/xfs_healthmon.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/fs/xfs/xfs_healthmon.c b/fs/xfs/xfs_healthmon.c index 1bb4b0adf247..4a8cbd879322 100644 --- a/fs/xfs/xfs_healthmon.c +++ b/fs/xfs/xfs_healthmon.c @@ -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, }; /* |
