summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2022-11-09xfs: don't check secondary super inode pointers when metadir enabledDarrick J. Wong
When metadata directories are enabled, the rt and quota inodes are no longer pointed to by the superblock, so it doesn't make sense to check these. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: teach nlink scrubber to deal with metadata directory rootsDarrick J. Wong
Enhance the inode link count online fsck code alter their behavior when they detect metadata directory tree roots, just like they do for the regular root directory. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: scrub metadata directoriesDarrick J. Wong
Teach online scrub about the metadata directory tree. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: record health problems with the metadata directoryDarrick J. Wong
Make a report to the health monitoring subsystem any time we encounter something in the metadata directory tree that looks like corruption. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: enable creation of dynamically allocated metadir path structuresDarrick J. Wong
Add a few helper functions so that it's possible to allocate xfs_imeta_path objects dynamically, along with dynamically allocated path components. Eventually we're going to want to support paths of the form "/realtime/$rtgroup.rmap", and this is necessary for that. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: allow bulkstat to return metadata directoriesDarrick J. Wong
Allow the V5 bulkstat ioctl to return information about metadata directory files so that xfs_scrub can find and scrub them, since they are otherwise ordinary directories. (Metadata files of course require per-file scrub code and hence do not need exposure.) Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: advertise metadata directory featureDarrick J. Wong
Advertise the existence of the metadata directory feature; this will be used by scrub to decide if it needs to scan the metadir too. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: hide metadata inodes from everyone because they are specialDarrick J. Wong
Metadata inodes are private files and therefore cannot be exposed to userspace. This means no bulkstat, no open-by-handle, no linking them into the directory tree, and no feeding them to LSMs. As such, we mark them S_PRIVATE, which stops all that. While we're at it, put them in a separate lockdep class so that it won't get confused by "recursive" i_rwsem locking such as what happens when we write to a rt file and need to allocate from the rt bitmap file. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: update imeta transaction reservations for metadirDarrick J. Wong
Update the new metadata inode transaction reservations to handle metadata directories if that feature is enabled. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: create transaction reservations for metadata inode operationsDarrick J. Wong
Create transaction reservation types and block reservation helpers to help us calculate transaction requirements. Right now the reservations are the same as always; we're just separating the symbols for a future patch. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: don't use the incore struct xfs_sb for offsets into struct xfs_dsbDarrick J. Wong
Currently, the XFS_SB_CRC_OFF macro uses the incore superblock struct (xfs_sb) to compute the address of sb_crc within the ondisk superblock struct (xfs_dsb). This is a landmine if we ever change the layout of the incore superblock (as we're about to do), so redefine the macro to use xfs_dsb to compute the layout of xfs_dsb. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: get rid of cross_renameinode-refactor_2022-11-09Darrick J. Wong
Get rid of the largely pointless xfs_cross_rename now that we've refactored its parent. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: hoist xfs_{bump,drop}link to libxfsDarrick J. Wong
Move xfs_bumplink and xfs_droplink to libxfs. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: hoist xfs_iunlink to libxfsDarrick J. Wong
Move xfs_iunlink and xfs_iunlink_remove to libxfs. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: wrap inode creation dqalloc callsDarrick J. Wong
Create a helper that calls dqalloc to allocate and grab a reference to dquots for the user, group, and project ids listed in an icreate structure. This simplifies the creat-related dqalloc callsites scattered around the code base. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: push xfs_icreate_args creation out of xfs_create*Darrick J. Wong
Move the initialization of the xfs_icreate_args structure out of xfs_create and xfs_create_tempfile into their callers so that we can set the new inode's attributes in one place and pass that through instead of open coding the collection of attributes all over the code. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: hoist new inode initialization functions to libxfsDarrick J. Wong
Move all the code that initializes a new inode's attributes from the icreate_args structure and the parent directory into libxfs. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: split new inode creation into two piecesDarrick J. Wong
There are two parts to initializing a newly allocated inode: setting up the incore structures, and initializing the new inode core based on the parent inode and the current user's environment. The initialization code is not specific to the kernel, so we would like to share that with userspace by hoisting it to libxfs. Therefore, split xfs_icreate into separate functions to prepare for the next few patches. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: pack icreate initialization parameters into a separate structureDarrick J. Wong
Callers that want to create an inode currently pass all possible file attribute values for the new inode into xfs_init_new_inode as ten separate parameters. This causes two code maintenance issues: first, we have large multi-line call sites which programmers must read carefully to make sure they did not accidentally invert a value. Second, all three file id parameters must be passed separately to the quota functions; any discrepancy results in quota count errors. Clean this up by creating a new icreate_args structure to hold all this information, some helpers to initialize them properly, and make the callers pass this structure through to the creation function, whose name we shorten to xfs_icreate. This eliminates the issues, enables us to keep the inode init code in sync with userspace via libxfs, and is needed for future metadata directory tree management. (A subsequent cleanup will also fix the quota alloc calls.) Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: hoist project id get/set functions to libxfsDarrick J. Wong
Move the project id get and set functions into libxfs. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: hoist inode flag conversion functions to libxfsDarrick 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_util.c file in libxfs. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: 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 <djwong@kernel.org>
2022-11-09xfs: move inode copy-on-write predicates to xfs_inode.[ch]Darrick J. Wong
Move these inode predicate functions to xfs_inode.[ch] since they're not reflink functions. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: repair AGI unlinked inode bucket listsrepair-iunlink_2022-11-09Darrick J. Wong
Teach the AGI repair code to rebuild the unlinked buckets and lists. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: hoist AGI repair context to a heap objectDarrick J. Wong
Save ~460 bytes of stack space by moving all the repair context to a heap object. We're going to add even more context data in the next patch, which is why we really need to do this now. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: check AGI unlinked inode bucketsDarrick J. Wong
Look for corruptions in the AGI unlinked bucket chains. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: use i_prev_unlinked to distinguish inodes that are not on the unlinked listDarrick J. Wong
Alter the definition of i_prev_unlinked slightly to make it more obvious when an inode with 0 link count is not part of the iunlink bucket lists rooted in the AGI. An upcoming enhancement to the online AGI fsck code will need to make this distinction to check and rebuild the AGI unlinked buckets. This distinction is necessary because it is not sufficient to check xfs_inode.i_nlink to decide if an inode is on the unlinked list. Updates to i_nlink can happen while holding only ILOCK_EXCL, but updates to an inode's position in the AGI unlinked list requires both ILOCK_EXCL and the AGI buffer lock. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: online repair of symbolic linksrepair-symlink_2022-11-09Darrick J. Wong
If a symbolic link target looks bad, try to sift through the rubble to find as much of the target buffer that we can, and stage a new target (short or remote format as needed) in a temporary file and use the atomic extent swapping mechanism to commit the results. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: ensure dentry consistency when the orphanage adopts a filerepair-orphanage_2022-11-09Darrick J. Wong
When the orphanage adopts a file, that file becomes a child of the orphanage. The dentry cache may have entries for the orphanage directory and the name we've chosen, so (1) make sure we abort if the dcache has a positive entry because something's not right; and (2) invalidate and purge negative dentries if the adoption goes through. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: move files to orphanage instead of letting nlinks drop to zeroDarrick J. Wong
If we encounter an inode with a nonzero link count but zero observed links, move it to the orphanage. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-11-09xfs: move orphan files to the orphanageDarrick J. Wong
If we can't find a parent for a file, move it to the orphanage. Signed-off-by: Darrick J. Wong <djwong@kernel.org>