summaryrefslogtreecommitdiffstats
path: root/sys/ufs
diff options
context:
space:
mode:
authortruckman <truckman@FreeBSD.org>2005-09-29 21:50:26 +0000
committertruckman <truckman@FreeBSD.org>2005-09-29 21:50:26 +0000
commiteccf618ca4d82d35e94fec5dbf08c181329036d0 (patch)
tree9d348d274c0d44e0a1a567e65c48e729e95f6158 /sys/ufs
parentc5c0b326f7c9fc45ee430b93b2175d243cdca4f1 (diff)
downloadFreeBSD-src-eccf618ca4d82d35e94fec5dbf08c181329036d0.zip
FreeBSD-src-eccf618ca4d82d35e94fec5dbf08c181329036d0.tar.gz
After a rmdir()ed directory has been truncated, force an update of
the directory's inode after queuing the dirrem that will decrement the parent directory's link count. This will force the update of the parent directory's actual link to actually be scheduled. Without this change the parent directory's actual link count would not be updated until ufs_inactive() cleared the inode of the newly removed directory, which might be deferred indefinitely. ufs_inactive() will not be called as long as any process holds a reference to the removed directory, and ufs_inactive() will not clear the inode if the link count is non-zero, which could be the result of an earlier system crash. If a background fsck is run before the update of the parent directory's actual link count has been performed, or at least scheduled by putting the dirrem on the leaf directory's inodedep id_bufwait list, fsck will corrupt the file system by decrementing the parent directory's effective link count, which was previously correct because it already took the removal of the leaf directory into account, and setting the actual link count to the same value as the effective link count after the dangling, removed, leaf directory has been removed. This happens because fsck acts based on the actual link count, which will be too high when fsck creates the file system snapshot that it references. This change has the fortunate side effect of more quickly cleaning up the large number dirrem structures that linger for an extended time after the removal of a large directory tree. It also fixes a potential problem with the shutdown of the syncer thread timing out if the system is rebooted immediately after removing a large directory tree. Submitted by: tegge MFC after: 3 days
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/ffs/ffs_softdep.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c
index 3127150..7687113 100644
--- a/sys/ufs/ffs/ffs_softdep.c
+++ b/sys/ufs/ffs/ffs_softdep.c
@@ -3477,6 +3477,8 @@ handle_workitem_remove(dirrem, xp)
}
WORKLIST_INSERT(&inodedep->id_inowait, &dirrem->dm_list);
FREE_LOCK(&lk);
+ ip->i_flag |= IN_CHANGE;
+ ffs_update(vp, 0);
vput(vp);
}
OpenPOWER on IntegriCloud