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.
This commit is contained in:
parent
74d87364e1
commit
d986d4580c
@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/bio.h>
|
#include <sys/bio.h>
|
||||||
|
#include <sys/conf.h>
|
||||||
#include <sys/buf.h>
|
#include <sys/buf.h>
|
||||||
#include <sys/devicestat.h>
|
#include <sys/devicestat.h>
|
||||||
#include <sys/eventhandler.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.
|
* Call back function from struct bio back up to struct buf.
|
||||||
* The corresponding initialization lives in sys/conf.h:DEV_STRATEGY().
|
* The corresponding initialization lives in sys/conf.h:DEV_STRATEGY().
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
bufdonebio(struct bio *bp)
|
bufdonebio(struct bio *bp)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -3064,6 +3065,21 @@ bufdonebio(struct bio *bp)
|
|||||||
mtx_unlock(&Giant);
|
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:
|
* bufdone:
|
||||||
*
|
*
|
||||||
|
@ -501,7 +501,6 @@ struct buf *getblk(struct vnode *, daddr_t, int, int, int, int);
|
|||||||
struct buf *geteblk(int);
|
struct buf *geteblk(int);
|
||||||
int bufwait(struct buf *);
|
int bufwait(struct buf *);
|
||||||
void bufdone(struct buf *);
|
void bufdone(struct buf *);
|
||||||
void bufdonebio(struct bio *);
|
|
||||||
|
|
||||||
void cluster_callback(struct buf *);
|
void cluster_callback(struct buf *);
|
||||||
int cluster_read(struct vnode *, u_quad_t, daddr_t, long,
|
int cluster_read(struct vnode *, u_quad_t, daddr_t, long,
|
||||||
|
@ -175,23 +175,7 @@ typedef int dumper_t(
|
|||||||
off_t offset, /* Byte-offset to write at. */
|
off_t offset, /* Byte-offset to write at. */
|
||||||
size_t length); /* Number of bytes to dump. */
|
size_t length); /* Number of bytes to dump. */
|
||||||
|
|
||||||
#define BIO_STRATEGY(bp) \
|
#define DEV_STRATEGY(bp) dev_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)
|
|
||||||
|
|
||||||
#endif /* _KERNEL */
|
#endif /* _KERNEL */
|
||||||
|
|
||||||
@ -296,6 +280,7 @@ struct cdevsw *devsw(dev_t _dev);
|
|||||||
const char *devtoname(dev_t _dev);
|
const char *devtoname(dev_t _dev);
|
||||||
int dev_named(dev_t _pdev, const char *_name);
|
int dev_named(dev_t _pdev, const char *_name);
|
||||||
void dev_depends(dev_t _pdev, dev_t _cdev);
|
void dev_depends(dev_t _pdev, dev_t _cdev);
|
||||||
|
void dev_strategy(struct buf *bp);
|
||||||
void freedev(dev_t _dev);
|
void freedev(dev_t _dev);
|
||||||
dev_t makebdev(int _maj, int _min);
|
dev_t makebdev(int _maj, int _min);
|
||||||
dev_t make_dev(struct cdevsw *_devsw, int _minor, uid_t _uid, gid_t _gid,
|
dev_t make_dev(struct cdevsw *_devsw, int _minor, uid_t _uid, gid_t _gid,
|
||||||
|
@ -175,23 +175,7 @@ typedef int dumper_t(
|
|||||||
off_t offset, /* Byte-offset to write at. */
|
off_t offset, /* Byte-offset to write at. */
|
||||||
size_t length); /* Number of bytes to dump. */
|
size_t length); /* Number of bytes to dump. */
|
||||||
|
|
||||||
#define BIO_STRATEGY(bp) \
|
#define DEV_STRATEGY(bp) dev_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)
|
|
||||||
|
|
||||||
#endif /* _KERNEL */
|
#endif /* _KERNEL */
|
||||||
|
|
||||||
@ -296,6 +280,7 @@ struct cdevsw *devsw(dev_t _dev);
|
|||||||
const char *devtoname(dev_t _dev);
|
const char *devtoname(dev_t _dev);
|
||||||
int dev_named(dev_t _pdev, const char *_name);
|
int dev_named(dev_t _pdev, const char *_name);
|
||||||
void dev_depends(dev_t _pdev, dev_t _cdev);
|
void dev_depends(dev_t _pdev, dev_t _cdev);
|
||||||
|
void dev_strategy(struct buf *bp);
|
||||||
void freedev(dev_t _dev);
|
void freedev(dev_t _dev);
|
||||||
dev_t makebdev(int _maj, int _min);
|
dev_t makebdev(int _maj, int _min);
|
||||||
dev_t make_dev(struct cdevsw *_devsw, int _minor, uid_t _uid, gid_t _gid,
|
dev_t make_dev(struct cdevsw *_devsw, int _minor, uid_t _uid, gid_t _gid,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user