summaryrefslogtreecommitdiffstats
path: root/sys/geom
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2002-09-30 08:54:46 +0000
committerphk <phk@FreeBSD.org>2002-09-30 08:54:46 +0000
commit852521acba9ca655f9805890d434284e77dc3553 (patch)
treeaecab093ebd65e53e9ed7f0ce1ad3248a7fb3cb0 /sys/geom
parent72d7c1eb0e7571a3a567c7dcb80c59931eb6545d (diff)
downloadFreeBSD-src-852521acba9ca655f9805890d434284e77dc3553.zip
FreeBSD-src-852521acba9ca655f9805890d434284e77dc3553.tar.gz
Retire g_io_fail() and let g_io_deliver() take an error argument instead.
Sponsored by: DARPA & NAI Labs.
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/geom.h3
-rw-r--r--sys/geom/geom_aes.c9
-rw-r--r--sys/geom/geom_bsd.c20
-rw-r--r--sys/geom/geom_disk.c5
-rw-r--r--sys/geom/geom_dump.c10
-rw-r--r--sys/geom/geom_io.c36
-rw-r--r--sys/geom/geom_slice.c13
-rw-r--r--sys/geom/geom_subr.c8
8 files changed, 43 insertions, 61 deletions
diff --git a/sys/geom/geom.h b/sys/geom/geom.h
index 36acaf5..c687e0e 100644
--- a/sys/geom/geom.h
+++ b/sys/geom/geom.h
@@ -215,8 +215,7 @@ void g_std_spoiled(struct g_consumer *cp);
/* geom_io.c */
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);
+void g_io_deliver(struct bio *bp, int error);
int g_io_getattr(const 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(const char *attr, struct g_consumer *cp, int len, void *ptr);
diff --git a/sys/geom/geom_aes.c b/sys/geom/geom_aes.c
index ea11fa6..6aae347 100644
--- a/sys/geom/geom_aes.c
+++ b/sys/geom/geom_aes.c
@@ -196,7 +196,7 @@ g_aes_start(struct bio *bp)
case BIO_READ:
bp2 = g_clone_bio(bp);
if (bp2 == NULL) {
- g_io_fail(bp, ENOMEM);
+ g_io_deliver(bp, ENOMEM);
return;
}
bp2->bio_done = g_aes_read_done;
@@ -206,7 +206,7 @@ g_aes_start(struct bio *bp)
case BIO_WRITE:
bp2 = g_clone_bio(bp);
if (bp2 == NULL) {
- g_io_fail(bp, ENOMEM);
+ g_io_deliver(bp, ENOMEM);
return;
}
bp2->bio_done = g_aes_write_done;
@@ -235,7 +235,7 @@ g_aes_start(struct bio *bp)
return;
bp2 = g_clone_bio(bp);
if (bp2 == NULL) {
- g_io_fail(bp, ENOMEM);
+ g_io_deliver(bp, ENOMEM);
return;
}
bp2->bio_done = g_std_done;
@@ -243,8 +243,7 @@ g_aes_start(struct bio *bp)
g_io_request(bp2, cp);
break;
default:
- bp->bio_error = EOPNOTSUPP;
- g_io_deliver(bp);
+ g_io_deliver(bp, EOPNOTSUPP);
return;
}
return;
diff --git a/sys/geom/geom_bsd.c b/sys/geom/geom_bsd.c
index d7cd742..f21f6a4 100644
--- a/sys/geom/geom_bsd.c
+++ b/sys/geom/geom_bsd.c
@@ -379,7 +379,6 @@ g_bsd_modify(struct g_geom *gp, struct disklabel *dl)
}
}
-
/* Look good, go for it... */
for (i = 0; i < gsp->nslice; i++) {
ppp = &dl->d_partitions[i];
@@ -478,6 +477,11 @@ g_bsd_ioctl(void *arg)
struct g_bsd_softc *ms;
struct disklabel *dl;
struct g_ioctl *gio;
+ struct g_consumer *cp;
+ u_char *buf;
+ off_t secoff;
+ u_int secsize;
+ int error;
/* We don't need topology for now */
g_topology_unlock();
@@ -493,10 +497,10 @@ g_bsd_ioctl(void *arg)
dl = gio->data;
/* Validate and modify our slice instance to match */
- bp->bio_error = g_bsd_modify(gp, dl); /* picks up topology lock */
- if (bp->bio_error != 0) {
+ error = g_bsd_modify(gp, dl); /* picks up topology lock on success */
+ if (error) {
g_topology_lock();
- g_io_deliver(bp);
+ g_io_deliver(bp, error);
return;
}
/* Update our copy of the disklabel */
@@ -506,7 +510,8 @@ g_bsd_ioctl(void *arg)
/* XXX: DIOCWDINFO write to disk */
/* return the request */
- g_io_deliver(bp);
+ g_io_deliver(bp, 0);
+ return;
}
/*-
@@ -546,8 +551,7 @@ g_bsd_start(struct bio *bp)
case DIOCGDINFO:
/* Return a copy of the disklabel to userland */
bcopy(&ms->inram, gio->data, sizeof ms->inram);
- bp->bio_error = 0;
- g_io_deliver(bp);
+ g_io_deliver(bp, 0);
return (1);
case DIOCSDINFO:
case DIOCWDINFO:
@@ -558,7 +562,7 @@ g_bsd_start(struct bio *bp)
*/
error = g_call_me(g_bsd_ioctl, bp);
if (error)
- g_io_fail(bp, error);
+ g_io_deliver(bp, error);
/*
* We must return non-zero to indicate that we will deal
* with this bio, even though we have not done so yet.
diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c
index 3869f50..bd2f4af 100644
--- a/sys/geom/geom_disk.c
+++ b/sys/geom/geom_disk.c
@@ -112,7 +112,7 @@ g_disk_kerneldump(struct bio *bp, struct disk *dp)
di.mediaoffset = gkd->offset;
di.mediasize = gkd->length;
error = set_dumper(&di);
- g_io_fail(bp, error);
+ g_io_deliver(bp, error);
}
static void
@@ -178,8 +178,7 @@ g_disk_start(struct bio *bp)
break;
}
if (error) {
- bp->bio_error = error;
- g_io_deliver(bp);
+ g_io_deliver(bp, error);
}
return;
}
diff --git a/sys/geom/geom_dump.c b/sys/geom/geom_dump.c
index 619e0ed..311b76d 100644
--- a/sys/geom/geom_dump.c
+++ b/sys/geom/geom_dump.c
@@ -230,19 +230,13 @@ void
g_trace(int level, char *fmt, ...)
{
va_list ap;
- struct sbuf *sb;
g_sanity(NULL);
if (!(g_debugflags & level))
return;
va_start(ap, fmt);
- mtx_lock(&Giant);
- sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
- sbuf_vprintf(sb, fmt, ap);
- sbuf_finish(sb);
- mtx_unlock(&Giant);
- printf("%s\n", sbuf_data(sb));
- sbuf_delete(sb);
+ vprintf(fmt, ap);
+ printf("\n");
}
void
diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c
index f86c5e2..ab6c9e4 100644
--- a/sys/geom/geom_io.c
+++ b/sys/geom/geom_io.c
@@ -211,20 +211,6 @@ g_io_getattr(const char *attr, struct g_consumer *cp, int *len, void *ptr)
}
void
-g_io_fail(struct bio *bp, int error)
-{
-
- bp->bio_error = error;
-
- g_trace(G_T_BIO,
- "bio_fail(%p) from %p(%s) to %p(%s) cmd %d error %d\n",
- bp, bp->bio_from, bp->bio_from->geom->name,
- bp->bio_to, bp->bio_to->name, bp->bio_cmd, bp->bio_error);
- g_io_deliver(bp);
- return;
-}
-
-void
g_io_request(struct bio *bp, struct g_consumer *cp)
{
int error;
@@ -242,7 +228,7 @@ g_io_request(struct bio *bp, struct g_consumer *cp)
atomic_add_int(&cp->biocount, 1);
/* Fail on unattached consumers */
if (bp->bio_to == NULL) {
- g_io_fail(bp, ENXIO);
+ g_io_deliver(bp, ENXIO);
return;
}
/* Fail if access doesn't allow operation */
@@ -250,14 +236,14 @@ g_io_request(struct bio *bp, struct g_consumer *cp)
case BIO_READ:
case BIO_GETATTR:
if (cp->acr == 0) {
- g_io_fail(bp, EPERM);
+ g_io_deliver(bp, EPERM);
return;
}
break;
case BIO_WRITE:
case BIO_DELETE:
if (cp->acw == 0) {
- g_io_fail(bp, EPERM);
+ g_io_deliver(bp, EPERM);
return;
}
break;
@@ -267,17 +253,17 @@ g_io_request(struct bio *bp, struct g_consumer *cp)
printf("setattr on %s mode (%d,%d,%d)\n",
cp->provider->name,
cp->acr, cp->acw, cp->ace);
- g_io_fail(bp, EPERM);
+ g_io_deliver(bp, EPERM);
return;
}
break;
default:
- g_io_fail(bp, EPERM);
+ g_io_deliver(bp, EPERM);
return;
}
/* if provider is marked for error, don't disturb. */
if (bp->bio_to->error) {
- g_io_fail(bp, bp->bio_to->error);
+ g_io_deliver(bp, bp->bio_to->error);
return;
}
switch(bp->bio_cmd) {
@@ -286,7 +272,7 @@ g_io_request(struct bio *bp, struct g_consumer *cp)
case BIO_DELETE:
/* Reject requests past the end of media. */
if (bp->bio_offset > bp->bio_to->mediasize) {
- g_io_fail(bp, EIO);
+ g_io_deliver(bp, EIO);
return;
}
/* Truncate requests to the end of providers media. */
@@ -297,7 +283,7 @@ g_io_request(struct bio *bp, struct g_consumer *cp)
}
/* Deliver zero length transfers right here. */
if (bp->bio_length == 0) {
- g_io_deliver(bp);
+ g_io_deliver(bp, 0);
return;
}
break;
@@ -313,15 +299,17 @@ g_io_request(struct bio *bp, struct g_consumer *cp)
}
void
-g_io_deliver(struct bio *bp)
+g_io_deliver(struct bio *bp, int error)
{
g_trace(G_T_BIO,
"g_io_deliver(%p) from %p(%s) to %p(%s) cmd %d error %d",
bp, bp->bio_from, bp->bio_from->geom->name,
- bp->bio_to, bp->bio_to->name, bp->bio_cmd, bp->bio_error);
+ bp->bio_to, bp->bio_to->name, bp->bio_cmd, error);
/* finish_stats(&bp->stats); */
+ bp->bio_error = error;
+
g_bioq_enqueue_tail(bp, &g_bio_run_up);
wakeup(&g_wait_up);
diff --git a/sys/geom/geom_slice.c b/sys/geom/geom_slice.c
index 816bf4e..c8b4323 100644
--- a/sys/geom/geom_slice.c
+++ b/sys/geom/geom_slice.c
@@ -144,13 +144,12 @@ g_slice_start(struct bio *bp)
case BIO_WRITE:
case BIO_DELETE:
if (bp->bio_offset > gsl->length) {
- bp->bio_error = EINVAL; /* XXX: EWHAT ? */
- g_io_deliver(bp);
+ g_io_deliver(bp, EINVAL); /* XXX: EWHAT ? */
return;
}
bp2 = g_clone_bio(bp);
if (bp2 == NULL) {
- g_io_fail(bp, ENOMEM);
+ g_io_deliver(bp, ENOMEM);
return;
}
if (bp2->bio_offset + bp2->bio_length > gsl->length)
@@ -192,15 +191,14 @@ g_slice_start(struct bio *bp)
#endif
bp2 = g_clone_bio(bp);
if (bp2 == NULL) {
- g_io_fail(bp, ENOMEM);
+ g_io_deliver(bp, ENOMEM);
return;
}
bp2->bio_done = g_std_done;
g_io_request(bp2, cp);
break;
default:
- bp->bio_error = EOPNOTSUPP;
- g_io_deliver(bp);
+ g_io_deliver(bp, EOPNOTSUPP);
return;
}
}
@@ -240,7 +238,8 @@ g_slice_config(struct g_geom *gp, int index, int how, off_t offset, off_t length
struct sbuf *sb;
int error, acc;
- g_trace(G_T_TOPOLOGY, "g_slice_config()");
+ g_trace(G_T_TOPOLOGY, "g_slice_config(%s, %d, %d)",
+ gp->name, index, how);
g_topology_assert();
gsp = gp->softc;
error = 0;
diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c
index 25f6a0c..bfb0732 100644
--- a/sys/geom/geom_subr.c
+++ b/sys/geom/geom_subr.c
@@ -479,8 +479,7 @@ g_handleattr(struct bio *bp, char *attribute, void *val, int len)
bcopy(val, bp->bio_data, len);
bp->bio_completed = len;
}
- bp->bio_error = error;
- g_io_deliver(bp);
+ g_io_deliver(bp, error);
return (1);
}
@@ -496,12 +495,13 @@ void
g_std_done(struct bio *bp)
{
struct bio *bp2;
+ int error;
bp2 = bp->bio_linkage;
- bp2->bio_error = bp->bio_error;
+ error = bp->bio_error;
bp2->bio_completed = bp->bio_completed;
g_destroy_bio(bp);
- g_io_deliver(bp2);
+ g_io_deliver(bp2, error);
}
/* XXX: maybe this is only g_slice_spoiled */
OpenPOWER on IntegriCloud