Deleted Added
sdiff udiff text old ( 155539 ) new ( 155545 )
full compact
1/*-
2 * Copyright (c) 2004-2005 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 155539 2006-02-11 14:42:23Z 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>

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

65static u_int g_mirror_reqs_per_sync = 5;
66SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, reqs_per_sync, CTLFLAG_RW,
67 &g_mirror_reqs_per_sync, 0,
68 "Number of regular I/O requests per synchronization request");
69static u_int g_mirror_syncs_per_sec = 1000;
70SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, syncs_per_sec, CTLFLAG_RW,
71 &g_mirror_syncs_per_sec, 0,
72 "Number of synchronizations requests per second");
73
74#define MSLEEP(ident, mtx, priority, wmesg, timeout) do { \
75 G_MIRROR_DEBUG(4, "%s: Sleeping %p.", __func__, (ident)); \
76 msleep((ident), (mtx), (priority), (wmesg), (timeout)); \
77 G_MIRROR_DEBUG(4, "%s: Woken up %p.", __func__, (ident)); \
78} while (0)
79
80static eventhandler_tag g_mirror_ehtag = NULL;

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

620 sector = malloc((size_t)length, M_MIRROR, M_WAITOK | M_ZERO);
621 if (md != NULL)
622 mirror_metadata_encode(md, sector);
623 g_topology_unlock();
624 error = g_write_data(cp, offset, sector, length);
625 g_topology_lock();
626 free(sector, M_MIRROR);
627 if (error != 0) {
628 disk->d_softc->sc_bump_id |= G_MIRROR_BUMP_GENID;
629 g_mirror_event_send(disk, G_MIRROR_DISK_STATE_DISCONNECTED,
630 G_MIRROR_EVENT_DONTWAIT);
631 }
632 return (error);
633}
634
635static int
636g_mirror_clear_metadata(struct g_mirror_disk *disk)
637{
638 int error;

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

879 G_MIRROR_LOGREQ(3, pbp, "Request delivered.");
880 pbp->bio_completed = pbp->bio_length;
881 g_io_deliver(pbp, pbp->bio_error);
882 }
883 return;
884 } else if (bp->bio_error != 0) {
885 if (pbp->bio_error == 0)
886 pbp->bio_error = bp->bio_error;
887 G_MIRROR_LOGREQ(0, bp, "Request failed (error=%d).",
888 bp->bio_error);
889 if (disk != NULL) {
890 sc->sc_bump_id |= G_MIRROR_BUMP_GENID;
891 g_mirror_event_send(disk,
892 G_MIRROR_DISK_STATE_DISCONNECTED,
893 G_MIRROR_EVENT_DONTWAIT);
894 }
895 switch (pbp->bio_cmd) {
896 case BIO_DELETE:
897 case BIO_WRITE:
898 pbp->bio_inbed--;
899 pbp->bio_children--;
900 break;
901 }
902 }
903 g_destroy_bio(bp);
904
905 switch (pbp->bio_cmd) {
906 case BIO_READ:
907 if (pbp->bio_children == pbp->bio_inbed) {
908 pbp->bio_error = 0;
909 mtx_lock(&sc->sc_queue_mtx);
910 bioq_disksort(&sc->sc_queue, pbp);
911 G_MIRROR_DEBUG(4, "%s: Waking up %p.", __func__, sc);
912 wakeup(sc);
913 mtx_unlock(&sc->sc_queue_mtx);
914 }
915 break;

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

2734 } \
2735} while (0)
2736 ADD_FLAG(G_MIRROR_DISK_FLAG_DIRTY, "DIRTY");
2737 ADD_FLAG(G_MIRROR_DISK_FLAG_HARDCODED, "HARDCODED");
2738 ADD_FLAG(G_MIRROR_DISK_FLAG_INACTIVE, "INACTIVE");
2739 ADD_FLAG(G_MIRROR_DISK_FLAG_SYNCHRONIZING,
2740 "SYNCHRONIZING");
2741 ADD_FLAG(G_MIRROR_DISK_FLAG_FORCE_SYNC, "FORCE_SYNC");
2742#undef ADD_FLAG
2743 }
2744 sbuf_printf(sb, "</Flags>\n");
2745 sbuf_printf(sb, "%s<Priority>%u</Priority>\n", indent,
2746 disk->d_priority);
2747 sbuf_printf(sb, "%s<State>%s</State>\n", indent,
2748 g_mirror_disk_state2str(disk->d_state));
2749 } else {

--- 81 unchanged lines hidden ---