- /* Make sure we have a buffer, creating one if necessary. */
- if (nobuf = (bp == NULL)) {
- bp = buf_alloc((vnode_t)0);
- }
-
- /* [while the buffer is marked busy] */
- while (((error = (int)buf_acquire(bp, 0, 0, 0)) == EAGAIN));
-
- if (error) {
- if (nobuf)
- buf_free(bp);
- return (error);
- }
+ /*
+ * 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);