From 2050a95dbd712073e4fa87c6a3c3f5191ef5580d Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Wed, 5 Jan 2011 05:20:56 +0100 Subject: [PATCH] hptmv(4): Fix shutting down. This didn't work at all. pAdapter->eh was never assigned to and the event handler for deregistering was wrong, too. So the driver ended up deregistering all callbacks of the shutdown_final handler during shutdown_post_sync. --- sys/dev/raid/hptmv/entry.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sys/dev/raid/hptmv/entry.c b/sys/dev/raid/hptmv/entry.c index 15aed04ce7..362598a64e 100644 --- a/sys/dev/raid/hptmv/entry.c +++ b/sys/dev/raid/hptmv/entry.c @@ -78,6 +78,8 @@ static void hpt_intr(void *arg); static void hpt_async(void *callback_arg, u_int32_t code, struct cam_path *path, void *arg); static void hpt_action(struct cam_sim *sim, union ccb *ccb); +static struct thread *hptdaemonproc; + static device_method_t driver_methods[] = { /* Device interface */ DEVMETHOD(device_probe, hpt_probe), @@ -2085,6 +2087,13 @@ hpt_attach(device_t dev) if (device_get_unit(dev) == 0) { /* Start the work thread. XXX */ launch_worker_thread(); + + /* + * hpt_worker_thread needs to be suspended after shutdown + * sync, when fs sync finished. + */ + pAdapter->eh = EVENTHANDLER_REGISTER(shutdown_post_sync, + shutdown_kproc, hptdaemonproc, SHUTDOWN_PRI_FIRST); } return 0; @@ -2172,7 +2181,7 @@ hpt_shutdown(device_t dev) if (pAdapter == NULL) return (EINVAL); - EVENTHANDLER_DEREGISTER(shutdown_final, pAdapter->eh); + EVENTHANDLER_DEREGISTER(shutdown_post_sync, pAdapter->eh); FlushAdapter(pAdapter); /* give the flush some time to happen, *otherwise "shutdown -p now" will make file system corrupted */ @@ -2486,7 +2495,6 @@ static void hpt_worker_thread(void) } } -static struct thread *hptdaemonproc; static struct kproc_desc hpt_kp = { "hpt_wt", hpt_worker_thread, @@ -2516,11 +2524,6 @@ launch_worker_thread(void) (UCHAR)((pVDev->u.array.CriticalMembers || pVDev->VDeviceType == VD_RAID_1)? DUPLICATE : REBUILD_PARITY)); } } - - /* - * hpt_worker_thread needs to be suspended after shutdown sync, when fs sync finished. - */ - EVENTHANDLER_REGISTER(shutdown_post_sync, shutdown_kproc, hptdaemonproc, SHUTDOWN_PRI_FIRST); } /* *SYSINIT(hptwt, SI_SUB_KTHREAD_IDLE, SI_ORDER_FIRST, launch_worker_thread, NULL); -- 2.41.0