Deleted Added
full compact
g_gate.h (147843) g_gate.h (155174)
1/*-
2 * Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>
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.
1/*-
2 * Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>
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 *
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS 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 AUTHORS 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 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS 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 AUTHORS 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: head/sys/geom/gate/g_gate.h 147843 2005-07-08 21:08:53Z pjd $
26 * $FreeBSD: head/sys/geom/gate/g_gate.h 155174 2006-02-01 12:06:01Z pjd $
27 */
28
29#ifndef _G_GATE_H_
30#define _G_GATE_H_
31
32#include <sys/param.h>
33#include <sys/lock.h>
34#include <sys/mutex.h>
35#include <sys/queue.h>
36
37#include <geom/geom.h>
38
39#define G_GATE_CLASS_NAME "GATE"
40#define G_GATE_PROVIDER_NAME "ggate"
41#define G_GATE_MOD_NAME "ggate"
42#define G_GATE_CTL_NAME "ggctl"
43
44#define G_GATE_VERSION 1
45
46/*
47 * Maximum number of request that can be stored in
48 * the queue when there are no workers.
49 */
50#define G_GATE_MAX_QUEUE_SIZE 4096
51
52#define G_GATE_FLAG_READONLY 0x0001
53#define G_GATE_FLAG_WRITEONLY 0x0002
54#define G_GATE_FLAG_DESTROY 0x1000
55#define G_GATE_USERFLAGS (G_GATE_FLAG_READONLY | G_GATE_FLAG_WRITEONLY)
56
57#define G_GATE_CMD_CREATE _IOWR('m', 0, struct g_gate_ctl_create)
58#define G_GATE_CMD_DESTROY _IOWR('m', 1, struct g_gate_ctl_destroy)
59#define G_GATE_CMD_CANCEL _IOWR('m', 2, struct g_gate_ctl_cancel)
60#define G_GATE_CMD_START _IOWR('m', 3, struct g_gate_ctl_io)
61#define G_GATE_CMD_DONE _IOWR('m', 4, struct g_gate_ctl_io)
62
63#define G_GATE_INFOSIZE 2048
64
65#ifdef _KERNEL
66/*
67 * 'P:' means 'Protected by'.
68 */
69struct g_gate_softc {
70 int sc_unit; /* P: (read-only) */
71 int16_t sc_ref; /* P: g_gate_list_mtx */
72 struct g_provider *sc_provider; /* P: (read-only) */
73 uint32_t sc_flags; /* P: (read-only) */
74
75 struct bio_queue_head sc_inqueue; /* P: sc_queue_mtx */
76 struct bio_queue_head sc_outqueue; /* P: sc_queue_mtx */
77 struct mtx sc_queue_mtx;
78 uint32_t sc_queue_count; /* P: sc_queue_mtx */
79 uint32_t sc_queue_size; /* P: (read-only) */
80 u_int sc_timeout; /* P: (read-only) */
81 struct callout sc_callout; /* P: (modified only
82 from callout
83 thread) */
84 uintptr_t sc_seq; /* P: (modified only
85 from g_down
86 thread) */
87 LIST_ENTRY(g_gate_softc) sc_next; /* P: g_gate_list_mtx */
88 char sc_info[G_GATE_INFOSIZE]; /* P: (read-only) */
89};
90#define sc_name sc_provider->geom->name
91
92#define G_GATE_DEBUG(lvl, ...) do { \
93 if (g_gate_debug >= (lvl)) { \
94 printf("GEOM_GATE"); \
95 if (g_gate_debug > 0) \
96 printf("[%u]", lvl); \
97 printf(": "); \
98 printf(__VA_ARGS__); \
99 printf("\n"); \
100 } \
101} while (0)
102#define G_GATE_LOGREQ(lvl, bp, ...) do { \
103 if (g_gate_debug >= (lvl)) { \
104 printf("GEOM_GATE"); \
105 if (g_gate_debug > 0) \
106 printf("[%u]", lvl); \
107 printf(": "); \
108 printf(__VA_ARGS__); \
109 printf(" "); \
110 g_print_bio(bp); \
111 printf("\n"); \
112 } \
113} while (0)
114#endif /* !_KERNEL */
115
116struct g_gate_ctl_create {
117 u_int gctl_version;
118 off_t gctl_mediasize;
119 u_int gctl_sectorsize;
120 u_int gctl_flags;
121 u_int gctl_maxcount;
122 u_int gctl_timeout;
123 char gctl_info[G_GATE_INFOSIZE];
124 int gctl_unit; /* out */
125};
126
127struct g_gate_ctl_destroy {
128 u_int gctl_version;
129 int gctl_unit;
130 int gctl_force;
131};
132
133struct g_gate_ctl_cancel {
134 u_int gctl_version;
135 int gctl_unit;
136 uintptr_t gctl_seq;
137};
138
139struct g_gate_ctl_io {
140 u_int gctl_version;
141 int gctl_unit;
142 uintptr_t gctl_seq;
143 u_int gctl_cmd;
144 off_t gctl_offset;
145 off_t gctl_length;
146 void *gctl_data;
147 int gctl_error;
148};
149#endif /* !_G_GATE_H_ */
27 */
28
29#ifndef _G_GATE_H_
30#define _G_GATE_H_
31
32#include <sys/param.h>
33#include <sys/lock.h>
34#include <sys/mutex.h>
35#include <sys/queue.h>
36
37#include <geom/geom.h>
38
39#define G_GATE_CLASS_NAME "GATE"
40#define G_GATE_PROVIDER_NAME "ggate"
41#define G_GATE_MOD_NAME "ggate"
42#define G_GATE_CTL_NAME "ggctl"
43
44#define G_GATE_VERSION 1
45
46/*
47 * Maximum number of request that can be stored in
48 * the queue when there are no workers.
49 */
50#define G_GATE_MAX_QUEUE_SIZE 4096
51
52#define G_GATE_FLAG_READONLY 0x0001
53#define G_GATE_FLAG_WRITEONLY 0x0002
54#define G_GATE_FLAG_DESTROY 0x1000
55#define G_GATE_USERFLAGS (G_GATE_FLAG_READONLY | G_GATE_FLAG_WRITEONLY)
56
57#define G_GATE_CMD_CREATE _IOWR('m', 0, struct g_gate_ctl_create)
58#define G_GATE_CMD_DESTROY _IOWR('m', 1, struct g_gate_ctl_destroy)
59#define G_GATE_CMD_CANCEL _IOWR('m', 2, struct g_gate_ctl_cancel)
60#define G_GATE_CMD_START _IOWR('m', 3, struct g_gate_ctl_io)
61#define G_GATE_CMD_DONE _IOWR('m', 4, struct g_gate_ctl_io)
62
63#define G_GATE_INFOSIZE 2048
64
65#ifdef _KERNEL
66/*
67 * 'P:' means 'Protected by'.
68 */
69struct g_gate_softc {
70 int sc_unit; /* P: (read-only) */
71 int16_t sc_ref; /* P: g_gate_list_mtx */
72 struct g_provider *sc_provider; /* P: (read-only) */
73 uint32_t sc_flags; /* P: (read-only) */
74
75 struct bio_queue_head sc_inqueue; /* P: sc_queue_mtx */
76 struct bio_queue_head sc_outqueue; /* P: sc_queue_mtx */
77 struct mtx sc_queue_mtx;
78 uint32_t sc_queue_count; /* P: sc_queue_mtx */
79 uint32_t sc_queue_size; /* P: (read-only) */
80 u_int sc_timeout; /* P: (read-only) */
81 struct callout sc_callout; /* P: (modified only
82 from callout
83 thread) */
84 uintptr_t sc_seq; /* P: (modified only
85 from g_down
86 thread) */
87 LIST_ENTRY(g_gate_softc) sc_next; /* P: g_gate_list_mtx */
88 char sc_info[G_GATE_INFOSIZE]; /* P: (read-only) */
89};
90#define sc_name sc_provider->geom->name
91
92#define G_GATE_DEBUG(lvl, ...) do { \
93 if (g_gate_debug >= (lvl)) { \
94 printf("GEOM_GATE"); \
95 if (g_gate_debug > 0) \
96 printf("[%u]", lvl); \
97 printf(": "); \
98 printf(__VA_ARGS__); \
99 printf("\n"); \
100 } \
101} while (0)
102#define G_GATE_LOGREQ(lvl, bp, ...) do { \
103 if (g_gate_debug >= (lvl)) { \
104 printf("GEOM_GATE"); \
105 if (g_gate_debug > 0) \
106 printf("[%u]", lvl); \
107 printf(": "); \
108 printf(__VA_ARGS__); \
109 printf(" "); \
110 g_print_bio(bp); \
111 printf("\n"); \
112 } \
113} while (0)
114#endif /* !_KERNEL */
115
116struct g_gate_ctl_create {
117 u_int gctl_version;
118 off_t gctl_mediasize;
119 u_int gctl_sectorsize;
120 u_int gctl_flags;
121 u_int gctl_maxcount;
122 u_int gctl_timeout;
123 char gctl_info[G_GATE_INFOSIZE];
124 int gctl_unit; /* out */
125};
126
127struct g_gate_ctl_destroy {
128 u_int gctl_version;
129 int gctl_unit;
130 int gctl_force;
131};
132
133struct g_gate_ctl_cancel {
134 u_int gctl_version;
135 int gctl_unit;
136 uintptr_t gctl_seq;
137};
138
139struct g_gate_ctl_io {
140 u_int gctl_version;
141 int gctl_unit;
142 uintptr_t gctl_seq;
143 u_int gctl_cmd;
144 off_t gctl_offset;
145 off_t gctl_length;
146 void *gctl_data;
147 int gctl_error;
148};
149#endif /* !_G_GATE_H_ */