summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2019-10-09xfs: create a polled function to force inode inactivationdeferred-inactivation_2019-10-09Darrick 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: flush speculative space allocations when we run out of spacereclaim-space-harder_2019-10-09Darrick 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: hide most of the incore inode walk interfaceincore-inode-walk_2019-10-09Darrick 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: repair quotasrepair-quota_2019-10-09Darrick J. Wong
Fix anything that causes the quota verifiers to fail. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2019-10-09xfs: scrub should set preen if attr leaf has holesrepair-inode-data_2019-10-09Darrick 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: 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>
2019-10-09xfs: convert xfs_itruncate_extents_flags to use __xfs_bunmapiDarrick J. Wong
There's no reason why we can't consume unmap_len, just use the raw version. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2019-10-09xfs: 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>
2019-10-09xfs: repair damaged symlinksDarrick J. Wong
Repair inconsistent symbolic link data. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2019-10-09xfs: repair inode block mapsrepair-inodes_2019-10-09Darrick J. Wong
Use the reverse-mapping btree information to rebuild an inode block map. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2019-10-09xfs: zap broken inode forksDarrick J. Wong
Determine if inode fork damage is responsible for the inode being unable to pass the ifork verifiers in xfs_iget and zap the fork contents if this is true. Once this is done the fork will be empty but we'll be able to construct an in-core inode, and a subsequent call to the inode fork repair ioctl will search the rmapbt to rebuild the records that were in the fork. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2019-10-09xfs: repair inode recordsDarrick J. Wong
Try to reinitialize corrupt inodes, or clear the reflink flag if it's not needed. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2019-10-09xfs: repair refcount btreesrepair-ag-btrees_2019-10-09Darrick J. Wong
Reconstruct the refcount data from the rmap btree. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2019-10-09xfs: repair inode btreesDarrick J. Wong
Use the rmapbt to find inode chunks, query the chunks to compute hole and free masks, and with that information rebuild the inobt and finobt. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2019-10-09xfs: repair free space btreesDarrick J. Wong
Rebuild the free space btrees from the gaps in the rmap btree. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2019-10-09xfs: create a big array data structureDarrick J. Wong
Create a simple 'big array' data structure for storage of fixed-size metadata records that will be used to reconstruct a btree index. For repair operations, the most important operations are append, iterate, and sort. Earlier implementations of the big array used linked lists and suffered from severe problems -- pinning all records in kernel memory was not a good idea and frequently lead to OOM situations; random access was very inefficient; and record overhead for the lists was unacceptably high at 40-60%. Therefore, the big memory array relies on the 'xfile' abstraction, which creates a memfd file and stores the records in page cache pages. Since the memfd is created in tmpfs, the memory pages can be pushed out to disk if necessary and we have a built-in usage limit of 50% of physical memory. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2019-10-09xfs: log EFIs for all btree blocks being used to stage a btreerepair-prep-for-bulk-loading_2019-10-09Darrick J. Wong
We need to log EFIs for every extent that we allocate for the purpose of staging a new btree so that if we fail then the blocks will be freed during log recovery. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2019-10-09xfs: implement block reservation accounting for btrees we're stagingDarrick J. Wong
Create a new xrep_newbt structure to encapsulate a fake root for creating a staged btree cursor as well as to track all the blocks that we need to reserve in order to build that btree. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2019-10-09xfs: add debug knobs to control btree bulk load slack factorsDarrick J. Wong
Add some debug knobs so that we can control the leaf and node block slack when rebuilding btrees. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2019-10-09xfs: always rescan allegedly healthy per-ag metadata after repairrepair-health_2019-10-09Darrick J. Wong
After an online repair function runs for a per-AG metadata structure, sc->sick_mask is supposed to reflect the per-AG metadata that the repair function fixed. Our next move is to re-check the metadata to assess the completeness of our repair, so we don't want the rebuilt structure to be excluded from the rescan just because the health system previously logged a problem with the data structure. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2019-10-09xfs: add a repair revalidation function pointerDarrick J. Wong
Allow repair functions to set a separate function pointer to validate the metadata that they've rebuilt. This prevents us from exiting from a repair function that rebuilds both A and B without checking that both A and B can pass a scrub test. We'll need this for the free space and inode btree repair strategies. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2019-10-09xfs: convert xbitmap to interval treerepair-bitmap-rework_2019-10-09Darrick J. Wong
Convert the xbitmap code to use interval trees instead of linked lists. This reduces the amount of coding required to handle the disunion operation and in the future will make it easier to set bits in arbitrary order yet later be able to extract maximally sized extents, which we'll need for rebuilding certain structures. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2019-10-09xfs: remove the for_each_xbitmap_ helpersDarrick J. Wong
Remove the for_each_xbitmap_ macros in favor of proper iterator functions. We'll soon be switching this data structure over to an interval tree implementation, which means that we can't allow callers to modify the bitmap during iteration without telling us. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>