151882Sbostic /*- 263375Sbostic * Copyright (c) 1991, 1993 363375Sbostic * The Regents of the University of California. All rights reserved. 451882Sbostic * 551882Sbostic * %sccs.include.redist.c% 651882Sbostic * 7*65738Sbostic * @(#)lfs_syscalls.c 8.4 (Berkeley) 01/13/94 851882Sbostic */ 951882Sbostic 1051882Sbostic #include <sys/param.h> 1151882Sbostic #include <sys/proc.h> 1251882Sbostic #include <sys/buf.h> 1351882Sbostic #include <sys/mount.h> 1451882Sbostic #include <sys/vnode.h> 1551882Sbostic #include <sys/malloc.h> 1651882Sbostic #include <sys/kernel.h> 1751882Sbostic 1851882Sbostic #include <ufs/ufs/quota.h> 1951882Sbostic #include <ufs/ufs/inode.h> 2051882Sbostic #include <ufs/ufs/ufsmount.h> 2155941Sbostic #include <ufs/ufs/ufs_extern.h> 2251882Sbostic 2351882Sbostic #include <ufs/lfs/lfs.h> 2451882Sbostic #include <ufs/lfs/lfs_extern.h> 2556479Smargo #define BUMP_FIP(SP) \ 2656479Smargo (SP)->fip = (FINFO *) (&(SP)->fip->fi_blocks[(SP)->fip->fi_nblocks]) 2751882Sbostic 2856479Smargo #define INC_FINFO(SP) ++((SEGSUM *)((SP)->segsum))->ss_nfinfo 2956479Smargo #define DEC_FINFO(SP) --((SEGSUM *)((SP)->segsum))->ss_nfinfo 3056479Smargo 3156479Smargo /* 3256479Smargo * Before committing to add something to a segment summary, make sure there 3356479Smargo * is enough room. S is the bytes added to the summary. 3456479Smargo */ 3556479Smargo #define CHECK_SEG(s) \ 3656479Smargo if (sp->sum_bytes_left < (s)) { \ 3756479Smargo (void) lfs_writeseg(fs, sp); \ 3856479Smargo } 3955941Sbostic struct buf *lfs_fakebuf __P((struct vnode *, int, size_t, caddr_t)); 4055941Sbostic 4151882Sbostic /* 4251882Sbostic * lfs_markv: 4351882Sbostic * 4451882Sbostic * This will mark inodes and blocks dirty, so they are written into the log. 4551882Sbostic * It will block until all the blocks have been written. The segment create 4651882Sbostic * time passed in the block_info and inode_info structures is used to decide 4751882Sbostic * if the data is valid for each block (in case some process dirtied a block 4851882Sbostic * or inode that is being cleaned between the determination that a block is 4951882Sbostic * live and the lfs_markv call). 5051882Sbostic * 5151882Sbostic * 0 on success 5251882Sbostic * -1/errno is return on error. 5351882Sbostic */ 5457770Smargo struct lfs_markv_args { 55*65738Sbostic fsid_t *fsidp; /* file system */ 5657770Smargo BLOCK_INFO *blkiov; /* block array */ 5757770Smargo int blkcnt; /* count of block array entries */ 5857770Smargo }; 5951882Sbostic int 6051882Sbostic lfs_markv(p, uap, retval) 6151882Sbostic struct proc *p; 6257770Smargo struct lfs_markv_args *uap; 6351882Sbostic int *retval; 6451882Sbostic { 6555941Sbostic struct segment *sp; 6651882Sbostic BLOCK_INFO *blkp; 6751882Sbostic IFILE *ifp; 6855941Sbostic struct buf *bp, **bpp; 6952087Sbostic struct inode *ip; 7051882Sbostic struct lfs *fs; 7151882Sbostic struct mount *mntp; 7251882Sbostic struct vnode *vp; 73*65738Sbostic fsid_t fsid; 7452173Sbostic void *start; 7552087Sbostic ino_t lastino; 7655941Sbostic daddr_t b_daddr, v_daddr; 7751882Sbostic u_long bsize; 7851882Sbostic int cnt, error; 7951882Sbostic 8051882Sbostic if (error = suser(p->p_ucred, &p->p_acflag)) 8151882Sbostic return (error); 82*65738Sbostic 83*65738Sbostic if (error = copyin(uap->fsidp, &fsid, sizeof(fsid_t))) 84*65738Sbostic return (error); 85*65738Sbostic if ((mntp = getvfs(&fsid)) == NULL) 8651882Sbostic return (EINVAL); 8751882Sbostic 8851882Sbostic cnt = uap->blkcnt; 8952996Sbostic start = malloc(cnt * sizeof(BLOCK_INFO), M_SEGMENT, M_WAITOK); 9055941Sbostic if (error = copyin(uap->blkiov, start, cnt * sizeof(BLOCK_INFO))) 9155941Sbostic goto err1; 9251882Sbostic 9355941Sbostic /* Mark blocks/inodes dirty. */ 9452087Sbostic fs = VFSTOUFS(mntp)->um_lfs; 9552820Sbostic bsize = fs->lfs_bsize; 9655941Sbostic error = 0; 9755941Sbostic 9857073Smargo lfs_seglock(fs, SEGM_SYNC | SEGM_CLEAN); 9957073Smargo sp = fs->lfs_sp; 10055941Sbostic for (v_daddr = LFS_UNUSED_DADDR, lastino = LFS_UNUSED_INUM, 10155941Sbostic blkp = start; cnt--; ++blkp) { 10252087Sbostic /* 10352087Sbostic * Get the IFILE entry (only once) and see if the file still 10452087Sbostic * exists. 10552087Sbostic */ 10652087Sbostic if (lastino != blkp->bi_inode) { 10755941Sbostic if (lastino != LFS_UNUSED_INUM) { 10856479Smargo /* Finish up last file */ 10956029Sbostic lfs_updatemeta(sp); 11055941Sbostic lfs_writeinode(fs, sp, ip); 11157073Smargo lfs_vunref(vp); 11256479Smargo if (sp->fip->fi_nblocks) 11356479Smargo BUMP_FIP(sp); 11456479Smargo else { 11556479Smargo DEC_FINFO(sp); 11656479Smargo sp->sum_bytes_left += 11756479Smargo sizeof(FINFO) - sizeof(daddr_t); 11856479Smargo 11956191Smargo } 12055941Sbostic } 12156479Smargo 12256479Smargo /* Start a new file */ 12356479Smargo CHECK_SEG(sizeof(FINFO)); 12456479Smargo sp->sum_bytes_left -= sizeof(FINFO) - sizeof(daddr_t); 12556479Smargo INC_FINFO(sp); 12656479Smargo sp->start_lbp = &sp->fip->fi_blocks[0]; 12756479Smargo sp->vp = NULL; 12856369Smargo sp->fip->fi_version = blkp->bi_version; 12956369Smargo sp->fip->fi_nblocks = 0; 13056369Smargo sp->fip->fi_ino = blkp->bi_inode; 13152087Sbostic lastino = blkp->bi_inode; 13256161Sbostic if (blkp->bi_inode == LFS_IFILE_INUM) 13356161Sbostic v_daddr = fs->lfs_idaddr; 13456161Sbostic else { 13556161Sbostic LFS_IENTRY(ifp, fs, blkp->bi_inode, bp); 13656161Sbostic v_daddr = ifp->if_daddr; 13756161Sbostic brelse(bp); 13856161Sbostic } 13955941Sbostic if (v_daddr == LFS_UNUSED_DADDR) 14052087Sbostic continue; 14156479Smargo 14255941Sbostic /* Get the vnode/inode. */ 14355941Sbostic if (lfs_fastvget(mntp, blkp->bi_inode, v_daddr, &vp, 14456369Smargo blkp->bi_lbn == LFS_UNUSED_LBN ? 14556369Smargo blkp->bi_bp : NULL)) { 14655941Sbostic #ifdef DIAGNOSTIC 14755941Sbostic printf("lfs_markv: VFS_VGET failed (%d)\n", 14855941Sbostic blkp->bi_inode); 14955941Sbostic #endif 15056029Sbostic lastino = LFS_UNUSED_INUM; 15156479Smargo v_daddr = LFS_UNUSED_DADDR; 15255941Sbostic continue; 15355941Sbostic } 15456029Sbostic sp->vp = vp; 15555941Sbostic ip = VTOI(vp); 15655941Sbostic } else if (v_daddr == LFS_UNUSED_DADDR) 15755941Sbostic continue; 15852087Sbostic 15955941Sbostic /* If this BLOCK_INFO didn't contain a block, keep going. */ 16055941Sbostic if (blkp->bi_lbn == LFS_UNUSED_LBN) 16151882Sbostic continue; 16256479Smargo if (VOP_BMAP(vp, blkp->bi_lbn, NULL, &b_daddr, NULL) || 16356161Sbostic b_daddr != blkp->bi_daddr) 16452173Sbostic continue; 16555941Sbostic /* 16655941Sbostic * If we got to here, then we are keeping the block. If it 16755941Sbostic * is an indirect block, we want to actually put it in the 16855941Sbostic * buffer cache so that it can be updated in the finish_meta 16955941Sbostic * section. If it's not, we need to allocate a fake buffer 17055941Sbostic * so that writeseg can perform the copyin and write the buffer. 17155941Sbostic */ 17255941Sbostic if (blkp->bi_lbn >= 0) /* Data Block */ 17355941Sbostic bp = lfs_fakebuf(vp, blkp->bi_lbn, bsize, 17455941Sbostic blkp->bi_bp); 17555941Sbostic else { 17657806Smckusick bp = getblk(vp, blkp->bi_lbn, bsize, 0, 0); 17756625Smargo if (!(bp->b_flags & (B_DELWRI | B_DONE | B_CACHE)) && 17864527Sbostic (error = copyin(blkp->bi_bp, bp->b_data, 17955941Sbostic bsize))) 18055941Sbostic goto err2; 18155941Sbostic if (error = VOP_BWRITE(bp)) 18255941Sbostic goto err2; 18352087Sbostic } 18456029Sbostic while (lfs_gatherblock(sp, bp, NULL)); 18551882Sbostic } 18656029Sbostic if (sp->vp) { 18756029Sbostic lfs_updatemeta(sp); 18856029Sbostic lfs_writeinode(fs, sp, ip); 18957073Smargo lfs_vunref(vp); 19056479Smargo if (!sp->fip->fi_nblocks) { 19156479Smargo DEC_FINFO(sp); 19256479Smargo sp->sum_bytes_left += sizeof(FINFO) - sizeof(daddr_t); 19356479Smargo } 19456029Sbostic } 19555941Sbostic (void) lfs_writeseg(fs, sp); 19655941Sbostic lfs_segunlock(fs); 19752173Sbostic free(start, M_SEGMENT); 19855941Sbostic return (error); 19955941Sbostic /* 20055941Sbostic * XXX If we come in to error 2, we might have indirect blocks that were 20155941Sbostic * updated and now have bad block pointers. I don't know what to do 20255941Sbostic * about this. 20355941Sbostic */ 20451882Sbostic 20557073Smargo err2: lfs_vunref(vp); 20655941Sbostic /* Free up fakebuffers */ 20755941Sbostic for (bpp = --sp->cbpp; bpp >= sp->bpp; --bpp) 20855941Sbostic if ((*bpp)->b_flags & B_CALL) { 20955941Sbostic brelvp(*bpp); 21055941Sbostic free(*bpp, M_SEGMENT); 21155941Sbostic } else 21255941Sbostic brelse(*bpp); 21355941Sbostic lfs_segunlock(fs); 214*65738Sbostic err1: 21552173Sbostic free(start, M_SEGMENT); 21655941Sbostic return(error); 21751882Sbostic } 21851882Sbostic 21951882Sbostic /* 22051882Sbostic * lfs_bmapv: 22151882Sbostic * 22252087Sbostic * This will fill in the current disk address for arrays of blocks. 22351882Sbostic * 22451882Sbostic * 0 on success 22551882Sbostic * -1/errno is return on error. 22651882Sbostic */ 22757770Smargo struct lfs_bmapv_args { 228*65738Sbostic fsid_t *fsidp; /* file system */ 22957770Smargo BLOCK_INFO *blkiov; /* block array */ 23057770Smargo int blkcnt; /* count of block array entries */ 23157770Smargo }; 23251882Sbostic int 23351882Sbostic lfs_bmapv(p, uap, retval) 23451882Sbostic struct proc *p; 23557770Smargo struct lfs_bmapv_args *uap; 23651882Sbostic int *retval; 23751882Sbostic { 23851882Sbostic BLOCK_INFO *blkp; 23951882Sbostic struct mount *mntp; 24051882Sbostic struct vnode *vp; 241*65738Sbostic fsid_t fsid; 24252173Sbostic void *start; 24351882Sbostic daddr_t daddr; 24452173Sbostic int cnt, error, step; 24551882Sbostic 24651882Sbostic if (error = suser(p->p_ucred, &p->p_acflag)) 24751882Sbostic return (error); 248*65738Sbostic 249*65738Sbostic if (error = copyin(uap->fsidp, &fsid, sizeof(fsid_t))) 250*65738Sbostic return (error); 251*65738Sbostic if ((mntp = getvfs(&fsid)) == NULL) 25251882Sbostic return (EINVAL); 25351882Sbostic 25451882Sbostic cnt = uap->blkcnt; 25552173Sbostic start = blkp = malloc(cnt * sizeof(BLOCK_INFO), M_SEGMENT, M_WAITOK); 25651882Sbostic if (error = copyin(uap->blkiov, blkp, cnt * sizeof(BLOCK_INFO))) { 25751882Sbostic free(blkp, M_SEGMENT); 25851882Sbostic return (error); 25951882Sbostic } 26051882Sbostic 26152173Sbostic for (step = cnt; step--; ++blkp) { 26256161Sbostic if (blkp->bi_lbn == LFS_UNUSED_LBN) 26356161Sbostic continue; 26457073Smargo /* Could be a deadlock ? */ 26554662Smckusick if (VFS_VGET(mntp, blkp->bi_inode, &vp)) 26652173Sbostic daddr = LFS_UNUSED_DADDR; 26752173Sbostic else { 26856479Smargo if (VOP_BMAP(vp, blkp->bi_lbn, NULL, &daddr, NULL)) 26952173Sbostic daddr = LFS_UNUSED_DADDR; 27052173Sbostic vput(vp); 27152173Sbostic } 27252173Sbostic blkp->bi_daddr = daddr; 27352173Sbostic } 27452173Sbostic copyout(start, uap->blkiov, cnt * sizeof(BLOCK_INFO)); 27552173Sbostic free(start, M_SEGMENT); 27651882Sbostic return (0); 27751882Sbostic } 27851882Sbostic 27951882Sbostic /* 28051882Sbostic * lfs_segclean: 28151882Sbostic * 28251882Sbostic * Mark the segment clean. 28351882Sbostic * 28451882Sbostic * 0 on success 28551882Sbostic * -1/errno is return on error. 28651882Sbostic */ 28757770Smargo struct lfs_segclean_args { 288*65738Sbostic fsid_t *fsidp; /* file system */ 28957770Smargo u_long segment; /* segment number */ 29057770Smargo }; 29151882Sbostic int 29251882Sbostic lfs_segclean(p, uap, retval) 29351882Sbostic struct proc *p; 29457770Smargo struct lfs_segclean_args *uap; 29551882Sbostic int *retval; 29651882Sbostic { 29751928Sbostic CLEANERINFO *cip; 29851882Sbostic SEGUSE *sup; 29951882Sbostic struct buf *bp; 30051882Sbostic struct mount *mntp; 30151882Sbostic struct lfs *fs; 302*65738Sbostic fsid_t fsid; 30351882Sbostic int error; 30451882Sbostic 30551882Sbostic if (error = suser(p->p_ucred, &p->p_acflag)) 30651882Sbostic return (error); 307*65738Sbostic 308*65738Sbostic if (error = copyin(uap->fsidp, &fsid, sizeof(fsid_t))) 309*65738Sbostic return (error); 310*65738Sbostic if ((mntp = getvfs(&fsid)) == NULL) 31151882Sbostic return (EINVAL); 31251882Sbostic 31351882Sbostic fs = VFSTOUFS(mntp)->um_lfs; 31451928Sbostic 31556369Smargo if (datosn(fs, fs->lfs_curseg) == uap->segment) 31656369Smargo return (EBUSY); 31756369Smargo 31851882Sbostic LFS_SEGENTRY(sup, fs, uap->segment, bp); 31956369Smargo if (sup->su_flags & SEGUSE_ACTIVE) { 32056369Smargo brelse(bp); 32156369Smargo return(EBUSY); 32256369Smargo } 32355941Sbostic fs->lfs_avail += fsbtodb(fs, fs->lfs_ssize) - 1; 32455593Sbostic fs->lfs_bfree += (sup->su_nsums * LFS_SUMMARY_SIZE / DEV_BSIZE) + 32555593Sbostic sup->su_ninos * btodb(fs->lfs_bsize); 32651882Sbostic sup->su_flags &= ~SEGUSE_DIRTY; 32755941Sbostic (void) VOP_BWRITE(bp); 32851928Sbostic 32951928Sbostic LFS_CLEANERINFO(cip, fs, bp); 33051928Sbostic ++cip->clean; 33151928Sbostic --cip->dirty; 33255941Sbostic (void) VOP_BWRITE(bp); 33355941Sbostic wakeup(&fs->lfs_avail); 33451882Sbostic return (0); 33551882Sbostic } 33651882Sbostic 33751882Sbostic /* 33851882Sbostic * lfs_segwait: 33951882Sbostic * 34051882Sbostic * This will block until a segment in file system fsid is written. A timeout 34151882Sbostic * in milliseconds may be specified which will awake the cleaner automatically. 34251882Sbostic * An fsid of -1 means any file system, and a timeout of 0 means forever. 34351882Sbostic * 34451882Sbostic * 0 on success 34551882Sbostic * 1 on timeout 34651882Sbostic * -1/errno is return on error. 34751882Sbostic */ 34857770Smargo struct lfs_segwait_args { 349*65738Sbostic fsid_t *fsidp; /* file system */ 35057770Smargo struct timeval *tv; /* timeout */ 35157770Smargo }; 35251882Sbostic int 35351882Sbostic lfs_segwait(p, uap, retval) 35451882Sbostic struct proc *p; 35557770Smargo struct lfs_segwait_args *uap; 35651882Sbostic int *retval; 35751882Sbostic { 35851882Sbostic extern int lfs_allclean_wakeup; 35951882Sbostic struct mount *mntp; 36051882Sbostic struct timeval atv; 361*65738Sbostic fsid_t fsid; 36251882Sbostic void *addr; 36351882Sbostic u_long timeout; 36451882Sbostic int error, s; 36551882Sbostic 36655941Sbostic if (error = suser(p->p_ucred, &p->p_acflag)) { 36751882Sbostic return (error); 36855941Sbostic } 36951882Sbostic #ifdef WHEN_QUADS_WORK 370*65738Sbostic if (error = copyin(uap->fsidp, &fsid, sizeof(fsid_t))) 371*65738Sbostic return (error); 372*65738Sbostic if (fsid == (fsid_t)-1) 37351882Sbostic addr = &lfs_allclean_wakeup; 37451882Sbostic else { 375*65738Sbostic if ((mntp = getvfs(&fsid)) == NULL) 37651882Sbostic return (EINVAL); 37751882Sbostic addr = &VFSTOUFS(mntp)->um_lfs->lfs_nextseg; 37851882Sbostic } 37951882Sbostic #else 380*65738Sbostic if (error = copyin(uap->fsidp, &fsid, sizeof(fsid_t))) 381*65738Sbostic return (error); 382*65738Sbostic if ((mntp = getvfs(&fsid)) == NULL) 38351882Sbostic addr = &lfs_allclean_wakeup; 38451882Sbostic else 38551882Sbostic addr = &VFSTOUFS(mntp)->um_lfs->lfs_nextseg; 38651882Sbostic #endif 38751882Sbostic 38851882Sbostic if (uap->tv) { 38951882Sbostic if (error = copyin(uap->tv, &atv, sizeof(struct timeval))) 39051882Sbostic return (error); 39151882Sbostic if (itimerfix(&atv)) 39251882Sbostic return (EINVAL); 39354764Smckusick s = splclock(); 39454764Smckusick timevaladd(&atv, (struct timeval *)&time); 39551882Sbostic timeout = hzto(&atv); 39654277Sbostic splx(s); 39751882Sbostic } else 39851882Sbostic timeout = 0; 39951882Sbostic 40051882Sbostic error = tsleep(addr, PCATCH | PUSER, "segment", timeout); 40151882Sbostic return (error == ERESTART ? EINTR : 0); 40251882Sbostic } 40355941Sbostic 40455941Sbostic /* 40555941Sbostic * VFS_VGET call specialized for the cleaner. The cleaner already knows the 40655941Sbostic * daddr from the ifile, so don't look it up again. If the cleaner is 40755941Sbostic * processing IINFO structures, it may have the ondisk inode already, so 40855941Sbostic * don't go retrieving it again. 40955941Sbostic */ 41055941Sbostic int 41155941Sbostic lfs_fastvget(mp, ino, daddr, vpp, dinp) 41255941Sbostic struct mount *mp; 41355941Sbostic ino_t ino; 41455941Sbostic daddr_t daddr; 41555941Sbostic struct vnode **vpp; 41655941Sbostic struct dinode *dinp; 41755941Sbostic { 41855941Sbostic register struct inode *ip; 41955941Sbostic struct vnode *vp; 42055941Sbostic struct ufsmount *ump; 42155941Sbostic struct buf *bp; 42255941Sbostic dev_t dev; 42355941Sbostic int error; 42455941Sbostic 42555941Sbostic ump = VFSTOUFS(mp); 42655941Sbostic dev = ump->um_dev; 42757073Smargo /* 42857073Smargo * This is playing fast and loose. Someone may have the inode 42957073Smargo * locked, in which case they are going to be distinctly unhappy 43057073Smargo * if we trash something. 43157073Smargo */ 43257073Smargo if ((*vpp = ufs_ihashlookup(dev, ino)) != NULL) { 43357073Smargo lfs_vref(*vpp); 43457073Smargo if ((*vpp)->v_flag & VXLOCK) 43557073Smargo printf ("Cleaned vnode VXLOCKED\n"); 43656191Smargo ip = VTOI(*vpp); 43764612Sbostic if (ip->i_flags & IN_LOCKED) 43864612Sbostic printf("cleaned vnode locked\n"); 43964612Sbostic if (!(ip->i_flag & IN_MODIFIED)) { 44056369Smargo ++ump->um_lfs->lfs_uinodes; 44164612Sbostic ip->i_flag |= IN_MODIFIED; 44256369Smargo } 44364612Sbostic ip->i_flag |= IN_MODIFIED; 44455941Sbostic return (0); 44556191Smargo } 44655941Sbostic 44755941Sbostic /* Allocate new vnode/inode. */ 44855941Sbostic if (error = lfs_vcreate(mp, ino, &vp)) { 44955941Sbostic *vpp = NULL; 45055941Sbostic return (error); 45155941Sbostic } 45255941Sbostic 45355941Sbostic /* 45455941Sbostic * Put it onto its hash chain and lock it so that other requests for 45555941Sbostic * this inode will block if they arrive while we are sleeping waiting 45655941Sbostic * for old data structures to be purged or for the contents of the 45755941Sbostic * disk portion of this inode to be read. 45855941Sbostic */ 45955941Sbostic ip = VTOI(vp); 46055941Sbostic ufs_ihashins(ip); 46155941Sbostic 46255941Sbostic /* 46355941Sbostic * XXX 46455941Sbostic * This may not need to be here, logically it should go down with 46555941Sbostic * the i_devvp initialization. 46655941Sbostic * Ask Kirk. 46755941Sbostic */ 46855941Sbostic ip->i_lfs = ump->um_lfs; 46955941Sbostic 47055941Sbostic /* Read in the disk contents for the inode, copy into the inode. */ 47155941Sbostic if (dinp) 47255941Sbostic if (error = copyin(dinp, &ip->i_din, sizeof(struct dinode))) 47355941Sbostic return (error); 47455941Sbostic else { 47555941Sbostic if (error = bread(ump->um_devvp, daddr, 47655941Sbostic (int)ump->um_lfs->lfs_bsize, NOCRED, &bp)) { 47755941Sbostic /* 47855941Sbostic * The inode does not contain anything useful, so it 47955941Sbostic * would be misleading to leave it on its hash chain. 48055941Sbostic * Iput() will return it to the free list. 48155941Sbostic */ 48255941Sbostic ufs_ihashrem(ip); 48355941Sbostic 48455941Sbostic /* Unlock and discard unneeded inode. */ 48557073Smargo lfs_vunref(vp); 48655941Sbostic brelse(bp); 48755941Sbostic *vpp = NULL; 48855941Sbostic return (error); 48955941Sbostic } 49064527Sbostic ip->i_din = 49164527Sbostic *lfs_ifind(ump->um_lfs, ino, (struct dinode *)bp->b_data); 49255941Sbostic brelse(bp); 49355941Sbostic } 49455941Sbostic 49556054Sbostic /* Inode was just read from user space or disk, make sure it's locked */ 49664612Sbostic ip->i_flag |= IN_LOCKED; 49756054Sbostic 49855941Sbostic /* 49955941Sbostic * Initialize the vnode from the inode, check for aliases. In all 50055941Sbostic * cases re-init ip, the underlying vnode/inode may have changed. 50155941Sbostic */ 50255941Sbostic if (error = ufs_vinit(mp, lfs_specop_p, LFS_FIFOOPS, &vp)) { 50357073Smargo lfs_vunref(vp); 50455941Sbostic *vpp = NULL; 50555941Sbostic return (error); 50655941Sbostic } 50755941Sbostic /* 50855941Sbostic * Finish inode initialization now that aliasing has been resolved. 50955941Sbostic */ 51055941Sbostic ip->i_devvp = ump->um_devvp; 51164612Sbostic ip->i_flag |= IN_MODIFIED; 51255941Sbostic ++ump->um_lfs->lfs_uinodes; 51355941Sbostic VREF(ip->i_devvp); 51455941Sbostic *vpp = vp; 51555941Sbostic return (0); 51655941Sbostic } 51755941Sbostic struct buf * 51855941Sbostic lfs_fakebuf(vp, lbn, size, uaddr) 51955941Sbostic struct vnode *vp; 52055941Sbostic int lbn; 52155941Sbostic size_t size; 52255941Sbostic caddr_t uaddr; 52355941Sbostic { 52455941Sbostic struct buf *bp; 52555941Sbostic 52655941Sbostic bp = lfs_newbuf(vp, lbn, 0); 52755941Sbostic bp->b_saveaddr = uaddr; 52855941Sbostic bp->b_bufsize = size; 52955941Sbostic bp->b_bcount = size; 53055941Sbostic bp->b_flags |= B_INVAL; 53155941Sbostic return(bp); 53255941Sbostic } 533