summaryrefslogtreecommitdiff
path: root/fs
AgeCommit message (Collapse)Author
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>
2020-10-26xfs: hoist xfs_{bump,drop}link to libxfsDarrick J. Wong
Move xfs_bumplink and xfs_droplink to libxfs. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: hoist xfs_iunlink to libxfsDarrick J. Wong
Move xfs_iunlink and xfs_iunlink_remove to libxfs. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: move xfs_dir_ialloc to libxfsDarrick J. Wong
Move xfs_dir_ialloc to libxfs, and make xfs_ialloc static since we only needed it to be non-static temporarily. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: refactor special inode roll out of xfs_dir_iallocDarrick J. Wong
In xfs_dir_ialloc, we roll the transaction if we had to allocate a new inode chunk and before we actually initialize the inode. In the kernel this requires us to detach the transaction's quota charge information from the ichunk allocation transaction and to attach it the ialloc transaction because we don't charge quota for inode chunks. This doesn't exist in the userspace side of things, so pop it out into a separately called function. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: push xfs_ialloc_args creation out of xfs_dir_iallocDarrick J. Wong
Move the initialization of the xfs_ialloc_args structure out of xfs_dir_ialloc into its callers' callers so that we can set the new inode's parameters in one place and pass it through instead of open coding the new uid/gid/prid all over the code. This also prepares us for moving xfs_dir_ialloc and xfs_create to libxfs. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: hoist inode allocation functionDarrick J. Wong
Move the inode allocation function into libxfs. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: delegate post-allocation igetDarrick J. Wong
Create a post-allocation iget helper so that the upcoming libxfs hoist doesn't have to determine the xfs_iget interface. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: split inode allocation and initializationDarrick J. Wong
Split new inode allocation and initialization into separate helpers. Eventually we'll supply a force-reinitialization function so that xfs_repair can use libxfs to reset the root directory and friends. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: use xfs_trans_ichgtime to set times when allocating inodeDarrick J. Wong
Use xfs_trans_ichgtime to set the inode times when allocating an inode, instead of open-coding them here. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: implement atime updates in xfs_trans_ichgtimeDarrick J. Wong
Enable xfs_trans_ichgtime to change the inode access time so that we can use this function to set inode times when allocating inodes instead of open-coding it. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: pack inode allocation parameters into a separate structureDarrick J. Wong
Instead of open-coding new inode parameters through xfs_dir_ialloc and xfs_Ialloc, put everything into a structure and pass that instead. This will make it easier to share code with xfsprogs while maintaining the ability for xfsprogs to supply extra new inode parameters. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: hoist project id get/set functionsDarrick J. Wong
Move the project id get and set functions into libxfs. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: hoist inode flag conversion functionsDarrick J. Wong
Hoist the inode flag conversion functions into libxfs so that we can keep them in sync. Do this by creating a new xfs_inode_utils.c file in libxfs. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: hoist extent size helpers to libxfsDarrick J. Wong
Move the extent size helpers to xfs_bmap.c in libxfs since they're used there already. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: online repair of parent pointersrepair-dirs_2020-10-26Darrick J. Wong
Teach the online repair code to fix directory '..' entries (aka parent pointers). Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: parent repair should try the dcache firstDarrick J. Wong
If we need to find a directory's parent, try the dcache first. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: online repair of directoriesDarrick 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, scan the directory tree for the parent (if needed), stage the new directory contents in a temporary file and use the atomic extent swapping mechanism to commit the results in bulk. As a side effect of this patch, directory inactivation will be able to purge any leftover dir blocks. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: scrub should set preen if attr leaf has holesrepair-xattrs_2020-10-26Darrick 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-10-26xfs: repair extended attributesDarrick J. Wong
If the extended attributes look bad, try to sift through the rubble to find whatever keys/values we can, stage a new attribute structure in a temporary file and use the atomic extent swapping mechanism to commit the results in bulk. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: 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>
2020-10-26xfs: online repair of realtime summariesrepair-rtsummary_2020-10-26Darrick J. Wong
Repair the realtime summary data by constructing a new rtsummary file in the scrub temporary file, then atomically swapping the contents. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: create temporary files and directories for online repairDarrick J. Wong
Teach the online repair code how to create temporary files or directories. These temporary files can be used to stage reconstructed information until we're ready to perform an atomic extent swap to commit the new metadata. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: 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-10-26xfs: enable atomic swapext featureatomic-file-updates_2020-10-26Darrick J. Wong
Add the atomic swapext feature to the set of features that we will permit. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: condense directories after an atomic swapDarrick J. Wong
The previous commit added a new swapext flag that enables us to perform post-swap processing on file2 once we're done swapping the extent maps. Now add this ability for directories. This isn't used anywhere right now, but we need to have the basic ondisk flags in place so that a future online directory repair feature can create salvaged dirents in a temporary directory and swap the data forks when ready. If one file is in extents format and the other is inline, we will have to promote both to extents format to perform the swap. After the swap, we can try to condense the fixed directory down to inline format if possible. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: condense extended attributes after an atomic swapDarrick J. Wong
Add a new swapext flag that enables us to perform post-swap processing on file2 once we're done swapping the extent maps. If we were swapping the extended attributes, we want to be able to convert file2's attr fork from block to inline format. This isn't used anywhere right now, but we need to have the basic ondisk flags in place so that a future online xattr repair feature can create salvaged attrs in a temporary file and swap the attr forks when ready. If one file is in extents format and the other is inline, we will have to promote both to extents format to perform the swap. After the swap, we can try to condense the fixed file's attr fork back down to inline format if possible. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: remove old swap extents implementationDarrick J. Wong
Migrate the old XFS_IOC_SWAPEXT implementation to use our shiny new one. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: allow xfs_swap_range to use older extent swap algorithmsDarrick J. Wong
If userspace permits non-atomic swap operations, use the older code paths to implement the same functionality. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2020-10-26xfs: refactor reflink flag handling in xfs_swap_extent_forksDarrick J. Wong
Refactor the old data fork swap function to use the new reflink flag helpers to propagate reflink flags between the two files. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>