Deleted Added
sdiff udiff text old ( 137254 ) new ( 137259 )
full compact
1/*-
2 * Copyright (c) 2004 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 137254 2004-11-05 12:35:21Z 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>

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

749 G_MIRROR_DEBUG(1, "Disk %s (device %s) marked as dirty.",
750 g_mirror_get_diskname(disk), sc->sc_name);
751 disk->d_flags |= G_MIRROR_DISK_FLAG_DIRTY;
752 g_mirror_update_metadata(disk);
753 }
754 g_topology_unlock();
755}
756
757static __inline int
758bintime_cmp(struct bintime *bt1, struct bintime *bt2)
759{
760
761 if (bt1->sec < bt2->sec)
762 return (-1);
763 else if (bt1->sec > bt2->sec)
764 return (1);

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

1501 sync->ds_resync = -1;
1502 }
1503 g_mirror_sync_one(disk);
1504 }
1505 G_MIRROR_DEBUG(5, "%s: I'm here 2.", __func__);
1506 goto sleep;
1507 }
1508 if (bp == NULL) {
1509#define G_MIRROR_IS_IDLE(sc) ((sc)->sc_idle || \
1510 ((sc)->sc_provider != NULL && \
1511 (sc)->sc_provider->acw == 0))
1512 if (G_MIRROR_IS_IDLE(sc)) {
1513 /*
1514 * If we're already in idle state, sleep without
1515 * a timeout.
1516 */
1517 MSLEEP(sc, &sc->sc_queue_mtx, PRIBIO | PDROP,
1518 "m:w1", 0);
1519 G_MIRROR_DEBUG(5, "%s: I'm here 3.", __func__);
1520 } else {
1521 u_int idletime;
1522
1523 idletime = g_mirror_idletime;
1524 if (idletime == 0)
1525 idletime = 1;
1526 idletime *= hz;
1527 if (msleep(sc, &sc->sc_queue_mtx, PRIBIO | PDROP,
1528 "m:w2", idletime) == EWOULDBLOCK) {
1529 G_MIRROR_DEBUG(5, "%s: I'm here 4.",
1530 __func__);
1531 /*
1532 * No I/O requests in 5 seconds, so mark
1533 * components as clean.
1534 */
1535 g_mirror_idle(sc);
1536 }
1537 G_MIRROR_DEBUG(5, "%s: I'm here 5.", __func__);
1538 }
1539 continue;
1540 }
1541 nreqs++;
1542 bioq_remove(&sc->sc_queue, bp);
1543 mtx_unlock(&sc->sc_queue_mtx);
1544

--- 1326 unchanged lines hidden ---