- ip->i_count++;
- ip->i_flag |= ILOCKED;
-}
-
-/*
- * Decrement reference count of
- * an inode structure.
- * On the last reference,
- * write the inode out and if necessary,
- * truncate and deallocate the file.
- */
-iput(ip)
- register struct inode *ip;
-{
-
- if ((ip->i_flag & ILOCKED) == 0)
- panic("iput");
- IUNLOCK(ip);
- irele(ip);
-}
-
-irele(ip)
- register struct inode *ip;
-{
- int mode;
-
- if (ip->i_count == 1) {
- ip->i_flag |= ILOCKED;
- if (ip->i_nlink <= 0 && ip->i_fs->fs_ronly == 0) {
- itrunc(ip, (u_long)0);
- mode = ip->i_mode;
- ip->i_mode = 0;
- ip->i_rdev = 0;
- ip->i_flag |= IUPD|ICHG;
- ifree(ip, ip->i_number, mode);
-#ifdef QUOTA
- (void) chkiq(ip->i_dev, ip, ip->i_uid, 0);
- dqrele(ip->i_dquot);
- ip->i_dquot = NODQUOT;
-#endif
- }
- IUPDAT(ip, &time, &time, 0);
- IUNLOCK(ip);
- ip->i_flag = 0;
- /*
- * Put the inode on the end of the free list.
- * Possibly in some cases it would be better to
- * put the inode at the head of the free list,
- * (eg: where i_mode == 0 || i_number == 0)
- * but I will think about that later .. kre
- * (i_number is rarely 0 - only after an i/o error in iget,
- * where i_mode == 0, the inode will probably be wanted
- * again soon for an ialloc, so possibly we should keep it)
- */
- if (ifreeh) {
- *ifreet = ip;
- ip->i_freeb = ifreet;
- } else {
- ifreeh = ip;
- ip->i_freeb = &ifreeh;
- }
- ip->i_freef = NULL;
- ifreet = &ip->i_freef;
- } else if (!(ip->i_flag & ILOCKED))
- ITIMES(ip, &time, &time);
- ip->i_count--;