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