g_journal.c (170307) | g_journal.c (172836) |
---|---|
1/*- 2 * Copyright (c) 2005-2006 Pawel Jakub Dawidek <pjd@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2005-2006 Pawel Jakub Dawidek <pjd@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/geom/journal/g_journal.c 170307 2007-06-05 00:00:57Z jeff $"); | 28__FBSDID("$FreeBSD: head/sys/geom/journal/g_journal.c 172836 2007-10-20 23:23:23Z julian $"); |
29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/kernel.h> 33#include <sys/module.h> 34#include <sys/limits.h> 35#include <sys/lock.h> 36#include <sys/mutex.h> --- 2104 unchanged lines hidden (view full) --- 2141 continue; 2142 } 2143 if (sc->sc_flags & GJF_DEVICE_DESTROY) { 2144 GJ_DEBUG(1, "Shutting down worker " 2145 "thread for %s.", gp->name); 2146 sc->sc_worker = NULL; 2147 wakeup(&sc->sc_worker); 2148 mtx_unlock(&sc->sc_mtx); | 29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/kernel.h> 33#include <sys/module.h> 34#include <sys/limits.h> 35#include <sys/lock.h> 36#include <sys/mutex.h> --- 2104 unchanged lines hidden (view full) --- 2141 continue; 2142 } 2143 if (sc->sc_flags & GJF_DEVICE_DESTROY) { 2144 GJ_DEBUG(1, "Shutting down worker " 2145 "thread for %s.", gp->name); 2146 sc->sc_worker = NULL; 2147 wakeup(&sc->sc_worker); 2148 mtx_unlock(&sc->sc_mtx); |
2149 kthread_exit(0); | 2149 kproc_exit(0); |
2150 } 2151sleep: 2152 g_journal_wait(sc, last_write); 2153 continue; 2154 } 2155 /* 2156 * If we're in switch process, we need to delay all new 2157 * write requests until its done. --- 218 unchanged lines hidden (view full) --- 2376 if ((sc->sc_type & GJ_TYPE_COMPLETE) != GJ_TYPE_COMPLETE) { 2377 /* Journal is not complete yet. */ 2378 return (gp); 2379 } else { 2380 /* Journal complete, cancel timeout. */ 2381 callout_drain(&sc->sc_callout); 2382 } 2383 | 2150 } 2151sleep: 2152 g_journal_wait(sc, last_write); 2153 continue; 2154 } 2155 /* 2156 * If we're in switch process, we need to delay all new 2157 * write requests until its done. --- 218 unchanged lines hidden (view full) --- 2376 if ((sc->sc_type & GJ_TYPE_COMPLETE) != GJ_TYPE_COMPLETE) { 2377 /* Journal is not complete yet. */ 2378 return (gp); 2379 } else { 2380 /* Journal complete, cancel timeout. */ 2381 callout_drain(&sc->sc_callout); 2382 } 2383 |
2384 error = kthread_create(g_journal_worker, sc, &sc->sc_worker, 0, 0, | 2384 error = kproc_create(g_journal_worker, sc, &sc->sc_worker, 0, 0, |
2385 "g_journal %s", sc->sc_name); 2386 if (error != 0) { 2387 GJ_DEBUG(0, "Cannot create worker thread for %s.journal.", 2388 sc->sc_name); 2389 g_journal_destroy(sc); 2390 return (NULL); 2391 } 2392 --- 368 unchanged lines hidden (view full) --- 2761 g_journal_event_shutdown = EVENTHANDLER_REGISTER(shutdown_post_sync, 2762 g_journal_shutdown, mp, EVENTHANDLER_PRI_FIRST); 2763 if (g_journal_event_shutdown == NULL) 2764 GJ_DEBUG(0, "Warning! Cannot register shutdown event."); 2765 g_journal_event_lowmem = EVENTHANDLER_REGISTER(vm_lowmem, 2766 g_journal_lowmem, mp, EVENTHANDLER_PRI_FIRST); 2767 if (g_journal_event_lowmem == NULL) 2768 GJ_DEBUG(0, "Warning! Cannot register lowmem event."); | 2385 "g_journal %s", sc->sc_name); 2386 if (error != 0) { 2387 GJ_DEBUG(0, "Cannot create worker thread for %s.journal.", 2388 sc->sc_name); 2389 g_journal_destroy(sc); 2390 return (NULL); 2391 } 2392 --- 368 unchanged lines hidden (view full) --- 2761 g_journal_event_shutdown = EVENTHANDLER_REGISTER(shutdown_post_sync, 2762 g_journal_shutdown, mp, EVENTHANDLER_PRI_FIRST); 2763 if (g_journal_event_shutdown == NULL) 2764 GJ_DEBUG(0, "Warning! Cannot register shutdown event."); 2765 g_journal_event_lowmem = EVENTHANDLER_REGISTER(vm_lowmem, 2766 g_journal_lowmem, mp, EVENTHANDLER_PRI_FIRST); 2767 if (g_journal_event_lowmem == NULL) 2768 GJ_DEBUG(0, "Warning! Cannot register lowmem event."); |
2769 error = kthread_create(g_journal_switcher, mp, NULL, 0, 0, | 2769 error = kproc_create(g_journal_switcher, mp, NULL, 0, 0, |
2770 "g_journal switcher"); 2771 KASSERT(error == 0, ("Cannot create switcher thread.")); 2772} 2773 2774static void 2775g_journal_fini(struct g_class *mp) 2776{ 2777 --- 242 unchanged lines hidden (view full) --- 3020 for (;;) { 3021 g_journal_switcher_wokenup = 0; 3022 error = tsleep(&g_journal_switcher_state, PRIBIO, "jsw:wait", 3023 g_journal_switch_time * hz); 3024 if (g_journal_switcher_state == GJ_SWITCHER_DIE) { 3025 g_journal_switcher_state = GJ_SWITCHER_DIED; 3026 GJ_DEBUG(1, "Switcher exiting."); 3027 wakeup(&g_journal_switcher_state); | 2770 "g_journal switcher"); 2771 KASSERT(error == 0, ("Cannot create switcher thread.")); 2772} 2773 2774static void 2775g_journal_fini(struct g_class *mp) 2776{ 2777 --- 242 unchanged lines hidden (view full) --- 3020 for (;;) { 3021 g_journal_switcher_wokenup = 0; 3022 error = tsleep(&g_journal_switcher_state, PRIBIO, "jsw:wait", 3023 g_journal_switch_time * hz); 3024 if (g_journal_switcher_state == GJ_SWITCHER_DIE) { 3025 g_journal_switcher_state = GJ_SWITCHER_DIED; 3026 GJ_DEBUG(1, "Switcher exiting."); 3027 wakeup(&g_journal_switcher_state); |
3028 kthread_exit(0); | 3028 kproc_exit(0); |
3029 } 3030 if (error == 0 && g_journal_sync_requested == 0) { 3031 GJ_DEBUG(1, "Out of cache, force switch (used=%u " 3032 "limit=%u).", g_journal_cache_used, 3033 g_journal_cache_limit); 3034 } 3035 GJ_TIMER_START(1, &bt); 3036 g_journal_do_switch(mp, td); 3037 GJ_TIMER_STOP(1, &bt, "Entire switch time"); 3038 if (g_journal_sync_requested > 0) { 3039 g_journal_sync_requested = 0; 3040 wakeup(&g_journal_sync_requested); 3041 } 3042 } 3043} | 3029 } 3030 if (error == 0 && g_journal_sync_requested == 0) { 3031 GJ_DEBUG(1, "Out of cache, force switch (used=%u " 3032 "limit=%u).", g_journal_cache_used, 3033 g_journal_cache_limit); 3034 } 3035 GJ_TIMER_START(1, &bt); 3036 g_journal_do_switch(mp, td); 3037 GJ_TIMER_STOP(1, &bt, "Entire switch time"); 3038 if (g_journal_sync_requested > 0) { 3039 g_journal_sync_requested = 0; 3040 wakeup(&g_journal_sync_requested); 3041 } 3042 } 3043} |