summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2020-10-26xfs: add metadata reservations for realtime btreesreserve-rt-metadata-space_2020-10-26Darrick J. Wong
Extend the per-AG metadata block reservation system (which is really just an accounting trick) to support reserving blocks for realtime metadata btrees. This ensures that we will never run out of blocks for the rt rmap or refcount btrees during an operation, similar to what the per-ag reservations do. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: widen per-ag reservation structures to 64-bitsDarrick J. Wong
Widen all of the fields in the per-ag reservation structure to be 64-bit fields in preparation for using it with the rt metadata btrees. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: refactor realtime inode lockingrefactor-rt-locking_2020-10-26Darrick J. Wong
Refactor realtime metadata inode locking so that we can get some sense here. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: refactor realtime scrubbing context managementDarrick J. Wong
Create a pair of helpers to deal with setting up the necessary incore context to check metadata records against the realtime metadata. Right now this is limited to locking the realtime bitmap and summary inodes, but as we add rmap and reflink to the realtime device this will grow to include btree cursors. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: trace log intent item recovery failuresfix-recovered-log-intent-validation_2020-10-26Darrick J. Wong
Add a trace point so that we can capture when a recovered log intent item fails to recover. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: improve the code that checks recovered extent-free intent itemsDarrick J. Wong
The code that validates recovered extent-free intent items is kind of a mess -- it doesn't use the standard xfs type validators, and it doesn't check for things that it should. Fix the validator function to use the standard validation helpers and look for more types of obvious errors. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: hoist recovered extent-free intent checks out of xfs_efi_item_recoverDarrick J. Wong
When we recover a extent-free intent from the log, we need to validate its contents before we try to replay them. Hoist the checking code into a separate function so that we can fix some problems and then add realtime support. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: improve the code that checks recovered refcount intent itemsDarrick J. Wong
The code that validates recovered refcount intent items is kind of a mess -- it doesn't use the standard xfs type validators, and it doesn't check for things that it should. Fix the validator function to use the standard validation helpers and look for more types of obvious errors. Note that we can't actually check the startblock until we know if the refcount item is targetting the realtime device, so that has to be separate. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: hoist recovered refcount intent checks out of xfs_cui_item_recoverDarrick J. Wong
When we recover a refcount intent from the log, we need to validate its contents before we try to replay them. Hoist the checking code into a separate function so that we can fix some problems and then add realtime support. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: improve the code that checks recovered rmap intent itemsDarrick J. Wong
The code that validates recovered rmap intent items is kind of a mess -- it doesn't use the standard xfs type validators, and it doesn't check for things that it should. Fix the validator function to use the standard validation helpers and look for more types of obvious errors. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: hoist recovered rmap intent checks out of xfs_rui_item_recoverDarrick J. Wong
When we recover a rmap intent from the log, we need to validate its contents before we try to replay them. Hoist the checking code into a separate function so that we can fix some problems and then add realtime support. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: improve the code that checks recovered bmap intent itemsDarrick J. Wong
The code that validates recovered bmap intent items is kind of a mess -- it doesn't use the standard xfs type validators, and it doesn't check for things that it should. Fix the validator function to use the standard validation helpers and look for more types of obvious errors. Note that we can't actually check the startblock until we know if the bmap item is targetting the realtime device, so that has to be separate. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: hoist recovered bmap intent checks out of xfs_bui_item_recoverDarrick J. Wong
When we recover a bmap intent from the log, we need to validate its contents before we try to replay them. Hoist the checking code into a separate function so that we can fix some problems and then add realtime support. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: support dynamic btree cursor sizebtree-dynamic-depth_2020-10-26Darrick J. Wong
Split out the btree level information into a separate struct and put it at the end of the cursor structure as a VLA. The realtime rmapbt will require the ability to support many more levels than a regular cursor. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: remove xfs_btree_cur_t typedefDarrick J. Wong
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: update btree keys correctly when _insrec splits an inode root blockbtree-ifork-records_2020-10-26Darrick J. Wong
In commit 2c813ad66a72, I partially fixed a bug wherein xfs_btree_insrec would erroneously try to update the parent's key for a block that had been split if we decided to insert the new record into the new block. The solution was to detect this situation and update the in-core key value that we pass up to the caller so that the caller will (eventually) add the new block to the parent level of the tree with the correct key. However, I missed a subtlety about the way inode-rooted btrees work. If the full block was a maximally sized inode root block, we'll solve that fullness by moving the root block's records to a new block, resizing the root block, and updating the root to point to the new block. We don't pass a pointer to the new block to the caller because that work has already been done. The new record will /always/ land in the new block, so in this case we need to use xfs_btree_update_keys to update the keys. This bug can theoretically manifest itself in the very rare case that we split a bmbt root block and the new record lands in the very first slot of the new block, though I've never managed to trigger it in practice. However, it is very easy to reproduce by running generic/522 with the realtime rmapbt patchset if rtinherit=1. Fixes: 2c813ad66a72 ("xfs: support btrees with overlapping intervals for keys") Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: support storing records in the inode core rootDarrick J. Wong
Add the necessary flags and code so that we can support storing leaf records in the inode root block of a btree. This hasn't been necessary before, but the realtime rmapbt will need to be able to do this. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: hoist the node iroot update code out of xfs_btree_kill_irootDarrick J. Wong
In preparation for allowing records in an inode btree root, hoist the code that copies keyptrs from an existing node child into the root block to a separate function. Remove some unnecessary conditionals and clean up a few function calls in the new function. Note that this change reorders the ->free_block call with respect to the change in bc_nlevels to make it easier to support inode root leaf blocks in the next patch. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: hoist the node iroot update code out of xfs_btree_new_irootDarrick J. Wong
In preparation for allowing records in an inode btree root, hoist the code that copies keyptrs from an existing node root into a child block to a separate function. Note that the new function explicitly computes the keys of the new child block and stores that in the root block; while the bmap btree could rely on leaving the key alone, realtime rmap needs to set the new high key. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: support leaves in the incore btree root block in xfs_iroot_reallocDarrick J. Wong
Add some logic to xfs_iroot_realloc so that we can handle leaf records in the btree root block correctly. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: generalize the btree root reallocation functionDarrick J. Wong
In preparation for storing realtime rmap btree roots in an inode fork, make xfs_iroot_realloc take an ops structure that takes care of all the btree-specific geometry pieces. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: standardize the btree maxrecs function parametersDarrick J. Wong
Standardize the parameters in xfs_{alloc,bm,ino,rmap,refcount}bt_maxrecs so that we have consistent calling conventions. This doesn't affect the kernel that much, but enables us to clean up userspace a bit. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: rearrange xfs_iroot_realloc a bitDarrick J. Wong
Rearrange the innards of xfs_iroot_realloc so that we can reduce duplicated code prior to genericizing the function. No functional changes. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: move the zero records logic into xfs_bmap_broot_space_calcDarrick J. Wong
The bmap btree cannot ever have zero records in an incore btree block. If the number of records drops to zero, that means we're converting the fork to extents format and are trying to remove the tree. This logic won't hold for the future realtime rmap btree, so move the logic into the bmbt code. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: hoist the code that moves the incore inode fork broot memoryDarrick J. Wong
Whenever we change the size of the memory buffer holding an inode fork btree root block, we have to copy the contents over. Refactor all this into a single function that handles both, in preparation for making xfs_iroot_realloc more generic. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: fix a sloppy memory handling bug in xfs_iroot_reallocDarrick J. Wong
While refactoring code, I noticed that when xfs_iroot_realloc tries to shrink a bmbt root block, it allocates a smaller new block and then copies "records" and pointers to the new block. However, bmbt root blocks cannot ever be leaves, which means that it's not technically correct to copy records. We /should/ be copying keys. Note that this has never resulted in actual memory corruption because sizeof(bmbt_rec) == (sizeof(bmbt_key) + sizeof(bmbt_ptr)). However, this will no longer be true when we start adding realtime rmap stuff, so fix this now. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: refactor creation of bmap btree rootsDarrick J. Wong
Now that we've created inode fork helpers to allocate and free btree roots, create a new bmap btree helper to create a new bmbt root, and refactor the extents <-> btree conversion functions to use our new helpers. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: refactor the allocation and freeing of incore inode fork btree rootsDarrick J. Wong
Refactor the code that allocates and freese the incore inode fork btree roots. This will help us disentangle some of the weird logic when we're creating and tearing down inode-based btrees. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: replace shouty XFS_BM{BT,DR} macrosDarrick J. Wong
Replace all the shouty bmap btree and bmap disk root macros with actual functions, and fix a type handling error in the xattr code that the macros previously didn't care about. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: enable metadata directory featuremetadir_2020-10-26Darrick J. Wong
Enable the metadata directory feature. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: put metadata inodes in a separate lockdep classDarrick J. Wong
Metadata inodes are not supposed to be exposed to userspace, which eliminates most conflicts with vfs rwseasm, page cache locks, etc. This means that we actually /can/ do things like copy data to userspace while holding a metadata inode's ILOCK, since, uh.... well what happens if we copy rt fsmap data to an rt file, which then causes an rt allocation and therfore needs the rtrmap ilock...? Confused-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: disable the agi rotor for metadata inodesDarrick J. Wong
Ideally, we'd put all the metadata inodes in one place if we could, so that the metadata all stay reasonably close together instead of spreading out over the disk. Furthermore, if the log is internal we'd probably prefer to keep the metadata near the log. Therefore, disable AGI rotoring for metadata inode allocations. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: ensure metadata directory paths exist before creating filesDarrick J. Wong
Since xfs_imeta_create can create new metadata files arbitrarily deep in the metadata directory tree, we must supply a function that can ensure that all directories in a path exist, and call it before the quota functions create the quota inodes. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: read and write metadata inode directoryDarrick J. Wong
Plumb in the bits we need to look up metadata inode numbers from the metadata inode directory and save them back. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: enforce metadata inode flagDarrick J. Wong
Add checks for the metadata inode flag so that we don't ever leak metadata inodes out to userspace, and we don't ever try to read a regular inode as metadata. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: convert metadata inode lookup keys to use pathsDarrick J. Wong
Convert the magic metadata inode lookup keys to use actual strings for paths. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: load metadata directory root at mount timeDarrick J. Wong
Load the metadata directory root inode into memory at mount time and release it at unmount time. We also make sure that the obsolete inode pointers in the superblock are not logged or read from the superblock. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: define the on-disk format for the metadir featureDarrick J. Wong
Define the on-disk layout and feature flags for the metadata inode directory feature. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: iget for metadata inodesDarrick J. Wong
Create a xfs_iget_meta function for metadata inodes to ensure that we always check that the inobt thinks a metadata inode is in use. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: convert all users to xfs_imeta_logDarrick J. Wong
Convert all open-coded sb metadata inode pointer logging to use xfs_imeta_log. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: refactor the v4 group/project inode pointer switchDarrick J. Wong
Refactor the group and project quota inode pointer switcheroo that happens only on v4 filesystems into a separate function prior to enhancing the xfs_qm_qino_alloc function. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: create transaction reservations for metadata inode operationsDarrick J. Wong
Create transaction reservation types and block reservation helpers to help us calculate transaction requirements. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: create imeta abstractions to get and set metadata inodesDarrick J. Wong
Create some helper routines to get and set metadata inode numbers instead of open-coding them throughout xfs. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: get rid of cross_renameinode-refactor_2020-10-26Darrick J. Wong
Get rid of the largely pointless xfs_cross_rename now that we've refactored its parent. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: create libxfs helper to rename two directory entriesDarrick J. Wong
Create a new libxfs function to rename two directory entries. The upcoming metadata directory feature will need this to replace a metadata inode directory entry. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: create libxfs helper to exchange two directory entriesDarrick J. Wong
Create a new libxfs function to exchange two directory entries. The upcoming metadata directory feature will need this to replace a metadata inode directory entry. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: create libxfs helper to remove an existing inode/name from a directoryDarrick J. Wong
Create a new libxfs function to remove a (name, inode) entry from a directory. The upcoming metadata directory feature will need this to create a metadata directory tree. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: hoist inode free function to libxfsDarrick J. Wong
Create a libxfs helper function that marks an inode free on disk. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: create libxfs helper to link an existing inode into a directoryDarrick J. Wong
Create a new libxfs function to link an existing inode into a directory. The upcoming metadata directory feature will need this to create a metadata directory tree. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: create libxfs helper to link a new inode into a directoryDarrick J. Wong
Create a new libxfs function to link a newly created inode into a directory. The upcoming metadata directory feature will need this to create a metadata directory tree. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>