summaryrefslogtreecommitdiff
path: root/fs
AgeCommit message (Collapse)Author
2020-03-03xfs: create a polled function to force inode inactivationdeferred-inactivation_2020-03-03Darrick J. Wong
Create a polled version of xfs_inactive_force so that we can force inactivation while holding a lock (usually the umount lock) without tripping over the softlockup timer. This is for callers that hold vfs locks while calling inactivation, which is currently unmount, iunlink processing during mount, and rw->ro remount. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: parallelize inode inactivationDarrick J. Wong
Split the inode inactivation work into per-AG work items so that we can take advantage of parallelization. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: force inactivation before fallocate when space is lowDarrick J. Wong
If we think that inactivation will free enough blocks to make it easier to satisfy an fallocate request, force inactivation. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: force inode inactivation and retry fs writes when there isn't spaceDarrick J. Wong
Any time we try to modify a file's contents and it fails due to ENOSPC or EDQUOT, force inactivation work to free up some resources and try one more time. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: deferred inode inactivationDarrick J. Wong
Instead of calling xfs_inactive directly from xfs_fs_destroy_inode, defer the inactivation phase to a separate workqueue. With this we avoid blocking memory reclaim on filesystem metadata updates that are necessary to free an in-core inode, such as post-eof block freeing, COW staging extent freeing, and truncating and freeing unlinked inodes. Now that work is deferred to a workqueue where we can do the freeing in batches. We introduce two new inode flags -- NEEDS_INACTIVE and INACTIVATING. The first flag helps our worker find inodes needing inactivation, and the second flag marks inodes that are in the process of being inactivated. A concurrent xfs_iget on the inode can still resurrect the inode by clearing NEEDS_INACTIVE (or bailing if INACTIVATING is set). Unfortunately, deferring the inactivation has one huge downside -- eventual consistency. Since all the freeing is deferred to a worker thread, one can rm a file but the space doesn't come back immediately. This can cause some odd side effects with quota accounting and statfs, so we also force inactivation scans in order to maintain the existing behaviors, at least outwardly. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: pass around xfs_inode_ag_walk iget/irele helper functionsDarrick J. Wong
Create an alternative version of xfs_ici_walk() that allow a caller to pass in custom inode grab and inode release helper functions. Deferred inode inactivation deals with xfs inodes that are still in memory but no longer visible to the vfs, which means that it has to screen and process those inodes differently. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: pass per-ag structure to the xfs_ici_walk execute functionDarrick J. Wong
Pass the per-AG structure to the xfs_ici_walk execute function. This isn't needed now, but deferred inactivation will need it to modify some per-ag data. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: track unlinked inactive inode quota countersDarrick J. Wong
Set up quota counters to track the number of inodes and blocks that will be freed from inactivating unlinked inodes. We'll use this in the deferred inactivation patch to hide the effects of deferred processing. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: track unlinked inactive inode fs summary countersDarrick J. Wong
Set up counters to track the number of inodes and blocks that will be freed from inactivating unlinked inodes. We'll use this in the deferred inactivation patch to hide the effects of deferred processing. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: decide if inode needs inactivationDarrick J. Wong
Add a predicate function to decide if an inode needs (deferred) inactivation. Any file that has been unlinked or has speculative preallocations either for post-EOF writes or for CoW qualifies. This function will also be used by the upcoming deferred inactivation patch. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: parallelize block preallocation garbage collectioneofblocks-consolidation_2020-03-03Darrick J. Wong
Split the block preallocation garbage collection work into per-AG work items so that we can take advantage of parallelization. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: rename block gc start and stop functionsDarrick J. Wong
Shorten the names of the two functions that start and stop block preallocation garbage collection and move them up to the other blockgc functions. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: only walk the incore inode tree once per blockgc scanDarrick J. Wong
Perform background block preallocation gc scans more efficiently by walking the incore inode tree once. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: remove the separate cowblocks workerDarrick J. Wong
Remove the separate cowblocks work items and knob so that we can control and run everything from a single blockgc work queue. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: consolidate incore inode radix tree posteof/cowblocks tagsDarrick J. Wong
The clearing of posteof blocks and cowblocks serve the same purpose: removing speculative block preallocations from inactive files. We don't need to burn two radix tree tags on this, so combine them into one. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: refactor the predicate part of xfs_free_eofblocksDarrick J. Wong
Refactor the part of _free_eofblocks that decides if it's really going to truncate post-EOF blocks into a separate helper function. The upcoming deferred inode inactivation patch requires us to be able to decide this prior to actual inactivation. No functionality changes. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: flush speculative space allocations when we run out of spacereclaim-space-harder_2020-03-03Darrick J. Wong
If a fs modification (creation, file write, reflink, etc.) is unable to reserve enough space to handle the modification, try clearing whatever space the filesystem might have been hanging onto in the hopes of speeding up the filesystem. The flushing behavior will become particularly important when we add deferred inode inactivation because that will increase the amount of space that isn't actively tied to user data. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: flush speculative space allocations when we run out of quotaDarrick J. Wong
If a fs modification (creation, file write, reflink, etc.) is unable to reserve enough quota to handle the modification, try clearing whatever space the filesystem might have been hanging onto in the hopes of speeding up the filesystem. The flushing behavior will become particularly important when we add deferred inode inactivation because that will increase the amount of space that isn't actively tied to user data. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: xfs_inode_free_quota_blocks should scan project quotaDarrick J. Wong
Buffered writers who have run out of quota reservation call xfs_inode_free_quota_blocks to try to free any space reservations that might reduce the quota usage. Unfortunately, the buffered write path treats "out of project quota" the same as "out of overall space" so this function has never supported scanning for space that might ease an "out of project quota" condition. We're about to start using this function for cases where we actually /can/ tell if we're out of project quota, so add in this functionality. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: move inode flush to a workqueueDarrick J. Wong
Move the inode dirty data flushing to a workqueue so that multiple threads can take advantage of a single thread's flush work. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: don't stall cowblocks scan if we can't take locksDarrick J. Wong
Don't stall the cowblocks scan on a locked inode if we possibly can. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: refactor messy xfs_inode_free_quota_* functionsDarrick J. Wong
The functions to run an eof/cowblocks scan to try to reduce quota usage are kind of a mess -- the logic repeatedly initializes an eofb structure and there are logic bugs in the code that result in the cowblocks scan never actually happening. Replace all three functions with a single function that fills out an eofb if we're low on quota and runs both eof and cowblocks scans. Fixes: 83104d449e8c4 ("xfs: garbage collect old cowextsz reservations") Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: hide most of the incore inode walk interfaceincore-inode-walk_2020-03-03Darrick J. Wong
Hide the incore inode walk interface because callers outside of the icache code don't need to know about iter_flags and radix tags and other implementation details of the incore inode cache. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: move xfs_inode_ag_iterator to be closer to the perag walking codeDarrick J. Wong
Move the xfs_inode_ag_iterator function to be nearer xfs_inode_ag_walk so that we don't have to scroll back and forth to figure out how the incore inode walking function works. No functional changes. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: use bool for done in xfs_inode_ag_walkDarrick J. Wong
This is a boolean variable, so use the bool type. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: fix inode ag walk predicate function return valuesDarrick J. Wong
There are a number of predicate functions that help the incore inode walking code decide if we really want to apply the iteration function to the inode. These are boolean decisions, so change the return types to boolean to match. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: refactor eofb matching into a single helperDarrick J. Wong
Refactor the two eofb-matching logics into a single helper so that we don't repeat ourselves. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: remove __xfs_icache_free_eofblocksDarrick J. Wong
This is now a pointless wrapper, so kill it. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: remove flags argument from xfs_inode_ag_walkDarrick J. Wong
The incore inode walk code passes a flags argument and a pointer from the xfs_inode_ag_iterator caller all the way to the iteration function. We can reduce the function complexity by passing flags through the private pointer. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: remove xfs_inode_ag_iterator_flagsDarrick J. Wong
Combine xfs_inode_ag_iterator_flags and xfs_inode_ag_iterator_tag into a single wrapper function since there's only one caller of the _flags variant. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: remove unused xfs_inode_ag_iterator functionDarrick J. Wong
Not used by anyone, so get rid of it. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: replace open-coded XFS_ICI_NO_TAGDarrick J. Wong
Use XFS_ICI_NO_TAG instead of -1 when appropriate. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: move eofblocks conversion function to xfs_ioctl.cDarrick J. Wong
Move xfs_fs_eofblocks_from_user into the only file that actually uses it, so that we don't have this function cluttering up the header file. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: report XFS_CORRUPT_ON errors to the health systemcorruption-health-reports_2020-03-03Darrick J. Wong
Whenever we encounter XFS_CORRUPT_ON failures, we should report that to the health monitoring system for later reporting. I started with this and massaged everything until it built: @@ expression mp, test; @@ - if (XFS_CORRUPT_ON(mp, test)) return -EFSCORRUPTED; + if (XFS_CORRUPT_ON(mp, test)) { xfs_btree_mark_sick(cur); return -EFSCORRUPTED; } @@ expression mp, test; identifier label, error; @@ - if (XFS_CORRUPT_ON(mp, test)) { error = -EFSCORRUPTED; goto label; } + if (XFS_CORRUPT_ON(mp, test)) { xfs_btree_mark_sick(cur); error = -EFSCORRUPTED; goto label; } Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: report realtime metadata corruption errors to the health systemDarrick J. Wong
Whenever we encounter corrupt realtime metadat blocks, we should report that to the health monitoring system for later reporting. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: report quota block corruption errors to the health systemDarrick J. Wong
Whenever we encounter corrupt quota blocks, we should report that to the health monitoring system for later reporting. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: report inode corruption errors to the health systemDarrick J. Wong
Whenever we encounter corrupt inode records, we should report that to the health monitoring system for later reporting. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: report symlink block corruption errors to the health systemDarrick J. Wong
Whenever we encounter corrupt symbolic link blocks, we should report that to the health monitoring system for later reporting. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: report dir/attr block corruption errors to the health systemDarrick J. Wong
Whenever we encounter corrupt directory or extended attribute blocks, we should report that to the health monitoring system for later reporting. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: report btree block corruption errors to the health systemDarrick J. Wong
Whenever we encounter corrupt btree blocks, we should report that to the health monitoring system for later reporting. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: report block map corruption errors to the health tracking systemDarrick J. Wong
Whenever we encounter a corrupt block mapping, we should report that to the health monitoring system for later reporting. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: report ag header corruption errors to the health tracking systemDarrick J. Wong
Whenever we encounter a corrupt AG header, we should report that to the health monitoring system for later reporting. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: separate the marking of sick and checked metadataDarrick J. Wong
Split the setting of the sick and checked masks into separate functions as part of preparing to add the ability for regular runtime fs code (i.e. not scrub) to mark metadata structures sick when corruptions are found. Improve the documentation of libxfs' requirements for helper behavior. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: repair quotasrepair-quota_2020-03-03Darrick J. Wong
Fix anything that causes the quota verifiers to fail. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: online repair of directoriesrepair-inode-data_2020-03-03Darrick J. Wong
If a directory looks like it's in bad shape, try to sift through the rubble to find whatever directory entries we can, zap the old tree, and re-add the entries. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: scrub should set preen if attr leaf has holesDarrick J. Wong
If an attr block indicates that it could use compaction, set the preen flag to have the attr fork rebuilt, since the attr fork rebuilder can take care of that for us. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com>
2020-03-03xfs: repair extended attributesDarrick J. Wong
If the extended attributes look bad, try to sift through the rubble to find whatever keys/values we can, zap the attr tree, and re-add the values. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: create a new inode fork block unmap helperDarrick J. Wong
Create a new helper to unmap blocks from an inode's fork. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: remove unnecessary inode-transaction rollDarrick J. Wong
Remove the transaction roll at the end of the loop in xfs_itruncate_extents_flags. xfs_defer_finish takes care of rolling the transaction as needed and reattaching the inode, which means we already start each loop with a clean transaction. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-03-03xfs: create a blob array data structureDarrick J. Wong
Create a simple 'blob array' data structure for storage of arbitrarily sized metadata objects that will be used to reconstruct metadata. For the intended usage (temporarily storing extended attribute names and values) we only have to support storing objects and retrieving them. Use the xfile abstraction to store the attribute information in memory that can be swapped out. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>