From 448e7c12908c8a8680ec5f93934de43b8ad1a06f Mon Sep 17 00:00:00 2001 From: kib Date: Wed, 27 Mar 2013 11:34:27 +0000 Subject: Add dev_strategy_csw() function, which is similar to dev_strategy() but assumes that a thread reference was already obtained on the passed device. Use the function from physio(), to avoid two extra dev_mtx lock and unlock. Note that physio() is always used as the cdevsw method, or is called from a cdevsw method, and the caller already owns the reference. dev_strategy() is left to keep KPI intact, but now it is implemented as a wrapper around dev_strategy_csw(). Do some style cleanup in physio(). Requested and reviewed by: kan (previous version) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks --- sys/kern/kern_physio.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'sys/kern/kern_physio.c') diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c index 1eb5b8f..1387c8e 100644 --- a/sys/kern/kern_physio.c +++ b/sys/kern/kern_physio.c @@ -34,11 +34,11 @@ __FBSDID("$FreeBSD$"); int physio(struct cdev *dev, struct uio *uio, int ioflag) { - int i; - int error; + struct buf *bp; + struct cdevsw *csw; caddr_t sa; u_int iolen; - struct buf *bp; + int error, i, mapped; /* Keep the process UPAGES from being swapped. XXX: why ? */ PHOLD(curproc); @@ -91,11 +91,8 @@ physio(struct cdev *dev, struct uio *uio, int ioflag) bp->b_blkno = btodb(bp->b_offset); + csw = dev->si_devsw; if (uio->uio_segflg == UIO_USERSPACE) { - struct cdevsw *csw; - int mapped; - - csw = dev->si_devsw; if (csw != NULL && (csw->d_flags & D_UNMAPPED_IO) != 0) mapped = 0; @@ -107,7 +104,7 @@ physio(struct cdev *dev, struct uio *uio, int ioflag) } } - dev_strategy(dev, bp); + dev_strategy_csw(dev, csw, bp); if (uio->uio_rw == UIO_READ) bwait(bp, PRIBIO, "physrd"); else -- cgit v1.1