make comments more precise
[unix-history] / usr / src / sys / ufs / lfs / lfs_balloc.c
index 43700cd..8954954 100644 (file)
@@ -2,36 +2,27 @@
  * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * %sccs.include.redist.c%
  *
  *
- *     @(#)lfs_balloc.c        7.8 (Berkeley) %G%
+ *     @(#)lfs_balloc.c        7.13 (Berkeley) %G%
  */
 
 #include "param.h"
 #include "systm.h"
  */
 
 #include "param.h"
 #include "systm.h"
-#include "user.h"
 #include "buf.h"
 #include "proc.h"
 #include "file.h"
 #include "vnode.h"
 #include "buf.h"
 #include "proc.h"
 #include "file.h"
 #include "vnode.h"
-#include "../ufs/quota.h"
-#include "../ufs/inode.h"
-#include "../ufs/fs.h"
+
+#include "quota.h"
+#include "inode.h"
+#include "fs.h"
 
 /*
 
 /*
- * Bmap defines the structure of file system storage
- * by returning the physical block number on a device
- * given the inode and the logical block number in a file.
+ * Bmap converts a the logical block number of a file
+ * to its physical block number on the disk. The conversion
+ * is done by using the logical block number to index into
+ * the array of block pointers described by the dinode.
  */
 bmap(ip, bn, bnp)
        register struct inode *ip;
  */
 bmap(ip, bn, bnp)
        register struct inode *ip;
@@ -142,6 +133,7 @@ balloc(ip, bn, size, bpp, flags)
                        if (error)
                                return (error);
                        ip->i_size = (nb + 1) * fs->fs_bsize;
                        if (error)
                                return (error);
                        ip->i_size = (nb + 1) * fs->fs_bsize;
+                       vnode_pager_setsize(ITOV(ip), (u_long)ip->i_size);
                        ip->i_db[nb] = dbtofsb(fs, bp->b_blkno);
                        ip->i_flag |= IUPD|ICHG;
                        if (flags & B_SYNC)
                        ip->i_db[nb] = dbtofsb(fs, bp->b_blkno);
                        ip->i_flag |= IUPD|ICHG;
                        if (flags & B_SYNC)
@@ -327,15 +319,15 @@ balloc(ip, bn, size, bpp, flags)
                return (0);
        }
        brelse(bp);
                return (0);
        }
        brelse(bp);
-       nbp = getblk(vp, lbn, fs->fs_bsize);
-       nbp->b_blkno = fsbtodb(fs, nb);
-       if ((flags & B_CLRBUF) && (nbp->b_flags & (B_DONE|B_DELWRI)) == 0) {
-               brelse(nbp);
+       if (flags & B_CLRBUF) {
                error = bread(vp, lbn, (int)fs->fs_bsize, NOCRED, &nbp);
                if (error) {
                        brelse(nbp);
                        return (error);
                }
                error = bread(vp, lbn, (int)fs->fs_bsize, NOCRED, &nbp);
                if (error) {
                        brelse(nbp);
                        return (error);
                }
+       } else {
+               nbp = getblk(vp, lbn, fs->fs_bsize);
+               nbp->b_blkno = fsbtodb(fs, nb);
        }
        *bpp = nbp;
        return (0);
        }
        *bpp = nbp;
        return (0);