for-next
Commits on Mar 9, 2018
-
xfs_repair: don't fail directory repairs when grabbing inodes
There are a few places where xfs_repair needs to be able to load a damaged directory inode to perform repairs. Since inline data fork verifiers can now be customized, refactor libxfs_iget to enable repair to get at this so that we don't crash in phase 6. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
xfs_db: print transaction reservation type information
Create a new xfs_db command to print the transaction reservation info for a given filesystem. This will make it easier to compare the calculations made by the kernel and xfsprogs in case there is a discrepancy. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
xfs_scrub: don't try to scan xattrs if bstat says there aren't any
Only try to scan the extended attributes of a file if bstat says that the file actually has any. Surprisingly, this reduces the phase 5 runtime by 40% if most of the files don't have attrs. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
xfs_scrub: fix #include ordering to avoid build failure
Fix the ordering of the header includes in all the scrub source. We put xfs.h first so that it will pull in include/linux.h which pulls in linux/fs.h + whatever overrides are necessary (currently limited to struct fsxattr) to make things work on this platform, and then we remove the #includes for anything that will get pulled (directly or indirectly) by xfs.h for cleanliness. Without this, a user compiling new xfsprogs on a system with a 4.7 kernel gets this: Building scrub [CC] disk.o In file included from ../include/xfs.h:37:0, from disk.c:40: ../include/xfs/linux.h:185:8: error: redefinition of 'struct fsxattr' struct fsxattr { ^~~~~~~ In file included from disk.c:31:0: /usr/include/linux/fs.h:155:8: note: originally defined here struct fsxattr { ^~~~~~~ gmake[2]: *** [../include/buildrules:60: disk.o] Error 1 gmake[1]: *** [include/buildrules:36: scrub] Error 2 make: *** [Makefile:77: default] Error 2 Reported-by: Mikael Magnusson <mikachu@gmail.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net> -
xfs_scrub: don't ask user to run xfs_repair for only warnings
Don't advise the user to run xfs_repair on a filesystem that triggers warnings but no errors; there's no corruption for it to fix. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
xfs_scrub: log operational messages when interactive
Record the summary of an interactive session in the system log so that future support requests can get a better picture of what happened. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
xfs_db: don't crash in ablock if there's no inode
Make sure we actually have an inode selected before trying to unwrap its attribute fork. Found via a crash in xfs/288 with project quotas enabled. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
Fix various compiler warnings that pop up in 7.3. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
xfsprogs: new libxfs-apply option for Signed-off-by: tag
Technically when a maintainer moves a patch from another project, they should add their Signed-off-by: tag. Get that info automatically from git-config, and add an option to to override it if desired, to make that easy when cross-porting libxfs patches Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Eric Sandeen committedMar 9, 2018 -
xfsprogs: call libxfs_destroy from other utilities
Call libxfs_destroy() from xfs_copy, xfs_db, mkfs.xfs, and xfs_repair to allow us to detect leaked items in these utilities as well. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Eric Sandeen committedMar 9, 2018 -
libxfs: Catch non-empty zones on destroy
Create and use a kmem_zone_destroy which warns if we are releasing a non-empty zone when the LIBXFS_LEAK_CHECK environment variable is set, wire this into libxfs_destroy(), and call that when various tools exit. The LIBXFS_LEAK_CHECK environment variable also causes the program to exit with failure when a leak is detected, useful for failing automated tests if leaks are encountered. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Eric Sandeen committedMar 9, 2018 -
libxfs: move xfs_inode_zone to rdwr.c
The zone itself is created in rdwr.c, so define it there as well, and add it to the list of externs in manage_zones along with all the rest, for consistency. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Eric Sandeen committedMar 9, 2018 -
libxfs: add function to free all buffers in bcache
libxfs_bcache_purge simply moves all "free" buffers onto the xfs_buf_freelist mru list; add a new function to actually free them when we tear everything down, so leak checkers don't go nuts about lots of unfreed xfs_bufs at exit. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Eric Sandeen committedMar 9, 2018 -
libxfs: Replace XFS_BUF_SET_PTR with xfs_buf_associate_memory
We test the return value of the macro, but it returns returns a side-effect which looks like failure. Write a userspace-libxfs-specific version of xfs_buf_associate_memory to make this code a tad more like the kernel, with a proper return value to boot. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Eric Sandeen committedMar 9, 2018 -
xfs_io: add RWF_DSYNC support to pwrite
Enable testing write behaviour with the per-io RWF_DSYNC flag. Signed-Off-By: Dave Chinner <dchinner@redhat.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Dave Chinner authored and Eric Sandeen committedMar 9, 2018 -
xfs_scrub: make interpreter explicit to python3
Using #!/usr/bin/env makes some package dependency tools such as rpm complain given that it cannot verify package dependencies. Making it explicit resolves this lint rant. Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Luis R. Rodriguez authored and Eric Sandeen committedMar 9, 2018 -
xfs_repair: Add missing braces to allow zeroing of corrupt log
When xlog_find_tail() fails to find the head or the tail, the missing braces leads that an unparseable log always exits with status 2, even if we've asked for -n or -L which should proceed. We can expose this issue by xfstests case xfs/098. Fixes: commit b04647e ("xfs_repair: exit with status 2 if log dirtiness is unknown") Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
xfs_io: support a basic extent swap command
Extent swap is a low level mechanism exported by XFS to facilitate filesystem defragmentation. It is typically invoked by xfs_fsr under conditions that will atomically adjust inode extent state without loss of file data. While xfs_fsr provides some debug capability to tailor its behavior, it is not flexible enough to facilitate low level tests of the extent swap mechanism. For example, xfs_fsr may skip swaps between inodes that consist solely of preallocated extents because it considers such files already 100% defragmented. Further, xfs_fsr copies data between files where doing so may be unnecessary and thus inefficient for lower level tests. Add a basic swapext command to xfs_io that allows userspace invocation of the command under more controlled conditions. This facilites targeted tests without interference from xfs_fsr policy, such as using files with only preallocated extents, known/expected failure cases, etc. This command makes no effort to retain data across the operation. As such, it is for testing purposes only. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Brian Foster authored and Eric Sandeen committedMar 9, 2018 -
xfs_io: Add missing perror for write_once (-O)
This got missed in the last set of patches. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
misc: enable link time optimization, if requested
Enable link time optimization (LTO) if the builder requests it. The extra link optimization results in smaller binaries. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
misc: enable retpolines across all xfsprogs utilities
Detect and enable retpolines for all code, to mitigate Spectre v2 (branch target injection) on x86. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Commits on Feb 28, 2018
-
xfs: fix u32 type usage in sb validation function
Source kernel commit: 131fa58d391fc0939f6c66b23776ad5df5db20f9 Don't use u32, use uint32_t, because this won't work in xfsprogs. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> [sandeen: no-op commit, fixed previously to keep build working] Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Commits on Feb 27, 2018
-
xfs: don't screw up direct writes when freesp is fragmented
Source kernel commit: 6d8a45ce29c7d67cc4fc3016dc2a07660c62482a xfs_bmap_btalloc is given a range of file offset blocks that must be allocated to some data/attr/cow fork. If the fork has an extent size hint associated with it, the request will be enlarged on both ends to try to satisfy the alignment hint. If free space is fragmentated, sometimes we can allocate some blocks but not enough to fulfill any of the requested range. Since bmapi_allocate always trims the new extent mapping to match the originally requested range, this results in bmapi_write returning zero and no mapping. The consequences of this vary -- buffered writes will simply re-call bmapi_write until it can satisfy at least one block from the original request. Direct IO overwrites notice nmaps == 0 and return -ENOSPC through the dio mechanism out to userspace with the weird result that writes fail even when we have enough space because the ENOSPC return overrides any partial write status. For direct CoW writes the situation was disastrous because nobody notices us returning an invalid zero-length wrong-offset mapping to iomap and the write goes off into space. Therefore, if free space is so fragmented that we managed to allocate some space but not enough to map into even a single block of the original allocation request range, we should break the alignment hint in order to guarantee at least some forward progress for the direct write. If we return a short allocation to iomap_apply it'll call back about the remaining blocks. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
xfs: treat CoW fork operations as delalloc for quota accounting
Source kernel commit: 4b4c1326fd7c7210d23d9dd3bfc51f2b6477bb9e Since the CoW fork only exists in memory, it is incorrect to update the on-disk quota block counts when we modify the CoW fork. Unlike the data fork, even real extents in the CoW fork are only delalloc-style reservations (on-disk they're owned by the refcountbt) so they must not be tracked in the on disk quota info. Ensure the i_delayed_blks accounting reflects this too. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
xfs: refactor accounting updates out of xfs_bmap_btalloc
Source kernel commit: 751f3767c245f9adf4f0a4f8f04aae9ae1d675a0 Move all the inode and quota accounting updates out of xfs_bmap_btalloc in preparation for fixing some quota accounting problems with copy on write. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
xfs: refactor inode verifier corruption error printing
Source kernel commit: 22431bf3dfbf44d7356933776eb486a6a01dea6f Refactor inode verifier error reporting into a non-libxfs function so that we aren't encoding the message format in libxfs. This also changes the kernel dmesg output to resemble buffer verifier errors more closely. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
Source kernel commit: 6ca30729c206d62d88730a904af7d543a56273d8 Remove the extent size hint and realtime inode relevant code from the xfs_bmapi_reserve_delalloc since it is not called on the inode with extent size hint set or on a realtime inode. Signed-off-by: Shan Hai <shan.hai@oracle.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Shan Hai authored and Eric Sandeen committedFeb 27, 2018 -
Source kernel commit: fb1755a645972ed096047583600838f6cf414e2b By splitting the b_fspriv field into two different fields (b_log_item and b_li_list). It's possible to get rid of an old ABI workaround, by using the new b_log_item field to store xfs_buf_log_item separated from the log items attached to the buffer, which will be linked in the new b_li_list field. This way, there is no more need to reorder the log items list to place the buf_log_item at the beginning of the list, simplifying a bit the logic to handle buffer IO. This also opens the possibility to change buffer's log items list into a proper list_head. b_log_item field is still defined as a void *, because it is still used by the log buffers to store xlog_in_core structures, and there is no need to add an extra field on xfs_buf just for xlog_in_core. Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: Bill O'Donnell <billodo@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> [darrick: minor style changes] Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> [sandeen: b_li_list unused in userspace] Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
xfs: convert to new i_version API
Source kernel commit: f0e28280629e0ec7921f3179409a179b1ea41f24 Signed-off-by: Jeff Layton <jlayton@redhat.com> Acked-by: Darrick J. Wong <darrick.wong@oracle.com> Acked-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
xfs: check sb_agblocks and sb_agblklog when validating superblock
Source kernel commit: 4bb73d014785cc55225686f9f46e7192fb59d26b Currently, we don't check sb_agblocks or sb_agblklog when we validate the superblock, which means that we can fuzz garbage values into those values and the mount succeeds. This leads to all sorts of UBSAN warnings in xfs/350 since we can then coerce other parts of xfs into shifting by ridiculously large values. Once we've validated agblocks, make sure the agcount makes sense. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com> [sandeen: fix up u32 usage now so we keep building] Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
xfs: recheck reflink / dirty page status before freeing CoW reservations
Source kernel commit: be78ff0e72778eb4df4aac66edb9e97462bfe00d Eryu Guan reported seeing occasional hangs when running generic/269 with a new fsstress that supports clonerange/deduperange. The cause of this hang is an infinite loop when we convert the CoW fork extents from unwritten to real just prior to writing the pages out; the infinite loop happens because there's nothing in the CoW fork to convert, and so it spins forever. The fundamental issue here is that when we go to perform these CoW fork conversions, we're supposed to have an extent waiting for us, but the low space CoW reaper has snuck in and blown them away! There are four conditions that can dissuade the reaper from touching our file -- no reflink iflag; dirty page cache; writeback in progress; or directio in progress. We check the four conditions prior to taking the locks, but we neglect to recheck them once we have the locks, which is how we end up whacking the writeback that's in progress. Therefore, refactor the four checks into a helper function and call it once again once we have the locks to make sure we really want to reap the inode. While we're at it, add an ASSERT for this weird condition so that we'll fail noisily if we ever screw this up again. Reported-by: Eryu Guan <eguan@redhat.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Tested-by: Eryu Guan <eguan@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
xfs: btree format ifork loader should check for zero numrecs
Source kernel commit: 55e45429ce3e4ac9dd2bf4937b1a499a69ccc4ca A btree format inode fork with zero records makes no sense, so reject it if we see it, or else we can miscalculate memory allocations. Found by zeroes fuzzing {a,u3}.bmbt.numrecs in xfs/{374,378,412} with KASAN. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net> -
xfs: attr leaf verifier needs to check for obviously bad count
Source kernel commit: 79a69bf8dc240ebeb105226a8a8540df136bf987 In the attribute leaf verifier, we can check for obviously bad values of firstused and count so that later attempts at lasthash don't run off the end of the memory buffer. Found by ones fuzzing hdr.count in xfs/400 with KASAN. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
xfs: directory scrubber must walk through data block to offset
Source kernel commit: ce92d29ddf9908d397895c46b7c78e9db8df414d In xfs_scrub_dir_rec, we must walk through the directory block entries to arrive at the offset given by the hash structure. If we blindly trust the hash address, we can end up midway into a directory entry and stray outside the block. Found by lastbit fuzzing lents[3].address in xfs/390 with KASAN enabled. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-
xfs: cross-reference the realtime bitmap
Source kernel commit: 46d9bfb5e706493777b9dfed666cd8967f69e6fd While we're scrubbing various btrees, cross-reference the records with the other metadata. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>