LIST_FOREACH(dirrem, &pagedep->pd_dirremhd, dm_next) {
while ((dirrem = LIST_FIRST(&pagedep->pd_dirremhd))) {
deallocate_dependencies(bp, inodedep)	struct buf *bp;	struct inodedep *inodedep;{	struct worklist *wk;	struct indirdep *indirdep;	struct allocindir *aip;	struct pagedep *pagedep;	struct dirrem *dirrem;	struct diradd *dap;	int i;	while ((wk = LIST_FIRST(&bp->b_dep)) != NULL) {		switch (wk->wk_type) {		case D_INDIRDEP:			indirdep = WK_INDIRDEP(wk);			/*			 * None of the indirect pointers will ever be visible,			 * so they can simply be tossed. GOINGAWAY ensures			 * that allocated pointers will be saved in the buffer			 * cache until they are freed. Note that they will			 * only be able to be found by their physical address			 * since the inode mapping the logical address will			 * be gone. The save buffer used for the safe copy			 * was allocated in setup_allocindir_phase2 using			 * the physical address so it could be used for this			 * purpose. Hence we swap the safe copy with the real			 * copy, allowing the safe copy to be freed and holding			 * on to the real copy for later use in indir_trunc.			 */			if (indirdep->ir_state & GOINGAWAY) {				FREE_LOCK(&lk);				panic("deallocate_dependencies: already gone");			}			indirdep->ir_state |= GOINGAWAY;			while ((aip = LIST_FIRST(&indirdep->ir_deplisthd)) != 0)				free_allocindir(aip, inodedep);			if (bp->b_lblkno >= 0 ||			    bp->b_blkno != indirdep->ir_savebp->b_lblkno) {				FREE_LOCK(&lk);				panic("deallocate_dependencies: not indir");			}			bcopy(bp->b_data, indirdep->ir_savebp->b_data,			    bp->b_bcount);			WORKLIST_REMOVE(wk);			WORKLIST_INSERT(&indirdep->ir_savebp->b_dep, wk);			continue;		case D_PAGEDEP:			pagedep = WK_PAGEDEP(wk);			/*			 * None of the directory additions will ever be			 * visible, so they can simply be tossed.			 */			for (i = 0; i < DAHASHSZ; i++)				while ((dap =				    LIST_FIRST(&pagedep->pd_diraddhd[i])))					free_diradd(dap);			while ((dap = LIST_FIRST(&pagedep->pd_pendinghd)) != 0)				free_diradd(dap);			/*			 * Copy any directory remove dependencies to the list			 * to be processed after the zero'ed inode is written.			 * If the inode has already been written, then they 			 * can be dumped directly onto the work list.			 */			LIST_FOREACH(dirrem, &pagedep->pd_dirremhd, dm_next) {				LIST_REMOVE(dirrem, dm_next);				dirrem->dm_dirinum = pagedep->pd_ino;				if (inodedep == NULL ||				    (inodedep->id_state & ALLCOMPLETE) ==				     ALLCOMPLETE)					add_to_worklist(&dirrem->dm_list);				else					WORKLIST_INSERT(&inodedep->id_bufwait,					    &dirrem->dm_list);			}			if ((pagedep->pd_state & NEWBLOCK) != 0) {				LIST_FOREACH(wk, &inodedep->id_bufwait, wk_list)					if (wk->wk_type == D_NEWDIRBLK &&					    WK_NEWDIRBLK(wk)->db_pagedep ==					    pagedep)						break;				if (wk != NULL) {					WORKLIST_REMOVE(wk);					free_newdirblk(WK_NEWDIRBLK(wk));				} else {					FREE_LOCK(&lk);					panic("deallocate_dependencies: "					    "lost pagedep");					}			}			WORKLIST_REMOVE(&pagedep->pd_list);			LIST_REMOVE(pagedep, pd_hash);			WORKITEM_FREE(pagedep, D_PAGEDEP);			continue;		case D_ALLOCINDIR:			free_allocindir(WK_ALLOCINDIR(wk), inodedep);			continue;		case D_ALLOCDIRECT:		case D_INODEDEP:			FREE_LOCK(&lk);			panic("deallocate_dependencies: Unexpected type %s",			    TYPENAME(wk->wk_type));			/* NOTREACHED */		default:			FREE_LOCK(&lk);			panic("deallocate_dependencies: Unknown type %s",			    TYPENAME(wk->wk_type));			/* NOTREACHED */		}	}}