vget becomes a VFS op (Kirk); describe ap (Kirk); use ap instead of
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 6 Jul 1992 05:47:02 +0000 (21:47 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 6 Jul 1992 05:47:02 +0000 (21:47 -0800)
passing arguments for stackable file systems (Heideman);

SCCS-vsn: sys/ufs/lfs/lfs_inode.c 7.70

usr/src/sys/ufs/lfs/lfs_inode.c

index 6b8ce3c..5aa1644 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)lfs_inode.c 7.69 (Berkeley) %G%
+ *     @(#)lfs_inode.c 7.70 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -27,8 +27,6 @@
 #include <ufs/lfs/lfs.h>
 #include <ufs/lfs/lfs_extern.h>
 
 #include <ufs/lfs/lfs.h>
 #include <ufs/lfs/lfs_extern.h>
 
-static struct dinode *lfs_ifind __P((struct lfs *, ino_t, struct dinode *));
-
 int
 lfs_init()
 {
 int
 lfs_init()
 {
@@ -38,109 +36,8 @@ lfs_init()
        return (ufs_init());
 }
 
        return (ufs_init());
 }
 
-/*
- * Look up an LFS dinode number to find its incore vnode.  If not already
- * in core, read it in from the specified device.  Return the inode locked.
- * Detection and handling of mount points must be done by the calling routine.
- */
-int
-lfs_vget (ap)
-       struct vop_vget_args *ap;
-{
-       register struct lfs *fs;
-       register struct inode *ip;
-       struct buf *bp;
-       struct ifile *ifp;
-       struct vnode *vp;
-       struct ufsmount *ump;
-       daddr_t daddr;
-       dev_t dev;
-       int error;
-
-#ifdef VERBOSE
-       printf("lfs_vget\n");
-#endif
-       ump = VFSTOUFS(ap->a_mp);
-       dev = ump->um_dev;
-       if ((*ap->a_vpp = ufs_ihashget(dev, ap->a_ino)) != NULL)
-               return (0);
-
-       /* Translate the inode number to a disk address. */
-       fs = ump->um_lfs;
-       if (ap->a_ino == LFS_IFILE_INUM)
-               daddr = fs->lfs_idaddr;
-       else {
-               LFS_IENTRY(ifp, fs, ap->a_ino, bp);
-               daddr = ifp->if_daddr;
-               brelse(bp);
-               if (daddr == LFS_UNUSED_DADDR)
-                       return (ENOENT);
-       }
-
-       /* Allocate new vnode/inode. */
-       if (error = lfs_vcreate(ap->a_mp, ap->a_ino, &vp)) {
-               *ap->a_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 (error =
-           bread(ump->um_devvp, daddr, (int)fs->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.
-                */
-               remque(ip);
-               ip->i_forw = ip;
-               ip->i_back = ip;
-
-               /* Unlock and discard unneeded inode. */
-               ufs_iput(ip);
-               brelse(bp);
-               *ap->a_vpp = NULL;
-               return (error);
-       }
-       ip->i_din = *lfs_ifind(fs, ap->a_ino, bp->b_un.b_dino);
-       brelse(bp);
-
-       /*
-        * 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(ap->a_mp, lfs_specop_p, LFS_FIFOOPS, &vp)) {
-               ufs_iput(ip);
-               *ap->a_vpp = NULL;
-               return (error);
-       }
-       /*
-        * Finish inode initialization now that aliasing has been resolved.
-        */
-       ip->i_devvp = ump->um_devvp;
-       VREF(ip->i_devvp);
-       *ap->a_vpp = vp;
-       return (0);
-}
-
 /* Search a block for a specific dinode. */
 /* Search a block for a specific dinode. */
-static struct dinode *
+struct dinode *
 lfs_ifind(fs, ino, dip)
        struct lfs *fs;
        ino_t ino;
 lfs_ifind(fs, ino, dip)
        struct lfs *fs;
        ino_t ino;
@@ -161,8 +58,13 @@ lfs_ifind(fs, ino, dip)
 }
 
 int
 }
 
 int
-lfs_update (ap)
-       struct vop_update_args *ap;
+lfs_update(ap)
+       struct vop_update_args /* {
+               struct vnode *a_vp;
+               struct timeval *a_ta;
+               struct timeval *a_tm;
+               int a_waitfor;
+       } */ *ap;
 {
        struct vnode *vp = ap->a_vp;
        struct inode *ip;
 {
        struct vnode *vp = ap->a_vp;
        struct inode *ip;
@@ -215,13 +117,20 @@ lfs_update (ap)
  */
 /* ARGSUSED */
 int
  */
 /* ARGSUSED */
 int
-lfs_truncate (ap)
-       struct vop_truncate_args *ap;
+lfs_truncate(ap)
+       struct vop_truncate_args /* {
+               struct vnode *a_vp;
+               off_t a_length;
+               int a_flags;
+               struct ucred *a_cred;
+               struct proc *a_p;
+       } */ *ap;
 {
 {
-       USES_VOP_UPDATE;
        register INDIR *inp;
        register int i;
        register daddr_t *daddrp;
        register INDIR *inp;
        register int i;
        register daddr_t *daddrp;
+       register struct vnode *vp = ap->a_vp;
+       off_t length = ap->a_length;
        struct buf *bp, *sup_bp;
        struct ifile *ifp;
        struct inode *ip;
        struct buf *bp, *sup_bp;
        struct ifile *ifp;
        struct inode *ip;
@@ -230,27 +139,27 @@ lfs_truncate (ap)
        SEGUSE *sup;
        daddr_t daddr, lastblock, lbn, olastblock;
        long off, blocksreleased;
        SEGUSE *sup;
        daddr_t daddr, lastblock, lbn, olastblock;
        long off, blocksreleased;
-       int error, depth, lastseg, num, offset, seg, size;
+       int e1, e2, depth, lastseg, num, offset, seg, size;
 
 #ifdef VERBOSE
        printf("lfs_truncate\n");
 #endif
 
 #ifdef VERBOSE
        printf("lfs_truncate\n");
 #endif
-       vnode_pager_setsize(ap->a_vp, (u_long)ap->a_length);
+       vnode_pager_setsize(vp, (u_long)length);
 
 
-       ip = VTOI(ap->a_vp);
+       ip = VTOI(vp);
        fs = ip->i_lfs;
 
        /* If truncating the file to 0, update the version number. */
        fs = ip->i_lfs;
 
        /* If truncating the file to 0, update the version number. */
-       if (ap->a_length == 0) {
+       if (length == 0) {
                LFS_IENTRY(ifp, fs, ip->i_number, bp);
                ++ifp->if_version;
                LFS_UBWRITE(bp);
        }
 
                LFS_IENTRY(ifp, fs, ip->i_number, bp);
                ++ifp->if_version;
                LFS_UBWRITE(bp);
        }
 
-       /* If ap->a_length is larger than the file, just update the times. */
-       if (ip->i_size <= ap->a_length) {
+       /* If length is larger than the file, just update the times. */
+       if (ip->i_size <= length) {
                ip->i_flag |= ICHG|IUPD;
                ip->i_flag |= ICHG|IUPD;
-               return (VOP_UPDATE(ap->a_vp, &time, &time, 1));
+               return (VOP_UPDATE(vp, &time, &time, 1));
        }
 
        /*
        }
 
        /*
@@ -258,7 +167,7 @@ lfs_truncate (ap)
         * blocks (if any) which we want to keep.  Lastblock is 0 when the
         * file is truncated to 0.
         */
         * blocks (if any) which we want to keep.  Lastblock is 0 when the
         * file is truncated to 0.
         */
-       lastblock = lblkno(fs, ap->a_length + fs->lfs_bsize - 1);
+       lastblock = lblkno(fs, length + fs->lfs_bsize - 1);
        olastblock = lblkno(fs, ip->i_size + fs->lfs_bsize - 1) - 1;
 
        /*
        olastblock = lblkno(fs, ip->i_size + fs->lfs_bsize - 1) - 1;
 
        /*
@@ -267,20 +176,20 @@ lfs_truncate (ap)
         * of the file must be zero'ed in case it ever become accessable again
         * because of subsequent file growth.
         */
         * of the file must be zero'ed in case it ever become accessable again
         * because of subsequent file growth.
         */
-       offset = blkoff(fs, ap->a_length);
+       offset = blkoff(fs, length);
        if (offset == 0)
        if (offset == 0)
-               ip->i_size = ap->a_length;
+               ip->i_size = length;
        else {
        else {
-               lbn = lblkno(fs, ap->a_length);
+               lbn = lblkno(fs, length);
 #ifdef QUOTA
 #ifdef QUOTA
-               if (error = getinoquota(ip))
-                       return (error);
+               if (e1 = getinoquota(ip))
+                       return (e1);
 #endif 
 #endif 
-               if (error = bread(ap->a_vp, lbn, fs->lfs_bsize, NOCRED, &bp))
-                       return (error);
-               ip->i_size = ap->a_length;
+               if (e1 = bread(vp, lbn, fs->lfs_bsize, NOCRED, &bp))
+                       return (e1);
+               ip->i_size = length;
                size = blksize(fs);
                size = blksize(fs);
-               (void)vnode_pager_uncache(ap->a_vp);
+               (void)vnode_pager_uncache(vp);
                bzero(bp->b_un.b_addr + offset, (unsigned)(size - offset));
                allocbuf(bp, size);
                LFS_UBWRITE(bp);
                bzero(bp->b_un.b_addr + offset, (unsigned)(size - offset));
                allocbuf(bp, size);
                LFS_UBWRITE(bp);
@@ -294,7 +203,7 @@ lfs_truncate (ap)
        lastseg = -1;
 
        for (lbn = olastblock; lbn >= lastblock;) {
        lastseg = -1;
 
        for (lbn = olastblock; lbn >= lastblock;) {
-               lfs_bmaparray(ap->a_vp, lbn, &daddr, a, &depth);
+               lfs_bmaparray(vp, lbn, &daddr, a, &depth);
                if (lbn == olastblock)
                        for (i = NIADDR + 2; i--;)
                                a_end[i] = a[i];
                if (lbn == olastblock)
                        for (i = NIADDR + 2; i--;)
                                a_end[i] = a[i];
@@ -325,7 +234,7 @@ lfs_truncate (ap)
                                 * bread will create one just so we can free
                                 * it.
                                 */
                                 * bread will create one just so we can free
                                 * it.
                                 */
-                               if (bread(ap->a_vp,
+                               if (bread(vp,
                                    inp->in_lbn, fs->lfs_bsize, NOCRED, &bp))
                                        panic("lfs_truncate: bread bno %d",
                                            inp->in_lbn);
                                    inp->in_lbn, fs->lfs_bsize, NOCRED, &bp))
                                        panic("lfs_truncate: bread bno %d",
                                            inp->in_lbn);
@@ -371,7 +280,7 @@ lfs_truncate (ap)
        if (ip->i_blocks < 0)
                ip->i_blocks = 0;
        ip->i_flag |= ICHG|IUPD;
        if (ip->i_blocks < 0)
                ip->i_blocks = 0;
        ip->i_flag |= ICHG|IUPD;
-       (void)vinvalbuf(ap->a_vp, ap->a_length > 0); 
-       error = VOP_UPDATE(ap->a_vp, &time, &time, MNT_WAIT);
-       return (0);
+       e1 = vinvalbuf(vp, length > 0, ap->a_cred, ap->a_p); 
+       e2 = VOP_UPDATE(vp, &time, &time, MNT_WAIT);
+       return (e1 ? e1 : e2 ? e2 : 0);
 }
 }