Lines Matching refs:vol
125 static void g_raid_destroy_provider(struct g_raid_volume *vol);
128 static int g_raid_update_volume(struct g_raid_volume *vol, u_int event);
590 g_raid_change_volume_state(struct g_raid_volume *vol, int state)
593 G_RAID_DEBUG1(0, vol->v_softc,
595 vol->v_name,
596 g_raid_volume_state2str(vol->v_state),
598 vol->v_state = state;
726 g_raid_nsubdisks(struct g_raid_volume *vol, int state)
732 sc = vol->v_softc;
736 for (i = 0; i < vol->v_disks_count; i++) {
737 subdisk = &vol->v_subdisks[i];
751 g_raid_get_subdisk(struct g_raid_volume *vol, int state)
757 sc = vol->v_softc;
760 for (i = 0; i < vol->v_disks_count; i++) {
761 sd = &vol->v_subdisks[i];
815 struct g_raid_volume *vol;
819 TAILQ_FOREACH(vol, &sc->sc_volumes, v_next) {
820 if (vol->v_provider_open != 0)
913 g_raid_clean(struct g_raid_volume *vol, int acw)
918 sc = vol->v_softc;
924 if (!vol->v_dirty)
926 if (vol->v_writes > 0)
929 vol->v_provider != NULL && vol->v_provider->acw > 0)) {
930 timeout = g_raid_clean_time - (time_uptime - vol->v_last_write);
934 vol->v_dirty = 0;
936 vol->v_name);
937 g_raid_write_metadata(sc, vol, NULL, NULL);
941 g_raid_dirty(struct g_raid_volume *vol)
945 sc = vol->v_softc;
951 vol->v_dirty = 1;
953 vol->v_name);
954 g_raid_write_metadata(sc, vol, NULL, NULL);
960 struct g_raid_volume *vol;
966 vol = tr->tro_volume;
973 for (i = 0; i < vol->v_disks_count; i++) {
974 sd = &vol->v_subdisks[i];
1010 struct g_raid_volume *vol;
1013 vol = tr->tro_volume;
1014 sc = vol->v_softc;
1023 bp.bio_to = vol->v_provider;
1039 struct g_raid_volume *vol;
1042 vol = (struct g_raid_volume *)arg;
1043 G_RAID_DEBUG1(3, vol->v_softc, "Dumping at off %llu len %llu.",
1046 error = G_RAID_TR_KERNELDUMP(vol->v_tr,
1056 struct g_raid_volume *vol;
1060 vol = pp->private;
1064 gkd->di.priv = vol;
1065 gkd->di.blocksize = vol->v_sectorsize;
1068 if ((gkd->offset + gkd->length) > vol->v_mediasize)
1069 gkd->length = vol->v_mediasize - gkd->offset;
1078 struct g_raid_volume *vol;
1083 vol = pp->private;
1084 for (i = 0; i < vol->v_disks_count; i++) {
1085 sd = &vol->v_subdisks[i];
1091 val = i < vol->v_disks_count;
1168 g_raid_is_in_locked_range(struct g_raid_volume *vol, const struct bio *bp)
1172 sx_assert(&vol->v_softc->sc_lock, SX_LOCKED);
1174 LIST_FOREACH(lp, &vol->v_locks, l_next) {
1185 struct g_raid_volume *vol;
1189 vol = bp->bio_to->private;
1199 g_raid_is_in_locked_range(vol, bp)) {
1201 bioq_insert_tail(&vol->v_locked, bp);
1210 if (!vol->v_dirty)
1211 g_raid_dirty(vol);
1212 vol->v_writes++;
1220 bioq_insert_tail(&vol->v_inflight, bp);
1222 G_RAID_TR_IOSTART(vol->v_tr, bp);
1226 g_raid_finish_with_locked_ranges(struct g_raid_volume *vol, struct bio *bp)
1232 vol->v_pending_lock = 0;
1233 LIST_FOREACH(lp, &vol->v_locks, l_next) {
1238 TAILQ_FOREACH(nbp, &vol->v_inflight.queue, bio_queue) {
1243 vol->v_pending_lock = 1;
1244 G_RAID_DEBUG1(4, vol->v_softc,
1250 G_RAID_DEBUG1(4, vol->v_softc,
1253 G_RAID_TR_LOCKED(vol->v_tr, lp->l_callback_arg);
1262 struct g_raid_volume *vol;
1266 vol = bp->bio_to->private;
1271 vol->v_writes--;
1272 vol->v_last_write = time_uptime;
1275 bioq_remove(&vol->v_inflight, bp);
1276 if (vol->v_pending_lock && g_raid_is_in_locked_range(vol, bp))
1277 g_raid_finish_with_locked_ranges(vol, bp);
1278 getmicrouptime(&vol->v_last_done);
1283 g_raid_lock_range(struct g_raid_volume *vol, off_t off, off_t len,
1290 sc = vol->v_softc;
1292 LIST_INSERT_HEAD(&vol->v_locks, lp, l_next);
1298 TAILQ_FOREACH(bp, &vol->v_inflight.queue, bio_queue) {
1308 vol->v_pending_lock = 1;
1315 G_RAID_TR_LOCKED(vol->v_tr, lp->l_callback_arg);
1320 g_raid_unlock_range(struct g_raid_volume *vol, off_t off, off_t len)
1326 sc = vol->v_softc;
1327 LIST_FOREACH(lp, &vol->v_locks, l_next) {
1341 while ((bp = bioq_takefirst(&vol->v_locked)) != NULL)
1448 struct g_raid_volume *vol;
1455 vol = sd->sd_volume;
1464 G_RAID_TR_IODONE(vol->v_tr, sd, bp);
1500 struct g_raid_volume *vol;
1518 vol = NULL;
1528 TAILQ_FOREACH(vol, &sc->sc_volumes, v_next) {
1529 if (bioq_first(&vol->v_inflight) == NULL &&
1530 vol->v_tr &&
1531 timevalcmp(&vol->v_last_done, &t, < ))
1532 t = vol->v_last_done;
1566 TAILQ_FOREACH(vol, &sc->sc_volumes, v_next) {
1567 g_raid_clean(vol, -1);
1568 if (bioq_first(&vol->v_inflight) == NULL &&
1569 vol->v_tr) {
1572 timevaladd(&t, &vol->v_last_done);
1575 G_RAID_TR_IDLE(vol->v_tr);
1576 vol->v_last_done = now;
1619 g_raid_launch_provider(struct g_raid_volume *vol)
1629 sc = vol->v_softc;
1634 snprintf(name, sizeof(name), "raid/%s", vol->v_name);
1635 if (g_raid_name_format == 0 || vol->v_name[0] == 0 ||
1638 snprintf(name, sizeof(name), "raid/r%d", vol->v_global_id);
1643 if (vol->v_tr->tro_class->trc_accept_unmapped) {
1645 for (i = 0; i < vol->v_disks_count; i++) {
1646 sd = &vol->v_subdisks[i];
1654 pp->private = vol;
1655 pp->mediasize = vol->v_mediasize;
1656 pp->sectorsize = vol->v_sectorsize;
1659 if (vol->v_raid_level == G_RAID_VOLUME_RL_RAID1 ||
1660 vol->v_raid_level == G_RAID_VOLUME_RL_RAID3 ||
1661 vol->v_raid_level == G_RAID_VOLUME_RL_SINGLE ||
1662 vol->v_raid_level == G_RAID_VOLUME_RL_CONCAT) {
1663 if ((disk = vol->v_subdisks[0].sd_disk) != NULL &&
1668 pp->stripeoffset = off + vol->v_subdisks[0].sd_offset;
1672 if (vol->v_raid_level == G_RAID_VOLUME_RL_RAID3) {
1673 pp->stripesize *= (vol->v_disks_count - 1);
1674 pp->stripeoffset *= (vol->v_disks_count - 1);
1677 pp->stripesize = vol->v_strip_size;
1678 vol->v_provider = pp;
1682 pp->name, vol->v_name);
1686 g_raid_destroy_provider(struct g_raid_volume *vol)
1693 sc = vol->v_softc;
1694 pp = vol->v_provider;
1695 KASSERT(pp != NULL, ("NULL provider (volume=%s).", vol->v_name));
1708 pp->name, vol->v_name);
1711 vol->v_provider = NULL;
1718 g_raid_update_volume(struct g_raid_volume *vol, u_int event)
1722 sc = vol->v_softc;
1727 vol->v_name);
1730 if (vol->v_provider != NULL)
1731 g_raid_destroy_provider(vol);
1734 if (vol->v_provider == NULL)
1735 g_raid_launch_provider(vol);
1738 if (vol->v_tr)
1739 G_RAID_TR_START(vol->v_tr);
1743 G_RAID_MD_VOLUME_EVENT(sc->sc_md, vol, event);
1748 if (vol->v_starting) {
1749 vol->v_starting = 0;
1750 G_RAID_DEBUG1(1, sc, "root_mount_rel %p", vol->v_rootmount);
1751 root_mount_rel(vol->v_rootmount);
1752 vol->v_rootmount = NULL;
1754 if (vol->v_stopping && vol->v_provider_open == 0)
1755 g_raid_destroy_volume(vol);
1766 struct g_raid_volume *vol;
1769 vol = sd->sd_volume;
1774 vol->v_name, sd->sd_pos,
1776 if (vol->v_tr)
1777 G_RAID_TR_EVENT(vol->v_tr, sd, event);
1823 struct g_raid_volume *vol;
1829 vol = pp->private;
1831 KASSERT(vol != NULL, ("NULL volume (provider=%s).", pp->name));
1845 if (vol->v_read_only && acw > 0) {
1850 g_raid_clean(vol, dcw);
1851 vol->v_provider_open += acr + acw + ace;
1854 vol->v_provider_open == 0) {
1864 if (vol->v_stopping && vol->v_provider_open == 0)
1865 g_raid_destroy_volume(vol);
1918 struct g_raid_volume *vol, *vol1;
1922 vol = malloc(sizeof(*vol), M_RAID, M_WAITOK | M_ZERO);
1923 vol->v_softc = sc;
1924 strlcpy(vol->v_name, name, G_RAID_MAX_VOLUMENAME);
1925 vol->v_state = G_RAID_VOLUME_S_STARTING;
1926 vol->v_raid_level = G_RAID_VOLUME_RL_UNKNOWN;
1927 vol->v_raid_level_qualifier = G_RAID_VOLUME_RLQ_UNKNOWN;
1928 vol->v_rotate_parity = 1;
1929 bioq_init(&vol->v_inflight);
1930 bioq_init(&vol->v_locked);
1931 LIST_INIT(&vol->v_locks);
1933 vol->v_subdisks[i].sd_softc = sc;
1934 vol->v_subdisks[i].sd_volume = vol;
1935 vol->v_subdisks[i].sd_pos = i;
1936 vol->v_subdisks[i].sd_state = G_RAID_DISK_S_NONE;
1941 vol1 = vol;
1958 vol->v_global_id = id;
1959 LIST_INSERT_HEAD(&g_raid_volumes, vol, v_global_next);
1963 vol->v_rootmount = root_mount_hold("GRAID");
1964 G_RAID_DEBUG1(1, sc, "root_mount_hold %p", vol->v_rootmount);
1965 vol->v_starting = 1;
1966 TAILQ_INSERT_TAIL(&sc->sc_volumes, vol, v_next);
1967 return (vol);
1984 int g_raid_start_volume(struct g_raid_volume *vol)
1990 G_RAID_DEBUG1(2, vol->v_softc, "Starting volume %s.", vol->v_name);
1994 G_RAID_DEBUG1(2, vol->v_softc,
1996 vol->v_name, class->name);
2000 obj->tro_volume = vol;
2001 status = G_RAID_TR_TASTE(obj, vol);
2007 G_RAID_DEBUG1(0, vol->v_softc,
2009 vol->v_name);
2010 vol->v_tr = NULL;
2011 g_raid_change_volume_state(vol, G_RAID_VOLUME_S_UNSUPPORTED);
2012 g_raid_event_send(vol, G_RAID_VOLUME_E_DOWN,
2016 G_RAID_DEBUG1(2, vol->v_softc,
2018 class->name, vol->v_name);
2019 vol->v_tr = obj;
2026 struct g_raid_volume *vol, *tmpv;
2031 TAILQ_FOREACH_SAFE(vol, &sc->sc_volumes, v_next, tmpv) {
2032 if (g_raid_destroy_volume(vol))
2075 g_raid_destroy_volume(struct g_raid_volume *vol)
2081 sc = vol->v_softc;
2082 G_RAID_DEBUG1(2, sc, "Destroying volume %s.", vol->v_name);
2083 vol->v_stopping = 1;
2084 if (vol->v_state != G_RAID_VOLUME_S_STOPPED) {
2085 if (vol->v_tr) {
2086 G_RAID_TR_STOP(vol->v_tr);
2089 vol->v_state = G_RAID_VOLUME_S_STOPPED;
2091 if (g_raid_event_check(sc, vol) != 0)
2093 if (vol->v_provider != NULL)
2095 if (vol->v_provider_open != 0)
2097 if (vol->v_tr) {
2098 G_RAID_TR_FREE(vol->v_tr);
2099 kobj_delete((kobj_t)vol->v_tr, M_RAID);
2100 vol->v_tr = NULL;
2102 if (vol->v_rootmount)
2103 root_mount_rel(vol->v_rootmount);
2105 LIST_REMOVE(vol, v_global_next);
2107 TAILQ_REMOVE(&sc->sc_volumes, vol, v_next);
2109 g_raid_event_cancel(sc, &vol->v_subdisks[i]);
2110 disk = vol->v_subdisks[i].sd_disk;
2113 TAILQ_REMOVE(&disk->d_subdisks, &vol->v_subdisks[i], sd_next);
2115 G_RAID_DEBUG1(2, sc, "Volume %s destroyed.", vol->v_name);
2117 G_RAID_MD_FREE_VOLUME(sc->sc_md, vol);
2118 g_raid_event_cancel(sc, vol);
2119 free(vol, M_RAID);
2304 void g_raid_write_metadata(struct g_raid_softc *sc, struct g_raid_volume *vol,
2311 G_RAID_MD_WRITE(sc->sc_md, vol, sd, disk);
2338 struct g_raid_volume *vol;
2349 vol = pp->private;
2354 g_raid_volume_level2str(vol->v_raid_level,
2355 vol->v_raid_level_qualifier));
2357 vol->v_name);
2359 g_raid_volume_level2str(vol->v_raid_level,
2360 vol->v_raid_level_qualifier));
2363 vol->v_tr ? vol->v_tr->tro_class->name : "NONE");
2365 vol->v_disks_count);
2367 vol->v_strip_size);
2369 g_raid_volume_state2str(vol->v_state));
2371 vol->v_dirty ? "Yes" : "No");
2373 for (i = 0; i < vol->v_disks_count; i++) {
2374 sd = &vol->v_subdisks[i];
2391 if (i + 1 < vol->v_disks_count)
2445 TAILQ_FOREACH(vol, &sc->sc_volumes, v_next) {
2446 if (vol->v_state < s)
2447 s = vol->v_state;
2463 struct g_raid_volume *vol;
2473 TAILQ_FOREACH(vol, &sc->sc_volumes, v_next)
2474 g_raid_clean(vol, -1);