STATIC struct buf *softdep_setup_pagecache __P((struct inode *, ufs_lbn_t, long)); STATIC void softdep_collect_pagecache __P((struct inode *)); STATIC void softdep_free_pagecache __P((struct inode *)); STATIC struct vnode *softdep_lookupvp(struct fs *, ino_t); STATIC struct buf *softdep_lookup_pcbp __P((struct vnode *, ufs_lbn_t)); void softdep_pageiodone __P((struct buf *));
STATIC	struct allocindir *newallocindir __P((struct inode *, int, ufs_daddr_t,	    ufs_daddr_t));STATIC	void handle_workitem_freefrag __P((struct freefrag *));STATIC	struct freefrag *newfreefrag __P((struct inode *, ufs_daddr_t, long));STATIC	void allocdirect_merge __P((struct allocdirectlst *,	    struct allocdirect *, struct allocdirect *));STATIC	struct bmsafemap *bmsafemap_lookup __P((struct buf *));STATIC	int newblk_lookup __P((struct fs *, ufs_daddr_t, int,	    struct newblk **));STATIC	int inodedep_lookup __P((struct fs *, ino_t, int, struct inodedep **));STATIC	int pagedep_lookup __P((struct inode *, ufs_lbn_t, int,	    struct pagedep **));STATIC	void pause_timer __P((void *));STATIC	int request_cleanup __P((int, int));STATIC	int process_worklist_item __P((struct mount *, int));STATIC	void add_to_worklist __P((struct worklist *));STATIC struct buf *softdep_setup_pagecache __P((struct inode *, ufs_lbn_t,						long));STATIC void softdep_collect_pagecache __P((struct inode *));STATIC void softdep_free_pagecache __P((struct inode *));STATIC struct vnode *softdep_lookupvp(struct fs *, ino_t);STATIC struct buf *softdep_lookup_pcbp __P((struct vnode *, ufs_lbn_t));void softdep_pageiodone __P((struct buf *));/* * Exported softdep operations. */void softdep_disk_io_initiation __P((struct buf *));void softdep_disk_write_complete __P((struct buf *));void softdep_deallocate_dependencies __P((struct buf *));void softdep_move_dependencies __P((struct buf *, struct buf *));int softdep_count_dependencies __P((struct buf *bp, int, int));struct bio_ops bioops = {	softdep_disk_io_initiation,		/* io_start */	softdep_disk_write_complete,		/* io_complete */	softdep_deallocate_dependencies,	/* io_deallocate */	softdep_move_dependencies,		/* io_movedeps */	softdep_count_dependencies,		/* io_countdeps */	softdep_pageiodone,			/* io_pagedone */};/* * Locking primitives. * * For a uniprocessor, all we need to do is protect against disk * interrupts. For a multiprocessor, this lock would have to be * a mutex. A single mutex is used throughout this file, though * finer grain locking could be used if contention warranted it. * * For a multiprocessor, the sleep call would accept a lock and * release it after the sleep processing was complete. In a uniprocessor * implementation there is no such interlock, so we simple mark * the places where it needs to be done with the `interlocked' form * of the lock calls. Since the uniprocessor sleep already interlocks * the spl, there is nothing that really needs to be done. */#ifndef /* NOT */ DEBUGSTATIC struct lockit {	int	lkt_spl;} lk = { 0 };#define ACQUIRE_LOCK(lk)		(lk)->lkt_spl = splbio()#define FREE_LOCK(lk)			splx((lk)->lkt_spl)#define ACQUIRE_LOCK_INTERLOCKED(lk,s)	(lk)->lkt_spl = (s)#define FREE_LOCK_INTERLOCKED(lk)	((lk)->lkt_spl)#else /* DEBUG */STATIC struct lockit {	int	lkt_spl;	pid_t	lkt_held;	int     lkt_line;} lk = { 0, -1 };STATIC int lockcnt;STATIC	void acquire_lock __P((struct lockit *, int));STATIC	void free_lock __P((struct lockit *, int));STATIC	void acquire_lock_interlocked __P((struct lockit *, int, int));STATIC	int free_lock_interlocked __P((struct lockit *, int));#define ACQUIRE_LOCK(lk)		acquire_lock(lk, __LINE__)#define FREE_LOCK(lk)			free_lock(lk, __LINE__)#define ACQUIRE_LOCK_INTERLOCKED(lk,s)	acquire_lock_interlocked(lk, (s), __LINE__)#define FREE_LOCK_INTERLOCKED(lk)	free_lock_interlocked(lk, __LINE__)STATIC voidacquire_lock(lk, line)	struct lockit *lk;	int line;{	pid_t holder;	int original_line;	if (lk->lkt_held != -1) {		holder = lk->lkt_held;		original_line = lk->lkt_line;		FREE_LOCK(lk);		if (holder == CURPROC->p_pid)			panic("softdep_lock: locking against myself, acquired at line %d, relocked at line %d", original_line, line);		else			panic("softdep_lock: lock held by %d, acquired at line %d, relocked at line %d", holder, original_line, line);	}	lk->lkt_spl = splbio();	lk->lkt_held = CURPROC->p_pid;	lk->lkt_line = line;	lockcnt++;}STATIC voidfree_lock(lk, line)	struct lockit *lk;	int line;{	if (lk->lkt_held == -1)		panic("softdep_unlock: lock not held at line %d", line);	lk->lkt_held = -1;	splx(lk->lkt_spl);}STATIC voidacquire_lock_interlocked(lk, s, line)	struct lockit *lk;	int s;	int line;{	pid_t holder;	int original_line;	if (lk->lkt_held != -1) {		holder = lk->lkt_held;		original_line = lk->lkt_line;		FREE_LOCK_INTERLOCKED(lk);		if (holder == CURPROC->p_pid)			panic("softdep_lock: locking against myself, acquired at line %d, relocked at line %d", original_line, line);		else			panic("softdep_lock: lock held by %d, acquired at line %d, relocked at line %d", holder, original_line, line);	}	lk->lkt_held = CURPROC->p_pid;	lk->lkt_line = line;	lk->lkt_spl = s;	lockcnt++;}STATIC intfree_lock_interlocked(lk, line)	struct lockit *lk;	int line;{	if (lk->lkt_held == -1)		panic("softdep_unlock_interlocked: lock not held at line %d", line);	lk->lkt_held = -1;	return (lk->lkt_spl);}#endif /* DEBUG *//* * Place holder for real semaphores. */struct sema {	int	value;	pid_t	holder;	char	*name;	int	prio;	int	timo;};STATIC	void sema_init __P((struct sema *, char *, int, int));STATIC	int sema_get __P((struct sema *, struct lockit *));STATIC	void sema_release __P((struct sema *));STATIC voidsema_init(semap, name, prio, timo)	struct sema *semap;	char *name;	int prio, timo;{	semap->holder = -1;	semap->value = 0;	semap->name = name;	semap->prio = prio;	semap->timo = timo;}STATIC intsema_get(semap, interlock)	struct sema *semap;	struct lockit *interlock;{	int s;	if (semap->value++ > 0) {		if (interlock != NULL)			s = FREE_LOCK_INTERLOCKED(interlock);		tsleep((caddr_t)semap, semap->prio, semap->name, semap->timo);		if (interlock != NULL) {			ACQUIRE_LOCK_INTERLOCKED(interlock, s);			FREE_LOCK(interlock);		}		return (0);	}	semap->holder = CURPROC->p_pid;	if (interlock != NULL)		FREE_LOCK(interlock);	return (1);}STATIC voidsema_release(semap)	struct sema *semap;{	if (semap->value <= 0 || semap->holder != CURPROC->p_pid) {#ifdef DEBUG		if (lk.lkt_held != -1)			FREE_LOCK(&lk);#endif		panic("sema_release: not held");	}	if (--semap->value > 0) {		semap->value = 0;		wakeup(semap);	}	semap->holder = -1;}/* * Worklist queue management. * These routines require that the lock be held. */#ifndef /* NOT */ DEBUG#define WORKLIST_INSERT(head, item) do {	\	(item)->wk_state |= ONWORKLIST;		\	LIST_INSERT_HEAD(head, item, wk_list);	\} while (0)#define WORKLIST_REMOVE(item) do {		\	(item)->wk_state &= ~ONWORKLIST;	\	LIST_REMOVE(item, wk_list);		\} while (0)#define WORKITEM_FREE(item, type) FREE(item, DtoM(type))#else /* DEBUG */STATIC	void worklist_insert __P((struct workhead *, struct worklist *));STATIC	void worklist_remove __P((struct worklist *));STATIC	void workitem_free __P((struct worklist *, int));#define WORKLIST_INSERT(head, item) worklist_insert(head, item)#define WORKLIST_REMOVE(item) worklist_remove(item)#define WORKITEM_FREE(item, type) workitem_free((struct worklist *)item, type)STATIC voidworklist_insert(head, item)	struct workhead *head;	struct worklist *item;{	if (lk.lkt_held == -1)		panic("worklist_insert: lock not held");	if (item->wk_state & ONWORKLIST) {		FREE_LOCK(&lk);		panic("worklist_insert: already on list");	}	item->wk_state |= ONWORKLIST;	LIST_INSERT_HEAD(head, item, wk_list);}STATIC voidworklist_remove(item)	struct worklist *item;{	if (lk.lkt_held == -1)		panic("worklist_remove: lock not held");	if ((item->wk_state & ONWORKLIST) == 0) {		FREE_LOCK(&lk);		panic("worklist_remove: not on list");	}	item->wk_state &= ~ONWORKLIST;	LIST_REMOVE(item, wk_list);}STATIC voidworkitem_free(item, type)	struct worklist *item;	int type;{	if (item->wk_state & ONWORKLIST) {		if (lk.lkt_held != -1)			FREE_LOCK(&lk);		panic("workitem_free: still on list");	}	if (item->wk_type != type) {		if (lk.lkt_held != -1)			FREE_LOCK(&lk);		panic("workitem_free: type mismatch");	}	FREE(item, DtoM(type));}#endif /* DEBUG *//* * Workitem queue management */STATIC struct workhead softdep_workitem_pending;STATIC int num_on_worklist;	/* number of worklist items to be processed */STATIC int softdep_worklist_busy; /* 1 => trying to do unmount */STATIC int softdep_worklist_req; /* serialized waiters */STATIC int max_softdeps;	/* maximum number of structs before slowdown */STATIC int tickdelay = 2;	/* number of ticks to pause during slowdown */STATIC int proc_waiting;	/* tracks whether we have a timeout posted */STATIC int *stat_countp;	/* statistic to count in proc_waiting timeout */STATIC struct timeout proc_waiting_timeout; STATIC struct proc *filesys_syncer; /* proc of filesystem syncer process */STATIC int req_clear_inodedeps;	/* syncer process flush some inodedeps */#define FLUSH_INODES	1STATIC int req_clear_remove;	/* syncer process flush some freeblks */#define FLUSH_REMOVE	2/* * runtime statistics */STATIC int stat_worklist_push;	/* number of worklist cleanups */STATIC int stat_blk_limit_push;	/* number of times block limit neared */STATIC int stat_ino_limit_push;	/* number of times inode limit neared */STATIC int stat_blk_limit_hit;	/* number of times block slowdown imposed */STATIC int stat_ino_limit_hit;	/* number of times inode slowdown imposed */STATIC int stat_sync_limit_hit;	/* number of synchronous slowdowns imposed */STATIC int stat_indir_blk_ptrs;	/* bufs redirtied as indir ptrs not written */STATIC int stat_inode_bitmap;	/* bufs redirtied as inode bitmap not written */STATIC int stat_direct_blk_ptrs;/* bufs redirtied as direct ptrs not written */STATIC int stat_dir_entry;	/* bufs redirtied as dir entry cannot write */#ifdef DEBUG#include <uvm/uvm_extern.h>#include <sys/sysctl.h>struct ctldebug debug20 = { "max_softdeps", &max_softdeps };struct ctldebug debug21 = { "tickdelay", &tickdelay };struct ctldebug debug22 = { "worklist_push", &stat_worklist_push };struct ctldebug debug23 = { "blk_limit_push", &stat_blk_limit_push };struct ctldebug debug24 = { "ino_limit_push", &stat_ino_limit_push };struct ctldebug debug25 = { "blk_limit_hit", &stat_blk_limit_hit };struct ctldebug debug26 = { "ino_limit_hit", &stat_ino_limit_hit };struct ctldebug debug27 = { "sync_limit_hit", &stat_sync_limit_hit }; struct ctldebug debug28 = { "indir_blk_ptrs", &stat_indir_blk_ptrs };struct ctldebug debug29 = { "inode_bitmap", &stat_inode_bitmap };struct ctldebug debug30 = { "direct_blk_ptrs", &stat_direct_blk_ptrs };struct ctldebug debug31 = { "dir_entry", &stat_dir_entry };#endif /* DEBUG *//* * Add an item to the end of the work queue. * This routine requires that the lock be held. * This is the only routine that adds items to the list. * The following routine is the only one that removes items * and does so in order from first to last. */STATIC voidadd_to_worklist(wk)	struct worklist *wk;{	static struct worklist *worklist_tail;	if (wk->wk_state & ONWORKLIST) {#ifdef DEBUG		if (lk.lkt_held != -1)			FREE_LOCK(&lk);#endif		panic("add_to_worklist: already on list");	}	wk->wk_state |= ONWORKLIST;	if (LIST_FIRST(&softdep_workitem_pending) == NULL)		LIST_INSERT_HEAD(&softdep_workitem_pending, wk, wk_list);	else		LIST_INSERT_AFTER(worklist_tail, wk, wk_list);	worklist_tail = wk;	num_on_worklist += 1;}/* * Process that runs once per second to handle items in the background queue. * * Note that we ensure that everything is done in the order in which they * appear in the queue. The code below depends on this property to ensure * that blocks of a file are freed before the inode itself is freed. This * ordering ensures that no new <vfsid, inum, lbn> triples will be generated * until all the old ones have been purged from the dependency lists. */int softdep_process_worklist(matchmnt)	struct mount *matchmnt;{	struct proc *p = CURPROC;	int matchcnt, loopcount;	struct timeval starttime;	/*	 * Record the process identifier of our caller so that we can give	 * this process preferential treatment in request_cleanup below.	 * We can't do this in softdep_initialize, because the syncer doesn't	 * have to run then.	 * NOTE! This function _could_ be called with a curproc != syncerproc.	 */	filesys_syncer = syncerproc;	matchcnt = 0;	/*	 * There is no danger of having multiple processes run this	 * code, but we have to single-thread it when softdep_flushfiles()	 * is in operation to get an accurate count of the number of items	 * related to its mount point that are in the list.	 */	if (matchmnt == NULL) {		if (softdep_worklist_busy < 0)			return(-1);		softdep_worklist_busy += 1;	}	/*	 * If requested, try removing inode or removal dependencies.	 */	if (req_clear_inodedeps) {		clear_inodedeps(p);		req_clear_inodedeps -= 1;		wakeup_one(&proc_waiting);	}	if (req_clear_remove) {		clear_remove(p);		req_clear_remove -= 1;		wakeup_one(&proc_waiting);	}	loopcount = 1;	starttime = time;	while (num_on_worklist > 0) {		matchcnt += process_worklist_item(matchmnt, 0);		/*		 * If a umount operation wants to run the worklist		 * accurately, abort.		 */		if (softdep_worklist_req && matchmnt == NULL) {			matchcnt = -1;			break;		}		/*		 * If requested, try removing inode or removal dependencies.		 */		if (req_clear_inodedeps) {			clear_inodedeps(p);			req_clear_inodedeps -= 1;			wakeup_one(&proc_waiting);		}		if (req_clear_remove) {			clear_remove(p);			req_clear_remove -= 1;			wakeup_one(&proc_waiting);		}		/*		 * We do not generally want to stop for buffer space, but if		 * we are really being a buffer hog, we will stop and wait.		 */#if 0		if (loopcount++ % 128 == 0)			bwillwrite();#endif		/*		 * Never allow processing to run for more than one		 * second. Otherwise the other syncer tasks may get		 * excessively backlogged.		 */		{			struct timeval diff;			timersub(&time, &starttime, &diff);			if (diff.tv_sec != 0 && matchmnt == NULL) {				matchcnt = -1;				break;			}		}	}	if (matchmnt == NULL) {		softdep_worklist_busy -= 1;		if (softdep_worklist_req && softdep_worklist_busy == 0)			wakeup(&softdep_worklist_req);	}	return (matchcnt);}/* * Process one item on the worklist. */STATIC intprocess_worklist_item(matchmnt, flags)	struct mount *matchmnt;	int flags;{	struct worklist *wk;	struct dirrem *dirrem;	struct mount *mp;	struct vnode *vp;	int matchcnt = 0;	ACQUIRE_LOCK(&lk);	/*	 * Normally we just process each item on the worklist in order.	 * However, if we are in a situation where we cannot lock any	 * inodes, we have to skip over any dirrem requests whose	 * vnodes are resident and locked.	 */	LIST_FOREACH(wk, &softdep_workitem_pending, wk_list) {		if ((flags & LK_NOWAIT) == 0 || wk->wk_type != D_DIRREM)			break;		dirrem = WK_DIRREM(wk);		vp = ufs_ihashlookup(VFSTOUFS(dirrem->dm_mnt)->um_dev,		    dirrem->dm_oldinum);		if (vp == NULL || !VOP_ISLOCKED(vp))			break;	}	if (wk == 0) {		FREE_LOCK(&lk);		return (0);	}	WORKLIST_REMOVE(wk);	num_on_worklist -= 1;	FREE_LOCK(&lk);	switch (wk->wk_type) {	case D_DIRREM:		/* removal of a directory entry */		mp = WK_DIRREM(wk)->dm_mnt;#if 0		if (vn_write_suspend_wait(NULL, mp, V_NOWAIT))			panic("%s: dirrem on suspended filesystem",				"process_worklist_item");#endif		if (mp == matchmnt)			matchcnt += 1;		handle_workitem_remove(WK_DIRREM(wk));		break;	case D_FREEBLKS:		/* releasing blocks and/or fragments from a file */		mp = WK_FREEBLKS(wk)->fb_mnt;#if 0		if (vn_write_suspend_wait(NULL, mp, V_NOWAIT))			panic("%s: freeblks on suspended filesystem",				"process_worklist_item");#endif		if (mp == matchmnt)			matchcnt += 1;		handle_workitem_freeblocks(WK_FREEBLKS(wk));		break;	case D_FREEFRAG:		/* releasing a fragment when replaced as a file grows */		mp = WK_FREEFRAG(wk)->ff_mnt;#if 0		if (vn_write_suspend_wait(NULL, mp, V_NOWAIT))			panic("%s: freefrag on suspended filesystem",				"process_worklist_item");#endif		if (mp == matchmnt)			matchcnt += 1;		handle_workitem_freefrag(WK_FREEFRAG(wk));		break;	case D_FREEFILE:		/* releasing an inode when its link count drops to 0 */		mp = WK_FREEFILE(wk)->fx_mnt;#if 0		if (vn_write_suspend_wait(NULL, mp, V_NOWAIT))			panic("%s: freefile on suspended filesystem",				"process_worklist_item");#endif		if (mp == matchmnt)			matchcnt += 1;		handle_workitem_freefile(WK_FREEFILE(wk));		break;	default:		panic("%s_process_worklist: Unknown type %s",		    "softdep", TYPENAME(wk->wk_type));		/* NOTREACHED */	}	return (matchcnt);}/* * Move dependencies from one buffer to another. */voidsoftdep_move_dependencies(oldbp, newbp)	struct buf *oldbp;	struct buf *newbp;{	struct worklist *wk, *wktail;	if (LIST_FIRST(&newbp->b_dep) != NULL)		panic("softdep_move_dependencies: need merge code");	wktail = 0;	ACQUIRE_LOCK(&lk);	while ((wk = LIST_FIRST(&oldbp->b_dep)) != NULL) {		LIST_REMOVE(wk, wk_list);		if (wktail == 0)			LIST_INSERT_HEAD(&newbp->b_dep, wk, wk_list);		else			LIST_INSERT_AFTER(wktail, wk, wk_list);		wktail = wk;	}	FREE_LOCK(&lk);}/* * Purge the work list of all items associated with a particular mount point. */intsoftdep_flushworklist(oldmnt, countp, p)	struct mount *oldmnt;	int *countp;	struct proc *p;{	struct vnode *devvp;	int count, error = 0;	/*	 * Await our turn to clear out the queue, then serialize access.	 */	while (softdep_worklist_busy) {		softdep_worklist_req += 1;		tsleep(&softdep_worklist_req, PRIBIO, "softflush", 0);		softdep_worklist_req -= 1;	}	softdep_worklist_busy = -1;	/*	 * Alternately flush the block device associated with the mount	 * point and process any dependencies that the flushing	 * creates. We continue until no more worklist dependencies	 * are found.	 */	*countp = 0;	devvp = VFSTOUFS(oldmnt)->um_devvp;	while ((count = softdep_process_worklist(oldmnt)) > 0) {		*countp += count;		vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);		error = VOP_FSYNC(devvp, p->p_ucred, MNT_WAIT, p);		VOP_UNLOCK(devvp, 0, p);		if (error)			break;	}	softdep_worklist_busy = 0;	if (softdep_worklist_req)		wakeup(&softdep_worklist_req);	return (error);}/* * Flush all vnodes and worklist items associated with a specified mount point. */intsoftdep_flushfiles(oldmnt, flags, p)	struct mount *oldmnt;	int flags;	struct proc *p;{	int error, count, loopcnt;	/*	 * Alternately flush the vnodes associated with the mount	 * point and process any dependencies that the flushing	 * creates. In theory, this loop can happen at most twice,	 * but we give it a few extra just to be sure.	 */	for (loopcnt = 10; loopcnt > 0; loopcnt--) {		/*		 * Do another flush in case any vnodes were brought in		 * as part of the cleanup operations.		 */		if ((error = ffs_flushfiles(oldmnt, flags, p)) != 0)			break;		if ((error = softdep_flushworklist(oldmnt, &count, p)) != 0 ||		    count == 0)			break;	}	/*	 * If we are unmounting then it is an error to fail. If we	 * are simply trying to downgrade to read-only, then filesystem	 * activity can keep us busy forever, so we just fail with EBUSY.	 */	if (loopcnt == 0) {		if (oldmnt->mnt_flag & MNT_UNMOUNT)			panic("softdep_flushfiles: looping");		error = EBUSY;	}	return (error);}/* * Structure hashing. *  * There are three types of structures that can be looked up: *	1) pagedep structures identified by mount point, inode number, *	   and logical block. *	2) inodedep structures identified by mount point and inode number. *	3) newblk structures identified by mount point and *	   physical block number. * * The "pagedep" and "inodedep" dependency structures are hashed * separately from the file blocks and inodes to which they correspond. * This separation helps when the in-memory copy of an inode or * file block must be replaced. It also obviates the need to access * an inode or file page when simply updating (or de-allocating) * dependency structures. Lookup of newblk structures is needed to * find newly allocated blocks when trying to associate them with * their allocdirect or allocindir structure. * * The lookup routines optionally create and hash a new instance when * an existing entry is not found. */#define DEPALLOC	0x0001	/* allocate structure if lookup fails */#define NODELAY         0x0002  /* cannot do background work *//* * Structures and routines associated with pagedep caching. */LIST_HEAD(pagedep_hashhead, pagedep) *pagedep_hashtbl;u_long	pagedep_hash;		/* size of hash table - 1 */#define	PAGEDEP_HASH(mp, inum, lbn) \	(&pagedep_hashtbl[((((register_t)(mp)) >> 13) + (inum) + (lbn)) & \	    pagedep_hash])STATIC struct sema pagedep_in_progress;/* * Look up a pagedep. Return 1 if found, 0 if not found. * If not found, allocate if DEPALLOC flag is passed. * Found or allocated entry is returned in pagedeppp. * This routine must be called with splbio interrupts blocked. */STATIC intpagedep_lookup(ip, lbn, flags, pagedeppp)	struct inode *ip;	ufs_lbn_t lbn;	int flags;	struct pagedep **pagedeppp;{	struct pagedep *pagedep;	struct pagedep_hashhead *pagedephd;	struct mount *mp;	int i;#ifdef DEBUG	if (lk.lkt_held == -1)		panic("pagedep_lookup: lock not held");#endif	mp = ITOV(ip)->v_mount;	pagedephd = PAGEDEP_HASH(mp, ip->i_number, lbn);top:	LIST_FOREACH(pagedep, pagedephd, pd_hash)		if (ip->i_number == pagedep->pd_ino &&		    lbn == pagedep->pd_lbn &&		    mp == pagedep->pd_mnt)			break;	if (pagedep) {		*pagedeppp = pagedep;		return (1);	}	if ((flags & DEPALLOC) == 0) {		*pagedeppp = NULL;		return (0);	}	if (sema_get(&pagedep_in_progress, &lk) == 0) {		ACQUIRE_LOCK(&lk);		goto top;	}	MALLOC(pagedep, struct pagedep *, sizeof(struct pagedep), M_PAGEDEP,		M_SOFTDEP_FLAGS);	bzero(pagedep, sizeof(struct pagedep));	pagedep->pd_list.wk_type = D_PAGEDEP;	pagedep->pd_mnt = mp;	pagedep->pd_ino = ip->i_number;	pagedep->pd_lbn = lbn;	LIST_INIT(&pagedep->pd_dirremhd);	LIST_INIT(&pagedep->pd_pendinghd);	for (i = 0; i < DAHASHSZ; i++)		LIST_INIT(&pagedep->pd_diraddhd[i]);	ACQUIRE_LOCK(&lk);	LIST_INSERT_HEAD(pagedephd, pagedep, pd_hash);	sema_release(&pagedep_in_progress);	*pagedeppp = pagedep;	return (0);}/* * Structures and routines associated with inodedep caching. */LIST_HEAD(inodedep_hashhead, inodedep) *inodedep_hashtbl;STATIC u_long	inodedep_hash;	/* size of hash table - 1 */STATIC long	num_inodedep;	/* number of inodedep allocated */#define	INODEDEP_HASH(fs, inum) \      (&inodedep_hashtbl[((((register_t)(fs)) >> 13) + (inum)) & inodedep_hash])STATIC struct sema inodedep_in_progress;/* * Look up a inodedep. Return 1 if found, 0 if not found. * If not found, allocate if DEPALLOC flag is passed. * Found or allocated entry is returned in inodedeppp. * This routine must be called with splbio interrupts blocked. */STATIC intinodedep_lookup(fs, inum, flags, inodedeppp)	struct fs *fs;	ino_t inum;	int flags;	struct inodedep **inodedeppp;{	struct inodedep *inodedep;	struct inodedep_hashhead *inodedephd;	int firsttry;#ifdef DEBUG	if (lk.lkt_held == -1)		panic("inodedep_lookup: lock not held");#endif	firsttry = 1;	inodedephd = INODEDEP_HASH(fs, inum);top:	LIST_FOREACH(inodedep, inodedephd, id_hash)		if (inum == inodedep->id_ino && fs == inodedep->id_fs)			break;	if (inodedep) {		*inodedeppp = inodedep;		return (1);	}	if ((flags & DEPALLOC) == 0) {		*inodedeppp = NULL;		return (0);	}	/*	 * If we are over our limit, try to improve the situation.	 */	if (num_inodedep > max_softdeps && firsttry && (flags & NODELAY) == 0 &&	    request_cleanup(FLUSH_INODES, 1)) {		firsttry = 0;		goto top;	}	if (sema_get(&inodedep_in_progress, &lk) == 0) {		ACQUIRE_LOCK(&lk);		goto top;	}	num_inodedep += 1;	MALLOC(inodedep, struct inodedep *, sizeof(struct inodedep),		M_INODEDEP, M_SOFTDEP_FLAGS);	inodedep->id_list.wk_type = D_INODEDEP;	inodedep->id_fs = fs;	inodedep->id_ino = inum;	inodedep->id_state = ALLCOMPLETE;	inodedep->id_nlinkdelta = 0;	inodedep->id_savedino = NULL;	inodedep->id_savedsize = -1;	inodedep->id_buf = NULL;	LIST_INIT(&inodedep->id_pendinghd);	LIST_INIT(&inodedep->id_inowait);	LIST_INIT(&inodedep->id_bufwait);	TAILQ_INIT(&inodedep->id_inoupdt);	TAILQ_INIT(&inodedep->id_newinoupdt);	ACQUIRE_LOCK(&lk);	LIST_INSERT_HEAD(inodedephd, inodedep, id_hash);	sema_release(&inodedep_in_progress);	*inodedeppp = inodedep;	return (0);}/* * Structures and routines associated with newblk caching. */LIST_HEAD(newblk_hashhead, newblk) *newblk_hashtbl;u_long	newblk_hash;		/* size of hash table - 1 */#define	NEWBLK_HASH(fs, inum) \	(&newblk_hashtbl[((((register_t)(fs)) >> 13) + (inum)) & newblk_hash])STATIC struct sema newblk_in_progress;/* * Look up a newblk. Return 1 if found, 0 if not found. * If not found, allocate if DEPALLOC flag is passed. * Found or allocated entry is returned in newblkpp. */STATIC intnewblk_lookup(fs, newblkno, flags, newblkpp)	struct fs *fs;	ufs_daddr_t newblkno;	int flags;	struct newblk **newblkpp;{	struct newblk *newblk;	struct newblk_hashhead *newblkhd;	newblkhd = NEWBLK_HASH(fs, newblkno);top:	LIST_FOREACH(newblk, newblkhd, nb_hash)		if (newblkno == newblk->nb_newblkno && fs == newblk->nb_fs)			break;	if (newblk) {		*newblkpp = newblk;		return (1);	}	if ((flags & DEPALLOC) == 0) {		*newblkpp = NULL;		return (0);	}	if (sema_get(&newblk_in_progress, 0) == 0)		goto top;	MALLOC(newblk, struct newblk *, sizeof(struct newblk),		M_NEWBLK, M_SOFTDEP_FLAGS);	newblk->nb_state = 0;	newblk->nb_fs = fs;	newblk->nb_newblkno = newblkno;	LIST_INSERT_HEAD(newblkhd, newblk, nb_hash);	sema_release(&newblk_in_progress);	*newblkpp = newblk;	return (0);}/* * Executed during filesystem system initialization before * mounting any file systems. */void softdep_initialize(){	int i;	LIST_INIT(&mkdirlisthd);	LIST_INIT(&softdep_workitem_pending);#ifdef KMEMSTATS	max_softdeps = min (desiredvnodes * 8,	    kmemstats[M_INODEDEP].ks_limit / (2 * sizeof(struct inodedep)));#else	max_softdeps = desiredvnodes * 4;#endif	pagedep_hashtbl = hashinit(desiredvnodes / 5, M_PAGEDEP, M_WAITOK,	    &pagedep_hash);	sema_init(&pagedep_in_progress, "pagedep", PRIBIO, 0);	inodedep_hashtbl = hashinit(desiredvnodes, M_INODEDEP, M_WAITOK,	    &inodedep_hash);	sema_init(&inodedep_in_progress, "inodedep", PRIBIO, 0);	newblk_hashtbl = hashinit(64, M_NEWBLK, M_WAITOK, &newblk_hash);	sema_init(&newblk_in_progress, "newblk", PRIBIO, 0);	timeout_set(&proc_waiting_timeout, pause_timer, 0);	pool_init(&sdpcpool, sizeof(struct buf), 0, 0, 0, "sdpcpool",	    0, pool_page_alloc_nointr, pool_page_free_nointr, M_TEMP);	for (i = 0; i < PCBPHASHSIZE; i++) {		LIST_INIT(&pcbphashhead[i]);	}}/* * Called at mount time to notify the dependency code that a * filesystem wishes to use it. */intsoftdep_mount(devvp, mp, fs, cred)	struct vnode *devvp;	struct mount *mp;	struct fs *fs;	struct ucred *cred;{	struct csum cstotal;	struct cg *cgp;	struct buf *bp;	int error, cyl;	/*	 * When doing soft updates, the counters in the	 * superblock may have gotten out of sync, so we have	 * to scan the cylinder groups and recalculate them.	 */	if ((fs->fs_flags & FS_UNCLEAN) == 0)		return (0);	bzero(&cstotal, sizeof cstotal);	for (cyl = 0; cyl < fs->fs_ncg; cyl++) {		if ((error = bread(devvp, fsbtodb(fs, cgtod(fs, cyl)),		    fs->fs_cgsize, cred, &bp)) != 0) {			brelse(bp);			return (error);		}		cgp = (struct cg *)bp->b_data;		cstotal.cs_nffree += cgp->cg_cs.cs_nffree;		cstotal.cs_nbfree += cgp->cg_cs.cs_nbfree;		cstotal.cs_nifree += cgp->cg_cs.cs_nifree;		cstotal.cs_ndir += cgp->cg_cs.cs_ndir;		fs->fs_cs(fs, cyl) = cgp->cg_cs;		brelse(bp);	}#ifdef DEBUG	if (bcmp(&cstotal, &fs->fs_cstotal, sizeof cstotal))		printf("ffs_mountfs: superblock updated for soft updates\n");#endif	bcopy(&cstotal, &fs->fs_cstotal, sizeof cstotal);	return (0);}/* * Protecting the freemaps (or bitmaps). *  * To eliminate the need to execute fsck before mounting a file system * after a power failure, one must (conservatively) guarantee that the * on-disk copy of the bitmaps never indicate that a live inode or block is * free.  So, when a block or inode is allocated, the bitmap should be * updated (on disk) before any new pointers.  When a block or inode is * freed, the bitmap should not be updated until all pointers have been * reset.  The latter dependency is handled by the delayed de-allocation * approach described below for block and inode de-allocation.  The former * dependency is handled by calling the following procedure when a block or * inode is allocated. When an inode is allocated an "inodedep" is created * with its DEPCOMPLETE flag cleared until its bitmap is written to disk. * Each "inodedep" is also inserted into the hash indexing structure so * that any additional link additions can be made dependent on the inode * allocation. *  * The ufs file system maintains a number of free block counts (e.g., per * cylinder group, per cylinder and per <cylinder, rotational position> pair) * in addition to the bitmaps.  These counts are used to improve efficiency * during allocation and therefore must be consistent with the bitmaps. * There is no convenient way to guarantee post-crash consistency of these * counts with simple update ordering, for two main reasons: (1) The counts * and bitmaps for a single cylinder group block are not in the same disk * sector.  If a disk write is interrupted (e.g., by power failure), one may * be written and the other not.  (2) Some of the counts are located in the * superblock rather than the cylinder group block. So, we focus our soft * updates implementation on protecting the bitmaps. When mounting a * filesystem, we recompute the auxiliary counts from the bitmaps. *//* * Called just after updating the cylinder group block to allocate an inode. */voidsoftdep_setup_inomapdep(bp, ip, newinum)	struct buf *bp;		/* buffer for cylgroup block with inode map */	struct inode *ip;	/* inode related to allocation */	ino_t newinum;		/* new inode number being allocated */{	struct inodedep *inodedep;	struct bmsafemap *bmsafemap;	/*	 * Create a dependency for the newly allocated inode.	 * Panic if it already exists as something is seriously wrong.	 * Otherwise add it to the dependency list for the buffer holding	 * the cylinder group map from which it was allocated.	 */	ACQUIRE_LOCK(&lk);	if (inodedep_lookup(ip->i_fs, newinum, DEPALLOC | NODELAY, &inodedep)	    != 0) {		FREE_LOCK(&lk);		panic("softdep_setup_inomapdep: found inode");	}	inodedep->id_buf = bp;	inodedep->id_state &= ~DEPCOMPLETE;	bmsafemap = bmsafemap_lookup(bp);	LIST_INSERT_HEAD(&bmsafemap->sm_inodedephd, inodedep, id_deps);	FREE_LOCK(&lk);}/* * Called just after updating the cylinder group block to * allocate block or fragment. */voidsoftdep_setup_blkmapdep(bp, fs, newblkno)	struct buf *bp;		/* buffer for cylgroup block with block map */	struct fs *fs;		/* filesystem doing allocation */	ufs_daddr_t newblkno;	/* number of newly allocated block */{	struct newblk *newblk;	struct bmsafemap *bmsafemap;	/*	 * Create a dependency for the newly allocated block.	 * Add it to the dependency list for the buffer holding	 * the cylinder group map from which it was allocated.	 */	if (newblk_lookup(fs, newblkno, DEPALLOC, &newblk) != 0)		panic("softdep_setup_blkmapdep: found block");	ACQUIRE_LOCK(&lk);	newblk->nb_bmsafemap = bmsafemap = bmsafemap_lookup(bp);	LIST_INSERT_HEAD(&bmsafemap->sm_newblkhd, newblk, nb_deps);	FREE_LOCK(&lk);}/* * Find the bmsafemap associated with a cylinder group buffer. * If none exists, create one. The buffer must be locked when * this routine is called and this routine must be called with * splbio interrupts blocked. */STATIC struct bmsafemap *bmsafemap_lookup(bp)	struct buf *bp;{	struct bmsafemap *bmsafemap;	struct worklist *wk;#ifdef DEBUG	if (lk.lkt_held == -1)		panic("bmsafemap_lookup: lock not held");#endif	LIST_FOREACH(wk, &bp->b_dep, wk_list)		if (wk->wk_type == D_BMSAFEMAP)			return (WK_BMSAFEMAP(wk));	FREE_LOCK(&lk);	MALLOC(bmsafemap, struct bmsafemap *, sizeof(struct bmsafemap),		M_BMSAFEMAP, M_SOFTDEP_FLAGS);	bmsafemap->sm_list.wk_type = D_BMSAFEMAP;	bmsafemap->sm_list.wk_state = 0;	bmsafemap->sm_buf = bp;	LIST_INIT(&bmsafemap->sm_allocdirecthd);	LIST_INIT(&bmsafemap->sm_allocindirhd);	LIST_INIT(&bmsafemap->sm_inodedephd);	LIST_INIT(&bmsafemap->sm_newblkhd);	ACQUIRE_LOCK(&lk);	WORKLIST_INSERT(&bp->b_dep, &bmsafemap->sm_list);	return (bmsafemap);}/* * Direct block allocation dependencies. *  * When a new block is allocated, the corresponding disk locations must be * initialized (with zeros or new data) before the on-disk inode points to * them.  Also, the freemap from which the block was allocated must be * updated (on disk) before the inode's pointer. These two dependencies are * independent of each other and are needed for all file blocks and indirect * blocks that are pointed to directly by the inode.  Just before the * "in-core" version of the inode is updated with a newly allocated block * number, a procedure (below) is called to setup allocation dependency * structures.  These structures are removed when the corresponding * dependencies are satisfied or when the block allocation becomes obsolete * (i.e., the file is deleted, the block is de-allocated, or the block is a * fragment that gets upgraded).  All of these cases are handled in * procedures described later. *  * When a file extension causes a fragment to be upgraded, either to a larger * fragment or to a full block, the on-disk location may change (if the * previous fragment could not simply be extended). In this case, the old * fragment must be de-allocated, but not until after the inode's pointer has * been updated. In most cases, this is handled by later procedures, which * will construct a "freefrag" structure to be added to the workitem queue * when the inode update is complete (or obsolete).  The main exception to * this is when an allocation occurs while a pending allocation dependency * (for the same block pointer) remains.  This case is handled in the main * allocation dependency setup procedure by immediately freeing the * unreferenced fragments. */ void softdep_setup_allocdirect(ip, lbn, newblkno, oldblkno, newsize, oldsize, bp)	struct inode *ip;	/* inode to which block is being added */	ufs_lbn_t lbn;		/* block pointer within inode */	ufs_daddr_t newblkno;	/* disk block number being added */	ufs_daddr_t oldblkno;	/* previous block number, 0 unless frag */	long newsize;		/* size of new block */	long oldsize;		/* size of new block */	struct buf *bp;		/* bp for allocated block */{	struct allocdirect *adp, *oldadp;	struct allocdirectlst *adphead;	struct bmsafemap *bmsafemap;	struct inodedep *inodedep;	struct pagedep *pagedep;	struct newblk *newblk;	MALLOC(adp, struct allocdirect *, sizeof(struct allocdirect),		M_ALLOCDIRECT, M_SOFTDEP_FLAGS);	bzero(adp, sizeof(struct allocdirect));	adp->ad_list.wk_type = D_ALLOCDIRECT;	adp->ad_lbn = lbn;	adp->ad_newblkno = newblkno;	adp->ad_oldblkno = oldblkno;	adp->ad_newsize = newsize;	adp->ad_oldsize = oldsize;	adp->ad_state = ATTACHED;	if (newblkno == oldblkno)		adp->ad_freefrag = NULL;	else		adp->ad_freefrag = newfreefrag(ip, oldblkno, oldsize);	if (newblk_lookup(ip->i_fs, newblkno, 0, &newblk) == 0)		panic("softdep_setup_allocdirect: lost block");	ACQUIRE_LOCK(&lk);	inodedep_lookup(ip->i_fs, ip->i_number, DEPALLOC | NODELAY, &inodedep);	adp->ad_inodedep = inodedep;	if (newblk->nb_state == DEPCOMPLETE) {		adp->ad_state |= DEPCOMPLETE;		adp->ad_buf = NULL;	} else {		bmsafemap = newblk->nb_bmsafemap;		adp->ad_buf = bmsafemap->sm_buf;		LIST_REMOVE(newblk, nb_deps);		LIST_INSERT_HEAD(&bmsafemap->sm_allocdirecthd, adp, ad_deps);	}	LIST_REMOVE(newblk, nb_hash);	FREE(newblk, M_NEWBLK);	/*	 * If we were not passed a bp to attach the dep to,	 * then this must be for a regular file.	 * Allocate a buffer to represent the page cache pages	 * that are the real dependency.  The pages themselves	 * cannot refer to the dependency since we don't want to	 * add a field to struct vm_page for this.	 */	if (bp == NULL) {		bp = softdep_setup_pagecache(ip, lbn, newsize);	}	WORKLIST_INSERT(&bp->b_dep, &adp->ad_list);	if (lbn >= NDADDR) {		/* allocating an indirect block */		if (oldblkno != 0) {			FREE_LOCK(&lk);			panic("softdep_setup_allocdirect: non-zero indir");		}	} else {		/*		 * Allocating a direct block.		 *		 * If we are allocating a directory block, then we must		 * allocate an associated pagedep to track additions and		 * deletions.		 */		if ((ip->i_ffs_mode & IFMT) == IFDIR &&		    pagedep_lookup(ip, lbn, DEPALLOC, &pagedep) == 0)			WORKLIST_INSERT(&bp->b_dep, &pagedep->pd_list);	}	/*	 * The list of allocdirects must be kept in sorted and ascending	 * order so that the rollback routines can quickly determine the	 * first uncommitted block (the size of the file stored on disk	 * ends at the end of the lowest committed fragment, or if there	 * are no fragments, at the end of the highest committed block).	 * Since files generally grow, the typical case is that the new	 * block is to be added at the end of the list. We speed this	 * special case by checking against the last allocdirect in the	 * list before laboriously traversing the list looking for the	 * insertion point.	 */	adphead = &inodedep->id_newinoupdt;	oldadp = TAILQ_LAST(adphead, allocdirectlst);	if (oldadp == NULL || oldadp->ad_lbn <= lbn) {		/* insert at end of list */		TAILQ_INSERT_TAIL(adphead, adp, ad_next);		if (oldadp != NULL && oldadp->ad_lbn == lbn)			allocdirect_merge(adphead, adp, oldadp);		FREE_LOCK(&lk);		return;	}	TAILQ_FOREACH(oldadp, adphead, ad_next) {		if (oldadp->ad_lbn >= lbn)			break;	}	if (oldadp == NULL) {		FREE_LOCK(&lk);		panic("softdep_setup_allocdirect: lost entry");	}	/* insert in middle of list */	TAILQ_INSERT_BEFORE(oldadp, adp, ad_next);	if (oldadp->ad_lbn == lbn)		allocdirect_merge(adphead, adp, oldadp);	FREE_LOCK(&lk);}/* * Replace an old allocdirect dependency with a newer one. * This routine must be called with splbio interrupts blocked. */STATIC voidallocdirect_merge(adphead, newadp, oldadp)	struct allocdirectlst *adphead;	/* head of list holding allocdirects */	struct allocdirect *newadp;	/* allocdirect being added */	struct allocdirect *oldadp;	/* existing allocdirect being checked */{	struct freefrag *freefrag;#ifdef DEBUG	if (lk.lkt_held == -1)		panic("allocdirect_merge: lock not held");#endif	if (newadp->ad_oldblkno != oldadp->ad_newblkno ||	    newadp->ad_oldsize != oldadp->ad_newsize ||	    newadp->ad_lbn >= NDADDR) {		FREE_LOCK(&lk);		panic("allocdirect_check: old %d != new %d || lbn %ld >= %d",		    newadp->ad_oldblkno, oldadp->ad_newblkno, newadp->ad_lbn,		    NDADDR);	}	newadp->ad_oldblkno = oldadp->ad_oldblkno;	newadp->ad_oldsize = oldadp->ad_oldsize;	/*	 * If the old dependency had a fragment to free or had never	 * previously had a block allocated, then the new dependency	 * can immediately post its freefrag and adopt the old freefrag.	 * This action is done by swapping the freefrag dependencies.	 * The new dependency gains the old one's freefrag, and the	 * old one gets the new one and then immediately puts it on	 * the worklist when it is freed by free_allocdirect. It is	 * not possible to do this swap when the old dependency had a	 * non-zero size but no previous fragment to free. This condition	 * arises when the new block is an extension of the old block.	 * Here, the first part of the fragment allocated to the new	 * dependency is part of the block currently claimed on disk by	 * the old dependency, so cannot legitimately be freed until the	 * conditions for the new dependency are fulfilled.	 */	if (oldadp->ad_freefrag != NULL || oldadp->ad_oldblkno == 0) {		freefrag = newadp->ad_freefrag;		newadp->ad_freefrag = oldadp->ad_freefrag;		oldadp->ad_freefrag = freefrag;	}	free_allocdirect(adphead, oldadp, 0);}		/* * Allocate a new freefrag structure if needed. */STATIC struct freefrag *newfreefrag(ip, blkno, size)	struct inode *ip;	ufs_daddr_t blkno;	long size;{	struct freefrag *freefrag;	struct fs *fs;	if (blkno == 0)		return (NULL);	fs = ip->i_fs;	if (fragnum(fs, blkno) + numfrags(fs, size) > fs->fs_frag)		panic("newfreefrag: frag size");	MALLOC(freefrag, struct freefrag *, sizeof(struct freefrag),		M_FREEFRAG, M_SOFTDEP_FLAGS);	freefrag->ff_list.wk_type = D_FREEFRAG;	freefrag->ff_state = ip->i_ffs_uid & ~ONWORKLIST; /* XXX - used below */	freefrag->ff_inum = ip->i_number;	freefrag->ff_mnt = ITOV(ip)->v_mount;	freefrag->ff_devvp = ip->i_devvp;	freefrag->ff_blkno = blkno;	freefrag->ff_fragsize = size;	return (freefrag);}/* * This workitem de-allocates fragments that were replaced during * file block allocation. */STATIC void handle_workitem_freefrag(freefrag)	struct freefrag *freefrag;{	struct inode tip;	tip.i_vnode = NULL;	tip.i_fs = VFSTOUFS(freefrag->ff_mnt)->um_fs;	tip.i_devvp = freefrag->ff_devvp;	tip.i_dev = freefrag->ff_devvp->v_rdev;	tip.i_number = freefrag->ff_inum;	tip.i_ffs_uid = freefrag->ff_state & ~ONWORKLIST; /* XXX - set above */	ffs_blkfree(&tip, freefrag->ff_blkno, freefrag->ff_fragsize);	FREE(freefrag, M_FREEFRAG);}/* * Indirect block allocation dependencies. *  * The same dependencies that exist for a direct block also exist when * a new block is allocated and pointed to by an entry in a block of * indirect pointers. The undo/redo states described above are also * used here. Because an indirect block contains many pointers that * may have dependencies, a second copy of the entire in-memory indirect * block is kept. The buffer cache copy is always completely up-to-date. * The second copy, which is used only as a source for disk writes, * contains only the safe pointers (i.e., those that have no remaining * update dependencies). The second copy is freed when all pointers * are safe. The cache is not allowed to replace indirect blocks with * pending update dependencies. If a buffer containing an indirect * block with dependencies is written, these routines will mark it * dirty again. It can only be successfully written once all the * dependencies are removed. The ffs_fsync routine in conjunction with * softdep_sync_metadata work together to get all the dependencies * removed so that a file can be successfully written to disk. Three * procedures are used when setting up indirect block pointer * dependencies. The division is necessary because of the organization * of the "balloc" routine and because of the distinction between file * pages and file metadata blocks. *//* * Allocate a new allocindir structure. */STATIC struct allocindir *newallocindir(ip, ptrno, newblkno, oldblkno)	struct inode *ip;	/* inode for file being extended */	int ptrno;		/* offset of pointer in indirect block */	ufs_daddr_t newblkno;	/* disk block number being added */	ufs_daddr_t oldblkno;	/* previous block number, 0 if none */{	struct allocindir *aip;	MALLOC(aip, struct allocindir *, sizeof(struct allocindir),		M_ALLOCINDIR, M_SOFTDEP_FLAGS);	bzero(aip,sizeof(struct allocindir));	aip->ai_list.wk_type = D_ALLOCINDIR;	aip->ai_state = ATTACHED;	aip->ai_offset = ptrno;	aip->ai_newblkno = newblkno;	aip->ai_oldblkno = oldblkno;	aip->ai_freefrag = newfreefrag(ip, oldblkno, ip->i_fs->fs_bsize);	return (aip);}