1/*- 2 * Copyright (c) 2004, 2007 Lukas Ertl 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 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * $FreeBSD$ 27 */ 28 29#ifndef _GEOM_VINUM_H_ 30#define _GEOM_VINUM_H_ 31 32/* geom_vinum_create.c */ 33void gv_concat(struct g_geom *gp, struct gctl_req *); 34void gv_mirror(struct g_geom *gp, struct gctl_req *); 35void gv_stripe(struct g_geom *gp, struct gctl_req *); 36void gv_raid5(struct g_geom *gp, struct gctl_req *); 37int gv_create_drive(struct gv_softc *, struct gv_drive *); 38int gv_create_volume(struct gv_softc *, struct gv_volume *); 39int gv_create_plex(struct gv_softc *, struct gv_plex *); 40int gv_create_sd(struct gv_softc *, struct gv_sd *); 41 42/* geom_vinum_drive.c */ 43void gv_save_config(struct gv_softc *); 44int gv_read_header(struct g_consumer *, struct gv_hdr *); 45int gv_write_header(struct g_consumer *, struct gv_hdr *); 46 47/* geom_vinum_init.c */ 48void gv_start_obj(struct g_geom *, struct gctl_req *); 49int gv_start_plex(struct gv_plex *); 50int gv_start_vol(struct gv_volume *); 51 52/* geom_vinum_list.c */ 53void gv_ld(struct g_geom *, struct gctl_req *, struct sbuf *); 54void gv_lp(struct g_geom *, struct gctl_req *, struct sbuf *); 55void gv_ls(struct g_geom *, struct gctl_req *, struct sbuf *); 56void gv_lv(struct g_geom *, struct gctl_req *, struct sbuf *); 57void gv_list(struct g_geom *, struct gctl_req *); 58 59/* geom_vinum_move.c */ 60void gv_move(struct g_geom *, struct gctl_req *); 61int gv_move_sd(struct gv_softc *, struct gv_sd *, struct gv_drive *, int); 62 63/* geom_vinum_rename.c */ 64void gv_rename(struct g_geom *, struct gctl_req *); 65int gv_rename_drive(struct gv_softc *, struct gv_drive *, char *, int); 66int gv_rename_plex(struct gv_softc *, struct gv_plex *, char *, int); 67int gv_rename_sd(struct gv_softc *, struct gv_sd *, char *, int); 68int gv_rename_vol(struct gv_softc *, struct gv_volume *, char *, int); 69 70/* geom_vinum_rm.c */ 71void gv_remove(struct g_geom *, struct gctl_req *); 72int gv_resetconfig(struct gv_softc *); 73void gv_rm_sd(struct gv_softc *sc, struct gv_sd *s); 74void gv_rm_drive(struct gv_softc *, struct gv_drive *, int); 75void gv_rm_plex(struct gv_softc *, struct gv_plex *); 76void gv_rm_vol(struct gv_softc *, struct gv_volume *); 77 78 79/* geom_vinum_state.c */ 80int gv_sdstatemap(struct gv_plex *); 81void gv_setstate(struct g_geom *, struct gctl_req *); 82int gv_set_drive_state(struct gv_drive *, int, int); 83int gv_set_sd_state(struct gv_sd *, int, int); 84int gv_set_vol_state(struct gv_volume *, int, int); 85int gv_set_plex_state(struct gv_plex *, int, int); 86void gv_update_sd_state(struct gv_sd *); 87void gv_update_plex_state(struct gv_plex *); 88void gv_update_vol_state(struct gv_volume *); 89 90/* geom_vinum_subr.c */ 91void gv_adjust_freespace(struct gv_sd *, off_t); 92void gv_free_sd(struct gv_sd *); 93struct gv_drive *gv_find_drive(struct gv_softc *, char *); 94struct gv_drive *gv_find_drive_device(struct gv_softc *, char *); 95struct gv_plex *gv_find_plex(struct gv_softc *, char *); 96struct gv_sd *gv_find_sd(struct gv_softc *, char *); 97struct gv_volume *gv_find_vol(struct gv_softc *, char *); 98void gv_format_config(struct gv_softc *, struct sbuf *, int, 99 char *); 100int gv_is_striped(struct gv_plex *); 101int gv_consumer_is_open(struct g_consumer *); 102int gv_provider_is_open(struct g_provider *); 103int gv_object_type(struct gv_softc *, char *); 104void gv_parse_config(struct gv_softc *, char *, 105 struct gv_drive *); 106int gv_sd_to_drive(struct gv_sd *, struct gv_drive *); 107int gv_sd_to_plex(struct gv_sd *, struct gv_plex *); 108int gv_sdcount(struct gv_plex *, int); 109void gv_update_plex_config(struct gv_plex *); 110void gv_update_vol_size(struct gv_volume *, off_t); 111off_t gv_vol_size(struct gv_volume *); 112off_t gv_plex_size(struct gv_plex *); 113int gv_plexdown(struct gv_volume *); 114int gv_attach_plex(struct gv_plex *, struct gv_volume *, 115 int); 116int gv_attach_sd(struct gv_sd *, struct gv_plex *, off_t, 117 int); 118int gv_detach_plex(struct gv_plex *, int); 119int gv_detach_sd(struct gv_sd *, int); 120 121/* geom_vinum.c */ 122void gv_worker(void *); 123void gv_post_event(struct gv_softc *, int, void *, void *, intmax_t, 124 intmax_t); 125void gv_worker_exit(struct gv_softc *); 126struct gv_event *gv_get_event(struct gv_softc *); 127void gv_remove_event(struct gv_softc *, struct gv_event *); 128void gv_drive_tasted(struct gv_softc *, struct g_provider *); 129void gv_drive_lost(struct gv_softc *, struct gv_drive *); 130void gv_setup_objects(struct gv_softc *); 131void gv_start(struct bio *); 132int gv_access(struct g_provider *, int, int, int); 133void gv_cleanup(struct gv_softc *); 134 135/* geom_vinum_volume.c */ 136void gv_done(struct bio *); 137void gv_volume_start(struct gv_softc *, struct bio *); 138void gv_volume_flush(struct gv_volume *); 139void gv_bio_done(struct gv_softc *, struct bio *); 140 141/* geom_vinum_plex.c */ 142void gv_plex_start(struct gv_plex *, struct bio *); 143void gv_plex_raid5_done(struct gv_plex *, struct bio *); 144void gv_plex_normal_done(struct gv_plex *, struct bio *); 145int gv_grow_request(struct gv_plex *, off_t, off_t, int, caddr_t); 146void gv_grow_complete(struct gv_plex *, struct bio *); 147void gv_init_request(struct gv_sd *, off_t, caddr_t, off_t); 148void gv_init_complete(struct gv_plex *, struct bio *); 149void gv_parity_request(struct gv_plex *, int, off_t); 150void gv_parity_complete(struct gv_plex *, struct bio *); 151void gv_rebuild_complete(struct gv_plex *, struct bio *); 152int gv_sync_request(struct gv_plex *, struct gv_plex *, off_t, off_t, int, 153 caddr_t); 154int gv_sync_complete(struct gv_plex *, struct bio *); 155 156extern u_int g_vinum_debug; 157 158#define G_VINUM_DEBUG(lvl, ...) do { \ 159 if (g_vinum_debug >= (lvl)) { \ 160 printf("GEOM_VINUM"); \ 161 if (g_vinum_debug > 0) \ 162 printf("[%u]", lvl); \ 163 printf(": "); \ 164 printf(__VA_ARGS__); \ 165 printf("\n"); \ 166 } \ 167} while (0) 168 169#define G_VINUM_LOGREQ(lvl, bp, ...) do { \ 170 if (g_vinum_debug >= (lvl)) { \ 171 printf("GEOM_VINUM"); \ 172 if (g_vinum_debug > 0) \ 173 printf("[%u]", lvl); \ 174 printf(": "); \ 175 printf(__VA_ARGS__); \ 176 printf(" "); \ 177 g_print_bio(bp); \ 178 printf("\n"); \ 179 } \ 180} while (0) 181 182#endif /* !_GEOM_VINUM_H_ */ 183