1 /*- 2 * Copyright (c) 2004 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 #define ERRBUFSIZ 1024 33 34 /* geom_vinum_drive.c */ 35 void gv_config_new_drive(struct gv_drive *); 36 void gv_drive_modify(struct gv_drive *); 37 int gv_read_header(struct g_consumer *, struct gv_hdr *); 38 void gv_save_config_all(struct gv_softc *); 39 void gv_save_config(struct g_consumer *, struct gv_drive *, 40 struct gv_softc *); 41 int gv_write_header(struct g_consumer *, struct gv_hdr *); 42 43 /* geom_vinum_init.c */ 44 void gv_parityop(struct g_geom *, struct gctl_req *); 45 void gv_start_obj(struct g_geom *, struct gctl_req *); 46 47 /* geom_vinum_list.c */ 48 void gv_ld(struct g_geom *, struct gctl_req *, struct sbuf *); 49 void gv_lp(struct g_geom *, struct gctl_req *, struct sbuf *); 50 void gv_ls(struct g_geom *, struct gctl_req *, struct sbuf *); 51 void gv_lv(struct g_geom *, struct gctl_req *, struct sbuf *); 52 void gv_list(struct g_geom *, struct gctl_req *); 53 54 /* geom_vinum_move.c */ 55 void gv_move(struct g_geom *, struct gctl_req *); 56 57 /* geom_vinum_rename.c */ 58 void gv_rename(struct g_geom *, struct gctl_req *); 59 60 /* geom_vinum_rm.c */ 61 void gv_remove(struct g_geom *, struct gctl_req *); 62 int gv_resetconfig(struct g_geom *, struct gctl_req *); 63 int gv_rm_sd(struct gv_softc *sc, struct gctl_req *req, 64 struct gv_sd *s, int flags); 65 66 /* geom_vinum_state.c */ 67 int gv_sdstatemap(struct gv_plex *); 68 void gv_setstate(struct g_geom *, struct gctl_req *); 69 int gv_set_drive_state(struct gv_drive *, int, int); 70 int gv_set_sd_state(struct gv_sd *, int, int); 71 void gv_update_sd_state(struct gv_sd *); 72 void gv_update_plex_state(struct gv_plex *); 73 void gv_update_vol_state(struct gv_volume *); 74 75 /* geom_vinum_subr.c */ 76 void gv_adjust_freespace(struct gv_sd *, off_t); 77 void gv_free_sd(struct gv_sd *); 78 struct g_geom *find_vinum_geom(void); 79 struct gv_drive *gv_find_drive(struct gv_softc *, char *); 80 struct gv_plex *gv_find_plex(struct gv_softc *, char *); 81 struct gv_sd *gv_find_sd(struct gv_softc *, char *); 82 struct gv_volume *gv_find_vol(struct gv_softc *, char *); 83 void gv_format_config(struct gv_softc *, struct sbuf *, int, char *); 84 int gv_is_striped(struct gv_plex *); 85 int gv_is_open(struct g_geom *); 86 void gv_kill_drive_thread(struct gv_drive *); 87 void gv_kill_plex_thread(struct gv_plex *); 88 void gv_kill_vol_thread(struct gv_volume *); 89 int gv_object_type(struct gv_softc *, char *); 90 void gv_parse_config(struct gv_softc *, u_char *, int); 91 int gv_sd_to_drive(struct gv_softc *, struct gv_drive *, struct gv_sd *, 92 char *, int); 93 int gv_sd_to_plex(struct gv_plex *, struct gv_sd *, int); 94 void gv_update_plex_config(struct gv_plex *); 95 void gv_update_vol_size(struct gv_volume *, off_t); 96 off_t gv_vol_size(struct gv_volume *); 97 off_t gv_plex_size(struct gv_plex *); 98 99 extern u_int g_vinum_debug; 100 101 #define G_VINUM_DEBUG(lvl, ...) do { \ 102 if (g_vinum_debug >= (lvl)) { \ 103 printf("GEOM_VINUM"); \ 104 if (g_vinum_debug > 0) \ 105 printf("[%u]", lvl); \ 106 printf(": "); \ 107 printf(__VA_ARGS__); \ 108 printf("\n"); \ 109 } \ 110 } while (0) 111 112 #define G_VINUM_LOGREQ(lvl, bp, ...) do { \ 113 if (g_vinum_debug >= (lvl)) { \ 114 printf("GEOM_VINUM"); \ 115 if (g_vinum_debug > 0) \ 116 printf("[%u]", lvl); \ 117 printf(": "); \ 118 printf(__VA_ARGS__); \ 119 printf(" "); \ 120 g_print_bio(bp); \ 121 printf("\n"); \ 122 } \ 123 } while (0) 124 125 #endif /* !_GEOM_VINUM_H_ */ 126