g_journal.c (7e7a4e1d189b4ee780c412ddf76126a67c428647) | g_journal.c (59d4932531aa4e97f68b2d42290a68cae6b17375) |
---|---|
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 --- 2829 unchanged lines hidden (view full) --- 2838 while (sc->sc_flags & GJF_DEVICE_SWITCH) { 2839 msleep(&sc->sc_journal_copying, &sc->sc_mtx, PRIBIO, 2840 "gj:switch", 0); 2841 } 2842 GJ_TIMER_STOP(1, &bt, "Switch time of %s", sc->sc_name); 2843} 2844 2845static void | 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 --- 2829 unchanged lines hidden (view full) --- 2838 while (sc->sc_flags & GJF_DEVICE_SWITCH) { 2839 msleep(&sc->sc_journal_copying, &sc->sc_mtx, PRIBIO, 2840 "gj:switch", 0); 2841 } 2842 GJ_TIMER_STOP(1, &bt, "Switch time of %s", sc->sc_name); 2843} 2844 2845static void |
2846g_journal_do_switch(struct g_class *classp, struct thread *td) | 2846g_journal_do_switch(struct g_class *classp) |
2847{ 2848 struct g_journal_softc *sc; 2849 const struct g_journal_desc *desc; 2850 struct g_geom *gp; 2851 struct mount *mp; 2852 struct bintime bt; 2853 char *mountpoint; 2854 int error, vfslocked; --- 19 unchanged lines hidden (view full) --- 2874 TAILQ_FOREACH(mp, &mountlist, mnt_list) { 2875 if (mp->mnt_gjprovider == NULL) 2876 continue; 2877 if (mp->mnt_flag & MNT_RDONLY) 2878 continue; 2879 desc = g_journal_find_desc(mp->mnt_stat.f_fstypename); 2880 if (desc == NULL) 2881 continue; | 2847{ 2848 struct g_journal_softc *sc; 2849 const struct g_journal_desc *desc; 2850 struct g_geom *gp; 2851 struct mount *mp; 2852 struct bintime bt; 2853 char *mountpoint; 2854 int error, vfslocked; --- 19 unchanged lines hidden (view full) --- 2874 TAILQ_FOREACH(mp, &mountlist, mnt_list) { 2875 if (mp->mnt_gjprovider == NULL) 2876 continue; 2877 if (mp->mnt_flag & MNT_RDONLY) 2878 continue; 2879 desc = g_journal_find_desc(mp->mnt_stat.f_fstypename); 2880 if (desc == NULL) 2881 continue; |
2882 if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, td)) | 2882 if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx)) |
2883 continue; 2884 /* mtx_unlock(&mountlist_mtx) was done inside vfs_busy() */ 2885 2886 DROP_GIANT(); 2887 g_topology_lock(); 2888 sc = g_journal_find_device(classp, mp->mnt_gjprovider); 2889 g_topology_unlock(); 2890 PICKUP_GIANT(); --- 77 unchanged lines hidden (view full) --- 2968 2969 mtx_lock(&sc->sc_mtx); 2970 g_journal_switch_wait(sc); 2971 mtx_unlock(&sc->sc_mtx); 2972 2973 vfs_write_resume(mp); 2974next: 2975 mtx_lock(&mountlist_mtx); | 2883 continue; 2884 /* mtx_unlock(&mountlist_mtx) was done inside vfs_busy() */ 2885 2886 DROP_GIANT(); 2887 g_topology_lock(); 2888 sc = g_journal_find_device(classp, mp->mnt_gjprovider); 2889 g_topology_unlock(); 2890 PICKUP_GIANT(); --- 77 unchanged lines hidden (view full) --- 2968 2969 mtx_lock(&sc->sc_mtx); 2970 g_journal_switch_wait(sc); 2971 mtx_unlock(&sc->sc_mtx); 2972 2973 vfs_write_resume(mp); 2974next: 2975 mtx_lock(&mountlist_mtx); |
2976 vfs_unbusy(mp, td); | 2976 vfs_unbusy(mp); |
2977 } 2978 mtx_unlock(&mountlist_mtx); 2979 2980 sc = NULL; 2981 for (;;) { 2982 DROP_GIANT(); 2983 g_topology_lock(); 2984 LIST_FOREACH(gp, &g_journal_class.geom, geom) { --- 21 unchanged lines hidden (view full) --- 3006 3007/* 3008 * TODO: Switcher thread should be started on first geom creation and killed on 3009 * last geom destruction. 3010 */ 3011static void 3012g_journal_switcher(void *arg) 3013{ | 2977 } 2978 mtx_unlock(&mountlist_mtx); 2979 2980 sc = NULL; 2981 for (;;) { 2982 DROP_GIANT(); 2983 g_topology_lock(); 2984 LIST_FOREACH(gp, &g_journal_class.geom, geom) { --- 21 unchanged lines hidden (view full) --- 3006 3007/* 3008 * TODO: Switcher thread should be started on first geom creation and killed on 3009 * last geom destruction. 3010 */ 3011static void 3012g_journal_switcher(void *arg) 3013{ |
3014 struct thread *td = curthread; | |
3015 struct g_class *mp; 3016 struct bintime bt; 3017 int error; 3018 3019 mp = arg; 3020 for (;;) { 3021 g_journal_switcher_wokenup = 0; 3022 error = tsleep(&g_journal_switcher_state, PRIBIO, "jsw:wait", --- 5 unchanged lines hidden (view full) --- 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); | 3014 struct g_class *mp; 3015 struct bintime bt; 3016 int error; 3017 3018 mp = arg; 3019 for (;;) { 3020 g_journal_switcher_wokenup = 0; 3021 error = tsleep(&g_journal_switcher_state, PRIBIO, "jsw:wait", --- 5 unchanged lines hidden (view full) --- 3027 kproc_exit(0); 3028 } 3029 if (error == 0 && g_journal_sync_requested == 0) { 3030 GJ_DEBUG(1, "Out of cache, force switch (used=%u " 3031 "limit=%u).", g_journal_cache_used, 3032 g_journal_cache_limit); 3033 } 3034 GJ_TIMER_START(1, &bt); |
3036 g_journal_do_switch(mp, td); | 3035 g_journal_do_switch(mp); |
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} | 3036 GJ_TIMER_STOP(1, &bt, "Entire switch time"); 3037 if (g_journal_sync_requested > 0) { 3038 g_journal_sync_requested = 0; 3039 wakeup(&g_journal_sync_requested); 3040 } 3041 } 3042} |