Home | History | Annotate | Line # | Download | only in lfs
lfs_alloc.c revision 1.83.2.6
      1  1.83.2.6      yamt /*	$NetBSD: lfs_alloc.c,v 1.83.2.6 2008/01/21 09:48:10 yamt Exp $	*/
      2       1.2       cgd 
      3      1.17  perseant /*-
      4  1.83.2.3      yamt  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007 The NetBSD Foundation, Inc.
      5      1.17  perseant  * All rights reserved.
      6      1.17  perseant  *
      7      1.17  perseant  * This code is derived from software contributed to The NetBSD Foundation
      8      1.17  perseant  * by Konrad E. Schroder <perseant (at) hhhh.org>.
      9      1.17  perseant  *
     10      1.17  perseant  * Redistribution and use in source and binary forms, with or without
     11      1.17  perseant  * modification, are permitted provided that the following conditions
     12      1.17  perseant  * are met:
     13      1.17  perseant  * 1. Redistributions of source code must retain the above copyright
     14      1.17  perseant  *    notice, this list of conditions and the following disclaimer.
     15      1.17  perseant  * 2. Redistributions in binary form must reproduce the above copyright
     16      1.17  perseant  *    notice, this list of conditions and the following disclaimer in the
     17      1.17  perseant  *    documentation and/or other materials provided with the distribution.
     18      1.17  perseant  * 3. All advertising materials mentioning features or use of this software
     19      1.17  perseant  *    must display the following acknowledgement:
     20      1.64  perseant  *	This product includes software developed by the NetBSD
     21      1.64  perseant  *	Foundation, Inc. and its contributors.
     22      1.17  perseant  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23      1.17  perseant  *    contributors may be used to endorse or promote products derived
     24      1.17  perseant  *    from this software without specific prior written permission.
     25      1.17  perseant  *
     26      1.17  perseant  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27      1.17  perseant  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28      1.17  perseant  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29      1.17  perseant  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30      1.17  perseant  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31      1.17  perseant  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32      1.17  perseant  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33      1.17  perseant  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34      1.17  perseant  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35      1.17  perseant  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36      1.17  perseant  * POSSIBILITY OF SUCH DAMAGE.
     37      1.17  perseant  */
     38       1.1   mycroft /*
     39       1.1   mycroft  * Copyright (c) 1991, 1993
     40       1.1   mycroft  *	The Regents of the University of California.  All rights reserved.
     41       1.1   mycroft  *
     42       1.1   mycroft  * Redistribution and use in source and binary forms, with or without
     43       1.1   mycroft  * modification, are permitted provided that the following conditions
     44       1.1   mycroft  * are met:
     45       1.1   mycroft  * 1. Redistributions of source code must retain the above copyright
     46       1.1   mycroft  *    notice, this list of conditions and the following disclaimer.
     47       1.1   mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     48       1.1   mycroft  *    notice, this list of conditions and the following disclaimer in the
     49       1.1   mycroft  *    documentation and/or other materials provided with the distribution.
     50      1.71       agc  * 3. Neither the name of the University nor the names of its contributors
     51       1.1   mycroft  *    may be used to endorse or promote products derived from this software
     52       1.1   mycroft  *    without specific prior written permission.
     53       1.1   mycroft  *
     54       1.1   mycroft  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     55       1.1   mycroft  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     56       1.1   mycroft  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     57       1.1   mycroft  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     58       1.1   mycroft  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     59       1.1   mycroft  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     60       1.1   mycroft  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     61       1.1   mycroft  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     62       1.1   mycroft  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     63       1.1   mycroft  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     64       1.1   mycroft  * SUCH DAMAGE.
     65       1.1   mycroft  *
     66       1.2       cgd  *	@(#)lfs_alloc.c	8.4 (Berkeley) 1/4/94
     67       1.1   mycroft  */
     68      1.52     lukem 
     69      1.52     lukem #include <sys/cdefs.h>
     70  1.83.2.6      yamt __KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.83.2.6 2008/01/21 09:48:10 yamt Exp $");
     71      1.12    scottr 
     72      1.47       mrg #if defined(_KERNEL_OPT)
     73      1.12    scottr #include "opt_quota.h"
     74      1.13    scottr #endif
     75       1.1   mycroft 
     76       1.1   mycroft #include <sys/param.h>
     77       1.3  christos #include <sys/systm.h>
     78       1.1   mycroft #include <sys/kernel.h>
     79       1.1   mycroft #include <sys/buf.h>
     80      1.56  perseant #include <sys/lock.h>
     81       1.1   mycroft #include <sys/vnode.h>
     82       1.1   mycroft #include <sys/syslog.h>
     83       1.1   mycroft #include <sys/mount.h>
     84  1.83.2.1      yamt #include <sys/malloc.h>
     85      1.15   thorpej #include <sys/pool.h>
     86      1.50       chs #include <sys/proc.h>
     87      1.81  perseant #include <sys/tree.h>
     88  1.83.2.1      yamt #include <sys/kauth.h>
     89       1.1   mycroft 
     90       1.1   mycroft #include <ufs/ufs/quota.h>
     91       1.1   mycroft #include <ufs/ufs/inode.h>
     92       1.1   mycroft #include <ufs/ufs/ufsmount.h>
     93       1.3  christos #include <ufs/ufs/ufs_extern.h>
     94       1.1   mycroft 
     95       1.1   mycroft #include <ufs/lfs/lfs.h>
     96       1.1   mycroft #include <ufs/lfs/lfs_extern.h>
     97       1.1   mycroft 
     98  1.83.2.3      yamt extern kmutex_t ufs_hashlock;
     99      1.17  perseant 
    100  1.83.2.1      yamt /* Constants for inode free bitmap */
    101  1.83.2.1      yamt #define BMSHIFT 5	/* 2 ** 5 = 32 */
    102  1.83.2.1      yamt #define BMMASK  ((1 << BMSHIFT) - 1)
    103  1.83.2.1      yamt #define SET_BITMAP_FREE(F, I) do { \
    104  1.83.2.1      yamt 	DLOG((DLOG_ALLOC, "lfs: ino %d wrd %d bit %d set\n", (int)(I), 	\
    105  1.83.2.1      yamt 	     (int)((I) >> BMSHIFT), (int)((I) & BMMASK)));		\
    106  1.83.2.1      yamt 	(F)->lfs_ino_bitmap[(I) >> BMSHIFT] |= (1 << ((I) & BMMASK));	\
    107  1.83.2.1      yamt } while (0)
    108  1.83.2.1      yamt #define CLR_BITMAP_FREE(F, I) do { \
    109  1.83.2.1      yamt 	DLOG((DLOG_ALLOC, "lfs: ino %d wrd %d bit %d clr\n", (int)(I), 	\
    110  1.83.2.1      yamt 	     (int)((I) >> BMSHIFT), (int)((I) & BMMASK)));		\
    111  1.83.2.1      yamt 	(F)->lfs_ino_bitmap[(I) >> BMSHIFT] &= ~(1 << ((I) & BMMASK));	\
    112  1.83.2.1      yamt } while(0)
    113  1.83.2.1      yamt 
    114  1.83.2.1      yamt #define ISSET_BITMAP_FREE(F, I) \
    115  1.83.2.1      yamt 	((F)->lfs_ino_bitmap[(I) >> BMSHIFT] & (1 << ((I) & BMMASK)))
    116  1.83.2.1      yamt 
    117      1.44  perseant /*
    118      1.65  perseant  * Add a new block to the Ifile, to accommodate future file creations.
    119      1.65  perseant  * Called with the segment lock held.
    120      1.56  perseant  */
    121  1.83.2.2      yamt int
    122  1.83.2.2      yamt lfs_extend_ifile(struct lfs *fs, kauth_cred_t cred)
    123      1.44  perseant {
    124      1.44  perseant 	struct vnode *vp;
    125      1.44  perseant 	struct inode *ip;
    126      1.44  perseant 	IFILE *ifp;
    127      1.48  perseant 	IFILE_V1 *ifp_v1;
    128      1.48  perseant 	struct buf *bp, *cbp;
    129      1.44  perseant 	int error;
    130      1.83  christos 	daddr_t i, blkno, xmax;
    131  1.83.2.1      yamt 	ino_t oldlast, maxino;
    132      1.48  perseant 	CLEANERINFO *cip;
    133      1.44  perseant 
    134      1.78  perseant 	ASSERT_SEGLOCK(fs);
    135      1.78  perseant 
    136      1.44  perseant 	vp = fs->lfs_ivnode;
    137      1.44  perseant 	ip = VTOI(vp);
    138      1.66      fvdl 	blkno = lblkno(fs, ip->i_size);
    139  1.83.2.1      yamt 	if ((error = lfs_balloc(vp, ip->i_size, fs->lfs_bsize, cred, 0,
    140      1.44  perseant 				&bp)) != 0) {
    141      1.44  perseant 		return (error);
    142      1.44  perseant 	}
    143      1.66      fvdl 	ip->i_size += fs->lfs_bsize;
    144      1.66      fvdl 	ip->i_ffs1_size = ip->i_size;
    145      1.66      fvdl 	uvm_vnp_setsize(vp, ip->i_size);
    146      1.75     perry 
    147  1.83.2.1      yamt 	maxino = ((ip->i_size >> fs->lfs_bshift) - fs->lfs_cleansz -
    148  1.83.2.1      yamt 		  fs->lfs_segtabsz) * fs->lfs_ifpb;
    149  1.83.2.1      yamt 	fs->lfs_ino_bitmap = (lfs_bm_t *)
    150  1.83.2.1      yamt 		realloc(fs->lfs_ino_bitmap, ((maxino + BMMASK) >> BMSHIFT) *
    151  1.83.2.1      yamt 			sizeof(lfs_bm_t), M_SEGMENT, M_WAITOK);
    152  1.83.2.1      yamt 	KASSERT(fs->lfs_ino_bitmap != NULL);
    153  1.83.2.1      yamt 
    154      1.44  perseant 	i = (blkno - fs->lfs_segtabsz - fs->lfs_cleansz) *
    155      1.44  perseant 		fs->lfs_ifpb;
    156  1.83.2.1      yamt 
    157  1.83.2.1      yamt 	/*
    158  1.83.2.1      yamt 	 * We insert the new inodes at the head of the free list.
    159  1.83.2.1      yamt 	 * Under normal circumstances, the free list is empty here,
    160  1.83.2.1      yamt 	 * so we are also incidentally placing them at the end (which
    161  1.83.2.1      yamt 	 * we must do if we are to keep them in order).
    162  1.83.2.1      yamt 	 */
    163      1.48  perseant 	LFS_GET_HEADFREE(fs, cip, cbp, &oldlast);
    164      1.48  perseant 	LFS_PUT_HEADFREE(fs, cip, cbp, i);
    165      1.44  perseant #ifdef DIAGNOSTIC
    166      1.63  perseant 	if (fs->lfs_freehd == LFS_UNUSED_INUM)
    167      1.44  perseant 		panic("inode 0 allocated [2]");
    168      1.44  perseant #endif /* DIAGNOSTIC */
    169      1.83  christos 	xmax = i + fs->lfs_ifpb;
    170      1.48  perseant 
    171      1.53       chs 	if (fs->lfs_version == 1) {
    172      1.83  christos 		for (ifp_v1 = (IFILE_V1 *)bp->b_data; i < xmax; ++ifp_v1) {
    173  1.83.2.1      yamt 			SET_BITMAP_FREE(fs, i);
    174      1.48  perseant 			ifp_v1->if_version = 1;
    175      1.48  perseant 			ifp_v1->if_daddr = LFS_UNUSED_DADDR;
    176      1.48  perseant 			ifp_v1->if_nextfree = ++i;
    177      1.48  perseant 		}
    178      1.48  perseant 		ifp_v1--;
    179      1.48  perseant 		ifp_v1->if_nextfree = oldlast;
    180      1.48  perseant 	} else {
    181      1.83  christos 		for (ifp = (IFILE *)bp->b_data; i < xmax; ++ifp) {
    182  1.83.2.1      yamt 			SET_BITMAP_FREE(fs, i);
    183      1.48  perseant 			ifp->if_version = 1;
    184      1.48  perseant 			ifp->if_daddr = LFS_UNUSED_DADDR;
    185      1.48  perseant 			ifp->if_nextfree = ++i;
    186      1.48  perseant 		}
    187      1.48  perseant 		ifp--;
    188      1.48  perseant 		ifp->if_nextfree = oldlast;
    189      1.44  perseant 	}
    190      1.83  christos 	LFS_PUT_TAILFREE(fs, cip, cbp, xmax - 1);
    191      1.48  perseant 
    192      1.56  perseant 	(void) LFS_BWRITE_LOG(bp); /* Ifile */
    193      1.44  perseant 
    194      1.44  perseant 	return 0;
    195      1.44  perseant }
    196      1.44  perseant 
    197       1.1   mycroft /* Allocate a new inode. */
    198       1.1   mycroft /* ARGSUSED */
    199      1.43  perseant /* VOP_BWRITE 2i times */
    200       1.1   mycroft int
    201  1.83.2.2      yamt lfs_valloc(struct vnode *pvp, int mode, kauth_cred_t cred,
    202  1.83.2.2      yamt     struct vnode **vpp)
    203       1.3  christos {
    204       1.1   mycroft 	struct lfs *fs;
    205      1.48  perseant 	struct buf *bp, *cbp;
    206       1.1   mycroft 	struct ifile *ifp;
    207       1.1   mycroft 	ino_t new_ino;
    208       1.1   mycroft 	int error;
    209      1.36  perseant 	int new_gen;
    210      1.48  perseant 	CLEANERINFO *cip;
    211       1.1   mycroft 
    212  1.83.2.1      yamt 	fs = VTOI(pvp)->i_lfs;
    213      1.38  perseant 	if (fs->lfs_ronly)
    214      1.38  perseant 		return EROFS;
    215      1.75     perry 
    216      1.78  perseant 	ASSERT_NO_SEGLOCK(fs);
    217      1.78  perseant 
    218      1.56  perseant 	lfs_seglock(fs, SEGM_PROT);
    219      1.78  perseant 	vn_lock(fs->lfs_ivnode, LK_EXCLUSIVE);
    220      1.17  perseant 
    221       1.1   mycroft 	/* Get the head of the freelist. */
    222      1.48  perseant 	LFS_GET_HEADFREE(fs, cip, cbp, &new_ino);
    223  1.83.2.1      yamt 	KASSERT(new_ino != LFS_UNUSED_INUM && new_ino != LFS_IFILE_INUM);
    224      1.48  perseant 
    225  1.83.2.1      yamt 	DLOG((DLOG_ALLOC, "lfs_valloc: allocate inode %lld\n",
    226  1.83.2.1      yamt 	     (long long)new_ino));
    227      1.75     perry 
    228       1.1   mycroft 	/*
    229       1.1   mycroft 	 * Remove the inode from the free list and write the new start
    230       1.1   mycroft 	 * of the free list into the superblock.
    231       1.1   mycroft 	 */
    232  1.83.2.1      yamt 	CLR_BITMAP_FREE(fs, new_ino);
    233       1.1   mycroft 	LFS_IENTRY(ifp, fs, new_ino, bp);
    234       1.1   mycroft 	if (ifp->if_daddr != LFS_UNUSED_DADDR)
    235  1.83.2.1      yamt 		panic("lfs_valloc: inuse inode %llu on the free list",
    236  1.83.2.1      yamt 		    (unsigned long long)new_ino);
    237      1.48  perseant 	LFS_PUT_HEADFREE(fs, cip, cbp, ifp->if_nextfree);
    238  1.83.2.1      yamt 	DLOG((DLOG_ALLOC, "lfs_valloc: headfree %lld -> %lld\n",
    239  1.83.2.1      yamt 	     (long long)new_ino, (long long)ifp->if_nextfree));
    240      1.48  perseant 
    241      1.37  perseant 	new_gen = ifp->if_version; /* version was updated by vfree */
    242  1.83.2.5      yamt 	brelse(bp, 0);
    243      1.30  perseant 
    244       1.1   mycroft 	/* Extend IFILE so that the next lfs_valloc will succeed. */
    245      1.63  perseant 	if (fs->lfs_freehd == LFS_UNUSED_INUM) {
    246  1.83.2.2      yamt 		if ((error = lfs_extend_ifile(fs, cred)) != 0) {
    247      1.48  perseant 			LFS_PUT_HEADFREE(fs, cip, cbp, new_ino);
    248      1.78  perseant 			VOP_UNLOCK(fs->lfs_ivnode, 0);
    249      1.56  perseant 			lfs_segunlock(fs);
    250      1.44  perseant 			return error;
    251       1.1   mycroft 		}
    252       1.1   mycroft 	}
    253      1.17  perseant #ifdef DIAGNOSTIC
    254      1.63  perseant 	if (fs->lfs_freehd == LFS_UNUSED_INUM)
    255      1.17  perseant 		panic("inode 0 allocated [3]");
    256      1.17  perseant #endif /* DIAGNOSTIC */
    257      1.48  perseant 
    258      1.78  perseant 	/* Set superblock modified bit and increment file count. */
    259  1.83.2.6      yamt 	mutex_enter(&lfs_lock);
    260      1.78  perseant 	fs->lfs_fmod = 1;
    261  1.83.2.6      yamt 	mutex_exit(&lfs_lock);
    262      1.78  perseant 	++fs->lfs_nfiles;
    263      1.78  perseant 
    264      1.78  perseant 	VOP_UNLOCK(fs->lfs_ivnode, 0);
    265      1.56  perseant 	lfs_segunlock(fs);
    266      1.63  perseant 
    267  1.83.2.1      yamt 	return lfs_ialloc(fs, pvp, new_ino, new_gen, vpp);
    268      1.44  perseant }
    269      1.44  perseant 
    270      1.65  perseant /*
    271      1.65  perseant  * Finish allocating a new inode, given an inode and generation number.
    272      1.65  perseant  */
    273  1.83.2.2      yamt int
    274      1.44  perseant lfs_ialloc(struct lfs *fs, struct vnode *pvp, ino_t new_ino, int new_gen,
    275      1.44  perseant 	   struct vnode **vpp)
    276      1.44  perseant {
    277      1.44  perseant 	struct inode *ip;
    278      1.44  perseant 	struct vnode *vp;
    279      1.40      fvdl 
    280      1.78  perseant 	ASSERT_NO_SEGLOCK(fs);
    281      1.78  perseant 
    282      1.77  perseant 	vp = *vpp;
    283  1.83.2.3      yamt 	mutex_enter(&ufs_hashlock);
    284      1.40      fvdl 	/* Create an inode to associate with the vnode. */
    285      1.44  perseant 	lfs_vcreate(pvp->v_mount, new_ino, vp);
    286      1.51       chs 
    287       1.1   mycroft 	ip = VTOI(vp);
    288  1.83.2.6      yamt 	mutex_enter(&lfs_lock);
    289      1.73   mycroft 	LFS_SET_UINO(ip, IN_CHANGE);
    290  1.83.2.6      yamt 	mutex_exit(&lfs_lock);
    291      1.66      fvdl 	/* on-disk structure has been zeroed out by lfs_vcreate */
    292      1.66      fvdl 	ip->i_din.ffs1_din->di_inumber = new_ino;
    293      1.51       chs 
    294      1.79  perseant 	/* Note no blocks yet */
    295      1.79  perseant 	ip->i_lfs_hiblk = -1;
    296      1.79  perseant 
    297       1.1   mycroft 	/* Set a new generation number for this inode. */
    298      1.66      fvdl 	if (new_gen) {
    299      1.66      fvdl 		ip->i_gen = new_gen;
    300      1.66      fvdl 		ip->i_ffs1_gen = new_gen;
    301      1.66      fvdl 	}
    302      1.51       chs 
    303       1.1   mycroft 	/* Insert into the inode hash table. */
    304       1.1   mycroft 	ufs_ihashins(ip);
    305  1.83.2.3      yamt 	mutex_exit(&ufs_hashlock);
    306      1.44  perseant 
    307      1.77  perseant 	ufs_vinit(vp->v_mount, lfs_specop_p, lfs_fifoop_p, vpp);
    308      1.77  perseant 	vp = *vpp;
    309      1.44  perseant 	ip = VTOI(vp);
    310      1.57      yamt 
    311      1.57      yamt 	memset(ip->i_lfs_fragsize, 0, NDADDR * sizeof(*ip->i_lfs_fragsize));
    312      1.51       chs 
    313      1.51       chs 	uvm_vnp_setsize(vp, 0);
    314      1.72      yamt 	lfs_mark_vnode(vp);
    315      1.54       chs 	genfs_node_init(vp, &lfs_genfsops);
    316      1.38  perseant 	VREF(ip->i_devvp);
    317       1.1   mycroft 	return (0);
    318       1.1   mycroft }
    319       1.1   mycroft 
    320       1.1   mycroft /* Create a new vnode/inode pair and initialize what fields we can. */
    321      1.40      fvdl void
    322      1.48  perseant lfs_vcreate(struct mount *mp, ino_t ino, struct vnode *vp)
    323       1.1   mycroft {
    324       1.1   mycroft 	struct inode *ip;
    325      1.66      fvdl 	struct ufs1_dinode *dp;
    326       1.1   mycroft 	struct ufsmount *ump;
    327      1.75     perry 
    328       1.1   mycroft 	/* Get a pointer to the private mount structure. */
    329       1.1   mycroft 	ump = VFSTOUFS(mp);
    330      1.75     perry 
    331      1.78  perseant 	ASSERT_NO_SEGLOCK(ump->um_lfs);
    332      1.78  perseant 
    333       1.1   mycroft 	/* Initialize the inode. */
    334      1.15   thorpej 	ip = pool_get(&lfs_inode_pool, PR_WAITOK);
    335      1.66      fvdl 	memset(ip, 0, sizeof(*ip));
    336      1.66      fvdl 	dp = pool_get(&lfs_dinode_pool, PR_WAITOK);
    337      1.66      fvdl 	memset(dp, 0, sizeof(*dp));
    338      1.63  perseant 	ip->inode_ext.lfs = pool_get(&lfs_inoext_pool, PR_WAITOK);
    339      1.74  perseant 	memset(ip->inode_ext.lfs, 0, sizeof(*ip->inode_ext.lfs));
    340      1.40      fvdl 	vp->v_data = ip;
    341      1.66      fvdl 	ip->i_din.ffs1_din = dp;
    342      1.66      fvdl 	ip->i_ump = ump;
    343      1.40      fvdl 	ip->i_vnode = vp;
    344       1.1   mycroft 	ip->i_devvp = ump->um_devvp;
    345       1.1   mycroft 	ip->i_dev = ump->um_dev;
    346      1.66      fvdl 	ip->i_number = dp->di_inumber = ino;
    347       1.1   mycroft 	ip->i_lfs = ump->um_lfs;
    348      1.66      fvdl 	ip->i_lfs_effnblks = 0;
    349      1.81  perseant 	SPLAY_INIT(&ip->i_lfs_lbtree);
    350      1.82  perseant 	ip->i_lfs_nbtree = 0;
    351  1.83.2.1      yamt 	LIST_INIT(&ip->i_lfs_segdhd);
    352       1.1   mycroft #ifdef QUOTA
    353  1.83.2.4      yamt 	ufsquota_init(ip);
    354       1.1   mycroft #endif
    355      1.76  perseant #ifdef DEBUG
    356      1.56  perseant 	if (ino == LFS_IFILE_INUM)
    357      1.56  perseant 		vp->v_vnlock->lk_wmesg = "inlock";
    358      1.56  perseant #endif
    359       1.1   mycroft }
    360       1.1   mycroft 
    361  1.83.2.1      yamt #if 0
    362  1.83.2.1      yamt /*
    363  1.83.2.1      yamt  * Find the highest-numbered allocated inode.
    364  1.83.2.1      yamt  * This will be used to shrink the Ifile.
    365  1.83.2.1      yamt  */
    366  1.83.2.1      yamt static inline ino_t
    367  1.83.2.1      yamt lfs_last_alloc_ino(struct lfs *fs)
    368  1.83.2.1      yamt {
    369  1.83.2.1      yamt 	ino_t ino, maxino;
    370  1.83.2.1      yamt 
    371  1.83.2.1      yamt 	maxino = ((fs->lfs_ivnode->v_size >> fs->lfs_bshift) -
    372  1.83.2.1      yamt 		  fs->lfs_cleansz - fs->lfs_segtabsz) * fs->lfs_ifpb;
    373  1.83.2.1      yamt 	for (ino = maxino - 1; ino > LFS_UNUSED_INUM; --ino) {
    374  1.83.2.1      yamt 		if (ISSET_BITMAP_FREE(fs, ino) == 0)
    375  1.83.2.1      yamt 			break;
    376  1.83.2.1      yamt 	}
    377  1.83.2.1      yamt 	return ino;
    378  1.83.2.1      yamt }
    379  1.83.2.1      yamt #endif
    380  1.83.2.1      yamt 
    381  1.83.2.1      yamt /*
    382  1.83.2.1      yamt  * Find the previous (next lowest numbered) free inode, if any.
    383  1.83.2.1      yamt  * If there is none, return LFS_UNUSED_INUM.
    384  1.83.2.1      yamt  */
    385  1.83.2.1      yamt static inline ino_t
    386  1.83.2.1      yamt lfs_freelist_prev(struct lfs *fs, ino_t ino)
    387  1.83.2.1      yamt {
    388  1.83.2.1      yamt 	ino_t tino, bound, bb, freehdbb;
    389  1.83.2.1      yamt 
    390  1.83.2.1      yamt 	if (fs->lfs_freehd == LFS_UNUSED_INUM)	 /* No free inodes at all */
    391  1.83.2.1      yamt 		return LFS_UNUSED_INUM;
    392  1.83.2.1      yamt 
    393  1.83.2.1      yamt 	/* Search our own word first */
    394  1.83.2.1      yamt 	bound = ino & ~BMMASK;
    395  1.83.2.1      yamt 	for (tino = ino - 1; tino >= bound && tino > LFS_UNUSED_INUM; tino--)
    396  1.83.2.1      yamt 		if (ISSET_BITMAP_FREE(fs, tino))
    397  1.83.2.1      yamt 			return tino;
    398  1.83.2.1      yamt 	/* If there are no lower words to search, just return */
    399  1.83.2.1      yamt 	if (ino >> BMSHIFT == 0)
    400  1.83.2.1      yamt 		return LFS_UNUSED_INUM;
    401  1.83.2.1      yamt 
    402  1.83.2.1      yamt 	/*
    403  1.83.2.1      yamt 	 * Find a word with a free inode in it.  We have to be a bit
    404  1.83.2.1      yamt 	 * careful here since ino_t is unsigned.
    405  1.83.2.1      yamt 	 */
    406  1.83.2.1      yamt 	freehdbb = (fs->lfs_freehd >> BMSHIFT);
    407  1.83.2.1      yamt 	for (bb = (ino >> BMSHIFT) - 1; bb >= freehdbb && bb > 0; --bb)
    408  1.83.2.1      yamt 		if (fs->lfs_ino_bitmap[bb])
    409  1.83.2.1      yamt 			break;
    410  1.83.2.1      yamt 	if (fs->lfs_ino_bitmap[bb] == 0)
    411  1.83.2.1      yamt 		return LFS_UNUSED_INUM;
    412  1.83.2.1      yamt 
    413  1.83.2.1      yamt 	/* Search the word we found */
    414  1.83.2.1      yamt 	for (tino = (bb << BMSHIFT) | BMMASK; tino >= (bb << BMSHIFT) &&
    415  1.83.2.1      yamt 	     tino > LFS_UNUSED_INUM; tino--)
    416  1.83.2.1      yamt 		if (ISSET_BITMAP_FREE(fs, tino))
    417  1.83.2.1      yamt 			break;
    418  1.83.2.1      yamt 
    419  1.83.2.1      yamt 	if (tino <= LFS_IFILE_INUM)
    420  1.83.2.1      yamt 		tino = LFS_UNUSED_INUM;
    421  1.83.2.1      yamt 
    422  1.83.2.1      yamt 	return tino;
    423  1.83.2.1      yamt }
    424  1.83.2.1      yamt 
    425       1.1   mycroft /* Free an inode. */
    426       1.1   mycroft /* ARGUSED */
    427      1.43  perseant /* VOP_BWRITE 2i times */
    428       1.1   mycroft int
    429  1.83.2.1      yamt lfs_vfree(struct vnode *vp, ino_t ino, int mode)
    430       1.3  christos {
    431       1.1   mycroft 	SEGUSE *sup;
    432      1.48  perseant 	CLEANERINFO *cip;
    433      1.48  perseant 	struct buf *cbp, *bp;
    434       1.1   mycroft 	struct ifile *ifp;
    435       1.1   mycroft 	struct inode *ip;
    436       1.1   mycroft 	struct lfs *fs;
    437      1.59      fvdl 	daddr_t old_iaddr;
    438  1.83.2.1      yamt 	ino_t otail;
    439      1.75     perry 
    440       1.1   mycroft 	/* Get the inode number and file system. */
    441      1.30  perseant 	ip = VTOI(vp);
    442       1.1   mycroft 	fs = ip->i_lfs;
    443       1.1   mycroft 	ino = ip->i_number;
    444      1.34  perseant 
    445      1.78  perseant 	ASSERT_NO_SEGLOCK(fs);
    446  1.83.2.1      yamt 	DLOG((DLOG_ALLOC, "lfs_vfree: free ino %lld\n", (long long)ino));
    447      1.78  perseant 
    448      1.48  perseant 	/* Drain of pending writes */
    449  1.83.2.6      yamt 	mutex_enter(&vp->v_interlock);
    450  1.83.2.6      yamt 	while (fs->lfs_version > 1 && WRITEINPROG(vp)) {
    451  1.83.2.6      yamt 		cv_wait(&vp->v_cv, &vp->v_interlock);
    452  1.83.2.6      yamt 	}
    453  1.83.2.6      yamt 	mutex_exit(&vp->v_interlock);
    454      1.48  perseant 
    455      1.63  perseant 	lfs_seglock(fs, SEGM_PROT);
    456      1.78  perseant 	vn_lock(fs->lfs_ivnode, LK_EXCLUSIVE);
    457      1.75     perry 
    458      1.72      yamt 	lfs_unmark_vnode(vp);
    459  1.83.2.6      yamt 	mutex_enter(&lfs_lock);
    460  1.83.2.5      yamt 	if (vp->v_uflag & VU_DIROP) {
    461  1.83.2.5      yamt 		vp->v_uflag &= ~VU_DIROP;
    462      1.30  perseant 		--lfs_dirvcount;
    463  1.83.2.1      yamt 		--fs->lfs_dirvcount;
    464      1.63  perseant 		TAILQ_REMOVE(&fs->lfs_dchainhd, ip, i_lfs_dchain);
    465  1.83.2.1      yamt 		wakeup(&fs->lfs_dirvcount);
    466      1.30  perseant 		wakeup(&lfs_dirvcount);
    467  1.83.2.6      yamt 		mutex_exit(&lfs_lock);
    468      1.30  perseant 		lfs_vunref(vp);
    469  1.83.2.1      yamt 
    470  1.83.2.1      yamt 		/*
    471  1.83.2.1      yamt 		 * If this inode is not going to be written any more, any
    472  1.83.2.1      yamt 		 * segment accounting left over from its truncation needs
    473  1.83.2.1      yamt 		 * to occur at the end of the next dirops flush.  Attach
    474  1.83.2.1      yamt 		 * them to the fs-wide list for that purpose.
    475  1.83.2.1      yamt 		 */
    476  1.83.2.1      yamt 		if (LIST_FIRST(&ip->i_lfs_segdhd) != NULL) {
    477  1.83.2.1      yamt 			struct segdelta *sd;
    478  1.83.2.1      yamt 
    479  1.83.2.1      yamt 			while((sd = LIST_FIRST(&ip->i_lfs_segdhd)) != NULL) {
    480  1.83.2.1      yamt 				LIST_REMOVE(sd, list);
    481  1.83.2.1      yamt 				LIST_INSERT_HEAD(&fs->lfs_segdhd, sd, list);
    482  1.83.2.1      yamt 			}
    483  1.83.2.1      yamt 		}
    484  1.83.2.1      yamt 	} else {
    485  1.83.2.1      yamt 		/*
    486  1.83.2.1      yamt 		 * If it's not a dirop, we can finalize right away.
    487  1.83.2.1      yamt 		 */
    488  1.83.2.6      yamt 		mutex_exit(&lfs_lock);
    489  1.83.2.1      yamt 		lfs_finalize_ino_seguse(fs, ip);
    490      1.38  perseant 	}
    491      1.30  perseant 
    492  1.83.2.6      yamt 	mutex_enter(&lfs_lock);
    493      1.42  perseant 	LFS_CLR_UINO(ip, IN_ACCESSED|IN_CLEANING|IN_MODIFIED);
    494  1.83.2.6      yamt 	mutex_exit(&lfs_lock);
    495      1.33  perseant 	ip->i_flag &= ~IN_ALLMOD;
    496  1.83.2.1      yamt 	ip->i_lfs_iflags |= LFSI_DELETED;
    497  1.83.2.1      yamt 
    498       1.1   mycroft 	/*
    499       1.1   mycroft 	 * Set the ifile's inode entry to unused, increment its version number
    500      1.48  perseant 	 * and link it onto the free chain.
    501       1.1   mycroft 	 */
    502  1.83.2.1      yamt 	SET_BITMAP_FREE(fs, ino);
    503       1.1   mycroft 	LFS_IENTRY(ifp, fs, ino, bp);
    504       1.1   mycroft 	old_iaddr = ifp->if_daddr;
    505       1.1   mycroft 	ifp->if_daddr = LFS_UNUSED_DADDR;
    506       1.1   mycroft 	++ifp->if_version;
    507      1.48  perseant 	if (fs->lfs_version == 1) {
    508      1.48  perseant 		LFS_GET_HEADFREE(fs, cip, cbp, &(ifp->if_nextfree));
    509      1.48  perseant 		LFS_PUT_HEADFREE(fs, cip, cbp, ino);
    510      1.56  perseant 		(void) LFS_BWRITE_LOG(bp); /* Ifile */
    511      1.48  perseant 	} else {
    512  1.83.2.1      yamt 		ino_t tino, onf;
    513  1.83.2.1      yamt 
    514      1.48  perseant 		ifp->if_nextfree = LFS_UNUSED_INUM;
    515      1.56  perseant 		(void) LFS_BWRITE_LOG(bp); /* Ifile */
    516  1.83.2.1      yamt 
    517  1.83.2.1      yamt 		tino = lfs_freelist_prev(fs, ino);
    518  1.83.2.1      yamt 		if (tino == LFS_UNUSED_INUM) {
    519  1.83.2.1      yamt 			/* Nothing free below us, put us on the head */
    520  1.83.2.1      yamt 			LFS_IENTRY(ifp, fs, ino, bp);
    521  1.83.2.1      yamt 			LFS_GET_HEADFREE(fs, cip, cbp, &(ifp->if_nextfree));
    522  1.83.2.1      yamt 			LFS_PUT_HEADFREE(fs, cip, cbp, ino);
    523  1.83.2.1      yamt 			DLOG((DLOG_ALLOC, "lfs_vfree: headfree %lld -> %lld\n",
    524  1.83.2.1      yamt 			     (long long)ifp->if_nextfree, (long long)ino));
    525  1.83.2.1      yamt 			LFS_BWRITE_LOG(bp); /* Ifile */
    526  1.83.2.1      yamt 
    527  1.83.2.1      yamt 			/* If the list was empty, set tail too */
    528  1.83.2.1      yamt 			LFS_GET_TAILFREE(fs, cip, cbp, &otail);
    529  1.83.2.1      yamt 			if (otail == LFS_UNUSED_INUM) {
    530  1.83.2.1      yamt 				LFS_PUT_TAILFREE(fs, cip, cbp, ino);
    531  1.83.2.1      yamt 				DLOG((DLOG_ALLOC, "lfs_vfree: tailfree %lld "
    532  1.83.2.1      yamt 				      "-> %lld\n", (long long)otail,
    533  1.83.2.1      yamt 				      (long long)ino));
    534  1.83.2.1      yamt 			}
    535  1.83.2.1      yamt 		} else {
    536  1.83.2.1      yamt 			/*
    537  1.83.2.1      yamt 			 * Insert this inode into the list after tino.
    538  1.83.2.1      yamt 			 * We hold the segment lock so we don't have to
    539  1.83.2.1      yamt 			 * worry about blocks being written out of order.
    540  1.83.2.1      yamt 			 */
    541  1.83.2.1      yamt 			DLOG((DLOG_ALLOC, "lfs_vfree: insert ino %lld "
    542  1.83.2.1      yamt 			      " after %lld\n", ino, tino));
    543  1.83.2.1      yamt 
    544  1.83.2.1      yamt 			LFS_IENTRY(ifp, fs, tino, bp);
    545  1.83.2.1      yamt 			onf = ifp->if_nextfree;
    546  1.83.2.1      yamt 			ifp->if_nextfree = ino;
    547  1.83.2.1      yamt 			LFS_BWRITE_LOG(bp);	/* Ifile */
    548  1.83.2.1      yamt 
    549  1.83.2.1      yamt 			LFS_IENTRY(ifp, fs, ino, bp);
    550  1.83.2.1      yamt 			ifp->if_nextfree = onf;
    551  1.83.2.1      yamt 			LFS_BWRITE_LOG(bp);	/* Ifile */
    552  1.83.2.1      yamt 
    553  1.83.2.1      yamt 			/* If we're last, put us on the tail */
    554  1.83.2.1      yamt 			if (onf == LFS_UNUSED_INUM) {
    555  1.83.2.1      yamt 				LFS_GET_TAILFREE(fs, cip, cbp, &otail);
    556  1.83.2.1      yamt 				LFS_PUT_TAILFREE(fs, cip, cbp, ino);
    557  1.83.2.1      yamt 				DLOG((DLOG_ALLOC, "lfs_vfree: tailfree %lld "
    558  1.83.2.1      yamt 				      "-> %lld\n", (long long)otail,
    559  1.83.2.1      yamt 				      (long long)ino));
    560  1.83.2.1      yamt 			}
    561  1.83.2.1      yamt 		}
    562      1.48  perseant 	}
    563      1.17  perseant #ifdef DIAGNOSTIC
    564      1.53       chs 	if (ino == LFS_UNUSED_INUM) {
    565      1.17  perseant 		panic("inode 0 freed");
    566      1.17  perseant 	}
    567      1.17  perseant #endif /* DIAGNOSTIC */
    568       1.1   mycroft 	if (old_iaddr != LFS_UNUSED_DADDR) {
    569      1.48  perseant 		LFS_SEGENTRY(sup, fs, dtosn(fs, old_iaddr), bp);
    570      1.22  perseant #ifdef DIAGNOSTIC
    571      1.66      fvdl 		if (sup->su_nbytes < sizeof (struct ufs1_dinode)) {
    572      1.43  perseant 			printf("lfs_vfree: negative byte count"
    573      1.62      yamt 			       " (segment %" PRIu32 " short by %d)\n",
    574      1.48  perseant 			       dtosn(fs, old_iaddr),
    575      1.66      fvdl 			       (int)sizeof (struct ufs1_dinode) -
    576      1.66      fvdl 				    sup->su_nbytes);
    577      1.22  perseant 			panic("lfs_vfree: negative byte count");
    578      1.66      fvdl 			sup->su_nbytes = sizeof (struct ufs1_dinode);
    579      1.17  perseant 		}
    580      1.22  perseant #endif
    581      1.66      fvdl 		sup->su_nbytes -= sizeof (struct ufs1_dinode);
    582      1.63  perseant 		LFS_WRITESEGENTRY(sup, fs, dtosn(fs, old_iaddr), bp); /* Ifile */
    583       1.1   mycroft 	}
    584      1.75     perry 
    585       1.1   mycroft 	/* Set superblock modified bit and decrement file count. */
    586  1.83.2.6      yamt 	mutex_enter(&lfs_lock);
    587       1.1   mycroft 	fs->lfs_fmod = 1;
    588  1.83.2.6      yamt 	mutex_exit(&lfs_lock);
    589       1.1   mycroft 	--fs->lfs_nfiles;
    590      1.75     perry 
    591      1.78  perseant 	VOP_UNLOCK(fs->lfs_ivnode, 0);
    592      1.56  perseant 	lfs_segunlock(fs);
    593      1.63  perseant 
    594       1.1   mycroft 	return (0);
    595       1.1   mycroft }
    596  1.83.2.1      yamt 
    597  1.83.2.1      yamt /*
    598  1.83.2.1      yamt  * Sort the freelist and set up the free-inode bitmap.
    599  1.83.2.1      yamt  * To be called by lfs_mountfs().
    600  1.83.2.1      yamt  */
    601  1.83.2.1      yamt void
    602  1.83.2.1      yamt lfs_order_freelist(struct lfs *fs)
    603  1.83.2.1      yamt {
    604  1.83.2.1      yamt 	CLEANERINFO *cip;
    605  1.83.2.1      yamt 	IFILE *ifp = NULL;
    606  1.83.2.1      yamt 	struct buf *bp;
    607  1.83.2.1      yamt 	ino_t ino, firstino, lastino, maxino;
    608  1.83.2.2      yamt #ifdef notyet
    609  1.83.2.2      yamt 	struct vnode *vp;
    610  1.83.2.2      yamt #endif
    611  1.83.2.1      yamt 
    612  1.83.2.2      yamt 	ASSERT_NO_SEGLOCK(fs);
    613  1.83.2.2      yamt 	lfs_seglock(fs, SEGM_PROT);
    614  1.83.2.2      yamt 
    615  1.83.2.1      yamt 	maxino = ((fs->lfs_ivnode->v_size >> fs->lfs_bshift) -
    616  1.83.2.1      yamt 		  fs->lfs_cleansz - fs->lfs_segtabsz) * fs->lfs_ifpb;
    617  1.83.2.1      yamt 	fs->lfs_ino_bitmap = (lfs_bm_t *)
    618  1.83.2.1      yamt 		malloc(((maxino + BMMASK) >> BMSHIFT) * sizeof(lfs_bm_t),
    619  1.83.2.1      yamt 		       M_SEGMENT, M_WAITOK | M_ZERO);
    620  1.83.2.1      yamt 	KASSERT(fs->lfs_ino_bitmap != NULL);
    621  1.83.2.1      yamt 
    622  1.83.2.1      yamt 	firstino = lastino = LFS_UNUSED_INUM;
    623  1.83.2.1      yamt 	for (ino = 0; ino < maxino; ino++) {
    624  1.83.2.1      yamt 		if (ino % fs->lfs_ifpb == 0)
    625  1.83.2.1      yamt 			LFS_IENTRY(ifp, fs, ino, bp);
    626  1.83.2.1      yamt 		else
    627  1.83.2.1      yamt 			++ifp;
    628  1.83.2.1      yamt 
    629  1.83.2.1      yamt 		/* Don't put zero or ifile on the free list */
    630  1.83.2.1      yamt 		if (ino == LFS_UNUSED_INUM || ino == LFS_IFILE_INUM)
    631  1.83.2.1      yamt 			continue;
    632  1.83.2.1      yamt 
    633  1.83.2.2      yamt #ifdef notyet
    634  1.83.2.2      yamt 		/* Address orphaned files */
    635  1.83.2.2      yamt 		if (ifp->if_nextfree == LFS_ORPHAN_NEXTFREE &&
    636  1.83.2.2      yamt 		    VFS_VGET(fs->lfs_ivnode->v_mount, ino, &vp) == 0) {
    637  1.83.2.6      yamt 			lfs_truncate(vp, 0, 0, NOCRED);
    638  1.83.2.2      yamt 			vput(vp);
    639  1.83.2.2      yamt 			LFS_SEGENTRY(sup, fs, dtosn(fs, ifp->if_daddr), bp);
    640  1.83.2.2      yamt 			KASSERT(sup->su_nbytes >= DINODE1_SIZE);
    641  1.83.2.2      yamt 			sup->su_nbytes -= DINODE1_SIZE;
    642  1.83.2.2      yamt 			LFS_WRITESEGENTRY(sup, fs, dtosn(fs, ifp->if_daddr), bp);
    643  1.83.2.2      yamt 
    644  1.83.2.2      yamt 			/* Set up to fall through to next section */
    645  1.83.2.2      yamt 			ifp->if_daddr = LFS_UNUSED_DADDR;
    646  1.83.2.2      yamt 			LFS_BWRITE_LOG(bp);
    647  1.83.2.2      yamt 			LFS_IENTRY(ifp, fs, ino, bp);
    648  1.83.2.2      yamt 		}
    649  1.83.2.2      yamt #endif
    650  1.83.2.2      yamt 
    651  1.83.2.1      yamt 		if (ifp->if_daddr == LFS_UNUSED_DADDR) {
    652  1.83.2.1      yamt 			if (firstino == LFS_UNUSED_INUM)
    653  1.83.2.1      yamt 				firstino = ino;
    654  1.83.2.1      yamt 			else {
    655  1.83.2.5      yamt 				brelse(bp, 0);
    656  1.83.2.1      yamt 
    657  1.83.2.1      yamt 				LFS_IENTRY(ifp, fs, lastino, bp);
    658  1.83.2.1      yamt 				ifp->if_nextfree = ino;
    659  1.83.2.1      yamt 				LFS_BWRITE_LOG(bp);
    660  1.83.2.1      yamt 
    661  1.83.2.1      yamt 				LFS_IENTRY(ifp, fs, ino, bp);
    662  1.83.2.1      yamt 			}
    663  1.83.2.1      yamt 			lastino = ino;
    664  1.83.2.1      yamt 
    665  1.83.2.1      yamt 			SET_BITMAP_FREE(fs, ino);
    666  1.83.2.1      yamt 		}
    667  1.83.2.1      yamt 
    668  1.83.2.1      yamt 		if ((ino + 1) % fs->lfs_ifpb == 0)
    669  1.83.2.5      yamt 			brelse(bp, 0);
    670  1.83.2.1      yamt 	}
    671  1.83.2.1      yamt 
    672  1.83.2.1      yamt 	LFS_PUT_HEADFREE(fs, cip, bp, firstino);
    673  1.83.2.1      yamt 	LFS_PUT_TAILFREE(fs, cip, bp, lastino);
    674  1.83.2.2      yamt 
    675  1.83.2.2      yamt 	lfs_segunlock(fs);
    676  1.83.2.2      yamt }
    677  1.83.2.2      yamt 
    678  1.83.2.2      yamt void
    679  1.83.2.2      yamt lfs_orphan(struct lfs *fs, ino_t ino)
    680  1.83.2.2      yamt {
    681  1.83.2.2      yamt 	IFILE *ifp;
    682  1.83.2.2      yamt 	struct buf *bp;
    683  1.83.2.2      yamt 
    684  1.83.2.2      yamt 	LFS_IENTRY(ifp, fs, ino, bp);
    685  1.83.2.2      yamt 	ifp->if_nextfree = LFS_ORPHAN_NEXTFREE;
    686  1.83.2.2      yamt 	LFS_BWRITE_LOG(bp);
    687  1.83.2.1      yamt }
    688