summaryrefslogtreecommitdiffstats
path: root/sys/ufs
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2015-07-23 19:13:41 +0000
committerjeff <jeff@FreeBSD.org>2015-07-23 19:13:41 +0000
commit3fb666cfae854507b98d7718c7fe4c8255c66bec (patch)
tree8566305d1f16ae2ae3c1c2a1637f450ce912744a /sys/ufs
parent873d1b1d46a05df6b6409530d9398e439ab1b7dc (diff)
downloadFreeBSD-src-3fb666cfae854507b98d7718c7fe4c8255c66bec.zip
FreeBSD-src-3fb666cfae854507b98d7718c7fe4c8255c66bec.tar.gz
Refactor unmapped buffer address handling.
- Use pointer assignment rather than a combination of pointers and flags to switch buffers between unmapped and mapped. This eliminates multiple flags and generally simplifies the logic. - Eliminate b_saveaddr since it is only used with pager bufs which have their b_data re-initialized on each allocation. - Gather up some convenience routines in the buffer cache for manipulating buf space and buf malloc space. - Add an inline, buf_mapped(), to standardize checks around unmapped buffers. In collaboration with: mlaier Reviewed by: kib Tested by: pho (many small revisions ago) Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/ffs/ffs_rawread.c29
-rw-r--r--sys/ufs/ffs/ffs_vfsops.c2
-rw-r--r--sys/ufs/ffs/ffs_vnops.c4
3 files changed, 10 insertions, 25 deletions
diff --git a/sys/ufs/ffs/ffs_rawread.c b/sys/ufs/ffs/ffs_rawread.c
index aaa052e..84fa0db 100644
--- a/sys/ufs/ffs/ffs_rawread.c
+++ b/sys/ufs/ffs/ffs_rawread.c
@@ -62,8 +62,7 @@ static int ffs_rawread_readahead(struct vnode *vp,
off_t offset,
size_t len,
struct thread *td,
- struct buf *bp,
- caddr_t sa);
+ struct buf *bp);
static int ffs_rawread_main(struct vnode *vp,
struct uio *uio);
@@ -190,8 +189,7 @@ ffs_rawread_readahead(struct vnode *vp,
off_t offset,
size_t len,
struct thread *td,
- struct buf *bp,
- caddr_t sa)
+ struct buf *bp)
{
int error;
u_int iolen;
@@ -219,7 +217,6 @@ ffs_rawread_readahead(struct vnode *vp,
bp->b_iocmd = BIO_READ;
bp->b_iodone = bdone;
bp->b_data = udata;
- bp->b_saveaddr = sa;
blockno = offset / bsize;
blockoff = (offset % bsize) / DEV_BSIZE;
if ((daddr_t) blockno != blockno) {
@@ -272,7 +269,6 @@ ffs_rawread_main(struct vnode *vp,
{
int error, nerror;
struct buf *bp, *nbp, *tbp;
- caddr_t sa, nsa, tsa;
u_int iolen;
int spl;
caddr_t udata;
@@ -295,18 +291,15 @@ ffs_rawread_main(struct vnode *vp,
bp = NULL;
nbp = NULL;
- sa = NULL;
- nsa = NULL;
while (resid > 0) {
if (bp == NULL) { /* Setup first read */
/* XXX: Leave some bufs for swap */
bp = getpbuf(&ffsrawbufcnt);
- sa = bp->b_data;
pbgetvp(vp, bp);
error = ffs_rawread_readahead(vp, udata, offset,
- resid, td, bp, sa);
+ resid, td, bp);
if (error != 0)
break;
@@ -317,7 +310,6 @@ ffs_rawread_main(struct vnode *vp,
else
nbp = NULL;
if (nbp != NULL) {
- nsa = nbp->b_data;
pbgetvp(vp, nbp);
nerror = ffs_rawread_readahead(vp,
@@ -328,8 +320,7 @@ ffs_rawread_main(struct vnode *vp,
resid -
bp->b_bufsize,
td,
- nbp,
- nsa);
+ nbp);
if (nerror) {
pbrelvp(nbp);
relpbuf(nbp, &ffsrawbufcnt);
@@ -365,8 +356,7 @@ ffs_rawread_main(struct vnode *vp,
offset,
bp->b_bufsize - iolen,
td,
- bp,
- sa);
+ bp);
if (error != 0)
break;
} else if (nbp != NULL) { /* Complete read with readahead */
@@ -375,10 +365,6 @@ ffs_rawread_main(struct vnode *vp,
bp = nbp;
nbp = tbp;
- tsa = sa;
- sa = nsa;
- nsa = tsa;
-
if (resid <= bp->b_bufsize) { /* No more readaheads */
pbrelvp(nbp);
relpbuf(nbp, &ffsrawbufcnt);
@@ -392,8 +378,7 @@ ffs_rawread_main(struct vnode *vp,
resid -
bp->b_bufsize,
td,
- nbp,
- nsa);
+ nbp);
if (nerror != 0) {
pbrelvp(nbp);
relpbuf(nbp, &ffsrawbufcnt);
@@ -404,7 +389,7 @@ ffs_rawread_main(struct vnode *vp,
break;
} else if (resid > 0) { /* More to read, no readahead */
error = ffs_rawread_readahead(vp, udata, offset,
- resid, td, bp, sa);
+ resid, td, bp);
if (error != 0)
break;
}
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index 1f59a86..ebd8520 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -2094,7 +2094,7 @@ ffs_bufwrite(struct buf *bp)
if (newbp == NULL)
goto normal_write;
- KASSERT((bp->b_flags & B_UNMAPPED) == 0, ("Unmapped cg"));
+ KASSERT(buf_mapped(bp), ("Unmapped cg"));
memcpy(newbp->b_data, bp->b_data, bp->b_bufsize);
BO_LOCK(bp->b_bufobj);
bp->b_vflags |= BV_BKGRDINPROG;
diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c
index 618ed8e..5a70e5c 100644
--- a/sys/ufs/ffs/ffs_vnops.c
+++ b/sys/ufs/ffs/ffs_vnops.c
@@ -581,7 +581,7 @@ ffs_read(ap)
xfersize = size;
}
- if ((bp->b_flags & B_UNMAPPED) == 0) {
+ if (buf_mapped(bp)) {
error = vn_io_fault_uiomove((char *)bp->b_data +
blkoffset, (int)xfersize, uio);
} else {
@@ -758,7 +758,7 @@ ffs_write(ap)
if (size < xfersize)
xfersize = size;
- if ((bp->b_flags & B_UNMAPPED) == 0) {
+ if (buf_mapped(bp)) {
error = vn_io_fault_uiomove((char *)bp->b_data +
blkoffset, (int)xfersize, uio);
} else {
OpenPOWER on IntegriCloud