summaryrefslogtreecommitdiffstats
path: root/sys/geom
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2002-04-04 09:54:13 +0000
committerphk <phk@FreeBSD.org>2002-04-04 09:54:13 +0000
commitfd177bc9595b9076f3b0010d5c8d15d431382251 (patch)
treec6baa9879fc1591197958488bdcaff9076c51439 /sys/geom
parent069aa8e324a61f68be3ba5e22bf5fff15ddf4f09 (diff)
downloadFreeBSD-src-fd177bc9595b9076f3b0010d5c8d15d431382251.zip
FreeBSD-src-fd177bc9595b9076f3b0010d5c8d15d431382251.tar.gz
Move access and orphan member functions from class to geom.
Sponsored by: DARPA & NAI Labs
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/geom.h14
-rw-r--r--sys/geom/geom_bsd.c2
-rw-r--r--sys/geom/geom_dev.c3
-rw-r--r--sys/geom/geom_disk.c6
-rw-r--r--sys/geom/geom_event.c8
-rw-r--r--sys/geom/geom_mbr.c4
-rw-r--r--sys/geom/geom_pc98.c2
-rw-r--r--sys/geom/geom_slice.c12
-rw-r--r--sys/geom/geom_slice.h5
-rw-r--r--sys/geom/geom_subr.c9
-rw-r--r--sys/geom/geom_sunlabel.c2
11 files changed, 31 insertions, 36 deletions
diff --git a/sys/geom/geom.h b/sys/geom/geom.h
index 14862cd..d46269a 100644
--- a/sys/geom/geom.h
+++ b/sys/geom/geom.h
@@ -57,7 +57,6 @@ struct thread;
struct bio;
struct sbuf;
-#define G_CLASS_INITSTUFF { 0, 0 }, { 0 }, 0
typedef struct g_geom * g_create_geom_t (struct g_class *mp,
struct g_provider *pp, char *name);
@@ -81,20 +80,22 @@ typedef void g_dumpconf_t (struct sbuf *, char *indent, struct g_geom *,
* 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_class {
char *name;
g_taste_t *taste;
- g_access_t *access;
- g_orphan_t *orphan;
g_create_geom_t *create_geom;
+ /*
+ * The remaning elements are private and classes should use
+ * the G_CLASS_INITSTUFF macro to initialize them.
+ */
LIST_ENTRY(g_class) class;
LIST_HEAD(,g_geom) geom;
struct g_event *event;
};
+#define G_CLASS_INITSTUFF { 0, 0 }, { 0 }, 0
+
/*
* The g_geom is an instance of a g_class.
*/
@@ -109,6 +110,8 @@ struct g_geom {
g_start_t *start;
g_spoiled_t *spoiled;
g_dumpconf_t *dumpconf;
+ g_access_t *access;
+ g_orphan_t *orphan;
void *softc;
struct g_event *event;
unsigned flags;
@@ -205,6 +208,7 @@ void g_std_spoiled(struct g_consumer *cp);
struct bio * g_clone_bio(struct bio *);
void g_destroy_bio(struct bio *);
void g_io_deliver(struct bio *bp);
+void g_io_fail(struct bio *bp, int error);
int g_io_getattr(char *attr, struct g_consumer *cp, int *len, void *ptr);
void g_io_request(struct bio *bp, struct g_consumer *cp);
int g_io_setattr(char *attr, struct g_consumer *cp, int len, void *ptr);
diff --git a/sys/geom/geom_bsd.c b/sys/geom/geom_bsd.c
index f857dab..af19a4b 100644
--- a/sys/geom/geom_bsd.c
+++ b/sys/geom/geom_bsd.c
@@ -425,8 +425,6 @@ g_bsd_taste(struct g_class *mp, struct g_provider *pp, int flags)
static struct g_class g_bsd_class = {
BSD_CLASS_NAME,
g_bsd_taste,
- g_slice_access,
- g_slice_orphan,
NULL,
G_CLASS_INITSTUFF
};
diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c
index 31ca442..1365eea 100644
--- a/sys/geom/geom_dev.c
+++ b/sys/geom/geom_dev.c
@@ -80,8 +80,6 @@ static struct g_class g_dev_class = {
"DEV-class",
g_dev_taste,
NULL,
- g_dev_orphan,
- NULL,
G_CLASS_INITSTUFF
};
@@ -140,6 +138,7 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
if (cp->geom->class == mp)
return (NULL);
gp = g_new_geomf(mp, pp->name);
+ gp->orphan = g_dev_orphan;
cp = g_new_consumer(gp);
g_attach(cp, pp);
error = g_access_rel(cp, 1, 0, 0);
diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c
index 7639083..3cae0a3 100644
--- a/sys/geom/geom_disk.c
+++ b/sys/geom/geom_disk.c
@@ -59,11 +59,8 @@ static g_access_t g_disk_access;
struct g_class g_disk_class = {
"DISK-class",
NULL,
- g_disk_access,
NULL,
- NULL,
- { 0, 0 },
- { 0 }
+ G_CLASS_INITSTUFF
};
static int
@@ -193,6 +190,7 @@ disk_create(int unit, struct disk *dp, int flags, struct cdevsw *cdevsw, struct
g_topology_lock();
gp = g_new_geomf(&g_disk_class, "%s%d", cdevsw->d_name, unit);
gp->start = g_disk_start;
+ gp->access = g_disk_access;
gp->softc = dp;
dp->d_softc = gp;
pp = g_new_providerf(gp, "%s", gp->name);
diff --git a/sys/geom/geom_event.c b/sys/geom/geom_event.c
index ab6d228..f565d14 100644
--- a/sys/geom/geom_event.c
+++ b/sys/geom/geom_event.c
@@ -123,10 +123,10 @@ g_orphan_register(struct g_provider *pp)
cp = LIST_FIRST(&pp->consumers);
while (cp != NULL) {
cp2 = LIST_NEXT(cp, consumers);
- 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);
+ KASSERT(cp->geom->orphan != NULL,
+ ("geom %s has no orphan, class %s",
+ cp->geom->name, cp->geom->class->name));
+ cp->geom->orphan(cp);
cp = cp2;
}
}
diff --git a/sys/geom/geom_mbr.c b/sys/geom/geom_mbr.c
index e2e199d..9520bde6 100644
--- a/sys/geom/geom_mbr.c
+++ b/sys/geom/geom_mbr.c
@@ -244,8 +244,6 @@ g_mbr_taste(struct g_class *mp, struct g_provider *pp, int insist)
static struct g_class g_mbr_class = {
MBR_CLASS_NAME,
g_mbr_taste,
- g_slice_access,
- g_slice_orphan,
NULL,
G_CLASS_INITSTUFF
};
@@ -382,8 +380,6 @@ g_mbrext_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
static struct g_class g_mbrext_class = {
MBREXT_CLASS_NAME,
g_mbrext_taste,
- g_slice_access,
- g_slice_orphan,
NULL,
G_CLASS_INITSTUFF
};
diff --git a/sys/geom/geom_pc98.c b/sys/geom/geom_pc98.c
index ce7e9e4..9cc46a8 100644
--- a/sys/geom/geom_pc98.c
+++ b/sys/geom/geom_pc98.c
@@ -180,8 +180,6 @@ g_pc98_taste(struct g_class *mp, struct g_provider *pp, int flags)
static struct g_class g_pc98_class = {
PC98_CLASS_NAME,
g_pc98_taste,
- g_slice_access,
- g_slice_orphan,
NULL,
G_CLASS_INITSTUFF
};
diff --git a/sys/geom/geom_slice.c b/sys/geom/geom_slice.c
index 2df1ed0..ad91ade 100644
--- a/sys/geom/geom_slice.c
+++ b/sys/geom/geom_slice.c
@@ -60,6 +60,10 @@
#include <geom/geom_slice.h>
#include <machine/stdarg.h>
+static g_orphan_t g_slice_orphan;
+static g_access_t g_slice_access;
+static g_start_t g_slice_start;
+
struct g_slicer *
g_slice_init(unsigned nslice, unsigned scsize)
{
@@ -72,7 +76,7 @@ g_slice_init(unsigned nslice, unsigned scsize)
return (gsp);
}
-int
+static int
g_slice_access(struct g_provider *pp, int dr, int dw, int de)
{
int error, i;
@@ -114,7 +118,7 @@ g_slice_access(struct g_provider *pp, int dr, int dw, int de)
return (error);
}
-void
+static void
g_slice_start(struct bio *bp)
{
struct bio *bp2;
@@ -226,6 +230,8 @@ g_slice_new(struct g_class *mp, int slices, struct g_provider *pp, struct g_cons
gp = g_new_geomf(mp, "%s", pp->name);
gsp = g_slice_init(slices, extra);
gsp->start = start;
+ gp->access = g_slice_access;
+ gp->orphan = g_slice_orphan;
gp->softc = gsp;
gp->start = g_slice_start;
gp->spoiled = g_std_spoiled;
@@ -246,7 +252,7 @@ g_slice_new(struct g_class *mp, int slices, struct g_provider *pp, struct g_cons
return (gp);
}
-void
+static void
g_slice_orphan(struct g_consumer *cp)
{
struct g_geom *gp;
diff --git a/sys/geom/geom_slice.h b/sys/geom/geom_slice.h
index ae94feb..4d21533 100644
--- a/sys/geom/geom_slice.h
+++ b/sys/geom/geom_slice.h
@@ -50,11 +50,8 @@ struct g_slicer {
g_slice_start_t *start;
};
-g_orphan_t g_slice_orphan;
struct g_slicer * g_slice_init(unsigned nslice, unsigned scsize);
-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);
+g_dumpconf_t g_slice_dumpconf;
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_class *mp, int slices, struct g_provider *pp, struct g_consumer **cpp, void *extrap, int extra, g_slice_start_t *start);
diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c
index 2280efe..b9c6236 100644
--- a/sys/geom/geom_subr.c
+++ b/sys/geom/geom_subr.c
@@ -136,8 +136,9 @@ g_new_consumer(struct g_geom *gp)
struct g_consumer *cp;
g_topology_assert();
- KASSERT(gp->class->orphan != NULL,
- ("g_new_consumer on class(%s) without orphan", gp->class->name));
+ KASSERT(gp->orphan != NULL,
+ ("g_new_consumer on geom(%s) (class %s) without orphan",
+ gp->name, gp->class->name));
cp = g_malloc(sizeof *cp, M_WAITOK | M_ZERO);
cp->geom = gp;
@@ -378,7 +379,7 @@ 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->class->access != NULL, ("NULL class->access"));
+ KASSERT(pp->geom->access != NULL, ("NULL geom->access"));
/*
* If our class cares about being spoiled, and we have been, we
@@ -431,7 +432,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->class->access(pp, dcr, dcw, dce);
+ error = pp->geom->access(pp, dcr, dcw, dce);
if (!error) {
pp->acr += dcr;
pp->acw += dcw;
diff --git a/sys/geom/geom_sunlabel.c b/sys/geom/geom_sunlabel.c
index c7ab320..d31dad3 100644
--- a/sys/geom/geom_sunlabel.c
+++ b/sys/geom/geom_sunlabel.c
@@ -187,8 +187,6 @@ g_sunlabel_taste(struct g_class *mp, struct g_provider *pp, int flags)
static struct g_class g_sunlabel_class = {
SUNLABEL_CLASS_NAME,
g_sunlabel_taste,
- g_slice_access,
- g_slice_orphan,
NULL,
G_CLASS_INITSTUFF
};
OpenPOWER on IntegriCloud