return(EBUSY);
return(VM_PAGER_UNLOCK);
uao_get(uobj, offset, pps, npagesp, centeridx, access_type, advice, flags)	struct uvm_object *uobj;	voff_t offset;	struct vm_page **pps;	int *npagesp;	int centeridx, advice, flags;	vm_prot_t access_type;{	struct uvm_aobj *aobj = (struct uvm_aobj *)uobj;	voff_t current_offset;	struct vm_page *ptmp;	int lcv, gotpages, maxpages, swslot, rv, pageidx;	boolean_t done;	UVMHIST_FUNC("uao_get"); UVMHIST_CALLED(pdhist);	UVMHIST_LOG(pdhist, "aobj=%p offset=%d, flags=%d",		    aobj, offset, flags,0);	/* 	 * get number of pages 	 */	maxpages = *npagesp;	/* 	 * step 1: handled the case where fault data structures are locked. 	 */	if (flags & PGO_LOCKED) {		/* 		 * step 1a: get pages that are already resident.   only do		 * this if the data structures are locked (i.e. the first		 * time through). 		 */		done = TRUE;	/* be optimistic */		gotpages = 0;	/* # of pages we got so far */		for (lcv = 0, current_offset = offset ; lcv < maxpages ;		    lcv++, current_offset += PAGE_SIZE) {			/* do we care about this page?  if not, skip it */			if (pps[lcv] == PGO_DONTCARE)				continue;			ptmp = uvm_pagelookup(uobj, current_offset);			/* 			 * if page is new, attempt to allocate the page,			 * zero-fill'd. 			 */			if (ptmp == NULL && uao_find_swslot(aobj,			    current_offset >> PAGE_SHIFT) == 0) {				ptmp = uvm_pagealloc(uobj, current_offset,				    NULL, UVM_PGA_ZERO);				if (ptmp) {					/* new page */					ptmp->flags &= ~(PG_BUSY|PG_FAKE);					ptmp->pqflags |= PQ_AOBJ;					UVM_PAGE_OWN(ptmp, NULL);				}			}			/*			 * to be useful must get a non-busy, non-released page			 */			if (ptmp == NULL ||			    (ptmp->flags & (PG_BUSY|PG_RELEASED)) != 0) {				if (lcv == centeridx ||				    (flags & PGO_ALLPAGES) != 0)					/* need to do a wait or I/O! */					done = FALSE;					continue;			}			/*			 * useful page: busy/lock it and plug it in our			 * result array			 */			/* caller must un-busy this page */			ptmp->flags |= PG_BUSY;			UVM_PAGE_OWN(ptmp, "uao_get1");			pps[lcv] = ptmp;			gotpages++;		}	/* "for" lcv loop */		/* 		 * step 1b: now we've either done everything needed or we		 * to unlock and do some waiting or I/O. 		 */		UVMHIST_LOG(pdhist, "<- done (done=%d)", done, 0,0,0);		*npagesp = gotpages;		if (done)			/* bingo! */			return(0);		else			/* EEK!   Need to unlock and I/O */			return(EBUSY);	}	/* 	 * step 2: get non-resident or busy pages. 	 * object is locked.   data structures are unlocked. 	 */	for (lcv = 0, current_offset = offset ; lcv < maxpages ;	    lcv++, current_offset += PAGE_SIZE) {		/*		 * - skip over pages we've already gotten or don't want		 * - skip over pages we don't _have_ to get		 */		if (pps[lcv] != NULL ||		    (lcv != centeridx && (flags & PGO_ALLPAGES) == 0))			continue;		pageidx = current_offset >> PAGE_SHIFT;		/* 		 * we have yet to locate the current page (pps[lcv]).   we		 * first look for a page that is already at the current offset.		 * if we find a page, we check to see if it is busy or		 * released.  if that is the case, then we sleep on the page		 * until it is no longer busy or released and repeat the lookup.		 * if the page we found is neither busy nor released, then we		 * busy it (so we own it) and plug it into pps[lcv].   this		 * 'break's the following while loop and indicates we are		 * ready to move on to the next page in the "lcv" loop above. 		 * 		 * if we exit the while loop with pps[lcv] still set to NULL,		 * then it means that we allocated a new busy/fake/clean page		 * ptmp in the object and we need to do I/O to fill in the data. 		 */		/* top of "pps" while loop */		while (pps[lcv] == NULL) {			/* look for a resident page */			ptmp = uvm_pagelookup(uobj, current_offset);			/* not resident?   allocate one now (if we can) */			if (ptmp == NULL) {				ptmp = uvm_pagealloc(uobj, current_offset,				    NULL, 0);				/* out of RAM? */				if (ptmp == NULL) {					simple_unlock(&uobj->vmobjlock);					UVMHIST_LOG(pdhist,					    "sleeping, ptmp == NULL\n",0,0,0,0);					uvm_wait("uao_getpage");					simple_lock(&uobj->vmobjlock);					/* goto top of pps while loop */					continue;				}				/*				 * safe with PQ's unlocked: because we just				 * alloc'd the page				 */				ptmp->pqflags |= PQ_AOBJ;				/*				 * got new page ready for I/O.  break pps while				 * loop.  pps[lcv] is still NULL.				 */				break;			}			/* page is there, see if we need to wait on it */			if ((ptmp->flags & (PG_BUSY|PG_RELEASED)) != 0) {				ptmp->flags |= PG_WANTED;				UVMHIST_LOG(pdhist,				    "sleeping, ptmp->flags 0x%x\n",				    ptmp->flags,0,0,0);				UVM_UNLOCK_AND_WAIT(ptmp, &uobj->vmobjlock,				    FALSE, "uao_get", 0);				simple_lock(&uobj->vmobjlock);				continue;	/* goto top of pps while loop */			}			/* 			 * if we get here then the page has become resident and			 * unbusy between steps 1 and 2.  we busy it now (so we			 * own it) and set pps[lcv] (so that we exit the while			 * loop). 			 */			/* we own it, caller must un-busy */			ptmp->flags |= PG_BUSY;			UVM_PAGE_OWN(ptmp, "uao_get2");			pps[lcv] = ptmp;		}		/* 		 * if we own the valid page at the correct offset, pps[lcv] will 		 * point to it.   nothing more to do except go to the next page. 		 */		if (pps[lcv])			continue;			/* next lcv */		/* 		 * we have a "fake/busy/clean" page that we just allocated. 		 * do the needed "i/o", either reading from swap or zeroing. 		 */		swslot = uao_find_swslot(aobj, pageidx);		/* 		 * just zero the page if there's nothing in swap. 		 */		if (swslot == 0)		{			/*			 * page hasn't existed before, just zero it.			 */			uvm_pagezero(ptmp);		} else {			UVMHIST_LOG(pdhist, "pagein from swslot %d",			     swslot, 0,0,0);			/*			 * page in the swapped-out page.			 * unlock object for i/o, relock when done.			 */			simple_unlock(&uobj->vmobjlock);			rv = uvm_swap_get(ptmp, swslot, PGO_SYNCIO);			simple_lock(&uobj->vmobjlock);			/*			 * I/O done.  check for errors.			 */			if (rv != 0)			{				UVMHIST_LOG(pdhist, "<- done (error=%d)",				    rv,0,0,0);				if (ptmp->flags & PG_WANTED)					wakeup(ptmp);				/*				 * remove the swap slot from the aobj				 * and mark the aobj as having no real slot.				 * don't free the swap slot, thus preventing				 * it from being used again.				 */				swslot = uao_set_swslot(&aobj->u_obj, pageidx,							SWSLOT_BAD);				if (swslot != -1) {					uvm_swap_markbad(swslot, 1);				}				ptmp->flags &= ~(PG_WANTED|PG_BUSY);				UVM_PAGE_OWN(ptmp, NULL);				uvm_lock_pageq();				uvm_pagefree(ptmp);				uvm_unlock_pageq();				simple_unlock(&uobj->vmobjlock);				return (rv);			}		}		/* 		 * we got the page!   clear the fake flag (indicates valid		 * data now in page) and plug into our result array.   note		 * that page is still busy. 		 * 		 * it is the callers job to: 		 * => check if the page is released 		 * => unbusy the page 		 * => activate the page 		 */		ptmp->flags &= ~PG_FAKE;		/* data is valid ... */		pmap_clear_modify(ptmp);		/* ... and clean */		pps[lcv] = ptmp;	}	/* lcv loop */	/* 	 * finally, unlock object and return. 	 */	simple_unlock(&uobj->vmobjlock);	UVMHIST_LOG(pdhist, "<- done (OK)",0,0,0,0);	return(0);}