diff options
author | phk <phk@FreeBSD.org> | 2003-10-18 09:03:15 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2003-10-18 09:03:15 +0000 |
commit | 3dfc831549729fecf05cda278554a643f0f15049 (patch) | |
tree | 3739cd1a447c117bc422cf2eddc1b13ae20ff4b5 /sys | |
parent | eec76e0d92ea52c0b11dab9eb047119d0e6ce013 (diff) | |
download | FreeBSD-src-3dfc831549729fecf05cda278554a643f0f15049.zip FreeBSD-src-3dfc831549729fecf05cda278554a643f0f15049.tar.gz |
The size and contents of the DEV_STRATEGY() macro has progressed to
the point where it being a macro is no longer sensible, and it will
only be more so in days to come.
BIO_STRATEGY() is now only used from DEV_STRATEGY() and should not
be used directly anymore.
Put the contents of both in the new function dev_strategy() and
make DEV_STRATEGY() call that function.
In addition, this allows us to make the rather magic bufdonebio()
helper function static.
This alse saves hunderedandsome bytes of code in a typical kernel.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/vfs_bio.c | 18 | ||||
-rw-r--r-- | sys/sys/buf.h | 1 | ||||
-rw-r--r-- | sys/sys/conf.h | 19 | ||||
-rw-r--r-- | sys/sys/linedisc.h | 19 |
4 files changed, 21 insertions, 36 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 0c8d130..939f968 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> #include <sys/bio.h> +#include <sys/conf.h> #include <sys/buf.h> #include <sys/devicestat.h> #include <sys/eventhandler.h> @@ -3054,7 +3055,7 @@ 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 +static void bufdonebio(struct bio *bp) { @@ -3064,6 +3065,21 @@ bufdonebio(struct bio *bp) mtx_unlock(&Giant); } +void +dev_strategy(struct buf *bp) +{ + + if ((!bp->b_iocmd) || (bp->b_iocmd & (bp->b_iocmd - 1))) + panic("b_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); + bp->b_io.bio_done = bufdonebio; + bp->b_io.bio_caller2 = bp; + (*devsw(bp->b_io.bio_dev)->d_strategy)(&bp->b_io); +} + /* * bufdone: * diff --git a/sys/sys/buf.h b/sys/sys/buf.h index 78ef55b..0942761 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -501,7 +501,6 @@ struct buf *getblk(struct vnode *, daddr_t, int, int, int, int); struct buf *geteblk(int); int bufwait(struct buf *); void bufdone(struct buf *); -void bufdonebio(struct bio *); void cluster_callback(struct buf *); int cluster_read(struct vnode *, u_quad_t, daddr_t, long, diff --git a/sys/sys/conf.h b/sys/sys/conf.h index e4f0eab..fb39f08 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -175,23 +175,7 @@ typedef int dumper_t( off_t offset, /* Byte-offset to write at. */ size_t length); /* Number of bytes to dump. */ -#define BIO_STRATEGY(bp) \ - 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) \ - do { \ - if ((bp)->b_flags & B_PHYS) \ - (bp)->b_io.bio_offset = (bp)->b_offset; \ - else \ - (bp)->b_io.bio_offset = dbtob((bp)->b_blkno); \ - (bp)->b_io.bio_done = bufdonebio; \ - (bp)->b_io.bio_caller2 = (bp); \ - BIO_STRATEGY(&(bp)->b_io); \ - } while (0) +#define DEV_STRATEGY(bp) dev_strategy(bp) #endif /* _KERNEL */ @@ -296,6 +280,7 @@ struct cdevsw *devsw(dev_t _dev); const char *devtoname(dev_t _dev); int dev_named(dev_t _pdev, const char *_name); void dev_depends(dev_t _pdev, dev_t _cdev); +void dev_strategy(struct buf *bp); void freedev(dev_t _dev); dev_t makebdev(int _maj, int _min); dev_t make_dev(struct cdevsw *_devsw, int _minor, uid_t _uid, gid_t _gid, diff --git a/sys/sys/linedisc.h b/sys/sys/linedisc.h index e4f0eab..fb39f08 100644 --- a/sys/sys/linedisc.h +++ b/sys/sys/linedisc.h @@ -175,23 +175,7 @@ typedef int dumper_t( off_t offset, /* Byte-offset to write at. */ size_t length); /* Number of bytes to dump. */ -#define BIO_STRATEGY(bp) \ - 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) \ - do { \ - if ((bp)->b_flags & B_PHYS) \ - (bp)->b_io.bio_offset = (bp)->b_offset; \ - else \ - (bp)->b_io.bio_offset = dbtob((bp)->b_blkno); \ - (bp)->b_io.bio_done = bufdonebio; \ - (bp)->b_io.bio_caller2 = (bp); \ - BIO_STRATEGY(&(bp)->b_io); \ - } while (0) +#define DEV_STRATEGY(bp) dev_strategy(bp) #endif /* _KERNEL */ @@ -296,6 +280,7 @@ struct cdevsw *devsw(dev_t _dev); const char *devtoname(dev_t _dev); int dev_named(dev_t _pdev, const char *_name); void dev_depends(dev_t _pdev, dev_t _cdev); +void dev_strategy(struct buf *bp); void freedev(dev_t _dev); dev_t makebdev(int _maj, int _min); dev_t make_dev(struct cdevsw *_devsw, int _minor, uid_t _uid, gid_t _gid, |