summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2000-05-01 13:36:25 +0000
committerphk <phk@FreeBSD.org>2000-05-01 13:36:25 +0000
commit8f6a76b4dd073885aba26f3bee2a0bf76a3c21c8 (patch)
tree2c449be5174c7adc5d7066a40e57a9546c7b6105 /sys
parent1adeb7ffb16ca15e57e103f0b216470ee1d82d99 (diff)
downloadFreeBSD-src-8f6a76b4dd073885aba26f3bee2a0bf76a3c21c8.zip
FreeBSD-src-8f6a76b4dd073885aba26f3bee2a0bf76a3c21c8.tar.gz
Give struct bio it's own call back mechanism.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_diskslice.c26
-rw-r--r--sys/kern/vfs_bio.c18
-rw-r--r--sys/sys/bio.h17
-rw-r--r--sys/sys/buf.h17
-rw-r--r--sys/sys/conf.h13
-rw-r--r--sys/sys/linedisc.h13
6 files changed, 62 insertions, 42 deletions
diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c
index b5c197a..1e7d6c4 100644
--- a/sys/kern/subr_diskslice.c
+++ b/sys/kern/subr_diskslice.c
@@ -74,7 +74,7 @@ typedef u_char bool_t;
static volatile bool_t ds_debug;
static struct disklabel *clone_label __P((struct disklabel *lp));
-static void dsiodone __P((struct buf *bp));
+static void dsiodone __P((struct bio *bp));
static char *fixlabel __P((char *sname, struct diskslice *sp,
struct disklabel *lp, int writeflag));
static void free_ds_label __P((struct diskslices *ssp, int slice));
@@ -270,13 +270,6 @@ if (labelsect != 0) Debugger("labelsect != 0 in dscheck()");
* XXX probably need to copy the data to avoid even
* temporarily corrupting the in-core copy.
*/
-#ifdef notyet
- if (bp->b_vp != NULL) {
- s = splbio();
- bp->b_vp->v_numoutput++;
- splx(s);
- }
-#endif
/* XXX need name here. */
msg = fixlabel((char *)NULL, sp,
(struct disklabel *)
@@ -531,26 +524,25 @@ dsioctl(dev, cmd, data, flags, sspp)
static void
dsiodone(bp)
- struct buf *bp;
+ struct bio *bp;
{
struct iodone_chain *ic;
char *msg;
- ic = bp->b_iodone_chain;
- bp->b_flags = bp->b_flags & ~B_DONE;
- bp->b_iodone = ic->ic_prev_iodone;
- bp->b_iodone_chain = ic->ic_prev_iodone_chain;
- if (!(bp->b_iocmd == BIO_READ)
- || (!(bp->b_ioflags & BIO_ERROR) && bp->b_error == 0)) {
+ ic = bp->bio_done_chain;
+ bp->bio_done = ic->ic_prev_iodone;
+ bp->bio_done_chain = ic->ic_prev_iodone_chain;
+ if (!(bp->bio_cmd == BIO_READ)
+ || (!(bp->bio_flags & BIO_ERROR) && bp->bio_error == 0)) {
msg = fixlabel((char *)NULL, ic->ic_args[1].ia_ptr,
(struct disklabel *)
- (bp->b_data + ic->ic_args[0].ia_long),
+ (bp->bio_data + ic->ic_args[0].ia_long),
FALSE);
if (msg != NULL)
printf("%s\n", msg);
}
free(ic, M_DEVBUF);
- biodone((struct bio *)bp); /* XXX */
+ biodone(bp);
}
int
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 0338cc5..025d030 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -2603,8 +2603,18 @@ bufwait(register struct buf * bp)
}
}
+ /*
+ * Call back function from struct bio back up to struct buf.
+ * The corresponding initialization lives in sys/conf.h:DEV_STRATEGY().
+ */
+void
+bufdonebio(struct bio *bp)
+{
+ bufdone(bp->bio_caller2);
+}
+
/*
- * biodone:
+ * bufdone:
*
* Finish I/O on a buffer, optionally calling a completion function.
* This is usually called from an interrupt so process blocking is
@@ -2623,12 +2633,6 @@ bufwait(register struct buf * bp)
* in the biodone routine.
*/
void
-biodone(struct bio * bip)
-{
- bufdone((struct buf *)bip);
-}
-
-void
bufdone(struct buf *bp)
{
int s;
diff --git a/sys/sys/bio.h b/sys/sys/bio.h
index f8073cc..15fe014 100644
--- a/sys/sys/bio.h
+++ b/sys/sys/bio.h
@@ -45,6 +45,7 @@
#include <sys/queue.h>
#include <sys/lock.h>
+struct bio;
struct buf;
struct mount;
struct vnode;
@@ -71,7 +72,7 @@ extern struct bio_ops {
struct iodone_chain {
long ic_prev_flags;
- void (*ic_prev_iodone) __P((struct buf *));
+ void (*ic_prev_iodone) __P((struct bio *));
void *ic_prev_iodone_chain;
struct {
long ia_long;
@@ -93,7 +94,7 @@ struct bio {
struct buf *_bio_buf; /* Parent buffer. */
int bio_error; /* Errno for BIO_ERROR. */
long bio_resid; /* Remaining I/0 in bytes. */
- void (*bio_done) __P((struct buf *));
+ void (*bio_done) __P((struct bio *));
void *bio_driver1; /* Private use by the callee. */
void *bio_driver2; /* Private use by the callee. */
void *bio_caller1; /* Private use by the caller. */
@@ -105,6 +106,12 @@ struct bio {
struct iodone_chain *bio_done_chain;
};
+static __inline__ void
+biodone(struct bio *bp)
+{
+ bp->bio_done(bp);
+}
+
/*
* The buffer header describes an I/O operation in the kernel.
*
@@ -127,18 +134,16 @@ struct buf {
#define b_bcount b_io.bio_bcount
#define b_blkno b_io.bio_blkno
#define b_caller1 b_io.bio_caller1
-#define b_caller2 b_io.bio_caller2
#define b_data b_io.bio_data
#define b_dev b_io.bio_dev
#define b_driver1 b_io.bio_driver1
#define b_driver2 b_io.bio_driver2
#define b_error b_io.bio_error
#define b_iocmd b_io.bio_cmd
-#define b_iodone b_io.bio_done
-#define b_iodone_chain b_io.bio_done_chain
#define b_ioflags b_io.bio_flags
#define b_pblkno b_io.bio_pblkno
#define b_resid b_io.bio_resid
+ void (*b_iodone) __P((struct buf *));
off_t b_offset; /* Offset into file. */
LIST_ENTRY(buf) b_hash; /* Hash chain. */
TAILQ_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */
@@ -581,7 +586,7 @@ struct buf *getblk __P((struct vnode *, daddr_t, int, int, int));
struct buf *geteblk __P((int));
int bufwait __P((struct buf *));
void bufdone __P((struct buf *));
-void biodone __P((struct bio *));
+void bufdonebio __P((struct bio *));
void cluster_callback __P((struct buf *));
int cluster_read __P((struct vnode *, u_quad_t, daddr_t, long,
diff --git a/sys/sys/buf.h b/sys/sys/buf.h
index f8073cc..15fe014 100644
--- a/sys/sys/buf.h
+++ b/sys/sys/buf.h
@@ -45,6 +45,7 @@
#include <sys/queue.h>
#include <sys/lock.h>
+struct bio;
struct buf;
struct mount;
struct vnode;
@@ -71,7 +72,7 @@ extern struct bio_ops {
struct iodone_chain {
long ic_prev_flags;
- void (*ic_prev_iodone) __P((struct buf *));
+ void (*ic_prev_iodone) __P((struct bio *));
void *ic_prev_iodone_chain;
struct {
long ia_long;
@@ -93,7 +94,7 @@ struct bio {
struct buf *_bio_buf; /* Parent buffer. */
int bio_error; /* Errno for BIO_ERROR. */
long bio_resid; /* Remaining I/0 in bytes. */
- void (*bio_done) __P((struct buf *));
+ void (*bio_done) __P((struct bio *));
void *bio_driver1; /* Private use by the callee. */
void *bio_driver2; /* Private use by the callee. */
void *bio_caller1; /* Private use by the caller. */
@@ -105,6 +106,12 @@ struct bio {
struct iodone_chain *bio_done_chain;
};
+static __inline__ void
+biodone(struct bio *bp)
+{
+ bp->bio_done(bp);
+}
+
/*
* The buffer header describes an I/O operation in the kernel.
*
@@ -127,18 +134,16 @@ struct buf {
#define b_bcount b_io.bio_bcount
#define b_blkno b_io.bio_blkno
#define b_caller1 b_io.bio_caller1
-#define b_caller2 b_io.bio_caller2
#define b_data b_io.bio_data
#define b_dev b_io.bio_dev
#define b_driver1 b_io.bio_driver1
#define b_driver2 b_io.bio_driver2
#define b_error b_io.bio_error
#define b_iocmd b_io.bio_cmd
-#define b_iodone b_io.bio_done
-#define b_iodone_chain b_io.bio_done_chain
#define b_ioflags b_io.bio_flags
#define b_pblkno b_io.bio_pblkno
#define b_resid b_io.bio_resid
+ void (*b_iodone) __P((struct buf *));
off_t b_offset; /* Offset into file. */
LIST_ENTRY(buf) b_hash; /* Hash chain. */
TAILQ_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */
@@ -581,7 +586,7 @@ struct buf *getblk __P((struct vnode *, daddr_t, int, int, int));
struct buf *geteblk __P((int));
int bufwait __P((struct buf *));
void bufdone __P((struct buf *));
-void biodone __P((struct bio *));
+void bufdonebio __P((struct bio *));
void cluster_callback __P((struct buf *));
int cluster_read __P((struct vnode *, u_quad_t, daddr_t, long,
diff --git a/sys/sys/conf.h b/sys/sys/conf.h
index f4ae3d6..c50d225 100644
--- a/sys/sys/conf.h
+++ b/sys/sys/conf.h
@@ -138,15 +138,22 @@ typedef void devfs_remove_t __P((dev_t dev));
* of surgery, reset the flag and restart all the stuff on the stall
* queue.
*/
+#define BIO_STRATEGY(bp, dummy) \
+ do { \
+ if ((!(bp)->bio_cmd) || ((bp)->bio_cmd & ((bp)->bio_cmd - 1))) \
+ Debugger("bio_cmd botch"); \
+ (*devsw((bp)->bio_dev)->d_strategy)(bp); \
+ } while (0)
+
#define DEV_STRATEGY(bp, dummy) \
do { \
- if ((!(bp)->b_iocmd) || ((bp)->b_iocmd & ((bp)->b_iocmd - 1))) \
- Debugger("d_iocmd botch"); \
if ((bp)->b_flags & B_PHYS) \
(bp)->b_io.bio_offset = (bp)->b_offset; \
else \
(bp)->b_io.bio_offset = dbtob((bp)->b_blkno); \
- (*devsw((bp)->b_dev)->d_strategy)(&(bp)->b_io); \
+ (bp)->b_io.bio_done = bufdonebio; \
+ (bp)->b_io.bio_caller2 = (bp); \
+ BIO_STRATEGY(&(bp)->b_io, dummy); \
} while (0)
/*
diff --git a/sys/sys/linedisc.h b/sys/sys/linedisc.h
index f4ae3d6..c50d225 100644
--- a/sys/sys/linedisc.h
+++ b/sys/sys/linedisc.h
@@ -138,15 +138,22 @@ typedef void devfs_remove_t __P((dev_t dev));
* of surgery, reset the flag and restart all the stuff on the stall
* queue.
*/
+#define BIO_STRATEGY(bp, dummy) \
+ do { \
+ if ((!(bp)->bio_cmd) || ((bp)->bio_cmd & ((bp)->bio_cmd - 1))) \
+ Debugger("bio_cmd botch"); \
+ (*devsw((bp)->bio_dev)->d_strategy)(bp); \
+ } while (0)
+
#define DEV_STRATEGY(bp, dummy) \
do { \
- if ((!(bp)->b_iocmd) || ((bp)->b_iocmd & ((bp)->b_iocmd - 1))) \
- Debugger("d_iocmd botch"); \
if ((bp)->b_flags & B_PHYS) \
(bp)->b_io.bio_offset = (bp)->b_offset; \
else \
(bp)->b_io.bio_offset = dbtob((bp)->b_blkno); \
- (*devsw((bp)->b_dev)->d_strategy)(&(bp)->b_io); \
+ (bp)->b_io.bio_done = bufdonebio; \
+ (bp)->b_io.bio_caller2 = (bp); \
+ BIO_STRATEGY(&(bp)->b_io, dummy); \
} while (0)
/*
OpenPOWER on IntegriCloud