if (bp->b_vp != NULL) { if (write && (bp->b_flags & B_AGE) != 0) { vwakeup(bp->b_vp); }
if (write && (bp->b_flags & B_AGE) != 0 && bp->b_vp != NULL) { vwakeup(bp->b_vp);
uvm_aio_aiodone(bp)	struct buf *bp;{	int npages = bp->b_bufsize >> PAGE_SHIFT;	struct vm_page *pg, *pgs[npages];	struct uvm_object *uobj;	int s, i, error;	boolean_t write, swap;	UVMHIST_FUNC("uvm_aio_aiodone"); UVMHIST_CALLED(ubchist);	UVMHIST_LOG(ubchist, "bp %p", bp, 0,0,0);	error = (bp->b_flags & B_ERROR) ? (bp->b_error ? bp->b_error : EIO) : 0;	write = (bp->b_flags & B_READ) == 0;	/* XXXUBC B_NOCACHE is for swap pager, should be done differently */	if (write && !(bp->b_flags & B_NOCACHE) && bioops.io_pageiodone) {		(*bioops.io_pageiodone)(bp);	}	uobj = NULL;	for (i = 0; i < npages; i++) {		pgs[i] = uvm_pageratop((vaddr_t)bp->b_data + (i << PAGE_SHIFT));		UVMHIST_LOG(ubchist, "pgs[%d] = %p", i, pgs[i],0,0);	}	uvm_pagermapout((vaddr_t)bp->b_data, npages);#ifdef UVM_SWAP_ENCRYPT	/*	 * XXX - assumes that we only get ASYNC writes. used to be above.	 */	if (pgs[0]->pqflags & PQ_ENCRYPT) {		uvm_swap_freepages(pgs, npages);		goto freed;	}#endif /* UVM_SWAP_ENCRYPT */	for (i = 0; i < npages; i++) {		pg = pgs[i];		if (i == 0) {			swap = (pg->pqflags & PQ_SWAPBACKED) != 0;			if (!swap) {				uobj = pg->uobject;				simple_lock(&uobj->vmobjlock);			}		}		KASSERT(swap || pg->uobject == uobj);		if (swap) {			if (pg->pqflags & PQ_ANON) {				simple_lock(&pg->uanon->an_lock);			} else {				simple_lock(&pg->uobject->vmobjlock);			}		}		/*		 * if this is a read and we got an error, mark the pages		 * PG_RELEASED so that uvm_page_unbusy() will free them.		 */		if (!write && error) {			pg->flags |= PG_RELEASED;			continue;		}		KASSERT(!write || (pgs[i]->flags & PG_FAKE) == 0);		/*		 * if this is a read and the page is PG_FAKE,		 * or this was a successful write,		 * mark the page PG_CLEAN and not PG_FAKE.		 */		if ((pgs[i]->flags & PG_FAKE) || (write && error != ENOMEM)) {			pmap_clear_reference(pgs[i]);			pmap_clear_modify(pgs[i]);			pgs[i]->flags |= PG_CLEAN;			pgs[i]->flags &= ~PG_FAKE;		}		uvm_pageactivate(pg);		if (swap) {			if (pg->pqflags & PQ_ANON) {				simple_unlock(&pg->uanon->an_lock);			} else {				simple_unlock(&pg->uobject->vmobjlock);			}		}	}	uvm_page_unbusy(pgs, npages);	if (!swap) {		simple_unlock(&uobj->vmobjlock);	}#ifdef UVM_SWAP_ENCRYPTfreed:#endif	s = splbio();	if (bp->b_vp != NULL) {		if (write && (bp->b_flags & B_AGE) != 0) {			vwakeup(bp->b_vp);		}	}	(void) buf_cleanout(bp);	pool_put(&bufpool, bp);	splx(s);}