g_raid_md_if.m revision 219974
1219974Smav#- 2219974Smav# Copyright (c) 2010 Alexander Motin 3219974Smav# All rights reserved. 4219974Smav# 5219974Smav# Redistribution and use in source and binary forms, with or without 6219974Smav# modification, are permitted provided that the following conditions 7219974Smav# are met: 8219974Smav# 9219974Smav# 1. Redistributions of source code must retain the above copyright 10219974Smav# notice, this list of conditions and the following disclaimer. 11219974Smav# 2. Redistributions in binary form must reproduce the above copyright 12219974Smav# notice, this list of conditions and the following disclaimer in the 13219974Smav# documentation and/or other materials provided with the distribution. 14219974Smav# 15219974Smav# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16219974Smav# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17219974Smav# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18219974Smav# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19219974Smav# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20219974Smav# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21219974Smav# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22219974Smav# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23219974Smav# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24219974Smav# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25219974Smav# 26219974Smav# $FreeBSD: head/sys/geom/raid/g_raid_md_if.m 219974 2011-03-24 21:31:32Z mav $ 27219974Smav 28219974Smav#include <sys/param.h> 29219974Smav#include <sys/lock.h> 30219974Smav#include <sys/malloc.h> 31219974Smav#include <sys/mutex.h> 32219974Smav#include <sys/sbuf.h> 33219974Smav#include <sys/bus.h> 34219974Smav#include <machine/bus.h> 35219974Smav#include <sys/systm.h> 36219974Smav#include <geom/geom.h> 37219974Smav#include <geom/raid/g_raid.h> 38219974Smav 39219974Smav# The G_RAID metadata class interface. 40219974Smav 41219974SmavINTERFACE g_raid_md; 42219974Smav 43219974SmavHEADER { 44219974Smav#define G_RAID_MD_TASTE_FAIL -1 45219974Smav#define G_RAID_MD_TASTE_EXISTING 0 46219974Smav#define G_RAID_MD_TASTE_NEW 1 47219974Smav}; 48219974Smav 49219974Smav# Default implementations of methods. 50219974SmavCODE { 51219974Smav static int 52219974Smav g_raid_md_create_default(struct g_raid_md_object *md) 53219974Smav { 54219974Smav 55219974Smav return (G_RAID_MD_TASTE_FAIL); 56219974Smav } 57219974Smav 58219974Smav static int 59219974Smav g_raid_md_ctl_default(struct g_raid_md_object *md, 60219974Smav struct gctl_req *req) 61219974Smav { 62219974Smav 63219974Smav return (-1); 64219974Smav } 65219974Smav 66219974Smav static int 67219974Smav g_raid_md_volume_event_default(struct g_raid_md_object *md, 68219974Smav struct g_raid_volume *vol, u_int event) 69219974Smav { 70219974Smav 71219974Smav return (-1); 72219974Smav } 73219974Smav 74219974Smav static int 75219974Smav g_raid_md_free_disk_default(struct g_raid_md_object *md, 76219974Smav struct g_raid_volume *vol) 77219974Smav { 78219974Smav 79219974Smav return (0); 80219974Smav } 81219974Smav 82219974Smav static int 83219974Smav g_raid_md_free_volume_default(struct g_raid_md_object *md, 84219974Smav struct g_raid_volume *vol) 85219974Smav { 86219974Smav 87219974Smav return (0); 88219974Smav } 89219974Smav}; 90219974Smav 91219974Smav# create() - create new node from scratch. 92219974SmavMETHOD int create { 93219974Smav struct g_raid_md_object *md; 94219974Smav struct g_class *mp; 95219974Smav struct g_geom **gp; 96219974Smav} DEFAULT g_raid_md_create_default; 97219974Smav 98219974Smav# taste() - taste disk and, if needed, create new node. 99219974SmavMETHOD int taste { 100219974Smav struct g_raid_md_object *md; 101219974Smav struct g_class *mp; 102219974Smav struct g_consumer *cp; 103219974Smav struct g_geom **gp; 104219974Smav}; 105219974Smav 106219974Smav# ctl() - user-level control commands handling method. 107219974SmavMETHOD int ctl { 108219974Smav struct g_raid_md_object *md; 109219974Smav struct gctl_req *req; 110219974Smav} DEFAULT g_raid_md_ctl_default; 111219974Smav 112219974Smav# event() - events handling method. 113219974SmavMETHOD int event { 114219974Smav struct g_raid_md_object *md; 115219974Smav struct g_raid_disk *disk; 116219974Smav u_int event; 117219974Smav}; 118219974Smav 119219974Smav# volume_event() - events handling method. 120219974SmavMETHOD int volume_event { 121219974Smav struct g_raid_md_object *md; 122219974Smav struct g_raid_volume *vol; 123219974Smav u_int event; 124219974Smav} DEFAULT g_raid_md_volume_event_default; 125219974Smav 126219974Smav# write() - metadata write method. 127219974SmavMETHOD int write { 128219974Smav struct g_raid_md_object *md; 129219974Smav struct g_raid_volume *vol; 130219974Smav struct g_raid_subdisk *sd; 131219974Smav struct g_raid_disk *disk; 132219974Smav}; 133219974Smav 134219974Smav# fail_disk() - mark disk as failed and remove it from use. 135219974SmavMETHOD int fail_disk { 136219974Smav struct g_raid_md_object *md; 137219974Smav struct g_raid_subdisk *sd; 138219974Smav struct g_raid_disk *disk; 139219974Smav}; 140219974Smav 141219974Smav# free_disk() - disk destructor. 142219974SmavMETHOD int free_disk { 143219974Smav struct g_raid_md_object *md; 144219974Smav struct g_raid_disk *disk; 145219974Smav} DEFAULT g_raid_md_free_disk_default; 146219974Smav 147219974Smav# free_volume() - volume destructor. 148219974SmavMETHOD int free_volume { 149219974Smav struct g_raid_md_object *md; 150219974Smav struct g_raid_volume *vol; 151219974Smav} DEFAULT g_raid_md_free_volume_default; 152219974Smav 153219974Smav# free() - destructor. 154219974SmavMETHOD int free { 155219974Smav struct g_raid_md_object *md; 156219974Smav}; 157