Deleted Added
full compact
g_journal.c (231075) g_journal.c (241896)
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 231075 2012-02-06 11:04:36Z kib $");
28__FBSDID("$FreeBSD: head/sys/geom/journal/g_journal.c 241896 2012-10-22 17:50:54Z kib $");
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>

--- 2828 unchanged lines hidden (view full) ---

2865g_journal_do_switch(struct g_class *classp)
2866{
2867 struct g_journal_softc *sc;
2868 const struct g_journal_desc *desc;
2869 struct g_geom *gp;
2870 struct mount *mp;
2871 struct bintime bt;
2872 char *mountpoint;
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>

--- 2828 unchanged lines hidden (view full) ---

2865g_journal_do_switch(struct g_class *classp)
2866{
2867 struct g_journal_softc *sc;
2868 const struct g_journal_desc *desc;
2869 struct g_geom *gp;
2870 struct mount *mp;
2871 struct bintime bt;
2872 char *mountpoint;
2873 int error, save, vfslocked;
2873 int error, save;
2874
2875 DROP_GIANT();
2876 g_topology_lock();
2877 LIST_FOREACH(gp, &classp->geom, geom) {
2878 sc = gp->softc;
2879 if (sc == NULL)
2880 continue;
2881 if (sc->sc_flags & GJF_DEVICE_DESTROY)

--- 35 unchanged lines hidden (view full) ---

2917 sc->sc_flags &= ~GJF_DEVICE_BEFORE_SWITCH;
2918 mtx_unlock(&sc->sc_mtx);
2919 GJ_DEBUG(3, "No need for %s switch.", sc->sc_name);
2920 goto next;
2921 }
2922
2923 mountpoint = mp->mnt_stat.f_mntonname;
2924
2874
2875 DROP_GIANT();
2876 g_topology_lock();
2877 LIST_FOREACH(gp, &classp->geom, geom) {
2878 sc = gp->softc;
2879 if (sc == NULL)
2880 continue;
2881 if (sc->sc_flags & GJF_DEVICE_DESTROY)

--- 35 unchanged lines hidden (view full) ---

2917 sc->sc_flags &= ~GJF_DEVICE_BEFORE_SWITCH;
2918 mtx_unlock(&sc->sc_mtx);
2919 GJ_DEBUG(3, "No need for %s switch.", sc->sc_name);
2920 goto next;
2921 }
2922
2923 mountpoint = mp->mnt_stat.f_mntonname;
2924
2925 vfslocked = VFS_LOCK_GIANT(mp);
2926
2927 error = vn_start_write(NULL, &mp, V_WAIT);
2928 if (error != 0) {
2925 error = vn_start_write(NULL, &mp, V_WAIT);
2926 if (error != 0) {
2929 VFS_UNLOCK_GIANT(vfslocked);
2930 GJ_DEBUG(0, "vn_start_write(%s) failed (error=%d).",
2931 mountpoint, error);
2932 goto next;
2933 }
2934
2935 save = curthread_pflags_set(TDP_SYNCIO);
2936
2937 GJ_TIMER_START(1, &bt);

--- 8 unchanged lines hidden (view full) ---

2946 GJ_DEBUG(0, "Cannot sync file system %s (error=%d).",
2947 mountpoint, error);
2948 }
2949
2950 curthread_pflags_restore(save);
2951
2952 vn_finished_write(mp);
2953
2927 GJ_DEBUG(0, "vn_start_write(%s) failed (error=%d).",
2928 mountpoint, error);
2929 goto next;
2930 }
2931
2932 save = curthread_pflags_set(TDP_SYNCIO);
2933
2934 GJ_TIMER_START(1, &bt);

--- 8 unchanged lines hidden (view full) ---

2943 GJ_DEBUG(0, "Cannot sync file system %s (error=%d).",
2944 mountpoint, error);
2945 }
2946
2947 curthread_pflags_restore(save);
2948
2949 vn_finished_write(mp);
2950
2954 if (error != 0) {
2955 VFS_UNLOCK_GIANT(vfslocked);
2951 if (error != 0)
2956 goto next;
2952 goto next;
2957 }
2958
2959 /*
2960 * Send BIO_FLUSH before freezing the file system, so it can be
2961 * faster after the freeze.
2962 */
2963 GJ_TIMER_START(1, &bt);
2964 g_journal_flush_cache(sc);
2965 GJ_TIMER_STOP(1, &bt, "BIO_FLUSH time of %s", sc->sc_name);
2966
2967 GJ_TIMER_START(1, &bt);
2968 error = vfs_write_suspend(mp);
2953
2954 /*
2955 * Send BIO_FLUSH before freezing the file system, so it can be
2956 * faster after the freeze.
2957 */
2958 GJ_TIMER_START(1, &bt);
2959 g_journal_flush_cache(sc);
2960 GJ_TIMER_STOP(1, &bt, "BIO_FLUSH time of %s", sc->sc_name);
2961
2962 GJ_TIMER_START(1, &bt);
2963 error = vfs_write_suspend(mp);
2969 VFS_UNLOCK_GIANT(vfslocked);
2970 GJ_TIMER_STOP(1, &bt, "Suspend time of %s", mountpoint);
2971 if (error != 0) {
2972 GJ_DEBUG(0, "Cannot suspend file system %s (error=%d).",
2973 mountpoint, error);
2974 goto next;
2975 }
2976
2977 error = desc->jd_clean(mp);

--- 78 unchanged lines hidden ---
2964 GJ_TIMER_STOP(1, &bt, "Suspend time of %s", mountpoint);
2965 if (error != 0) {
2966 GJ_DEBUG(0, "Cannot suspend file system %s (error=%d).",
2967 mountpoint, error);
2968 goto next;
2969 }
2970
2971 error = desc->jd_clean(mp);

--- 78 unchanged lines hidden ---