summaryrefslogtreecommitdiff
tag namedeferred-inactivation_2019-08-10 (9dbb5b03ed2fce96cdcb4221639c6460b4cf4530)
tag date2019-08-10 09:58:24 -0700
tagged byDarrick J. Wong <darrick.wong@oracle.com>
tagged objectcommit 94c6e99854...
xfs: deferred inode inactivation
This patch series implements deferred inode inactivation. Inactivation is the process of updating all on-disk metadata when a file is deleted -- freeing the data/attr/COW fork extent allocations, removing the inode from the unlinked hash, marking the inode record itself free, and updating the inode btrees so that they show the inode as not being in use. Currently, all this inactivation is performed during in-core inode reclaim, which creates two big headaches: first, this makes direct memory reclamation /really/ slow, and second, it prohibits us from partially freezing the filesystem for online fsck activity because scrub can hit direct memory reclaim. It's ok for scrub to fail with ENOMEM, but it's not ok for scrub to deadlock memory reclaim. :) The implementation will be familiar to those who have studied how XFS scans for reclaimable in-core inodes -- we create a couple more inode state flags to mark an inode as needing inactivation and being in the middle of inactivation. When inodes need inactivation, we set iflags, set the RECLAIM radix tree tag, update a count of how many resources will be freed by the pending inactivations, and schedule a deferred work item. The deferred work item scans the inode radix tree for inodes to inactivate, and does all the on-disk metadata updates. Once the inode has been inactivated, it is left in the reclaim state and the background reclaim worker (or direct reclaim) will get to it eventually. Patch 1-2 refactor some of the inactivation predicates. Patches 3-4 implement the count of blocks/quota that can be freed by running inactivation; this is necessary to preserve the behavior where you rm a file and the fs counters update immediately. Patches 5-6 refactor more inode reclaim code so that we can reuse some of it for inactivation. Patch 8 delivers the core of the inactivation changes by altering the inode lifetime state machine to include the new inode flags and background workers. Patches 9-10 makes it so that if an allocation attempt hits ENOSPC it will force inactivation to free resources and try again. Patch 11 converts the per-fs inactivation scanner to be tracked on a per-AG basis so that we can be more targeted in our inactivation. Patches 12-14 teach the per-AG sick status to remember if we inactivate inodes that themselves had unfixed sick flags set, and for scrub to clear all those flags if it finds that the filesystem is clean.