summaryrefslogtreecommitdiff
path: root/fs
AgeCommit message (Collapse)Author
2022-10-14xfs: enable realtime group featurerealtime-groups_2022-10-14Darrick J. Wong
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: scrub each rtgroup's portion of the rtbitmap separatelyDarrick J. Wong
Create a new scrub type code so that userspace can scrub each rtgroup's portion of the rtbitmap file separately. This reduces the long tail latency that results from scanning the entire bitmap all at once, and prepares us for future patchsets, wherein we'll need to be able to lock a specific rtgroup so that we can rebuild that rtgroup's part of the rtbitmap contents from the rtgroup's rmap btree. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: repair secondary realtime group superblocksDarrick J. Wong
Repair secondary realtime group superblocks. They're not critical for anything, but some consistency would be a good idea. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: scrub the realtime group superblockDarrick J. Wong
Enable scrubbing of realtime group superblocks. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: encode the rtsummary in big endian formatDarrick J. Wong
Currently, the ondisk realtime summary file counters are accessed in units of 32-bit words. There's no endian translation of the contents of this file, which means that the Bad Things Happen(tm) if you go from (say) x86 to powerpc. Since we have a new feature flag, let's take the opportunity to enforce an endianness on the file. Encode the summary information in big endian format, like most of the rest of the filesystem. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: add block headers to realtime summary blocksDarrick J. Wong
Upgrade rtsummary blocks to have self describing metadata like most every other thing in XFS. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: encode the rtbitmap in little endian formatDarrick J. Wong
Currently, the ondisk realtime bitmap file is accessed in units of 32-bit words. There's no endian translation of the contents of this file, which means that the Bad Things Happen(tm) if you go from (say) x86 to powerpc. Since we have a new feature flag, let's take the opportunity to enforce an endianness on the file. The natural format of a bitmap is (IMHO) little endian, because the byte offsets of the bitmap data should always increase in step with the information being indexed. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: add block headers to realtime bitmap blocksDarrick J. Wong
Upgrade rtbitmap blocks to have self describing metadata like most every other thing in XFS. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: export the geometry of realtime groups to userspaceDarrick J. Wong
Create an ioctl so that the kernel can report the status of realtime groups to userspace. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: define locking primitives for realtime groupsDarrick J. Wong
Define helper functions to lock all metadata inodes related to a realtime group. There's not much to look at now, but this will become important when we add per-rtgroup metadata files and online fsck code for them. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: record rt group superblock errors in the health systemDarrick J. Wong
Record the state of per-rtgroup metadata sickness in the rtgroup structure for later reporting. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: add frextents to the lazysbcounters when rtgroups enabledDarrick J. Wong
Make the free rt extent count a part of the lazy sb counters when the realtime groups feature is enabled. This is possible because the patch to recompute frextents from the rtbitmap during log recovery predates the code adding rtgroup support, hence we know that the value will always be correct during runtime. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: check that rtblock extents do not overlap with the rt group metadataDarrick J. Wong
The ondisk format specifies that the start of each realtime group must have a superblock so that rt space mappings never cross an rtgroup boundary. Check that rt block pointers obey this. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: export realtime group geometry via XFS_FSOP_GEOMDarrick J. Wong
Export the realtime geometry information so that userspace can query it. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: always update secondary rt supers when we update secondary fs supersDarrick J. Wong
Make sure that any update to the secondary superblocks in the data section are also echoed to the secondary superblocks in the realtime section. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: grow the realtime section when realtime groups are enabledDarrick J. Wong
Enable growing the rt section when realtime groups are enabled. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: write secondary realtime superblocks to diskDarrick J. Wong
Create some library functions to make it easy to update all the secondary realtime superblocks on disk; this will be used by growfs, xfs_db, mkfs, and xfs_repair. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: update primary realtime super every time we update the primary fs superDarrick J. Wong
Every time we update parts of the primary filesystem superblock that are echoed in the primary rt super, we should update that primary realtime super. Avoid an ondisk log format change by using ordered buffers to write the primary rt super. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: check the realtime superblock at mount timeDarrick J. Wong
Check the realtime superblock at mount time, to ensure that the label actually matches the primary superblock. If the rt superblock is good, attach it to the xfs_mount so that the log can use ordered buffers to keep this primary in sync with the primary super on the data device. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: define the format of rt groupsDarrick J. Wong
Define the ondisk format of realtime group metadata. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: create incore realtime group structuresDarrick J. Wong
Create an incore object that will contain information about a realtime allocation group. This will eventually enable us to shard the realtime section in a similar manner to how we shard the data section. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: remove XFS_ILOCK_RT*refactor-rt-locking_2022-10-14Darrick J. Wong
Now that we've centralized the realtime metadata locking routines, get rid of the ILOCK subclasses since we now use explicit lockdep classes. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: refactor realtime inode lockingDarrick J. Wong
Create helper functions to deal with locking realtime metadata inodes. This enables us to maintain correct locking order once we start adding the realtime rmap and refcount btree inodes. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: use separate lock classes for realtime metadata inode ILOCKsDarrick J. Wong
Realtime metadata files are not quite regular files because userspace can't access the realtime bitmap directly, and because we take the ILOCK of the rt bitmap file while holding the ILOCK of a realtime file. The double nature of inodes confuses lockdep, so up until now we've created lockdep subclasses to help lockdep keep things straight. We've gotten away with using lockdep subclasses because there's only two rt metadata files, but with the coming addition of realtime rmap and refcounting, we'd need two more subclasses, which is a lot of class bits to burn on a side feature. Therefore, switch to manually setting the lockdep class of the rt metadata ILOCKs. In the next patch we'll remove the rt-related ILOCK subclasses. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: use accessor functions for summary info wordsrefactor-rtbitmap-macros_2022-10-14Darrick J. Wong
Create get and set functions for rtsummary words so that we can redefine the ondisk format with a specific endianness. Note that this requires the definition of a distinct type for ondisk summary info words so that the compiler can perform proper typechecking. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: create helpers for rtsummary block/wordcount computationsDarrick J. Wong
Create helper functions that compute the number of blocks or words necessary to store the rt summary file. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: use accessor functions for bitmap wordsDarrick J. Wong
Create get and set functions for rtbitmap words so that we can redefine the ondisk format with a specific endianness. Note that this requires the definition of a distinct type for ondisk rtbitmap words so that the compiler can perform proper typechecking as we go back and forth. In the upcoming rtgroups feature, we're going to fix the problem that rtwords are written in host endian order, which means we'll need the distinct rtword/rtword_raw types. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: create helpers for rtbitmap block/wordcount computationsDarrick J. Wong
Create helper functions that compute the number of blocks or words necessary to store the rt bitmap. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: convert rt summary macros to helpersDarrick J. Wong
Convert the realtime summary file macros to helper functions so that we can improve type checking. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: convert open-coded xfs_rtword_t pointer accesses to helperDarrick J. Wong
There are a bunch of places where we use open-coded logic to find a pointer to an xfs_rtword_t within a rt bitmap buffer. Convert all that to helper functions for better type safety. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: remove XFS_BLOCKWSIZE and XFS_BLOCKWMASK macrosDarrick J. Wong
Remove these trivial macros since they're not even part of the ondisk format. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: convert the rtbitmap block and bit macros to static inline functionsDarrick J. Wong
Replace these macros with typechecked helper functions. Eventually we're going to add more logic to the helpers and it'll be easier if we don't have to macro it up. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: use shifting and masking when converting rt extents, if possiblerefactor-rt-unit-conversions_2022-10-14Darrick J. Wong
Avoid the costs of integer division (32-bit and 64-bit) if the realtime extent size is a power of two. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: create rt extent rounding helpers for realtime extent blocksDarrick J. Wong
Create a pair of functions to round rtblock numbers up or down to the nearest rt extent. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: convert do_div calls to xfs_rtb_to_rtx helper callsDarrick J. Wong
Convert these calls to use the helpers, and clean up all these places where the same variable can have different units depending on where it is in the function. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: create helpers to convert rt block numbers to rt extent numbersDarrick J. Wong
Create helpers to do unit conversions of rt block numbers to rt extent numbers. There are two variations -- the suffix "t" denotes the one that returns only the truncated extent number; the other one also returns the misalignment. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: create a helper to compute leftovers of realtime extentsDarrick J. Wong
Create a helper to compute the realtime extent (xfs_rtxlen_t) from an extent length (xfs_extlen_t) value. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: create a helper to compute leftovers of realtime extentsDarrick J. Wong
Create a helper to compute the misalignment between a file extent (xfs_extlen_t) and a realtime extent. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: create a helper to convert rtextents to rtblocksDarrick J. Wong
Create a helper to convert a realtime extent to a realtime block. Later on we'll change the helper to use bit shifts when possible. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: convert rt extent numbers to xfs_rtxnum_tclean-up-realtime-units_2022-10-14Darrick J. Wong
Further disambiguate the xfs_rtblock_t uses by creating a new type, xfs_rtxnum_t, to store the position of an extent within the realtime section, in units of rtextents. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: rename xfs_verify_rtext to xfs_verify_rtbextDarrick J. Wong
This helper function validates that a range of *blocks* in the realtime section is completely contained within the realtime section. It does /not/ validate ranges of *rtextents*. Rename the function to avoid suggesting that it does, and change the type of the @len parameter since xfs_rtblock_t is a position unit, not a length unit. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: convert rt bitmap extent lengths to xfs_rtbxlen_tDarrick J. Wong
XFS uses xfs_rtblock_t for many different uses, which makes it much more difficult to perform a unit analysis on the codebase. One of these (ab)uses is when we need to store the length of a free space extent as stored in the realtime bitmap. Because there can be up to 2^64 realtime extents in a filesystem, we need a new type that is larger than xfs_rtxlen_t for callers that are querying the bitmap directly. This means scrub and growfs. Create this type as "xfs_rtbxlen_t" and use it to store 64-bit rtx lengths. 'b' stands for 'bitmap' or 'big'; reader's choice. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: convert rt bitmap/summary block numbers to xfs_fileoff_tDarrick J. Wong
We should use xfs_fileoff_t to store the file block offset of any location within the realtime bitmap or summary files. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: convert xfs_extlen_t to xfs_rtxlen_t in the rt allocatorDarrick J. Wong
In most of the filesystem, we use xfs_extlen_t to store the length of a file (or AG) space mapping in units of fs blocks. Unfortunately, the realtime allocator also uses it to store the length of a rt space mapping in units of rt extents. This is confusing, since one rt extent can consist of many fs blocks. Separate the two by introducing a new type (xfs_rtxlen_t) to store the length of a space mapping (in units of realtime extents) that would be found in a file. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: move the xfs_rtbitmap.c declarations to xfs_rtbitmap.hDarrick J. Wong
Move all the declarations for functionality in xfs_rtbitmap.c into a separate xfs_rtbitmap.h header file. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: make sure maxlen is still congruent with prod when rounding downDarrick J. Wong
In commit 2a6ca4baed62, we tried to fix an overflow problem in the realtime allocator that was caused by an overly large maxlen value causing xfs_rtcheck_range to run off the end of the realtime bitmap. Unfortunately, there is a subtle bug here -- maxlen (and minlen) both have to be aligned with @prod, but @prod can be larger than 1 if the user has set an extent size hint on the file, and that extent size hint is larger than the realtime extent size. If the rt free space extents are not aligned to this file's extszhint because other files without extent size hints allocated space (or the number of rt extents is similarly not aligned), then it's possible that maxlen after clamping to sb_rextents will no longer be aligned to prod. The allocation will succeed just fine, but we still trip the assertion. Fix the problem by reducing maxlen by any misalignment with prod. While we're at it, split the assertions into two so that we can tell which value had the bad alignment. Fixes: 2a6ca4baed62 ("xfs: make sure the rt allocator doesn't run off the end") Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: rt stubs should return negative errnos when rt disabledDarrick J. Wong
When realtime support is not compiled into the kernel, these functions should return negative errnos, not positive errnos. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: prevent rt growfs when quota is enabledDarrick J. Wong
Quotas aren't (yet) supported with realtime, so we shouldn't allow userspace to set up a realtime section when quotas are enabled, even if they attached one via mount options. IOWS, you shouldn't be able to do: # mkfs.xfs -f /dev/sda # mount /dev/sda /mnt -o rtdev=/dev/sdb # xfs_growfs -r /mnt Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: bump max fsgeom struct versionDarrick J. Wong
The latest version of the fs geometry structure is v5. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-10-14xfs: 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 <djwong@kernel.org>