kfree(event);
}
+ kfree(hm->unmount_event);
kfree(hm->buffer);
mutex_destroy(&hm->lock);
kfree_rcu_mightsleep(hm);
switch (existing->type) {
case XFS_HEALTHMON_RUNNING:
+ case XFS_HEALTHMON_UNMOUNT:
/* should only ever be one of these events anyway */
return false;
return error;
}
-/* Detach the xfs mount from this healthmon instance. */
+/*
+ * Report that the filesystem is being unmounted, then detach the xfs mount
+ * from this healthmon instance.
+ */
void
xfs_healthmon_unmount(
struct xfs_mount *mp)
if (!hm)
return;
+ trace_xfs_healthmon_report_unmount(hm);
+
+ /*
+ * 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 the unmount event, hm no longer owns that event.
+ */
+ __xfs_healthmon_insert(hm, hm->unmount_event);
+ hm->unmount_event = NULL;
+
xfs_healthmon_detach(hm);
xfs_healthmon_put(hm);
}
running_event->domain = XFS_HEALTHMON_MOUNT;
__xfs_healthmon_insert(hm, running_event);
+ /*
+ * Preallocate the unmount event so that we can't fail to notify the
+ * filesystem later. This is key for triggering fast exit of the
+ * xfs_healer daemon.
+ */
+ hm->unmount_event = kzalloc(sizeof(struct xfs_healthmon_event),
+ GFP_NOFS);
+ if (!hm->unmount_event) {
+ ret = -ENOMEM;
+ goto out_hm;
+ }
+ hm->unmount_event->type = XFS_HEALTHMON_UNMOUNT;
+ hm->unmount_event->domain = XFS_HEALTHMON_MOUNT;
+
/*
* Try to attach this health monitor to the xfs_mount. The monitor is
* considered live and will receive events if this succeeds.
struct xfs_healthmon_event *first_event;
struct xfs_healthmon_event *last_event;
+ /* preallocated event for unmount */
+ struct xfs_healthmon_event *unmount_event;
+
/* number of events in the list */
unsigned int events;
enum xfs_healthmon_type {
XFS_HEALTHMON_RUNNING, /* monitor running */
XFS_HEALTHMON_LOST, /* message lost */
+ XFS_HEALTHMON_UNMOUNT, /* filesystem is unmounting */
};
enum xfs_healthmon_domain {
DEFINE_HEALTHMON_EVENT(xfs_healthmon_read_finish);
DEFINE_HEALTHMON_EVENT(xfs_healthmon_release);
DEFINE_HEALTHMON_EVENT(xfs_healthmon_detach);
+DEFINE_HEALTHMON_EVENT(xfs_healthmon_report_unmount);
#define XFS_HEALTHMON_TYPE_STRINGS \
- { XFS_HEALTHMON_LOST, "lost" }
+ { XFS_HEALTHMON_LOST, "lost" }, \
+ { XFS_HEALTHMON_UNMOUNT, "unmount" }
#define XFS_HEALTHMON_DOMAIN_STRINGS \
{ XFS_HEALTHMON_MOUNT, "mount" }
TRACE_DEFINE_ENUM(XFS_HEALTHMON_LOST);
+TRACE_DEFINE_ENUM(XFS_HEALTHMON_UNMOUNT);
+
TRACE_DEFINE_ENUM(XFS_HEALTHMON_MOUNT);
DECLARE_EVENT_CLASS(xfs_healthmon_event_class,