+
+/*
+ * VFS_VGET call specialized for the cleaner. The cleaner already knows the
+ * daddr from the ifile, so don't look it up again. If the cleaner is
+ * processing IINFO structures, it may have the ondisk inode already, so
+ * don't go retrieving it again.
+ */
+int
+lfs_fastvget(mp, ino, daddr, vpp, dinp)
+ struct mount *mp;
+ ino_t ino;
+ daddr_t daddr;
+ struct vnode **vpp;
+ struct dinode *dinp;
+{
+ register struct inode *ip;
+ struct vnode *vp;
+ struct ufsmount *ump;
+ struct buf *bp;
+ dev_t dev;
+ int error;
+
+ ump = VFSTOUFS(mp);
+ dev = ump->um_dev;
+ if ((*vpp = ufs_ihashget(dev, ino)) != NULL) {
+ ip = VTOI(*vpp);
+ if (!(ip->i_flag & IMOD)) {
+ ++ump->um_lfs->lfs_uinodes;
+ ip->i_flag |= IMOD;
+ }
+ ip->i_flag |= IMOD;
+ return (0);
+ }
+
+ /* Allocate new vnode/inode. */
+ if (error = lfs_vcreate(mp, ino, &vp)) {
+ *vpp = NULL;
+ return (error);
+ }
+
+ /*
+ * Put it onto its hash chain and lock it so that other requests for
+ * this inode will block if they arrive while we are sleeping waiting
+ * for old data structures to be purged or for the contents of the
+ * disk portion of this inode to be read.
+ */
+ ip = VTOI(vp);
+ ufs_ihashins(ip);
+
+ /*
+ * XXX
+ * This may not need to be here, logically it should go down with
+ * the i_devvp initialization.
+ * Ask Kirk.
+ */
+ ip->i_lfs = ump->um_lfs;
+
+ /* Read in the disk contents for the inode, copy into the inode. */
+ if (dinp)
+ if (error = copyin(dinp, &ip->i_din, sizeof(struct dinode)))
+ return (error);
+ else {
+ if (error = bread(ump->um_devvp, daddr,
+ (int)ump->um_lfs->lfs_bsize, NOCRED, &bp)) {
+ /*
+ * The inode does not contain anything useful, so it
+ * would be misleading to leave it on its hash chain.
+ * Iput() will return it to the free list.
+ */
+ ufs_ihashrem(ip);
+
+ /* Unlock and discard unneeded inode. */
+ vput(vp);
+ brelse(bp);
+ *vpp = NULL;
+ return (error);
+ }
+ ip->i_din = *lfs_ifind(ump->um_lfs, ino, bp->b_un.b_dino);
+ brelse(bp);
+ }
+
+ /* Inode was just read from user space or disk, make sure it's locked */
+ ip->i_flag |= ILOCKED;
+
+ /*
+ * Initialize the vnode from the inode, check for aliases. In all
+ * cases re-init ip, the underlying vnode/inode may have changed.
+ */
+ if (error = ufs_vinit(mp, lfs_specop_p, LFS_FIFOOPS, &vp)) {
+ vput(vp);
+ *vpp = NULL;
+ return (error);
+ }
+ /*
+ * Finish inode initialization now that aliasing has been resolved.
+ */
+ ip->i_devvp = ump->um_devvp;
+ ip->i_flag |= IMOD;
+ ++ump->um_lfs->lfs_uinodes;
+ VREF(ip->i_devvp);
+ *vpp = vp;
+ return (0);
+}
+struct buf *
+lfs_fakebuf(vp, lbn, size, uaddr)
+ struct vnode *vp;
+ int lbn;
+ size_t size;
+ caddr_t uaddr;
+{
+ struct buf *bp;
+
+ bp = lfs_newbuf(vp, lbn, 0);
+ bp->b_saveaddr = uaddr;
+ bp->b_bufsize = size;
+ bp->b_bcount = size;
+ bp->b_flags |= B_INVAL;
+ return(bp);
+}