xref: /freebsd/sys/geom/raid/g_raid_tr_if.m (revision 031beb4e239bfce798af17f5fe8dba8bcaf13d99)
1*89b17223SAlexander Motin#-
2*89b17223SAlexander Motin# Copyright (c) 2010 Alexander Motin
3*89b17223SAlexander Motin# All rights reserved.
4*89b17223SAlexander Motin#
5*89b17223SAlexander Motin# Redistribution and use in source and binary forms, with or without
6*89b17223SAlexander Motin# modification, are permitted provided that the following conditions
7*89b17223SAlexander Motin# are met:
8*89b17223SAlexander Motin#
9*89b17223SAlexander Motin# 1. Redistributions of source code must retain the above copyright
10*89b17223SAlexander Motin#    notice, this list of conditions and the following disclaimer.
11*89b17223SAlexander Motin# 2. Redistributions in binary form must reproduce the above copyright
12*89b17223SAlexander Motin#    notice, this list of conditions and the following disclaimer in the
13*89b17223SAlexander Motin#    documentation and/or other materials provided with the distribution.
14*89b17223SAlexander Motin#
15*89b17223SAlexander Motin# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16*89b17223SAlexander Motin# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17*89b17223SAlexander Motin# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18*89b17223SAlexander Motin# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19*89b17223SAlexander Motin# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20*89b17223SAlexander Motin# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21*89b17223SAlexander Motin# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22*89b17223SAlexander Motin# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23*89b17223SAlexander Motin# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24*89b17223SAlexander Motin# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*89b17223SAlexander Motin#
26*89b17223SAlexander Motin
27*89b17223SAlexander Motin#include <sys/param.h>
28*89b17223SAlexander Motin#include <sys/lock.h>
29*89b17223SAlexander Motin#include <sys/malloc.h>
30*89b17223SAlexander Motin#include <sys/mutex.h>
31*89b17223SAlexander Motin#include <sys/sbuf.h>
32*89b17223SAlexander Motin#include <sys/bus.h>
33*89b17223SAlexander Motin#include <machine/bus.h>
34*89b17223SAlexander Motin#include <sys/systm.h>
35*89b17223SAlexander Motin#include <geom/geom.h>
36*89b17223SAlexander Motin#include <geom/raid/g_raid.h>
37*89b17223SAlexander Motin
38*89b17223SAlexander Motin# The G_RAID transformation class interface.
39*89b17223SAlexander Motin
40*89b17223SAlexander MotinINTERFACE g_raid_tr;
41*89b17223SAlexander Motin
42*89b17223SAlexander Motin# Default implementations of methods.
43*89b17223SAlexander MotinCODE {
44*89b17223SAlexander Motin	static int
45*89b17223SAlexander Motin	g_raid_tr_locked_default(struct g_raid_tr_object *tr, void *argp)
46*89b17223SAlexander Motin	{
47*89b17223SAlexander Motin
48*89b17223SAlexander Motin		return (0);
49*89b17223SAlexander Motin	}
50*89b17223SAlexander Motin};
51*89b17223SAlexander Motin
52*89b17223SAlexander MotinHEADER {
53*89b17223SAlexander Motin#define G_RAID_TR_TASTE_FAIL		-1
54*89b17223SAlexander Motin#define G_RAID_TR_TASTE_SUCCEED		 0
55*89b17223SAlexander Motin};
56*89b17223SAlexander Motin
57*89b17223SAlexander Motin# taste() - volume taste method.
58*89b17223SAlexander MotinMETHOD int taste {
59*89b17223SAlexander Motin	struct g_raid_tr_object *tr;
60*89b17223SAlexander Motin	struct g_raid_volume *volume;
61*89b17223SAlexander Motin};
62*89b17223SAlexander Motin
63*89b17223SAlexander Motin# event() - events handling method.
64*89b17223SAlexander MotinMETHOD int event {
65*89b17223SAlexander Motin	struct g_raid_tr_object *tr;
66*89b17223SAlexander Motin	struct g_raid_subdisk *sd;
67*89b17223SAlexander Motin	u_int event;
68*89b17223SAlexander Motin};
69*89b17223SAlexander Motin
70*89b17223SAlexander Motin# start() - begin operation.
71*89b17223SAlexander MotinMETHOD int start {
72*89b17223SAlexander Motin	struct g_raid_tr_object *tr;
73*89b17223SAlexander Motin};
74*89b17223SAlexander Motin
75*89b17223SAlexander Motin# stop() - stop operation.
76*89b17223SAlexander MotinMETHOD int stop {
77*89b17223SAlexander Motin	struct g_raid_tr_object *tr;
78*89b17223SAlexander Motin};
79*89b17223SAlexander Motin
80*89b17223SAlexander Motin# iorequest() - manage forward transformation and generates requests to disks.
81*89b17223SAlexander MotinMETHOD void iostart {
82*89b17223SAlexander Motin	struct g_raid_tr_object *tr;
83*89b17223SAlexander Motin	struct bio *bp;
84*89b17223SAlexander Motin};
85*89b17223SAlexander Motin
86*89b17223SAlexander Motin# iodone() - manages backward transformation and reports completion status.
87*89b17223SAlexander MotinMETHOD void iodone {
88*89b17223SAlexander Motin	struct g_raid_tr_object *tr;
89*89b17223SAlexander Motin	struct g_raid_subdisk *sd;
90*89b17223SAlexander Motin	struct bio *bp;
91*89b17223SAlexander Motin};
92*89b17223SAlexander Motin
93*89b17223SAlexander Motin# kerneldump() - optimized for rebustness (simplified) kernel dumping routine.
94*89b17223SAlexander MotinMETHOD int kerneldump {
95*89b17223SAlexander Motin	struct g_raid_tr_object *tr;
96*89b17223SAlexander Motin	void *virtual;
97*89b17223SAlexander Motin	off_t offset;
98*89b17223SAlexander Motin	size_t length;
99*89b17223SAlexander Motin} DEFAULT g_raid_tr_kerneldump_common;
100*89b17223SAlexander Motin
101*89b17223SAlexander Motin# locked() - callback method for lock().
102*89b17223SAlexander MotinMETHOD int locked {
103*89b17223SAlexander Motin	struct g_raid_tr_object *tr;
104*89b17223SAlexander Motin	void *argp;
105*89b17223SAlexander Motin} DEFAULT g_raid_tr_locked_default;
106*89b17223SAlexander Motin
107*89b17223SAlexander Motin# free() - destructor.
108*89b17223SAlexander MotinMETHOD int free {
109*89b17223SAlexander Motin	struct g_raid_tr_object *tr;
110*89b17223SAlexander Motin};
111*89b17223SAlexander Motin
112*89b17223SAlexander Motin# idle() - callback when the volume is idle for a while and the TR wants
113*89b17223SAlexander Motin# to schedule some work for that idle period.
114*89b17223SAlexander MotinMETHOD int idle {
115*89b17223SAlexander Motin	struct g_raid_tr_object *tr;
116*89b17223SAlexander Motin};
117