* Copyright (c) 1991 Regents of the University of California.
* %sccs.include.redist.c%
* @(#)ufs_inode.c 7.41 (Berkeley) %G%
#include <ufs/ufs/quota.h>
#include <ufs/ufs/inode.h>
#include <ufs/ufs/ufsmount.h>
#include <ufs/ufs/ufs_extern.h>
u_long nextgennumber
; /* Next generation number to assign. */
int prtactive
; /* 1 => print out reclaim of active vnodes */
if (VN_MAXPRIVATE
< sizeof(struct inode
))
panic("ufs_init: inode too small");
* Unlock and decrement the reference count of an inode structure.
register struct inode
*ip
;
if ((ip
->i_flag
& ILOCKED
) == 0)
* Last reference to an inode, write the inode out and if necessary,
* truncate and deallocate the file.
register struct inode
*ip
;
if (prtactive
&& vp
->v_usecount
!= 0)
vprint("ufs_inactive: pushing active", vp
);
/* Get rid of inodes related to stale file handles. */
if ((vp
->v_flag
& VXLOCK
) == 0)
ump
= VFSTOUFS(vp
->v_mount
);
if (ip
->i_nlink
<= 0 && (vp
->v_mount
->mnt_flag
& MNT_RDONLY
) == 0) {
(void)chkiq(ip
, -1, NOCRED
, 0);
error
= (ump
->um_itrunc
)(ip
, (u_long
)0, 0);
(ump
->um_ifree
)(ip
, ip
->i_number
, mode
);
if (ip
->i_flag
&(IUPD
|IACC
|ICHG
|IMOD
))
(ump
->um_iupdat
)(ip
, &time
, &time
, 0);
* If we are done with the inode, reclaim it
* so that it can be reused immediately.
if (vp
->v_usecount
== 0 && ip
->i_mode
== 0)
* Reclaim an inode so that it can be used for other purposes.
register struct vnode
*vp
;
register struct inode
*ip
;
if (prtactive
&& vp
->v_usecount
!= 0)
vprint("ufs_reclaim: pushing active", vp
);
* Remove the inode from its hash chain.
* Purge old data structures associated with the inode.
for (i
= 0; i
< MAXQUOTAS
; i
++) {
if (ip
->i_dquot
[i
] != NODQUOT
) {
dqrele(vp
, ip
->i_dquot
[i
]);
ip
->i_dquot
[i
] = NODQUOT
;
* Lock an inode. If its already locked, set the WANT bit and sleep.
register struct inode
*ip
;
while (ip
->i_flag
& ILOCKED
) {
if (ip
->i_spare0
== curproc
->p_pid
)
panic("locking against myself");
ip
->i_spare1
= curproc
->p_pid
;
(void) sleep((caddr_t
)ip
, PINOD
);
ip
->i_spare0
= curproc
->p_pid
;
* Unlock an inode. If WANT bit is on, wakeup.
register struct inode
*ip
;
if ((ip
->i_flag
& ILOCKED
) == 0)
vprint("ufs_iunlock: unlocked inode", ITOV(ip
));