- /* Make sure we have a buffer, creating one if necessary. */
- if (nobuf = (bp == NULL)) {
-// bp = getphysbuf();
- panic("physio: null buf pointer\n");
- }
-
- /* [raise the processor priority level to splbio;] */
- s = splbio();
-
- /* [while the buffer is marked busy] */
- while (bp->b_flags & B_BUSY) {
- /* [mark the buffer wanted] */
- bp->b_flags |= B_WANTED;
- /* [wait until the buffer is available] */
- tsleep((caddr_t)bp, PRIBIO+1, "physbuf", 0);
- }
-
- /* Mark it busy, so nobody else will use it. */
- bp->b_flags |= B_BUSY;
-
- /* [lower the priority level] */
- splx(s);
+ /*
+ * Make sure we have a buffer, creating one if necessary.
+ */
+ if (bp == NULL) {
+ bp = buf_alloc((vnode_t)0);
+ buf_allocated = 1;
+ } else
+ orig_bflags = buf_flags(bp);
+ /*
+ * at this point we should have a buffer
+ * that is marked BL_BUSY... we either
+ * acquired it via buf_alloc, or it was
+ * passed into us... if it was passed
+ * in, it needs to already be owned by
+ * the caller (i.e. BL_BUSY is set)
+ */
+ assert(bp->b_lflags & BL_BUSY);