projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Check for out of space condition before extending ifile.
[unix-history]
/
usr
/
src
/
sys
/
ufs
/
lfs
/
lfs_alloc.c
diff --git
a/usr/src/sys/ufs/lfs/lfs_alloc.c
b/usr/src/sys/ufs/lfs/lfs_alloc.c
index
984b1f4
..
96bd309
100644
(file)
--- a/
usr/src/sys/ufs/lfs/lfs_alloc.c
+++ b/
usr/src/sys/ufs/lfs/lfs_alloc.c
@@
-4,7
+4,7
@@
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)lfs_alloc.c 7.
4
4 (Berkeley) %G%
+ * @(#)lfs_alloc.c 7.
5
4 (Berkeley) %G%
*/
#include <sys/param.h>
*/
#include <sys/param.h>
@@
-29,12
+29,13
@@
extern u_long nextgennumber;
/* Allocate a new inode. */
/* ARGSUSED */
int
/* Allocate a new inode. */
/* ARGSUSED */
int
-lfs_valloc (ap)
- struct vop_valloc_args *ap;
-#define pvp (ap->a_pvp)
-#define notused (ap->a_mode)
-#define cred (ap->a_cred)
-#define vpp (ap->a_vpp)
+lfs_valloc(ap)
+ struct vop_valloc_args /* {
+ struct vnode *a_pvp;
+ int a_mode;
+ struct ucred *a_cred;
+ struct vnode **a_vpp;
+ } */ *ap;
{
struct lfs *fs;
struct buf *bp;
{
struct lfs *fs;
struct buf *bp;
@@
-44,13
+45,10
@@
lfs_valloc (ap)
daddr_t blkno;
ino_t new_ino;
u_long i, max;
daddr_t blkno;
ino_t new_ino;
u_long i, max;
- int error;
+ int
bb,
error;
-#ifdef VERBOSE
- printf("lfs_valloc\n");
-#endif
/* Get the head of the freelist. */
/* Get the head of the freelist. */
- fs = VTOI(pvp)->i_lfs;
+ fs = VTOI(
ap->a_
pvp)->i_lfs;
new_ino = fs->lfs_free;
#ifdef ALLOCPRINT
printf("lfs_ialloc: allocate inode %d\n", new_ino);
new_ino = fs->lfs_free;
#ifdef ALLOCPRINT
printf("lfs_ialloc: allocate inode %d\n", new_ino);
@@
-68,23
+66,17
@@
lfs_valloc (ap)
/* Extend IFILE so that the next lfs_valloc will succeed. */
if (fs->lfs_free == LFS_UNUSED_INUM) {
/* Extend IFILE so that the next lfs_valloc will succeed. */
if (fs->lfs_free == LFS_UNUSED_INUM) {
+ bb = fsbtodb(fs, 1);
+ if (!ISSPACE(fs, bb, ap->a_cred))
+ return(ENOSPC);
vp = fs->lfs_ivnode;
ip = VTOI(vp);
blkno = lblkno(fs, ip->i_size);
vp = fs->lfs_ivnode;
ip = VTOI(vp);
blkno = lblkno(fs, ip->i_size);
-printf("Extending ifile: blkno = %d\n", blkno);
bp = getblk(vp, blkno, fs->lfs_bsize);
bp = getblk(vp, blkno, fs->lfs_bsize);
- if (!bp) {
- uprintf("\n%s: no inodes left\n", fs->lfs_fsmnt);
- log(LOG_ERR, "uid %d on %s: out of inodes\n",
- cred->cr_uid, fs->lfs_fsmnt);
- return (ENOSPC);
- }
i = (blkno - fs->lfs_segtabsz - fs->lfs_cleansz) *
fs->lfs_ifpb;
i = (blkno - fs->lfs_segtabsz - fs->lfs_cleansz) *
fs->lfs_ifpb;
-printf("Extending ifile: first inum = %d\n", i);
fs->lfs_free = i;
max = i + fs->lfs_ifpb;
fs->lfs_free = i;
max = i + fs->lfs_ifpb;
-printf("Extending ifile: max inum = %d\n", max);
for (ifp = (struct ifile *)bp->b_un.b_words; i < max; ++ifp) {
ifp->if_version = 1;
ifp->if_daddr = LFS_UNUSED_DADDR;
for (ifp = (struct ifile *)bp->b_un.b_words; i < max; ++ifp) {
ifp->if_version = 1;
ifp->if_daddr = LFS_UNUSED_DADDR;
@@
-93,18
+85,20
@@
printf("Extending ifile: max inum = %d\n", max);
ifp--;
ifp->if_nextfree = LFS_UNUSED_INUM;
ifp--;
ifp->if_nextfree = LFS_UNUSED_INUM;
- ++ip->i_blocks; /* XXX This may not be right. */
+ ip->i_blocks += btodb(fs->lfs_bsize);
+ fs->lfs_bfree -= btodb(fs->lfs_bsize);
ip->i_size += fs->lfs_bsize;
ip->i_size += fs->lfs_bsize;
-printf("Extending ifile: blocks = %d size = %d\n", ip->i_blocks, ip->i_size);
vnode_pager_setsize(vp, (u_long)ip->i_size);
vnode_pager_uncache(vp);
vnode_pager_setsize(vp, (u_long)ip->i_size);
vnode_pager_uncache(vp);
- LFS_UBWRITE(bp);
+ if (error = VOP_BWRITE(bp))
+ return (error);
}
/* Create a vnode to associate with the inode. */
}
/* Create a vnode to associate with the inode. */
- if (error = lfs_vcreate(pvp->v_mount, new_ino, &vp))
+ if (error = lfs_vcreate(
ap->a_
pvp->v_mount, new_ino, &vp))
return (error);
return (error);
- *vpp = vp;
+ *ap->a_vpp = vp;
+ vp->v_flag |= VDIROP;
ip = VTOI(vp);
VREF(ip->i_devvp);
ip = VTOI(vp);
VREF(ip->i_devvp);
@@
-124,10
+118,6
@@
printf("Extending ifile: blocks = %d size = %d\n", ip->i_blocks, ip->i_size);
++fs->lfs_nfiles;
return (0);
}
++fs->lfs_nfiles;
return (0);
}
-#undef pvp
-#undef notused
-#undef cred
-#undef vpp
/* Create a new vnode/inode pair and initialize what fields we can. */
int
/* Create a new vnode/inode pair and initialize what fields we can. */
int
@@
-141,9
+131,6
@@
lfs_vcreate(mp, ino, vpp)
struct ufsmount *ump;
int error, i;
struct ufsmount *ump;
int error, i;
-#ifdef VERBOSE
- printf("lfs_vcreate: ino %d\n", ino);
-#endif
/* Create the vnode. */
if (error = getnewvnode(VT_LFS, mp, lfs_vnodeop_p, vpp)) {
*vpp = NULL;
/* Create the vnode. */
if (error = getnewvnode(VT_LFS, mp, lfs_vnodeop_p, vpp)) {
*vpp = NULL;
@@
-158,7
+145,7
@@
lfs_vcreate(mp, ino, vpp)
(*vpp)->v_data = ip;
ip->i_vnode = *vpp;
ip->i_devvp = ump->um_devvp;
(*vpp)->v_data = ip;
ip->i_vnode = *vpp;
ip->i_devvp = ump->um_devvp;
- ip->i_flag =
0
;
+ ip->i_flag =
IMOD
;
ip->i_dev = ump->um_dev;
ip->i_number = ip->i_din.di_inum = ino;
ip->i_lfs = ump->um_lfs;
ip->i_dev = ump->um_dev;
ip->i_number = ip->i_din.di_inum = ino;
ip->i_lfs = ump->um_lfs;
@@
-170,17
+157,20
@@
lfs_vcreate(mp, ino, vpp)
ip->i_diroff = 0;
ip->i_mode = 0;
ip->i_size = 0;
ip->i_diroff = 0;
ip->i_mode = 0;
ip->i_size = 0;
+ ip->i_blocks = 0;
+ ++ump->um_lfs->lfs_uinodes;
return (0);
}
/* Free an inode. */
/* ARGUSED */
int
return (0);
}
/* Free an inode. */
/* ARGUSED */
int
-lfs_vfree (ap)
- struct vop_vfree_args *ap;
-#define vp (ap->a_pvp)
-#define notused1 (ap->a_ino)
-#define notused2 (ap->a_mode)
+lfs_vfree(ap)
+ struct vop_vfree_args /* {
+ struct vnode *a_pvp;
+ ino_t a_ino;
+ int a_mode;
+ } */ *ap;
{
SEGUSE *sup;
struct buf *bp;
{
SEGUSE *sup;
struct buf *bp;
@@
-189,15
+179,16
@@
lfs_vfree (ap)
struct lfs *fs;
daddr_t old_iaddr;
ino_t ino;
struct lfs *fs;
daddr_t old_iaddr;
ino_t ino;
+ int error;
- ip = VTOI(vp);
-#ifdef VERBOSE
- printf("lfs_vfree: free %d\n", ip->i_number);
-#endif
/* Get the inode number and file system. */
/* Get the inode number and file system. */
+ ip = VTOI(ap->a_pvp);
fs = ip->i_lfs;
ino = ip->i_number;
fs = ip->i_lfs;
ino = ip->i_number;
-
+ if (ip->i_flag & IMOD) {
+ --fs->lfs_uinodes;
+ ip->i_flag &= ~(IMOD | IACC | IUPD | ICHG);
+ }
/*
* Set the ifile's inode entry to unused, increment its version number
* and link it into the free chain.
/*
* Set the ifile's inode entry to unused, increment its version number
* and link it into the free chain.
@@
-208,7
+199,7
@@
lfs_vfree (ap)
++ifp->if_version;
ifp->if_nextfree = fs->lfs_free;
fs->lfs_free = ino;
++ifp->if_version;
ifp->if_nextfree = fs->lfs_free;
fs->lfs_free = ino;
-
LFS_U
BWRITE(bp);
+
(void) VOP_
BWRITE(bp);
if (old_iaddr != LFS_UNUSED_DADDR) {
LFS_SEGENTRY(sup, fs, datosn(fs, old_iaddr), bp);
if (old_iaddr != LFS_UNUSED_DADDR) {
LFS_SEGENTRY(sup, fs, datosn(fs, old_iaddr), bp);
@@
-218,7
+209,7
@@
lfs_vfree (ap)
datosn(fs, old_iaddr));
#endif
sup->su_nbytes -= sizeof(struct dinode);
datosn(fs, old_iaddr));
#endif
sup->su_nbytes -= sizeof(struct dinode);
-
LFS_U
BWRITE(bp);
+
(void) VOP_
BWRITE(bp);
}
/* Set superblock modified bit and decrement file count. */
}
/* Set superblock modified bit and decrement file count. */
@@
-226,8
+217,3
@@
lfs_vfree (ap)
--fs->lfs_nfiles;
return (0);
}
--fs->lfs_nfiles;
return (0);
}
-#undef vp
-#undef notused1
-#undef notused2
-
-