- * Check accessed and update flags on
- * an inode structure.
- * If any is on, update the inode
- * with the current time.
- * If waitfor is given, then must insure
- * i/o order so wait for write to complete.
+ * Reclaim an inode so that it can be used for other purposes.
+ */
+ufs_reclaim(vp)
+ register struct vnode *vp;
+{
+ register struct inode *iq, *ip = VTOI(vp);
+
+ if (vp->v_count != 0)
+ panic("ufs_reclaim: active inode");
+ /*
+ * Remove the inode from its hash chain.
+ */
+ remque(ip);
+ ip->i_forw = ip;
+ ip->i_back = ip;
+ /*
+ * Purge old data structures associated with the inode.
+ */
+ cache_purge(vp);
+ if (ip->i_devvp) {
+ vrele(ip->i_devvp);
+ ip->i_devvp = 0;
+ }
+#ifdef QUOTA
+ dqrele(ip->i_dquot);
+ ip->i_dquot = NODQUOT;
+#endif
+ if (vp->v_type == VBLK) {
+ if (bdevlisth == ip) {
+ bdevlisth = ip->i_devlst;
+ } else {
+ for (iq = bdevlisth; iq; iq = iq->i_devlst) {
+ if (iq->i_devlst != ip)
+ continue;
+ iq->i_devlst = ip->i_devlst;
+ break;
+ }
+ if (iq == NULL)
+ panic("missing bdev");
+ }
+ }
+ vp->v_type = VNON;
+ ip->i_flag = 0;
+ return (0);
+}
+
+/*
+ * Check accessed and update flags on an inode structure.
+ * If any is on, update the inode with the current time.
+ * If waitfor is given, then must ensure I/O order,
+ * so wait for write to complete.