Skip to content

Commit c0e719c

Browse files
author
Darrick J. Wong
committed
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>
1 parent dfa8bad commit c0e719c

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

fs/xfs/xfs_healthmon.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "xfs_fsops.h"
2424
#include "xfs_notify_failure.h"
2525
#include "xfs_file.h"
26+
#include "xfs_ioctl.h"
2627

2728
#include <linux/anon_inodes.h>
2829
#include <linux/eventpoll.h>
@@ -1066,12 +1067,55 @@ xfs_healthmon_show_fdinfo(
10661067
mutex_unlock(&hm->lock);
10671068
}
10681069

1070+
/* Reconfigure the health monitor. */
1071+
STATIC long
1072+
xfs_healthmon_reconfigure(
1073+
struct file *file,
1074+
unsigned int cmd,
1075+
void __user *arg)
1076+
{
1077+
struct xfs_health_monitor hmo;
1078+
struct xfs_healthmon *hm = file->private_data;
1079+
1080+
if (copy_from_user(&hmo, arg, sizeof(hmo)))
1081+
return -EFAULT;
1082+
1083+
if (!xfs_healthmon_validate(&hmo))
1084+
return -EINVAL;
1085+
1086+
mutex_lock(&hm->lock);
1087+
hm->verbose = !!(hmo.flags & XFS_HEALTH_MONITOR_VERBOSE);
1088+
mutex_unlock(&hm->lock);
1089+
1090+
return 0;
1091+
}
1092+
1093+
/* Handle ioctls for the health monitoring thread. */
1094+
STATIC long
1095+
xfs_healthmon_ioctl(
1096+
struct file *file,
1097+
unsigned int cmd,
1098+
unsigned long p)
1099+
{
1100+
void __user *arg = (void __user *)p;
1101+
1102+
switch (cmd) {
1103+
case XFS_IOC_HEALTH_MONITOR:
1104+
return xfs_healthmon_reconfigure(file, cmd, arg);
1105+
default:
1106+
break;
1107+
}
1108+
1109+
return -ENOTTY;
1110+
}
1111+
10691112
static const struct file_operations xfs_healthmon_fops = {
10701113
.owner = THIS_MODULE,
10711114
.show_fdinfo = xfs_healthmon_show_fdinfo,
10721115
.read_iter = xfs_healthmon_read_iter,
10731116
.poll = xfs_healthmon_poll,
10741117
.release = xfs_healthmon_release,
1118+
.unlocked_ioctl = xfs_healthmon_ioctl,
10751119
};
10761120

10771121
/*

0 commit comments

Comments
 (0)