summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/sys/buf.h2
-rw-r--r--sys/vm/vm_pager.c42
2 files changed, 44 insertions, 0 deletions
diff --git a/sys/sys/buf.h b/sys/sys/buf.h
index bd12ca7..5a1cea4 100644
--- a/sys/sys/buf.h
+++ b/sys/sys/buf.h
@@ -519,7 +519,9 @@ void vunmapbuf(struct buf *);
void relpbuf(struct buf *, int *);
void brelvp(struct buf *);
void bgetvp(struct vnode *, struct buf *);
+void pbgetbo(struct bufobj *bo, struct buf *bp);
void pbgetvp(struct vnode *, struct buf *);
+void pbrelbo(struct buf *);
void pbrelvp(struct buf *);
int allocbuf(struct buf *bp, int size);
void reassignbuf(struct buf *);
diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c
index a8d061a..87f74d8 100644
--- a/sys/vm/vm_pager.c
+++ b/sys/vm/vm_pager.c
@@ -442,6 +442,24 @@ pbgetvp(struct vnode *vp, struct buf *bp)
}
/*
+ * Associate a p-buffer with a vnode.
+ *
+ * Also sets B_PAGING flag to indicate that vnode is not fully associated
+ * with the buffer. i.e. the bp has not been linked into the vnode or
+ * ref-counted.
+ */
+void
+pbgetbo(struct bufobj *bo, struct buf *bp)
+{
+
+ KASSERT(bp->b_vp == NULL, ("pbgetbo: not free (vnode)"));
+ KASSERT(bp->b_bufobj == NULL, ("pbgetbo: not free (bufobj)"));
+
+ bp->b_flags |= B_PAGING;
+ bp->b_bufobj = bo;
+}
+
+/*
* Disassociate a p-buffer from a vnode.
*/
void
@@ -465,3 +483,27 @@ pbrelvp(struct buf *bp)
bp->b_bufobj = NULL;
bp->b_flags &= ~B_PAGING;
}
+
+/*
+ * Disassociate a p-buffer from a bufobj.
+ */
+void
+pbrelbo(struct buf *bp)
+{
+
+ KASSERT(bp->b_vp == NULL, ("pbrelbo: vnode"));
+ KASSERT(bp->b_bufobj != NULL, ("pbrelbo: NULL bufobj"));
+
+ /* XXX REMOVE ME */
+ BO_LOCK(bp->b_bufobj);
+ if (TAILQ_NEXT(bp, b_bobufs) != NULL) {
+ panic(
+ "relpbuf(): b_vp was probably reassignbuf()d %p %x",
+ bp,
+ (int)bp->b_flags
+ );
+ }
+ BO_UNLOCK(bp->b_bufobj);
+ bp->b_bufobj = NULL;
+ bp->b_flags &= ~B_PAGING;
+}
OpenPOWER on IntegriCloud