g_mirror.c (163836) | g_mirror.c (163888) |
---|---|
1/*- 2 * Copyright (c) 2004-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) 2004-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/mirror/g_mirror.c 163836 2006-10-31 21:23:51Z pjd $"); | 28__FBSDID("$FreeBSD: head/sys/geom/mirror/g_mirror.c 163888 2006-11-01 22:51:49Z pjd $"); |
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> --- 760 unchanged lines hidden (view full) --- 797 struct g_mirror_disk *disk; 798 int timeout; 799 800 g_topology_assert_not(); 801 sx_assert(&sc->sc_lock, SX_XLOCKED); 802 803 if (sc->sc_provider == NULL) 804 return (0); | 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> --- 760 unchanged lines hidden (view full) --- 797 struct g_mirror_disk *disk; 798 int timeout; 799 800 g_topology_assert_not(); 801 sx_assert(&sc->sc_lock, SX_XLOCKED); 802 803 if (sc->sc_provider == NULL) 804 return (0); |
805 if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_NOFAILSYNC) != 0) 806 return (0); |
|
805 if (sc->sc_idle) 806 return (0); 807 if (sc->sc_writes > 0) 808 return (0); 809 if (acw > 0 || (acw == -1 && sc->sc_provider->acw > 0)) { 810 timeout = g_mirror_idletime - (time_uptime - sc->sc_last_write); 811 if (timeout > 0) 812 return (timeout); --- 13 unchanged lines hidden (view full) --- 826static void 827g_mirror_unidle(struct g_mirror_softc *sc) 828{ 829 struct g_mirror_disk *disk; 830 831 g_topology_assert_not(); 832 sx_assert(&sc->sc_lock, SX_XLOCKED); 833 | 807 if (sc->sc_idle) 808 return (0); 809 if (sc->sc_writes > 0) 810 return (0); 811 if (acw > 0 || (acw == -1 && sc->sc_provider->acw > 0)) { 812 timeout = g_mirror_idletime - (time_uptime - sc->sc_last_write); 813 if (timeout > 0) 814 return (timeout); --- 13 unchanged lines hidden (view full) --- 828static void 829g_mirror_unidle(struct g_mirror_softc *sc) 830{ 831 struct g_mirror_disk *disk; 832 833 g_topology_assert_not(); 834 sx_assert(&sc->sc_lock, SX_XLOCKED); 835 |
836 if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_NOFAILSYNC) != 0) 837 return; |
|
834 sc->sc_idle = 0; 835 sc->sc_last_write = time_uptime; 836 LIST_FOREACH(disk, &sc->sc_disks, d_next) { 837 if (disk->d_state != G_MIRROR_DISK_STATE_ACTIVE) 838 continue; 839 G_MIRROR_DEBUG(1, "Disk %s (device %s) marked as dirty.", 840 g_mirror_get_diskname(disk), sc->sc_name); 841 disk->d_flags |= G_MIRROR_DISK_FLAG_DIRTY; --- 1037 unchanged lines hidden (view full) --- 1879} 1880 1881static void 1882g_mirror_update_idle(struct g_mirror_softc *sc, struct g_mirror_disk *disk) 1883{ 1884 1885 sx_assert(&sc->sc_lock, SX_LOCKED); 1886 | 838 sc->sc_idle = 0; 839 sc->sc_last_write = time_uptime; 840 LIST_FOREACH(disk, &sc->sc_disks, d_next) { 841 if (disk->d_state != G_MIRROR_DISK_STATE_ACTIVE) 842 continue; 843 G_MIRROR_DEBUG(1, "Disk %s (device %s) marked as dirty.", 844 g_mirror_get_diskname(disk), sc->sc_name); 845 disk->d_flags |= G_MIRROR_DISK_FLAG_DIRTY; --- 1037 unchanged lines hidden (view full) --- 1883} 1884 1885static void 1886g_mirror_update_idle(struct g_mirror_softc *sc, struct g_mirror_disk *disk) 1887{ 1888 1889 sx_assert(&sc->sc_lock, SX_LOCKED); 1890 |
1891 if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_NOFAILSYNC) != 0) 1892 return; |
|
1887 if (!sc->sc_idle && (disk->d_flags & G_MIRROR_DISK_FLAG_DIRTY) == 0) { 1888 G_MIRROR_DEBUG(1, "Disk %s (device %s) marked as dirty.", 1889 g_mirror_get_diskname(disk), sc->sc_name); 1890 disk->d_flags |= G_MIRROR_DISK_FLAG_DIRTY; 1891 } else if (sc->sc_idle && 1892 (disk->d_flags & G_MIRROR_DISK_FLAG_DIRTY) != 0) { 1893 G_MIRROR_DEBUG(1, "Disk %s (device %s) marked as clean.", 1894 g_mirror_get_diskname(disk), sc->sc_name); --- 28 unchanged lines hidden (view full) --- 1923 ("Cannot attach to %s (error=%d).", sc->sc_name, error)); 1924 error = g_access(cp, 1, 0, 0); 1925 KASSERT(error == 0, ("Cannot open %s (error=%d).", sc->sc_name, error)); 1926 g_topology_unlock(); 1927 sx_xlock(&sc->sc_lock); 1928 1929 G_MIRROR_DEBUG(0, "Device %s: rebuilding provider %s.", sc->sc_name, 1930 g_mirror_get_diskname(disk)); | 1893 if (!sc->sc_idle && (disk->d_flags & G_MIRROR_DISK_FLAG_DIRTY) == 0) { 1894 G_MIRROR_DEBUG(1, "Disk %s (device %s) marked as dirty.", 1895 g_mirror_get_diskname(disk), sc->sc_name); 1896 disk->d_flags |= G_MIRROR_DISK_FLAG_DIRTY; 1897 } else if (sc->sc_idle && 1898 (disk->d_flags & G_MIRROR_DISK_FLAG_DIRTY) != 0) { 1899 G_MIRROR_DEBUG(1, "Disk %s (device %s) marked as clean.", 1900 g_mirror_get_diskname(disk), sc->sc_name); --- 28 unchanged lines hidden (view full) --- 1929 ("Cannot attach to %s (error=%d).", sc->sc_name, error)); 1930 error = g_access(cp, 1, 0, 0); 1931 KASSERT(error == 0, ("Cannot open %s (error=%d).", sc->sc_name, error)); 1932 g_topology_unlock(); 1933 sx_xlock(&sc->sc_lock); 1934 1935 G_MIRROR_DEBUG(0, "Device %s: rebuilding provider %s.", sc->sc_name, 1936 g_mirror_get_diskname(disk)); |
1931 disk->d_flags |= G_MIRROR_DISK_FLAG_DIRTY; | 1937 if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_NOFAILSYNC) == 0) 1938 disk->d_flags |= G_MIRROR_DISK_FLAG_DIRTY; |
1932 KASSERT(disk->d_sync.ds_consumer == NULL, 1933 ("Sync consumer already exists (device=%s, disk=%s).", 1934 sc->sc_name, g_mirror_get_diskname(disk))); 1935 1936 disk->d_sync.ds_consumer = cp; 1937 disk->d_sync.ds_consumer->private = disk; 1938 disk->d_sync.ds_consumer->index = 0; 1939 --- 1235 unchanged lines hidden (view full) --- 3175 if ((sc->sc_flags & (flag)) != 0) { \ 3176 if (!first) \ 3177 sbuf_printf(sb, ", "); \ 3178 else \ 3179 first = 0; \ 3180 sbuf_printf(sb, name); \ 3181 } \ 3182} while (0) | 1939 KASSERT(disk->d_sync.ds_consumer == NULL, 1940 ("Sync consumer already exists (device=%s, disk=%s).", 1941 sc->sc_name, g_mirror_get_diskname(disk))); 1942 1943 disk->d_sync.ds_consumer = cp; 1944 disk->d_sync.ds_consumer->private = disk; 1945 disk->d_sync.ds_consumer->index = 0; 1946 --- 1235 unchanged lines hidden (view full) --- 3182 if ((sc->sc_flags & (flag)) != 0) { \ 3183 if (!first) \ 3184 sbuf_printf(sb, ", "); \ 3185 else \ 3186 first = 0; \ 3187 sbuf_printf(sb, name); \ 3188 } \ 3189} while (0) |
3190 ADD_FLAG(G_MIRROR_DEVICE_FLAG_NOFAILSYNC, "NOFAILSYNC"); |
|
3183 ADD_FLAG(G_MIRROR_DEVICE_FLAG_NOAUTOSYNC, "NOAUTOSYNC"); 3184#undef ADD_FLAG 3185 } 3186 sbuf_printf(sb, "</Flags>\n"); 3187 sbuf_printf(sb, "%s<Slice>%u</Slice>\n", indent, 3188 (u_int)sc->sc_slice); 3189 sbuf_printf(sb, "%s<Balance>%s</Balance>\n", indent, 3190 balance_name(sc->sc_balance)); --- 64 unchanged lines hidden --- | 3191 ADD_FLAG(G_MIRROR_DEVICE_FLAG_NOAUTOSYNC, "NOAUTOSYNC"); 3192#undef ADD_FLAG 3193 } 3194 sbuf_printf(sb, "</Flags>\n"); 3195 sbuf_printf(sb, "%s<Slice>%u</Slice>\n", indent, 3196 (u_int)sc->sc_slice); 3197 sbuf_printf(sb, "%s<Balance>%s</Balance>\n", indent, 3198 balance_name(sc->sc_balance)); --- 64 unchanged lines hidden --- |