Cave in to tradition and rename "methods" to "classes".

This commit is contained in:
Poul-Henning Kamp 2002-03-26 21:40:06 +00:00
parent 62edbd31c7
commit e805e8f0e8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=93248
12 changed files with 122 additions and 122 deletions

View File

@ -48,7 +48,7 @@
#include <geom_sim.h>
#endif
struct g_method;
struct g_class;
struct g_geom;
struct g_consumer;
struct g_provider;
@ -57,7 +57,7 @@ struct thread;
struct bio;
struct sbuf;
LIST_HEAD(method_list_head, g_method);
LIST_HEAD(class_list_head, g_class);
TAILQ_HEAD(g_tailq_head, g_geom);
TAILQ_HEAD(event_tailq_head, g_event);
@ -66,11 +66,11 @@ extern struct event_tailq_head events;
extern int g_debugflags;
#define G_METHOD_INITSTUFF { 0, 0 }, { 0 }, 0
#define G_CLASS_INITSTUFF { 0, 0 }, { 0 }, 0
typedef struct g_geom * g_create_geom_t (struct g_method *mp,
typedef struct g_geom * g_create_geom_t (struct g_class *mp,
struct g_provider *pp, char *name);
typedef struct g_geom * g_taste_t (struct g_method *, struct g_provider *,
typedef struct g_geom * g_taste_t (struct g_class *, struct g_provider *,
struct thread *tp, int flags);
#define G_TF_NORMAL 0
#define G_TF_INSIST 1
@ -85,31 +85,31 @@ typedef void g_dumpconf_t (struct sbuf *, char *indent, struct g_geom *,
struct g_consumer *, struct g_provider *);
/*
* The g_method structure describes a transformation method. In other words
* all BSD disklabel handlers share one g_method, all MBR handlers share
* one common g_method and so on.
* Certain operations are instantiated on the method, most notably the
* The g_class structure describes a transformation class. In other words
* all BSD disklabel handlers share one g_class, all MBR handlers share
* one common g_class and so on.
* Certain operations are instantiated on the class, most notably the
* taste and create_geom functions.
* XXX: should access and orphan go into g_geom ?
* XXX: would g_class be a better and less confusing name ?
*/
struct g_method {
struct g_class {
char *name;
g_taste_t *taste;
g_access_t *access;
g_orphan_t *orphan;
g_create_geom_t *create_geom;
LIST_ENTRY(g_method) method;
LIST_ENTRY(g_class) class;
LIST_HEAD(,g_geom) geom;
struct g_event *event;
};
/*
* The g_geom is an instance of a g_method.
* The g_geom is an instance of a g_class.
*/
struct g_geom {
char *name;
struct g_method *method;
struct g_class *class;
LIST_ENTRY(g_geom) geom;
LIST_HEAD(,g_consumer) consumer;
LIST_HEAD(,g_provider) provider;
@ -173,7 +173,7 @@ struct g_provider {
* an internal eventqueue.
*/
enum g_events {
EV_NEW_METHOD, /* method */
EV_NEW_CLASS, /* class */
EV_NEW_PROVIDER, /* provider */
EV_SPOILED, /* provider, consumer */
EV_LAST
@ -182,7 +182,7 @@ enum g_events {
struct g_event {
enum g_events event;
TAILQ_ENTRY(g_event) events;
struct g_method *method;
struct g_class *class;
struct g_geom *geom;
struct g_provider *provider;
struct g_consumer *consumer;
@ -190,7 +190,7 @@ struct g_event {
/* geom_dump.c */
struct sbuf * g_conf(void);
struct sbuf * g_conf_specific(struct g_method *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp);
struct sbuf * g_conf_specific(struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp);
struct sbuf * g_confdot(void);
void g_hexdump(void *ptr, int length);
void g_trace(int level, char *, ...);
@ -208,7 +208,7 @@ void g_enc_le4(u_char *p, uint32_t u);
/* geom_event.c */
void g_event_init(void);
void g_orphan_provider(struct g_provider *pp, int error);
void g_post_event(enum g_events ev, struct g_method *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp);
void g_post_event(enum g_events ev, struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp);
void g_rattle(void);
void g_run_events(struct thread *tp);
void g_silence(void);
@ -216,9 +216,9 @@ void g_silence(void);
/* geom_subr.c */
int g_access_abs(struct g_consumer *cp, int read, int write, int exclusive);
int g_access_rel(struct g_consumer *cp, int read, int write, int exclusive);
void g_add_method(struct g_method *mp);
void g_add_class(struct g_class *mp);
int g_attach(struct g_consumer *cp, struct g_provider *pp);
struct g_geom *g_create_geomf(char *method, struct g_provider *, char *fmt, ...);
struct g_geom *g_create_geomf(char *class, struct g_provider *, char *fmt, ...);
void g_destroy_consumer(struct g_consumer *cp);
void g_destroy_geom(struct g_geom *pp);
void g_destroy_provider(struct g_provider *pp);
@ -227,10 +227,10 @@ void g_error_provider(struct g_provider *pp, int error);
int g_haveattr(struct bio *bp, char *attribute, void *val, int len);
int g_haveattr_int(struct bio *bp, char *attribute, int val);
int g_haveattr_off_t(struct bio *bp, char *attribute, off_t val);
struct g_geom * g_insert_geom(char *method, struct g_consumer *cp);
extern struct method_list_head g_methods;
struct g_geom * g_insert_geom(char *class, struct g_consumer *cp);
extern struct class_list_head g_classs;
struct g_consumer * g_new_consumer(struct g_geom *gp);
struct g_geom * g_new_geomf(struct g_method *mp, char *fmt, ...);
struct g_geom * g_new_geomf(struct g_class *mp, char *fmt, ...);
struct g_provider * g_new_providerf(struct g_geom *gp, char *fmt, ...);
void g_spoil(struct g_provider *pp, struct g_consumer *cp);
int g_std_access(struct g_provider *pp, int dr, int dw, int de);
@ -289,12 +289,12 @@ extern struct sx topology_lock;
#define g_topology_unlock() sx_xunlock(&topology_lock)
#define g_topology_assert() sx_assert(&topology_lock, SX_XLOCKED)
#define DECLARE_GEOM_METHOD(method, name) \
#define DECLARE_GEOM_CLASS(class, name) \
static void \
name##init(void) \
{ \
mtx_unlock(&Giant); \
g_add_method(&method); \
g_add_class(&class); \
mtx_lock(&Giant); \
} \
SYSINIT(name, SI_SUB_PSEUDO, SI_ORDER_FIRST, name##init, NULL);

View File

@ -57,7 +57,7 @@
#include <geom/geom.h>
#include <geom/geom_slice.h>
#define BSD_METHOD_NAME "BSD-method"
#define BSD_CLASS_NAME "BSD-class"
struct g_bsd_softc {
struct disklabel ondisk;
@ -319,7 +319,7 @@ g_bsd_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, struct g_consum
}
static struct g_geom *
g_bsd_taste(struct g_method *mp, struct g_provider *pp, struct thread *tp, int flags)
g_bsd_taste(struct g_class *mp, struct g_provider *pp, struct thread *tp, int flags)
{
struct g_geom *gp;
struct g_consumer *cp;
@ -335,7 +335,7 @@ g_bsd_taste(struct g_method *mp, struct g_provider *pp, struct thread *tp, int f
g_trace(G_T_TOPOLOGY, "bsd_taste(%s,%s)", mp->name, pp->name);
g_topology_assert();
if (flags == G_TF_NORMAL &&
!strcmp(pp->geom->method->name, BSD_METHOD_NAME))
!strcmp(pp->geom->class->name, BSD_CLASS_NAME))
return (NULL);
gp = g_slice_new(mp, 8, pp, &cp, &ms, sizeof *ms, g_bsd_start);
if (gp == NULL)
@ -433,13 +433,13 @@ g_bsd_taste(struct g_method *mp, struct g_provider *pp, struct thread *tp, int f
return (NULL);
}
static struct g_method g_bsd_method = {
BSD_METHOD_NAME,
static struct g_class g_bsd_class = {
BSD_CLASS_NAME,
g_bsd_taste,
g_slice_access,
g_slice_orphan,
NULL,
G_METHOD_INITSTUFF
G_CLASS_INITSTUFF
};
DECLARE_GEOM_METHOD(g_bsd_method, g_bsd);
DECLARE_GEOM_CLASS(g_bsd_class, g_bsd);

View File

@ -76,13 +76,13 @@ static struct cdevsw g_dev_cdevsw = {
static g_taste_t g_dev_taste;
static g_orphan_t g_dev_orphan;
static struct g_method g_dev_method = {
"DEV-method",
static struct g_class g_dev_class = {
"DEV-class",
g_dev_taste,
NULL,
g_dev_orphan,
NULL,
G_METHOD_INITSTUFF
G_CLASS_INITSTUFF
};
static void
@ -98,7 +98,7 @@ g_dev_clone(void *arg, char *name, int namelen, dev_t *dev)
/* XXX: can I drop Giant here ??? */
/* g_topology_lock(); */
LIST_FOREACH(gp, &g_dev_method.geom, geom) {
LIST_FOREACH(gp, &g_dev_class.geom, geom) {
if (strcmp(gp->name, name))
continue;
*dev = gp->softc;
@ -124,7 +124,7 @@ g_dev_register_cloner(void *foo __unused)
SYSINIT(geomdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE,g_dev_register_cloner,NULL);
static struct g_geom *
g_dev_taste(struct g_method *mp, struct g_provider *pp, struct thread *tp __unused, int insist __unused)
g_dev_taste(struct g_class *mp, struct g_provider *pp, struct thread *tp __unused, int insist __unused)
{
struct g_geom *gp;
struct g_consumer *cp;
@ -137,7 +137,7 @@ g_dev_taste(struct g_method *mp, struct g_provider *pp, struct thread *tp __unus
g_trace(G_T_TOPOLOGY, "dev_taste(%s,%s)", mp->name, pp->name);
g_topology_assert();
LIST_FOREACH(cp, &pp->consumers, consumers)
if (cp->geom->method == mp)
if (cp->geom->class == mp)
return (NULL);
gp = g_new_geomf(mp, pp->name);
cp = g_new_consumer(gp);
@ -282,7 +282,7 @@ g_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
if (error != 0 && cmd == DIOCGDVIRGIN) {
g_topology_lock();
gp = g_create_geomf("BSD-method", cp->provider, NULL);
gp = g_create_geomf("BSD-class", cp->provider, NULL);
g_topology_unlock();
}
PICKUP_GIANT();
@ -386,5 +386,5 @@ g_dev_orphan(struct g_consumer *cp, struct thread *tp)
g_destroy_geom(gp);
}
DECLARE_GEOM_METHOD(g_dev_method, g_dev)
DECLARE_GEOM_CLASS(g_dev_class, g_dev)

View File

@ -56,8 +56,8 @@
static g_access_t g_disk_access;
struct g_method g_disk_method = {
"DISK-method",
struct g_class g_disk_class = {
"DISK-class",
NULL,
g_disk_access,
NULL,
@ -181,7 +181,7 @@ disk_create(int unit, struct disk *dp, int flags, struct cdevsw *cdevsw, struct
mtx_unlock(&Giant);
if (!once) {
g_add_method(&g_disk_method);
g_add_class(&g_disk_class);
once++;
}
dev = g_malloc(sizeof *dev, M_WAITOK | M_ZERO);
@ -190,7 +190,7 @@ disk_create(int unit, struct disk *dp, int flags, struct cdevsw *cdevsw, struct
dev->si_disk = dp;
dev->si_udev = dkmakeminor(unit, WHOLE_DISK_SLICE, RAW_PART);
g_topology_lock();
gp = g_new_geomf(&g_disk_method, "%s%d", cdevsw->d_name, unit);
gp = g_new_geomf(&g_disk_class, "%s%d", cdevsw->d_name, unit);
gp->start = g_disk_start;
gp->softc = dp;
dp->d_softc = gp;

View File

@ -77,7 +77,7 @@ g_confdot_geom(struct sbuf *sb, struct g_geom *gp)
struct g_provider *pp;
sbuf_printf(sb, "z%p [shape=box,label=\"%s\\n%s\\nr#%d\"];\n",
gp, gp->method->name, gp->name, gp->rank);
gp, gp->class->name, gp->name, gp->rank);
LIST_FOREACH(cp, &gp->consumer, consumer) {
g_confdot_consumer(sb, cp);
sbuf_printf(sb, "z%p -> z%p;\n", gp, cp);
@ -90,7 +90,7 @@ g_confdot_geom(struct sbuf *sb, struct g_geom *gp)
}
static void
g_confdot_method(struct sbuf *sb, struct g_method *mp)
g_confdot_class(struct sbuf *sb, struct g_class *mp)
{
struct g_geom *gp;
@ -101,14 +101,14 @@ g_confdot_method(struct sbuf *sb, struct g_method *mp)
struct sbuf *
g_confdot(void)
{
struct g_method *mp;
struct g_class *mp;
struct sbuf *sb;
sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
sbuf_clear(sb);
sbuf_printf(sb, "digraph geom {\n");
LIST_FOREACH(mp, &g_methods, method)
g_confdot_method(sb, mp);
LIST_FOREACH(mp, &g_classs, class)
g_confdot_class(sb, mp);
sbuf_printf(sb, "};\n");
sbuf_finish(sb);
return (sb);
@ -160,7 +160,7 @@ g_conf_geom(struct sbuf *sb, struct g_geom *gp, struct g_provider *pp, struct g_
sbuf_printf(sb, " <geom>\n");
sbuf_printf(sb, " <ref>%p</ref>\n", gp);
sbuf_printf(sb, " <method><ref>%p</ref></method>\n", gp->method);
sbuf_printf(sb, " <class><ref>%p</ref></class>\n", gp->class);
sbuf_printf(sb, " <name>%s</name>\n", gp->name);
sbuf_printf(sb, " <rank>%d</rank>\n", gp->rank);
if (gp->dumpconf) {
@ -183,11 +183,11 @@ g_conf_geom(struct sbuf *sb, struct g_geom *gp, struct g_provider *pp, struct g_
}
static void
g_conf_method(struct sbuf *sb, struct g_method *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp)
g_conf_class(struct sbuf *sb, struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp)
{
struct g_geom *gp2;
sbuf_printf(sb, " <method>\n");
sbuf_printf(sb, " <class>\n");
sbuf_printf(sb, " <ref>%p</ref>\n", mp);
sbuf_printf(sb, " <name>%s</name>\n", mp->name);
LIST_FOREACH(gp2, &mp->geom, geom) {
@ -195,22 +195,22 @@ g_conf_method(struct sbuf *sb, struct g_method *mp, struct g_geom *gp, struct g_
continue;
g_conf_geom(sb, gp2, pp, cp);
}
sbuf_printf(sb, " </method>\n");
sbuf_printf(sb, " </class>\n");
}
struct sbuf *
g_conf_specific(struct g_method *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp)
g_conf_specific(struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp)
{
struct g_method *mp2;
struct g_class *mp2;
struct sbuf *sb;
sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
sbuf_clear(sb);
sbuf_printf(sb, "<mesh>\n");
LIST_FOREACH(mp2, &g_methods, method) {
LIST_FOREACH(mp2, &g_classs, class) {
if (mp != NULL && mp != mp2)
continue;
g_conf_method(sb, mp2, gp, pp, cp);
g_conf_class(sb, mp2, gp, pp, cp);
}
sbuf_printf(sb, "</mesh>\n");
sbuf_finish(sb);

View File

@ -122,10 +122,10 @@ g_orphan_register(struct g_provider *pp, struct thread *tp)
cp = LIST_FIRST(&pp->consumers);
while (cp != NULL) {
cp2 = LIST_NEXT(cp, consumers);
KASSERT(cp->geom->method->orphan != NULL,
("method %s has no orphan, geom %s",
cp->geom->method->name, cp->geom->name));
cp->geom->method->orphan(cp, tp);
KASSERT(cp->geom->class->orphan != NULL,
("class %s has no orphan, geom %s",
cp->geom->class->name, cp->geom->name));
cp->geom->class->orphan(cp, tp);
cp = cp2;
}
}
@ -140,26 +140,26 @@ g_destroy_event(struct g_event *ep)
static void
g_do_event(struct g_event *ep, struct thread *tp)
{
struct g_method *mp, *mp2;
struct g_class *mp, *mp2;
struct g_geom *gp;
struct g_consumer *cp, *cp2;
struct g_provider *pp;
int i;
g_trace(G_T_TOPOLOGY, "g_do_event(%p) %d m:%p g:%p p:%p c:%p - ",
ep, ep->event, ep->method, ep->geom, ep->provider, ep->consumer);
ep, ep->event, ep->class, ep->geom, ep->provider, ep->consumer);
g_topology_assert();
switch (ep->event) {
case EV_NEW_METHOD:
mp2 = ep->method;
case EV_NEW_CLASS:
mp2 = ep->class;
if (mp2->taste == NULL)
break;
LIST_FOREACH(mp, &g_methods, method) {
LIST_FOREACH(mp, &g_classs, class) {
if (mp2 == mp)
continue;
LIST_FOREACH(gp, &mp->geom, geom) {
LIST_FOREACH(pp, &gp->provider, provider) {
mp2->taste(ep->method, pp, tp, 0);
mp2->taste(ep->class, pp, tp, 0);
g_topology_assert();
}
}
@ -168,12 +168,12 @@ g_do_event(struct g_event *ep, struct thread *tp)
case EV_NEW_PROVIDER:
g_trace(G_T_TOPOLOGY, "EV_NEW_PROVIDER(%s)",
ep->provider->name);
LIST_FOREACH(mp, &g_methods, method) {
LIST_FOREACH(mp, &g_classs, class) {
if (mp->taste == NULL)
continue;
i = 1;
LIST_FOREACH(cp, &ep->provider->consumers, consumers)
if(cp->geom->method == mp)
if(cp->geom->class == mp)
i = 0;
if (i) {
mp->taste(mp, ep->provider, tp, 0);
@ -226,8 +226,8 @@ one_event(struct thread *tp)
return (0);
}
TAILQ_REMOVE(&g_events, ep, events);
if (ep->method != NULL)
ep->method->event = NULL;
if (ep->class != NULL)
ep->class->event = NULL;
if (ep->geom != NULL)
ep->geom->event = NULL;
if (ep->provider != NULL)
@ -255,7 +255,7 @@ g_run_events(struct thread *tp)
}
void
g_post_event(enum g_events ev, struct g_method *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp)
g_post_event(enum g_events ev, struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp)
{
struct g_event *ep;
@ -265,8 +265,8 @@ g_post_event(enum g_events ev, struct g_method *mp, struct g_geom *gp, struct g_
ep = g_malloc(sizeof *ep, M_WAITOK | M_ZERO);
ep->event = ev;
if (mp != NULL) {
ep->method = mp;
KASSERT(mp->event == NULL, ("Double event on method"));
ep->class = mp;
KASSERT(mp->event == NULL, ("Double event on class"));
mp->event = ep;
}
if (gp != NULL) {

View File

@ -178,8 +178,8 @@ SYSCTL_PROC(_debug, OID_AUTO, geomconf, CTLTYPE_STRING|CTLFLAG_RD,
SYSCTL_INT(_debug, OID_AUTO, geomdebugflags, CTLTYPE_INT|CTLFLAG_RW,
&g_debugflags, 0, "");
SYSCTL_INT(_debug_sizeof, OID_AUTO, g_method, CTLTYPE_INT|CTLFLAG_RD,
0, sizeof(struct g_method), "");
SYSCTL_INT(_debug_sizeof, OID_AUTO, g_class, CTLTYPE_INT|CTLFLAG_RD,
0, sizeof(struct g_class), "");
SYSCTL_INT(_debug_sizeof, OID_AUTO, g_geom, CTLTYPE_INT|CTLFLAG_RD,
0, sizeof(struct g_geom), "");
SYSCTL_INT(_debug_sizeof, OID_AUTO, g_provider, CTLTYPE_INT|CTLFLAG_RD,

View File

@ -58,8 +58,8 @@
#include <geom/geom.h>
#include <geom/geom_slice.h>
#define MBR_METHOD_NAME "MBR-method"
#define MBREXT_METHOD_NAME "MBREXT-method"
#define MBR_CLASS_NAME "MBR-class"
#define MBREXT_CLASS_NAME "MBREXT-class"
static void
g_dec_dos_partition(u_char *ptr, struct dos_partition *d)
@ -164,7 +164,7 @@ g_mbr_print(int i __unused, struct dos_partition *dp __unused)
}
static struct g_geom *
g_mbr_taste(struct g_method *mp, struct g_provider *pp, struct thread *tp, int insist)
g_mbr_taste(struct g_class *mp, struct g_provider *pp, struct thread *tp, int insist)
{
struct g_geom *gp;
struct g_consumer *cp;
@ -241,16 +241,16 @@ g_mbr_taste(struct g_method *mp, struct g_provider *pp, struct thread *tp, int i
}
static struct g_method g_mbr_method = {
MBR_METHOD_NAME,
static struct g_class g_mbr_class = {
MBR_CLASS_NAME,
g_mbr_taste,
g_slice_access,
g_slice_orphan,
NULL,
G_METHOD_INITSTUFF
G_CLASS_INITSTUFF
};
DECLARE_GEOM_METHOD(g_mbr_method, g_mbr);
DECLARE_GEOM_CLASS(g_mbr_class, g_mbr);
#define NDOSEXTPART 32
struct g_mbrext_softc {
@ -304,7 +304,7 @@ g_mbrext_print(int i, struct dos_partition *dp)
}
static struct g_geom *
g_mbrext_taste(struct g_method *mp, struct g_provider *pp, struct thread *tp __unused, int insist __unused)
g_mbrext_taste(struct g_class *mp, struct g_provider *pp, struct thread *tp __unused, int insist __unused)
{
struct g_geom *gp;
struct g_consumer *cp;
@ -317,7 +317,7 @@ g_mbrext_taste(struct g_method *mp, struct g_provider *pp, struct thread *tp __u
g_trace(G_T_TOPOLOGY, "g_mbrext_taste(%s,%s)", mp->name, pp->name);
g_topology_assert();
if (strcmp(pp->geom->method->name, MBR_METHOD_NAME))
if (strcmp(pp->geom->class->name, MBR_CLASS_NAME))
return (NULL);
gp = g_slice_new(mp, NDOSEXTPART, pp, &cp, &ms, sizeof *ms, g_mbrext_start);
if (gp == NULL)
@ -379,13 +379,13 @@ g_mbrext_taste(struct g_method *mp, struct g_provider *pp, struct thread *tp __u
}
static struct g_method g_mbrext_method = {
MBREXT_METHOD_NAME,
static struct g_class g_mbrext_class = {
MBREXT_CLASS_NAME,
g_mbrext_taste,
g_slice_access,
g_slice_orphan,
NULL,
G_METHOD_INITSTUFF
G_CLASS_INITSTUFF
};
DECLARE_GEOM_METHOD(g_mbrext_method, g_mbrext);
DECLARE_GEOM_CLASS(g_mbrext_class, g_mbrext);

View File

@ -213,7 +213,7 @@ g_slice_addslice(struct g_geom *gp, int index, off_t offset, off_t length, char
}
struct g_geom *
g_slice_new(struct g_method *mp, int slices, struct g_provider *pp, struct g_consumer **cpp, void *extrap, int extra, g_slice_start_t *start)
g_slice_new(struct g_class *mp, int slices, struct g_provider *pp, struct g_consumer **cpp, void *extrap, int extra, g_slice_start_t *start)
{
struct g_geom *gp;
struct g_slicer *gsp;

View File

@ -56,5 +56,5 @@ int g_slice_access(struct g_provider *pp, int dr, int dw, int de);
void g_slice_start(struct bio *bp);
void g_slice_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, struct g_consumer *cp __unused, struct g_provider *pp);
struct g_provider * g_slice_addslice(struct g_geom *gp, int index, off_t offset, off_t length, char *fmt, ...);
struct g_geom * g_slice_new(struct g_method *mp, int slices, struct g_provider *pp, struct g_consumer **cpp, void *extrap, int extra, g_slice_start_t *start);
struct g_geom * g_slice_new(struct g_class *mp, int slices, struct g_provider *pp, struct g_consumer **cpp, void *extrap, int extra, g_slice_start_t *start);

View File

@ -60,7 +60,7 @@
#include <geom/geom.h>
#include <machine/stdarg.h>
struct method_list_head g_methods = LIST_HEAD_INITIALIZER(g_methods);
struct class_list_head g_classs = LIST_HEAD_INITIALIZER(g_classs);
static struct g_tailq_head geoms = TAILQ_HEAD_INITIALIZER(geoms);
static int g_nproviders;
char *g_wait_event, *g_wait_up, *g_wait_down, *g_wait_sim;
@ -68,7 +68,7 @@ char *g_wait_event, *g_wait_up, *g_wait_down, *g_wait_sim;
static int g_ignition;
void
g_add_method(struct g_method *mp)
g_add_class(struct g_class *mp)
{
if (!g_ignition) {
@ -76,16 +76,16 @@ g_add_method(struct g_method *mp)
g_init();
}
g_topology_lock();
g_trace(G_T_TOPOLOGY, "g_add_method(%s)", mp->name);
g_trace(G_T_TOPOLOGY, "g_add_class(%s)", mp->name);
LIST_INIT(&mp->geom);
LIST_INSERT_HEAD(&g_methods, mp, method);
LIST_INSERT_HEAD(&g_classs, mp, class);
if (g_nproviders > 0)
g_post_event(EV_NEW_METHOD, mp, NULL, NULL, NULL);
g_post_event(EV_NEW_CLASS, mp, NULL, NULL, NULL);
g_topology_unlock();
}
struct g_geom *
g_new_geomf(struct g_method *mp, char *fmt, ...)
g_new_geomf(struct g_class *mp, char *fmt, ...)
{
struct g_geom *gp;
va_list ap;
@ -100,7 +100,7 @@ g_new_geomf(struct g_method *mp, char *fmt, ...)
mtx_unlock(&Giant);
gp = g_malloc(sizeof *gp + sbuf_len(sb) + 1, M_WAITOK | M_ZERO);
gp->name = (char *)(gp + 1);
gp->method = mp;
gp->class = mp;
gp->rank = 1;
LIST_INIT(&gp->consumer);
LIST_INIT(&gp->provider);
@ -135,8 +135,8 @@ g_new_consumer(struct g_geom *gp)
struct g_consumer *cp;
g_topology_assert();
KASSERT(gp->method->orphan != NULL,
("g_new_consumer on method(%s) without orphan", gp->method->name));
KASSERT(gp->class->orphan != NULL,
("g_new_consumer on class(%s) without orphan", gp->class->name));
cp = g_malloc(sizeof *cp, M_WAITOK | M_ZERO);
cp->geom = gp;
@ -377,10 +377,10 @@ g_access_rel(struct g_consumer *cp, int dcr, int dcw, int dce)
KASSERT(cp->acr + dcr >= 0, ("access resulting in negative acr"));
KASSERT(cp->acw + dcw >= 0, ("access resulting in negative acw"));
KASSERT(cp->ace + dce >= 0, ("access resulting in negative ace"));
KASSERT(pp->geom->method->access != NULL, ("NULL method->access"));
KASSERT(pp->geom->class->access != NULL, ("NULL class->access"));
/*
* If our method cares about being spoiled, and we have been, we
* If our class cares about being spoiled, and we have been, we
* are probably just ahead of the event telling us that. Fail
* now rather than having to unravel this later.
*/
@ -430,7 +430,7 @@ g_access_rel(struct g_consumer *cp, int dcr, int dcw, int dce)
else if (pp->acw != 0 && pp->acw == -dcw && !(pp->geom->flags & G_GEOM_WITHER))
g_post_event(EV_NEW_PROVIDER, NULL, NULL, pp, NULL);
error = pp->geom->method->access(pp, dcr, dcw, dce);
error = pp->geom->class->access(pp, dcr, dcw, dce);
if (!error) {
pp->acr += dcr;
pp->acw += dcw;
@ -549,33 +549,33 @@ g_spoil(struct g_provider *pp, struct g_consumer *cp)
g_post_event(EV_SPOILED, NULL, NULL, pp, cp);
}
static struct g_method *
g_method_by_name(char *name)
static struct g_class *
g_class_by_name(char *name)
{
struct g_method *mp;
struct g_class *mp;
g_trace(G_T_TOPOLOGY, "g_method_by_name(%s)", name);
g_trace(G_T_TOPOLOGY, "g_class_by_name(%s)", name);
g_topology_assert();
LIST_FOREACH(mp, &g_methods, method)
LIST_FOREACH(mp, &g_classs, class)
if (!strcmp(mp->name, name))
return (mp);
return (NULL);
}
struct g_geom *
g_create_geomf(char *method, struct g_provider *pp, char *fmt, ...)
g_create_geomf(char *class, struct g_provider *pp, char *fmt, ...)
{
va_list ap;
struct sbuf *sb;
char *s;
struct g_method *mp;
struct g_class *mp;
struct g_geom *gp;
g_trace(G_T_TOPOLOGY, "g_create_geom(%s, %p(%s))", method,
g_trace(G_T_TOPOLOGY, "g_create_geom(%s, %p(%s))", class,
pp, pp == NULL ? "" : pp->name);
g_topology_assert();
gp = NULL;
mp = g_method_by_name(method);
mp = g_class_by_name(class);
if (mp == NULL)
return (NULL);
if (fmt != NULL) {
@ -600,19 +600,19 @@ g_create_geomf(char *method, struct g_provider *pp, char *fmt, ...)
}
struct g_geom *
g_insert_geom(char *method, struct g_consumer *cp)
g_insert_geom(char *class, struct g_consumer *cp)
{
struct g_method *mp;
struct g_class *mp;
struct g_geom *gp;
struct g_provider *pp, *pp2;
struct g_consumer *cp2;
int error;
g_trace(G_T_TOPOLOGY, "g_insert_geomf(%s, %p)", method, cp);
g_trace(G_T_TOPOLOGY, "g_insert_geomf(%s, %p)", class, cp);
g_topology_assert();
KASSERT(cp->provider != NULL, ("g_insert_geomf but not attached"));
/* XXX: check for events ?? */
mp = g_method_by_name(method);
mp = g_class_by_name(class);
if (mp == NULL)
return (NULL);
if (mp->create_geom == NULL)

View File

@ -57,7 +57,7 @@
#include <geom/geom_slice.h>
#include <machine/endian.h>
#define BSD_METHOD_NAME "SUNLABEL-method"
#define BSD_CLASS_NAME "SUNLABEL-class"
struct g_sunlabel_softc {
int foo;
@ -84,7 +84,7 @@ g_sunlabel_dumpconf(struct sbuf *sb, char *indent, struct g_geom *gp, struct g_c
}
static struct g_geom *
g_sunlabel_taste(struct g_method *mp, struct g_provider *pp, struct thread *tp, int flags)
g_sunlabel_taste(struct g_class *mp, struct g_provider *pp, struct thread *tp, int flags)
{
struct g_geom *gp;
struct g_consumer *cp;
@ -98,7 +98,7 @@ g_sunlabel_taste(struct g_method *mp, struct g_provider *pp, struct thread *tp,
g_trace(G_T_TOPOLOGY, "g_sunlabel_taste(%s,%s)", mp->name, pp->name);
g_topology_assert();
if (flags == G_TF_NORMAL &&
!strcmp(pp->geom->method->name, BSD_METHOD_NAME))
!strcmp(pp->geom->class->name, BSD_CLASS_NAME))
return (NULL);
gp = g_slice_new(mp, 8, pp, &cp, &ms, sizeof *ms, g_sunlabel_start);
if (gp == NULL)
@ -184,13 +184,13 @@ g_sunlabel_taste(struct g_method *mp, struct g_provider *pp, struct thread *tp,
return (NULL);
}
static struct g_method g_sunlabel_method = {
BSD_METHOD_NAME,
static struct g_class g_sunlabel_class = {
BSD_CLASS_NAME,
g_sunlabel_taste,
g_slice_access,
g_slice_orphan,
NULL,
G_METHOD_INITSTUFF
G_CLASS_INITSTUFF
};
DECLARE_GEOM_METHOD(g_sunlabel_method, g_sunlabel);
DECLARE_GEOM_CLASS(g_sunlabel_class, g_sunlabel);