geom.h (125755) | geom.h (126798) |
---|---|
1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 18 unchanged lines hidden (view full) --- 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * | 1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 18 unchanged lines hidden (view full) --- 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * |
35 * $FreeBSD: head/sys/geom/geom.h 125755 2004-02-12 22:42:11Z phk $ | 35 * $FreeBSD: head/sys/geom/geom.h 126798 2004-03-10 08:49:08Z phk $ |
36 */ 37 38#ifndef _GEOM_GEOM_H_ 39#define _GEOM_GEOM_H_ 40 41#include <sys/lock.h> 42#include <sys/mutex.h> 43#include <sys/sx.h> --- 172 unchanged lines hidden (view full) --- 216int g_getattr__(const char *attr, struct g_consumer *cp, void *var, int len); 217#define g_getattr(a, c, v) g_getattr__((a), (c), (v), sizeof *(v)) 218int g_handleattr(struct bio *bp, const char *attribute, void *val, int len); 219int g_handleattr_int(struct bio *bp, const char *attribute, int val); 220int g_handleattr_off_t(struct bio *bp, const char *attribute, off_t val); 221struct g_consumer * g_new_consumer(struct g_geom *gp); 222struct g_geom * g_new_geomf(struct g_class *mp, const char *fmt, ...); 223struct g_provider * g_new_providerf(struct g_geom *gp, const char *fmt, ...); | 36 */ 37 38#ifndef _GEOM_GEOM_H_ 39#define _GEOM_GEOM_H_ 40 41#include <sys/lock.h> 42#include <sys/mutex.h> 43#include <sys/sx.h> --- 172 unchanged lines hidden (view full) --- 216int g_getattr__(const char *attr, struct g_consumer *cp, void *var, int len); 217#define g_getattr(a, c, v) g_getattr__((a), (c), (v), sizeof *(v)) 218int g_handleattr(struct bio *bp, const char *attribute, void *val, int len); 219int g_handleattr_int(struct bio *bp, const char *attribute, int val); 220int g_handleattr_off_t(struct bio *bp, const char *attribute, off_t val); 221struct g_consumer * g_new_consumer(struct g_geom *gp); 222struct g_geom * g_new_geomf(struct g_class *mp, const char *fmt, ...); 223struct g_provider * g_new_providerf(struct g_geom *gp, const char *fmt, ...); |
224void g_sanity(void const *ptr); | |
225void g_spoil(struct g_provider *pp, struct g_consumer *cp); 226int g_std_access(struct g_provider *pp, int dr, int dw, int de); 227void g_std_done(struct bio *bp); 228void g_std_spoiled(struct g_consumer *cp); 229void g_wither_geom(struct g_geom *gp, int error); 230 | 224void g_spoil(struct g_provider *pp, struct g_consumer *cp); 225int g_std_access(struct g_provider *pp, int dr, int dw, int de); 226void g_std_done(struct bio *bp); 227void g_std_spoiled(struct g_consumer *cp); 228void g_wither_geom(struct g_geom *gp, int error); 229 |
230#ifdef DIAGNOSTIC 231int g_valid_obj(void const *ptr); 232#define G_VALID_CLASS(foo) \ 233 KASSERT(g_valid_obj(foo) == 1, ("%p is not a g_class", foo)) 234#define G_VALID_GEOM(foo) \ 235 KASSERT(g_valid_obj(foo) == 2, ("%p is not a g_geom", foo)) 236#define G_VALID_CONSUMER(foo) \ 237 KASSERT(g_valid_obj(foo) == 3, ("%p is not a g_consumer", foo)) 238#define G_VALID_PROVIDER(foo) \ 239 KASSERT(g_valid_obj(foo) == 4, ("%p is not a g_provider", foo)) 240#else 241#define G_VALID_CLASS(foo) do { } while (0) 242#define G_VALID_GEOM(foo) do { } while (0) 243#define G_VALID_CONSUMER(foo) do { } while (0) 244#define G_VALID_PROVIDER(foo) do { } while (0) 245#endif 246 |
|
231int g_modevent(module_t, int, void *); 232 233/* geom_io.c */ 234struct bio * g_clone_bio(struct bio *); 235void g_destroy_bio(struct bio *); 236void g_io_deliver(struct bio *bp, int error); 237int g_io_getattr(const char *attr, struct g_consumer *cp, int *len, void *ptr); 238void g_io_request(struct bio *bp, struct g_consumer *cp); --- 14 unchanged lines hidden (view full) --- 253MALLOC_DECLARE(M_GEOM); 254 255static __inline void * 256g_malloc(int size, int flags) 257{ 258 void *p; 259 260 p = malloc(size, M_GEOM, flags); | 247int g_modevent(module_t, int, void *); 248 249/* geom_io.c */ 250struct bio * g_clone_bio(struct bio *); 251void g_destroy_bio(struct bio *); 252void g_io_deliver(struct bio *bp, int error); 253int g_io_getattr(const char *attr, struct g_consumer *cp, int *len, void *ptr); 254void g_io_request(struct bio *bp, struct g_consumer *cp); --- 14 unchanged lines hidden (view full) --- 269MALLOC_DECLARE(M_GEOM); 270 271static __inline void * 272g_malloc(int size, int flags) 273{ 274 void *p; 275 276 p = malloc(size, M_GEOM, flags); |
261 g_sanity(p); 262 /* printf("malloc(%d, %x) -> %p\n", size, flags, p); */ | |
263 return (p); 264} 265 266static __inline void 267g_free(void *ptr) 268{ | 277 return (p); 278} 279 280static __inline void 281g_free(void *ptr) 282{ |
269 g_sanity(ptr); 270 /* printf("free(%p)\n", ptr); */ | 283 284#ifdef DIAGNOSTIC 285 KASSERT(g_valid_obj(ptr) == 0, 286 ("g_free(%p) of live object, type %d", ptr, g_valid_obj(ptr))); 287#endif |
271 free(ptr, M_GEOM); 272} 273 274extern struct sx topology_lock; 275 276#define g_topology_lock() \ 277 do { \ 278 mtx_assert(&Giant, MA_NOTOWNED); \ 279 sx_xlock(&topology_lock); \ 280 } while (0) 281 282#define g_topology_unlock() \ 283 do { \ | 288 free(ptr, M_GEOM); 289} 290 291extern struct sx topology_lock; 292 293#define g_topology_lock() \ 294 do { \ 295 mtx_assert(&Giant, MA_NOTOWNED); \ 296 sx_xlock(&topology_lock); \ 297 } while (0) 298 299#define g_topology_unlock() \ 300 do { \ |
284 g_sanity(NULL); \ | |
285 sx_xunlock(&topology_lock); \ 286 } while (0) 287 288#define g_topology_assert() \ 289 do { \ | 301 sx_xunlock(&topology_lock); \ 302 } while (0) 303 304#define g_topology_assert() \ 305 do { \ |
290 g_sanity(NULL); \ | |
291 sx_assert(&topology_lock, SX_XLOCKED); \ 292 } while (0) 293 294#define g_topology_assert_not() \ 295 do { \ | 306 sx_assert(&topology_lock, SX_XLOCKED); \ 307 } while (0) 308 309#define g_topology_assert_not() \ 310 do { \ |
296 g_sanity(NULL); \ | |
297 sx_assert(&topology_lock, SX_UNLOCKED); \ 298 } while (0) 299 300#define DECLARE_GEOM_CLASS(class, name) \ 301 static moduledata_t name##_mod = { \ 302 #name, g_modevent, &class \ 303 }; \ 304 DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); --- 14 unchanged lines hidden --- | 311 sx_assert(&topology_lock, SX_UNLOCKED); \ 312 } while (0) 313 314#define DECLARE_GEOM_CLASS(class, name) \ 315 static moduledata_t name##_mod = { \ 316 #name, g_modevent, &class \ 317 }; \ 318 DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); --- 14 unchanged lines hidden --- |