]> www.infradead.org Git - users/hch/xfsprogs.git/log
users/hch/xfsprogs.git
5 years agoxfs: devirtualize ->node_hdr_to_disk
Christoph Hellwig [Wed, 22 Jan 2020 16:29:41 +0000 (11:29 -0500)]
xfs: devirtualize ->node_hdr_to_disk

Source kernel commit: e1c8af1e02c7893f2d056aa44c4daf59fe0881ed

Replace the ->node_hdr_to_disk dir ops method with a directly called
xfs_da_node_hdr_to_disk helper that takes care of the v4 vs v5
difference.

Signed-off-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: devirtualize ->node_hdr_from_disk
Christoph Hellwig [Wed, 22 Jan 2020 16:29:41 +0000 (11:29 -0500)]
xfs: devirtualize ->node_hdr_from_disk

Source kernel commit: f475dc4dc7cc98ad653135db174084a55076b1ba

Replace the ->node_hdr_from_disk dir ops method with a directly called
xfs_da_node_hdr_from_disk helper that takes care of the v4 vs v5
difference.

Signed-off-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: use unsigned int for all size values in struct xfs_da_geometry
Christoph Hellwig [Wed, 22 Jan 2020 16:29:41 +0000 (11:29 -0500)]
xfs: use unsigned int for all size values in struct xfs_da_geometry

Source kernel commit: b16be561876ed9b72dcb2bf8c48b30f573f63c1c

None of these can ever be negative, so use unsigned types.

Signed-off-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: move incore structures out of xfs_da_format.h
Christoph Hellwig [Wed, 22 Jan 2020 16:29:41 +0000 (11:29 -0500)]
xfs: move incore structures out of xfs_da_format.h

Source kernel commit: a39f089a25e75c3d17b955d8eb8bc781f23364f3

Move the abstract in-memory version of various btree block headers
out of xfs_da_format.h as they aren't on-disk formats.

Signed-off-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: refactor "does this fork map blocks" predicate
Darrick J. Wong [Wed, 22 Jan 2020 16:29:40 +0000 (11:29 -0500)]
xfs: refactor "does this fork map blocks" predicate

Source kernel commit: 2fe4f92834c40e81945284b3eaf4610c4dd84e9d

Replace the open-coded checks for whether or not an inode fork maps
blocks with a macro that will implant the code for us.  This helps us
declutter the bmap code a bit.

Note that I had to use a macro instead of a static inline function
because of C header dependency problems between xfs_inode.h and
xfs_inode_fork.h.

Conversion was performed with the following Coccinelle script:

@@
expression ip, w;
@@

- XFS_IFORK_FORMAT(ip, w) == XFS_DINODE_FMT_EXTENTS || XFS_IFORK_FORMAT(ip, w) == XFS_DINODE_FMT_BTREE
+ xfs_ifork_has_extents(ip, w)

@@
expression ip, w;
@@

- XFS_IFORK_FORMAT(ip, w) != XFS_DINODE_FMT_EXTENTS && XFS_IFORK_FORMAT(ip, w) != XFS_DINODE_FMT_BTREE
+ !xfs_ifork_has_extents(ip, w)

@@
expression ip, w;
@@

- XFS_IFORK_FORMAT(ip, w) == XFS_DINODE_FMT_BTREE || XFS_IFORK_FORMAT(ip, w) == XFS_DINODE_FMT_EXTENTS
+ xfs_ifork_has_extents(ip, w)

@@
expression ip, w;
@@

- XFS_IFORK_FORMAT(ip, w) != XFS_DINODE_FMT_BTREE && XFS_IFORK_FORMAT(ip, w) != XFS_DINODE_FMT_EXTENTS
+ !xfs_ifork_has_extents(ip, w)

@@
expression ip, w;
@@

- (xfs_ifork_has_extents(ip, w))
+ xfs_ifork_has_extents(ip, w)

@@
expression ip, w;
@@

- (!xfs_ifork_has_extents(ip, w))
+ !xfs_ifork_has_extents(ip, w)

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>
5 years agoxfs: clean up weird while loop in xfs_alloc_ag_vextent_near
Darrick J. Wong [Wed, 22 Jan 2020 16:29:40 +0000 (11:29 -0500)]
xfs: clean up weird while loop in xfs_alloc_ag_vextent_near

Source kernel commit: 5113f8ec3753ed4d68a5d54d3345fee33a914bfe

Refactor the weird while loop out of existence.

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>
5 years agoxfs: Correct comment tyops -> typos
Joe Perches [Wed, 22 Jan 2020 16:29:40 +0000 (11:29 -0500)]
xfs: Correct comment tyops -> typos

Source kernel commit: cf085a1b5d221448c0c7425f3b9b9a9e2134e53e

Just fix the typos checkpatch notices...

Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.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>
5 years agoxfs: null out bma->prev if no previous extent
Darrick J. Wong [Wed, 22 Jan 2020 16:29:40 +0000 (11:29 -0500)]
xfs: null out bma->prev if no previous extent

Source kernel commit: f5be08446ee748785697527c8d772d896814b95f

Coverity complains that we don't check the return value of
xfs_iext_peek_prev_extent like we do nearly all of the time.  If there
is no previous extent then just null out bma->prev like we do elsewhere
in the bmap code.

Coverity-id: 1424057
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>
5 years agoxfs: fix missing header includes
Darrick J. Wong [Wed, 22 Jan 2020 16:29:40 +0000 (11:29 -0500)]
xfs: fix missing header includes

Source kernel commit: 5f213ddbcbe86577f517437ef0ecb4ef3bcc3434

Some of the xfs source files are missing header includes, so add them
back.  Sparse complains about non-static functions that don't have a
forward declaration anywhere.

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>
5 years agoxfs: decrease indenting problems in xfs_dabuf_map
Darrick J. Wong [Wed, 22 Jan 2020 16:29:40 +0000 (11:29 -0500)]
xfs: decrease indenting problems in xfs_dabuf_map

Source kernel commit: ee4fb16cbec9aa1ce6e837d143f411ee42df1bb5

Refactor the code that complains when a dir/attr mapping doesn't exist
but the caller requires a mapping.  This small restructuring helps us to
reduce the indenting level.

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>
5 years agoxfs: always log corruption errors
Darrick J. Wong [Wed, 22 Jan 2020 16:29:37 +0000 (11:29 -0500)]
xfs: always log corruption errors

Source kernel commit: a5155b870d687de1a5f07e774b49b1e8ef0f6f50

Make sure we log something to dmesg whenever we return -EFSCORRUPTED up
the call stack.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: relax shortform directory size checks
Darrick J. Wong [Thu, 16 Jan 2020 22:13:33 +0000 (17:13 -0500)]
xfs: relax shortform directory size checks

Source kernel commit: e91ec882af21c0e845bf962b35f3c13482f74b2f

Each of the four functions that operate on shortform directories checks
that the directory's di_size is at least as large as the shortform
directory header.  This is now checked by the inode fork verifiers
(di_size is used to allocate if_bytes, and if_bytes is checked against
the header structure size) so we can turn these checks into ASSERTions.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: cleanup use of the XFS_ALLOC_ flags
Christoph Hellwig [Thu, 16 Jan 2020 22:13:33 +0000 (17:13 -0500)]
xfs: cleanup use of the XFS_ALLOC_ flags

Source kernel commit: c34d570d158699c6c812f5df653aaf2e3a83acca

Always set XFS_ALLOC_USERDATA for data fork allocations, and check it
in xfs_alloc_is_userdata instead of the current obsfucated check.
Also remove the xfs_alloc_is_userdata and xfs_alloc_allow_busy_reuse
helpers to make the code a little easier to understand.

Signed-off-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: move extent zeroing to xfs_bmapi_allocate
Christoph Hellwig [Thu, 16 Jan 2020 22:13:33 +0000 (17:13 -0500)]
xfs: move extent zeroing to xfs_bmapi_allocate

Source kernel commit: fd638f1de1f3f736ea4debb3582999ea95506e0a

Move the extent zeroing case there for the XFS_BMAPI_ZERO flag outside
the low-level allocator and into xfs_bmapi_allocate, where is still
is in transaction context, but outside the very lowlevel code where
it doesn't belong.

Signed-off-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: refactor xfs_bmapi_allocate
Christoph Hellwig [Thu, 16 Jan 2020 22:13:33 +0000 (17:13 -0500)]
xfs: refactor xfs_bmapi_allocate

Source kernel commit: be6cacbeea8c562a06e9a03c95e3fdee065d1b7b

Avoid duplicate userdata and data fork checks by restructuring the code
so we only have a helper for userdata allocations that combines these
checks in a straight foward way.  That also helps to obsoletes the
comments explaining what the code does as it is now clearly obvious.

Signed-off-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: refactor xfs_iread_extents to use xfs_btree_visit_blocks
Darrick J. Wong [Thu, 16 Jan 2020 22:13:33 +0000 (17:13 -0500)]
xfs: refactor xfs_iread_extents to use xfs_btree_visit_blocks

Source kernel commit: e992ae8afdedcdfe65ededd96b5a15319f2e6bae

xfs_iread_extents open-codes everything in xfs_btree_visit_blocks, so
refactor the btree helper to be able to iterate only the records on
level 0, then port iread_extents to use it.

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>
5 years agoxfs: replace -EIO with -EFSCORRUPTED for corrupt metadata
Darrick J. Wong [Thu, 16 Jan 2020 22:13:33 +0000 (17:13 -0500)]
xfs: replace -EIO with -EFSCORRUPTED for corrupt metadata

Source kernel commit: c2414ad6e66ab96b867309454498f7fb29b7e855

There are a few places where we return -EIO instead of -EFSCORRUPTED
when we find corrupt metadata.  Fix those places.

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>
5 years agoxfs: namecheck attribute names before listing them
Darrick J. Wong [Thu, 16 Jan 2020 22:13:33 +0000 (17:13 -0500)]
xfs: namecheck attribute names before listing them

Source kernel commit: 16c6e92c7e9836ed08db5f9771e75845796bd87f

Actually call namecheck on attribute names before we hand them over to
userspace.

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>
5 years agoxfs: check attribute leaf block structure
Darrick J. Wong [Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)]
xfs: check attribute leaf block structure

Source kernel commit: c84760659dcf237902d4cc997cd5f55cb3b2807f

Add missing structure checks in the attribute leaf verifier.

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>
5 years agoxfs: don't set bmapi total block req where minleft is
Brian Foster [Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)]
xfs: don't set bmapi total block req where minleft is

Source kernel commit: da781e64b28c1d72f84bab6a884359c9c8d522aa

xfs_bmapi_write() takes a total block requirement parameter that is
passed down to the block allocation code and is used to specify the
total block requirement of the associated transaction. This is used
to try and select an AG that can not only satisfy the requested
extent allocation, but can also accommodate subsequent allocations
that might be required to complete the transaction. For example,
additional bmbt block allocations may be required on insertion of
the resulting extent to an inode data fork.

While it's important for callers to calculate and reserve such extra
blocks in the transaction, it is not necessary to pass the total
value to xfs_bmapi_write() in all cases. The latter automatically
sets minleft to ensure that sufficient free blocks remain after the
allocation attempt to expand the format of the associated inode
(i.e., such as extent to btree conversion, btree splits, etc).
Therefore, any callers that pass a total block requirement of the
bmap mapping length plus worst case bmbt expansion essentially
specify the additional reservation requirement twice. These callers
can pass a total of zero to rely on the bmapi minleft policy.

Beyond being superfluous, the primary motivation for this change is
that the total reservation logic in the bmbt code is dubious in
scenarios where minlen < maxlen and a maxlen extent cannot be
allocated (which is more common for data extent allocations where
contiguity is not required). The total value is based on maxlen in
the xfs_bmapi_write() caller. If the bmbt code falls back to an
allocation between minlen and maxlen, that allocation will not
succeed until total is reset to minlen, which essentially throws
away any additional reservation included in total by the caller. In
addition, the total value is not reset until after alignment is
dropped, which means that such callers drop alignment far too
aggressively than necessary.

Update all callers of xfs_bmapi_write() that pass a total block
value of the mapping length plus bmbt reservation to instead pass
zero and rely on xfs_bmapi_minleft() to enforce the bmbt reservation
requirement. This trades off slightly less conservative AG selection
for the ability to preserve alignment in more scenarios.
xfs_bmapi_write() callers that incorporate unrelated or additional
reservations in total beyond what is already included in minleft
must continue to use the former.

Signed-off-by: Brian Foster <bfoster@redhat.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>
5 years agoxfs: cap longest free extent to maximum allocatable
Dave Chinner [Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)]
xfs: cap longest free extent to maximum allocatable

Source kernel commit: 1c743574de8b5a47c323c0dc3089985b38f83390

Cap longest extent to the largest we can allocate based on limits
calculated at mount time. Dynamic state (such as finobt blocks)
can result in the longest free extent exceeding the size we can
allocate, and that results in failure to align full AG allocations
when the AG is empty.

Result:

xfs_io-4413  [003]   426.412459: xfs_alloc_vextent_loopfailed: dev 8:96 agno 0 agbno 32 minlen 243968 maxlen 244000 mod 0 prod 1 minleft 1 total 262148 alignment 32 minalignslop 0 len 0 type NEAR_BNO otype START_BNO wasdel 0 wasfromfl 0 resv 0 datatype 0x5 firstblock 0xffffffffffffffff

minlen and maxlen are now separated by the alignment size, and
allocation fails because args.total > free space in the AG.

[bfoster: Added xfs_bmap_btalloc() changes.]

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Brian Foster <bfoster@redhat.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>
5 years agoxfs: fix inode fork extent count overflow
Dave Chinner [Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)]
xfs: fix inode fork extent count overflow

Source kernel commit: 3f8a4f1d876d3e3e49e50b0396eaffcc4ba71b08

[commit message is verbose for discussion purposes - will trim it
down later. Some questions about implementation details at the end.]

Zorro Lang recently ran a new test to stress single inode extent
counts now that they are no longer limited by memory allocation.
The test was simply:

# xfs_io -f -c "falloc 0 40t" /mnt/scratch/big-file
# ~/src/xfstests-dev/punch-alternating /mnt/scratch/big-file

This test uncovered a problem where the hole punching operation
appeared to finish with no error, but apparently only created 268M
extents instead of the 10 billion it was supposed to.

Further, trying to punch out extents that should have been present
resulted in success, but no change in the extent count. It looked
like a silent failure.

While running the test and observing the behaviour in real time,
I observed the extent coutn growing at ~2M extents/minute, and saw
this after about an hour:

# xfs_io -f -c "stat" /mnt/scratch/big-file |grep next ; \
> sleep 60 ; \
> xfs_io -f -c "stat" /mnt/scratch/big-file |grep next
fsxattr.nextents = 127657993
fsxattr.nextents = 129683339
#

And a few minutes later this:

# xfs_io -f -c "stat" /mnt/scratch/big-file |grep next
fsxattr.nextents = 4177861124
#

Ah, what? Where did that 4 billion extra extents suddenly come from?

Stop the workload, unmount, mount:

# xfs_io -f -c "stat" /mnt/scratch/big-file |grep next
fsxattr.nextents = 166044375
#

And it's back at the expected number. i.e. the extent count is
correct on disk, but it's screwed up in memory. I loaded up the
extent list, and immediately:

# xfs_io -f -c "stat" /mnt/scratch/big-file |grep next
fsxattr.nextents = 4192576215
#

It's bad again. So, where does that number come from?
xfs_fill_fsxattr():

if (ip->i_df.if_flags & XFS_IFEXTENTS)
fa->fsx_nextents = xfs_iext_count(&ip->i_df);
else
fa->fsx_nextents = ip->i_d.di_nextents;

And that's the behaviour I just saw in a nutshell. The on disk count
is correct, but once the tree is loaded into memory, it goes whacky.
Clearly there's something wrong with xfs_iext_count():

inline xfs_extnum_t xfs_iext_count(struct xfs_ifork *ifp)
{
return ifp->if_bytes / sizeof(struct xfs_iext_rec);
}

Simple enough, but 134M extents is 2**27, and that's right about
where things went wrong. A struct xfs_iext_rec is 16 bytes in size,
which means 2**27 * 2**4 = 2**31 and we're right on target for an
integer overflow. And, sure enough:

struct xfs_ifork {
int                     if_bytes;       /* bytes in if_u1 */
....

Once we get 2**27 extents in a file, we overflow if_bytes and the
in-core extent count goes wrong. And when we reach 2**28 extents,
if_bytes wraps back to zero and things really start to go wrong
there. This is where the silent failure comes from - only the first
2**28 extents can be looked up directly due to the overflow, all the
extents above this index wrap back to somewhere in the first 2**28
extents. Hence with a regular pattern, trying to punch a hole in the
range that didn't have holes mapped to a hole in the first 2**28
extents and so "succeeded" without changing anything. Hence "silent
failure"...

Fix this by converting if_bytes to a int64_t and converting all the
index variables and size calculations to use int64_t types to avoid
overflows in future. Signed integers are still used to enable easy
detection of extent count underflows. This enables scalability of
extent counts to the limits of the on-disk format - MAXEXTNUM
(2**31) extents.

Current testing is at over 500M extents and still going:

fsxattr.nextents = 517310478

Reported-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Dave Chinner <dchinner@redhat.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>
5 years agoxfs: optimize near mode bnobt scans with concurrent cntbt lookups
Brian Foster [Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)]
xfs: optimize near mode bnobt scans with concurrent cntbt lookups

Source kernel commit: dc8e69bd721840bc22ffe5aa8598fd92b44f0334

The near mode fallback algorithm consists of a left/right scan of
the bnobt. This algorithm has very poor breakdown characteristics
under worst case free space fragmentation conditions. If a suitable
extent is far enough from the locality hint, each allocation may
scan most or all of the bnobt before it completes. This causes
pathological behavior and extremely high allocation latencies.

While locality is important to near mode allocations, it is not so
important as to incur pathological allocation latency to provide the
asolute best available locality for every allocation. If the
allocation is large enough or far enough away, there is a point of
diminishing returns. As such, we can bound the overall operation by
including an iterative cntbt lookup in the broader search. The cntbt
lookup is optimized to immediately find the extent with best
locality for the given size on each iteration. Since the cntbt is
indexed by extent size, the lookup repeats with a variably
aggressive increasing search key size until it runs off the edge of
the tree.

This approach provides a natural balance between the two algorithms
for various situations. For example, the bnobt scan is able to
satisfy smaller allocations such as for inode chunks or btree blocks
more quickly where the cntbt search may have to search through a
large set of extent sizes when the search key starts off small
relative to the largest extent in the tree. On the other hand, the
cntbt search more deterministically covers the set of suitable
extents for larger data extent allocation requests that the bnobt
scan may have to search the entire tree to locate.

Signed-off-by: Brian Foster <bfoster@redhat.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>
5 years agoxfs: factor out tree fixup logic into helper
Brian Foster [Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)]
xfs: factor out tree fixup logic into helper

Source kernel commit: d29688257fd425f7c64c3525fea29658b50fc390

Lift the btree fixup path into a helper function.

Signed-off-by: Brian Foster <bfoster@redhat.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>
5 years agoxfs: refactor near mode alloc bnobt scan into separate function
Brian Foster [Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)]
xfs: refactor near mode alloc bnobt scan into separate function

Source kernel commit: 0e26d5ca4a40211a4e2acd15a5cb229184c1f867

In preparation to enhance the near mode allocation bnobt scan algorithm, lift
it into a separate function. No functional changes.

Signed-off-by: Brian Foster <bfoster@redhat.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>
5 years agoxfs: refactor and reuse best extent scanning logic
Brian Foster [Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)]
xfs: refactor and reuse best extent scanning logic

Source kernel commit: 78d7aabdeea38368dc5e0aff2d3d1c353a7ab344

The bnobt "find best" helper implements a simple btree walker
function. This general pattern, or a subset thereof, is reused in
various parts of a near mode allocation operation. For example, the
bnobt left/right scans are each iterative btree walks along with the
cntbt lastblock scan.

Rework this function into a generic btree walker, add a couple
parameters to control termination behavior from various contexts and
reuse it where applicable.

Signed-off-by: Brian Foster <bfoster@redhat.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>
5 years agoxfs: refactor allocation tree fixup code
Brian Foster [Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)]
xfs: refactor allocation tree fixup code

Source kernel commit: 4a65b7c2c72c3940a4472c49743fdb65a03a9935

Both algorithms duplicate the same btree allocation code. Eliminate
the duplication and reuse the fallback algorithm codepath.

Signed-off-by: Brian Foster <bfoster@redhat.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>
5 years agoxfs: reuse best extent tracking logic for bnobt scan
Brian Foster [Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)]
xfs: reuse best extent tracking logic for bnobt scan

Source kernel commit: fec0afdaf498a9a923c3688cc9f9c91a73f5bcd8

The near mode bnobt scan searches left and right in the bnobt
looking for the closest free extent to the allocation hint that
satisfies minlen. Once such an extent is found, the left/right
search terminates, we search one more time in the opposite direction
and finish the allocation with the best overall extent.

The left/right and find best searches are currently controlled via a
combination of cursor state and local variables. Clean up this code
and prepare for further improvements to the near mode fallback
algorithm by reusing the allocation cursor best extent tracking
mechanism. Update the tracking logic to deactivate bnobt cursors
when out of allocation range and replace open-coded extent checks to
calls to the common helper. In doing so, rename some misnamed local
variables in the top-level near mode allocation function.

Signed-off-by: Brian Foster <bfoster@redhat.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>
5 years agoxfs: refactor cntbt lastblock scan best extent logic into helper
Brian Foster [Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)]
xfs: refactor cntbt lastblock scan best extent logic into helper

Source kernel commit: 396bbf3c657e540162b7297e426e5939c2909854

The cntbt lastblock scan checks the size, alignment, locality, etc.
of each free extent in the block and compares it with the current
best candidate. This logic will be reused by the upcoming optimized
cntbt algorithm, so refactor it into a separate helper. Note that
acur->diff is now initialized to -1 (unsigned) instead of 0 to
support the more granular comparison logic in the new helper.

Signed-off-by: Brian Foster <bfoster@redhat.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>
5 years agoxfs: track best extent from cntbt lastblock scan in alloc cursor
Brian Foster [Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)]
xfs: track best extent from cntbt lastblock scan in alloc cursor

Source kernel commit: c62321a2a0ea3c53ab7a41cf4d4071ee37bcc2c0

If the size lookup lands in the last block of the by-size btree, the
near mode algorithm scans the entire block for the extent with best
available locality. In preparation for similar best available
extent tracking across both btrees, extend the allocation cursor
with best extent data and lift the associated state from the cntbt
last block scan code. No functional changes.

Signed-off-by: Brian Foster <bfoster@redhat.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>
5 years agoxfs: track allocation busy state in allocation cursor
Brian Foster [Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)]
xfs: track allocation busy state in allocation cursor

Source kernel commit: d6d3aff20377fcb38913152d53c54e0010462ccb

Extend the allocation cursor to track extent busy state for an
allocation attempt. No functional changes.

Signed-off-by: Brian Foster <bfoster@redhat.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>
5 years agoxfs: introduce allocation cursor data structure
Brian Foster [Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)]
xfs: introduce allocation cursor data structure

Source kernel commit: f5e7dbea1e3ecc27f05e8cc83614c206903cc97a

Introduce a new allocation cursor data structure to encapsulate the
various states and structures used to perform an extent allocation.
This structure will eventually be used to track overall allocation
state across different search algorithms on both free space btrees.

To start, include the three btree cursors (one for the cntbt and two
for the bnobt left/right search) used by the near mode allocation
algorithm and refactor the cursor setup and teardown code into
helpers. This slightly changes cursor memory allocation patterns,
but otherwise makes no functional changes to the allocation
algorithm.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[darrick: fix sparse complaints]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: track active state of allocation btree cursors
Brian Foster [Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)]
xfs: track active state of allocation btree cursors

Source kernel commit: f6b428a46d60186a38105c71fa435f31240721f9

The upcoming allocation algorithm update searches multiple
allocation btree cursors concurrently. As such, it requires an
active state to track when a particular cursor should continue
searching. While active state will be modified based on higher level
logic, we can define base functionality based on the result of
allocation btree lookups.

Define an active flag in the private area of the btree cursor.
Update it based on the result of lookups in the existing allocation
btree helpers. Finally, provide a new helper to query the current
state.

Signed-off-by: Brian Foster <bfoster@redhat.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>
5 years agoxfs: use a struct iomap in xfs_writepage_ctx
Christoph Hellwig [Thu, 16 Jan 2020 22:12:49 +0000 (17:12 -0500)]
xfs: use a struct iomap in xfs_writepage_ctx

Source kernel commit: 4e087a3b313cc664057279b1e40372fc97e3e212

In preparation for moving the XFS writeback code to fs/iomap.c, switch
it to use struct iomap instead of the XFS-specific struct xfs_bmbt_irec.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.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>
5 years agoxfsprogs: Release v5.4.0 v5.4.0
Eric Sandeen [Fri, 20 Dec 2019 21:47:12 +0000 (16:47 -0500)]
xfsprogs: Release v5.4.0

Update all the necessary files for a 5.4.0 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: Release v5.4.0-rc1 v5.4.0-rc1
Eric Sandeen [Tue, 17 Dec 2019 21:59:46 +0000 (16:59 -0500)]
xfsprogs: Release v5.4.0-rc1

Update all the necessary files for a 5.4.0-rc1 prerelease.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agomkfs: tidy up discard notifications
Eric Sandeen [Tue, 17 Dec 2019 21:52:39 +0000 (16:52 -0500)]
mkfs: tidy up discard notifications

Only notify user of discard operations if the first one succeeds,
and be sure to print a trailing newline if we stop early.

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>
5 years agomkfs: Break block discard into chunks of 2 GB
Pavel Reichl [Fri, 13 Dec 2019 21:21:26 +0000 (16:21 -0500)]
mkfs: Break block discard into chunks of 2 GB

Some users are not happy about the BLKDISCARD taking too long and at the
same time not being informed about that - so they think that the command
actually hung.

This commit changes code so that progress reporting is possible and also
typing the ^C will cancel the ongoing BLKDISCARD.

Signed-off-by: Pavel Reichl <preichl@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>
5 years agoxfs_admin: enable online label getting and setting
Darrick J. Wong [Fri, 13 Dec 2019 21:21:19 +0000 (16:21 -0500)]
xfs_admin: enable online label getting and setting

Connect xfs_admin -L to the xfs_io label command so that we can get and
set the label for a live filesystem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_admin: support external log devices
Darrick J. Wong [Fri, 13 Dec 2019 21:21:18 +0000 (16:21 -0500)]
xfs_admin: support external log devices

Add to xfs_admin the ability to pass external log devices to xfs_db.
This is necessary to make changes on such filesystems.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: add missing line feeds in libxfs/rdwr.c
John Pittman [Fri, 13 Dec 2019 21:21:17 +0000 (16:21 -0500)]
xfsprogs: add missing line feeds in libxfs/rdwr.c

In libxfs/rdwr.c, there are several fprintf() calls that are
missing trailing line feeds. This translates to the following
CLI prompt being on the same line as the message. Add missing
line feeds, alleviating the issue.

Fixes: 0a7942b38215 ("libxfs: don't discard dirty buffers")
Signed-off-by: John Pittman <jpittman@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: remove stray libxfs whitespace
Eric Sandeen [Fri, 13 Dec 2019 21:21:16 +0000 (16:21 -0500)]
xfsprogs: remove stray libxfs whitespace

Not quite sure how these crept in but now's as good a time as any
to remove stray newline deltas vs. the kernel code.

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>
5 years agoxfsprogs: Release v5.4.0-rc0 v5.4.0-rc0
Eric Sandeen [Fri, 13 Dec 2019 21:21:06 +0000 (16:21 -0500)]
xfsprogs: Release v5.4.0-rc0

Update all the necessary files for a 5.4.0-rc0 prerelease.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: change the seconds fields in xfs_bulkstat to signed
Darrick J. Wong [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: change the seconds fields in xfs_bulkstat to signed

Source kernel commit: 5e0cd1ef64744e41e029dfca7d0ae285c486f386

64-bit time is a signed quantity in the kernel, so the bulkstat
structure should reflect that.  Note that the structure size stays
the same and that we have not yet published userspace headers for this
new ioctl so there are no users to break.

Fixes: 7035f9724f84 ("xfs: introduce new v5 bulkstat structure")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: move local to extent inode logging into bmap helper
Brian Foster [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: move local to extent inode logging into bmap helper

Source kernel commit: aeea4b75f045294e1c026acc380466daa43afc65

The callers of xfs_bmap_local_to_extents_empty() log the inode
external to the function, yet this function is where the on-disk
format value is updated. Push the inode logging down into the
function itself to help prevent future mistakes.

Note that internal bmap callers track the inode logging flags
independently and thus may log the inode core twice due to this
change. This is harmless, so leave this code around for consistency
with the other attr fork conversion functions.

Signed-off-by: Brian Foster <bfoster@redhat.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>
5 years agoxfs: remove broken error handling on failed attr sf to leaf change
Brian Foster [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: remove broken error handling on failed attr sf to leaf change

Source kernel commit: 603efebd6768356fb7cea02e4a822587c2dc5d7c

xfs_attr_shortform_to_leaf() attempts to put the shortform fork back
together after a failed attempt to convert from shortform to leaf
format. While this code reallocates and copies back the shortform
attr fork data, it never resets the inode format field back to local
format. Further, now that the inode is properly logged after the
initial switch from local format, any error that triggers the
recovery code will eventually abort the transaction and shutdown the
fs. Therefore, remove the broken and unnecessary error handling
code.

Signed-off-by: Brian Foster <bfoster@redhat.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>
5 years agoxfs: log the inode on directory sf to block format change
Brian Foster [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: log the inode on directory sf to block format change

Source kernel commit: 0b10d8a89f55c416f6a1f6a616669543fa8bdb69

When a directory changes from shortform (sf) to block format, the sf
format is copied to a temporary buffer, the inode format is modified
and the updated format filled with the dentries from the temporary
buffer. If the inode format is modified and attempt to grow the
inode fails (due to I/O error, for example), it is possible to
return an error while leaving the directory in an inconsistent state
and with an otherwise clean transaction. This results in corruption
of the associated directory and leads to xfs_dabuf_map() errors as
subsequent lookups cannot accurately determine the format of the
directory. This problem is reproduced occasionally by generic/475.

The fundamental problem is that xfs_dir2_sf_to_block() changes the
on-disk inode format without logging the inode. The inode is
eventually logged by the bmapi layer in the common case, but error
checking introduces the possibility of failing the high level
request before this happens.

Update both of the dir2 and attr callers of
xfs_bmap_local_to_extents_empty() to log the inode core as
consistent with the bmap local to extent format change codepath.
This ensures that any subsequent errors after the format has changed
cause the transaction to abort.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: remove unused flags arg from xfs_get_aghdr_buf()
Eric Sandeen [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: remove unused flags arg from xfs_get_aghdr_buf()

Source kernel commit: 6374ca03975ab0a2b1a5ced222e0ef2ea6e22f9e

The flags arg is always passed as zero, so remove it.

(xfs_buf_get_uncached takes flags to support XBF_NO_IOACCT for
the sb, but that should never be relevant for xfs_get_aghdr_buf)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: log proper length of superblock
Eric Sandeen [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: log proper length of superblock

Source kernel commit: 6f4ff81a4602dcfba436c6e2307d61ce9e9f652c

xfs_trans_log_buf takes first byte, last byte as args.  In this
case, it should be from 0 to sizeof() - 1.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.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>
5 years agoxfs: revert 1baa2800e62d ("xfs: remove the unused XFS_ALLOC_USERDATA flag")
Darrick J. Wong [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: revert 1baa2800e62d ("xfs: remove the unused XFS_ALLOC_USERDATA flag")

Source kernel commit: ce840429260a98bcfe4aaf487bb07fa346d86c41

Revert this commit, as it caused periodic regressions in xfs/173 w/
1k blocks.

[1] https://lore.kernel.org/lkml/20190919014602.GN15734@shao2-debian/

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>
5 years agoxfs: convert inode to extent format after extent merge due to shift
Brian Foster [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: convert inode to extent format after extent merge due to shift

Source kernel commit: e20e174ca1bd98241b42d5ccfa228d8c6522e4e7

The collapse range operation can merge extents if two newly adjacent
extents are physically contiguous. If the extent count is reduced on
a btree format inode, a change to extent format might be necessary.
This format change currently occurs as a side effect of the file
size update after extents have been shifted for the collapse. This
codepath ultimately calls xfs_bunmapi(), which happens to check for
and execute the format conversion even if there were no blocks
removed from the mapping.

While this ultimately puts the inode into the correct state, the
fact the format conversion occurs in a separate transaction from the
change that called for it is a problem. If an extent shift
transaction commits and the filesystem happens to crash before the
format conversion, the inode fork is left in a corrupted state after
log recovery. The inode fork verifier fails and xfs_repair
ultimately nukes the inode. This problem was originally reproduced
by generic/388.

Similar to how the insert range extent split code handles extent to
btree conversion, update the collapse range extent merge code to
handle btree to extent format conversion in the same transaction
that merges the extents. This ensures that the inode fork format
remains consistent if the filesystem happens to crash in the middle
of a collapse range operation that changes the inode fork format.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: define a flags field for the AG geometry ioctl structure
Darrick J. Wong [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: define a flags field for the AG geometry ioctl structure

Source kernel commit: 76f1793359db07205b9aefba66c7acbac988aaac

Define a flags field for the AG geometry ioctl structure.

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>
5 years agoxfs: add a xfs_valid_startblock helper
Christoph Hellwig [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: add a xfs_valid_startblock helper

Source kernel commit: eb77b23b565e7e1d2cc3a7d9e4cc186fb54e81a8

Add a helper that validates the startblock is valid.  This checks for a
non-zero block on the main device, but skips that check for blocks on
the realtime device.

Signed-off-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: remove the unused XFS_ALLOC_USERDATA flag
Christoph Hellwig [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: remove the unused XFS_ALLOC_USERDATA flag

Source kernel commit: 1baa2800e62d7d58c04cb871a6e4189fc3e1ccf1

Signed-off-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: allocate xattr buffer on demand
Dave Chinner [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: allocate xattr buffer on demand

Source kernel commit: ddbca70cc45c0ac97ff6d9529e45f10b8ae73ad4

When doing file lookups and checking for permissions, we end up in
xfs_get_acl() to see if there are any ACLs on the inode. This
requires and xattr lookup, and to do that we have to supply a buffer
large enough to hold an maximum sized xattr.

On workloads were we are accessing a wide range of cache cold files
under memory pressure (e.g. NFS fileservers) we end up spending a
lot of time allocating the buffer. The buffer is 64k in length, so
is a contiguous multi-page allocation, and if that then fails we
fall back to vmalloc(). Hence the allocation here is /expensive/
when we are looking up hundreds of thousands of files a second.

Initial numbers from a bpf trace show average time in xfs_get_acl()
is ~32us, with ~19us of that in the memory allocation. Note these
are average times, so there are going to be affected by the worst
case allocations more than the common fast case...

To avoid this, we could just do a "null"  lookup to see if the ACL
xattr exists and then only do the allocation if it exists. This,
however, optimises the path for the "no ACL present" case at the
expense of the "acl present" case. i.e. we can halve the time in
xfs_get_acl() for the no acl case (i.e down to ~10-15us), but that
then increases the ACL case by 30% (i.e. up to 40-45us).

To solve this and speed up both cases, drive the xattr buffer
allocation into the attribute code once we know what the actual
xattr length is. For the no-xattr case, we avoid the allocation
completely, speeding up that case. For the common ACL case, we'll
end up with a fast heap allocation (because it'll be smaller than a
page), and only for the rarer "we have a remote xattr" will we have
a multi-page allocation occur. Hence the common ACL case will be
much faster, too.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: consolidate attribute value copying
Dave Chinner [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: consolidate attribute value copying

Source kernel commit: 9df243a1a9e607e7cf5d20ee46edd5ec84b7e400

The same code is used to copy do the attribute copying in three
different places. Consolidate them into a single function in
preparation from on-demand buffer allocation.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: move remote attr retrieval into xfs_attr3_leaf_getvalue
Dave Chinner [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: move remote attr retrieval into xfs_attr3_leaf_getvalue

Source kernel commit: e3cc4554ce1b2cc43262c93ebe6d8cde780d29ee

Because we repeat exactly the same code to get the remote attribute
value after both calls to xfs_attr3_leaf_getvalue() if it's a remote
attr. Just do it in xfs_attr3_leaf_getvalue() so the callers don't
have to care about it.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: remove unnecessary indenting from xfs_attr3_leaf_getvalue
Dave Chinner [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: remove unnecessary indenting from xfs_attr3_leaf_getvalue

Source kernel commit: a0e959d3c9d52a83e01a97ef352a1465550f9329

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: make attr lookup returns consistent
Dave Chinner [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: make attr lookup returns consistent

Source kernel commit: 728bcaa3e0f9820e923dabe5e4c34e87100bb995

Shortform, leaf and remote value attr value retrieval return
different values for success. This makes it more complex to handle
actual errors xfs_attr_get() as some errors mean success and some
mean failure. Make the return values consistent for success and
failure consistent for all attribute formats.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: reverse search directory freespace indexes
Dave Chinner [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: reverse search directory freespace indexes

Source kernel commit: 756c6f0f7efe8759ff6dda35d220e2e753e2b0e3

When a directory is growing rapidly, new blocks tend to get added at
the end of the directory. These end up at the end of the freespace
index, and when the directory gets large finding these new
freespaces gets expensive. The code does a linear search across the
frespace index from the first block in the directory to the last,
hence meaning the newly added space is the last index searched.

Instead, do a reverse order index search, starting from the last
block and index in the freespace index. This makes most lookups for
free space on rapidly growing directories O(1) instead of O(N), but
should not have any impact on random insert workloads because the
average search length is the same regardless of which end of the
array we start at.

The result is a major improvement in large directory grow rates:

create time(sec) / rate (files/s)
File count     vanilla             Prev commit         Patched
10k         0.41 / 24.3k         0.42 / 23.8k       0.41 / 24.3k
20k         0.74 / 27.0k         0.76 / 26.3k       0.75 / 26.7k
100k         3.81 / 26.4k         3.47 / 28.8k       3.27 / 30.6k
200k         8.58 / 23.3k         7.19 / 27.8k       6.71 / 29.8k
1M        85.69 / 11.7k        48.53 / 20.6k      37.67 / 26.5k
2M       280.31 /  7.1k       130.14 / 15.3k      79.55 / 25.2k
10M      3913.26 /  2.5k                          552.89 / 18.1k

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: speed up directory bestfree block scanning
Dave Chinner [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: speed up directory bestfree block scanning

Source kernel commit: 610125ab1e4b1b48dcffe74d9d82b0606bf1b923

When running a "create millions inodes in a directory" test
recently, I noticed we were spending a huge amount of time
converting freespace block headers from disk format to in-memory
format:

31.47%  [kernel]  [k] xfs_dir2_node_addname
17.86%  [kernel]  [k] xfs_dir3_free_hdr_from_disk
3.55%  [kernel]  [k] xfs_dir3_free_bests_p

We shouldn't be hitting the best free block scanning code so hard
when doing sequential directory creates, and it turns out there's
a highly suboptimal loop searching the the best free array in
the freespace block - it decodes the block header before checking
each entry inside a loop, instead of decoding the header once before
running the entry search loop.

This makes a massive difference to create rates. Profile now looks
like this:

13.15%  [kernel]  [k] xfs_dir2_node_addname
3.52%  [kernel]  [k] xfs_dir3_leaf_check_int
3.11%  [kernel]  [k] xfs_log_commit_cil

And the wall time/average file create rate differences are
just as stark:

create time(sec) / rate (files/s)
File count           vanilla                patched
10k              0.41 / 24.3k            0.42 / 23.8k
20k              0.74 / 27.0k            0.76 / 26.3k
100k              3.81 / 26.4k            3.47 / 28.8k
200k              8.58 / 23.3k            7.19 / 27.8k
1M             85.69 / 11.7k           48.53 / 20.6k
2M            280.31 /  7.1k          130.14 / 15.3k

The larger the directory, the bigger the performance improvement.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: factor free block index lookup from xfs_dir2_node_addname_int()
Dave Chinner [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: factor free block index lookup from xfs_dir2_node_addname_int()

Source kernel commit: 0e822255f95db400e56e19773e04755d79b50bda

Simplify the logic in xfs_dir2_node_addname_int() by factoring out
the free block index lookup code that finds a block with enough free
space for the entry to be added. The code that is moved gets a major
cleanup at the same time, but there is no algorithm change here.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: factor data block addition from xfs_dir2_node_addname_int()
Dave Chinner [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: factor data block addition from xfs_dir2_node_addname_int()

Source kernel commit: a07258a695281109422011182db069a0e6f8855e

Factor out the code that adds a data block to a directory from
xfs_dir2_node_addname_int(). This makes the code flow cleaner and
more obvious and provides clear isolation of upcoming optimsations.

Signed-off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: move xfs_dir2_addname()
Dave Chinner [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: move xfs_dir2_addname()

Source kernel commit: aee7754bbeb1000992ed7e6945418a145d181074

This gets rid of the need for a forward  declaration of the static
function xfs_dir2_addname_int() and readies the code for factoring
of xfs_dir2_addname_int().

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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>
5 years agoxfs: remove all *_ITER_CONTINUE values
Darrick J. Wong [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: remove all *_ITER_CONTINUE values

Source kernel commit: 39ee2239a5a212cbba9d96050bd11cfd0f26634d

Iterator functions already use 0 to signal "continue iterating", so get
rid of the #defines and just do it directly.

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>
5 years agoxfs: remove all *_ITER_ABORT values
Darrick J. Wong [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: remove all *_ITER_ABORT values

Source kernel commit: e7ee96dfb8c2687a29d2c5c3b06c967fa54b839c

Use -ECANCELED to signal "stop iterating" instead of these magical
*_ITER_ABORT values, since it's duplicative.

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>
5 years agoxfs: reinitialize rm_flags when unpacking an offset into an rmap irec
Darrick J. Wong [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: reinitialize rm_flags when unpacking an offset into an rmap irec

Source kernel commit: ffb5696f7555e44c04b7c1212fcd83ddedc43498

In xfs_rmap_irec_offset_unpack, we should always clear the contents of
rm_flags before we begin unpacking the encoded (ondisk) offset into the
incore rm_offset and incore rm_flags fields.  Remove the open-coded
field zeroing as this encourages api misuse.

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>
5 years agoxfs: remove unnecessary int returns from deferred bmap functions
Darrick J. Wong [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: remove unnecessary int returns from deferred bmap functions

Source kernel commit: 3e08f42ae7828bac2e7445a950f5de2b08203352

Remove the return value from the functions that schedule deferred bmap
operations since they never fail and do not return status.

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>
5 years agoxfs: remove unnecessary int returns from deferred refcount functions
Darrick J. Wong [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: remove unnecessary int returns from deferred refcount functions

Source kernel commit: 74b4c5d4a9c073162a37d1c20c95cb33152ca474

Remove the return value from the functions that schedule deferred
refcount operations since they never fail and do not return status.

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>
5 years agoxfs: remove unnecessary int returns from deferred rmap functions
Darrick J. Wong [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: remove unnecessary int returns from deferred rmap functions

Source kernel commit: bc46ac64713f11c86cbbe11a86abd2a71274b15f

Remove the return value from the functions that schedule deferred rmap
operations since they never fail and do not return status.

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>
5 years agoxfs: remove unnecessary parameter from xfs_iext_inc_seq
Darrick J. Wong [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: remove unnecessary parameter from xfs_iext_inc_seq

Source kernel commit: 2ca09177ab9dae7cc0a888137bd2421f5829cd87

This function doesn't use the @state parameter, so get rid of it.

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>
5 years agoxfs: fix sign handling problem in xfs_bmbt_diff_two_keys
Darrick J. Wong [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: fix sign handling problem in xfs_bmbt_diff_two_keys

Source kernel commit: b521c89027f4b86af418083cb75db60a0e7a5997

In xfs_bmbt_diff_two_keys, we perform a signed int64_t subtraction with
two unsigned 64-bit quantities.  If the second quantity is actually the
"maximum" key (all ones) as used in _query_all, the subtraction
effectively becomes addition of two positive numbers and the function
returns incorrect results.  Fix this with explicit comparisons of the
unsigned values.  Nobody needs this now, but the online repair patches
will need this to work properly.

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>
5 years agoxfs: don't return _QUERY_ABORT from xfs_rmap_has_other_keys
Darrick J. Wong [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: don't return _QUERY_ABORT from xfs_rmap_has_other_keys

Source kernel commit: 7380e8fec16b3527baa1153255da9cc8d5d4d309

The xfs_rmap_has_other_keys helper aborts the iteration as soon as it
has an answer.  Don't let this abort leak out to callers.

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>
5 years agoxfs: fix maxicount division by zero error
Darrick J. Wong [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: fix maxicount division by zero error

Source kernel commit: c94613feefd7714ad0d03a1914632c15782114ff

In xfs_ialloc_setup_geometry, it's possible for a malicious/corrupt fs
image to set an unreasonably large value for sb_inopblog which will
cause ialloc_blks to be zero.  If sb_imax_pct is also set, this results
in a division by zero error in the second do_div call.  Therefore, force
maxicount to zero if ialloc_blks is zero.

Note that the kernel metadata verifiers will catch the garbage inopblog
value and abort the fs mount long before it tries to set up the inode
geometry; this is needed to avoid a crash in xfs_db while setting up the
xfs_mount structure.

Found by fuzzing sb_inopblog to 122 in xfs/350.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove excess function parameter description in 'xfs_btree_sblock_v5hdr_verify'
zhengbin [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: remove excess function parameter description in 'xfs_btree_sblock_v5hdr_verify'

Source kernel commit: 71912e08e06b7041ba3b40945328b84798dfe6fc

Fixes gcc warning:

fs/xfs/libxfs/xfs_btree.c:4475: warning: Excess function parameter 'max_recs' description in 'xfs_btree_sblock_v5hdr_verify'
fs/xfs/libxfs/xfs_btree.c:4475: warning: Excess function parameter 'pag_max_level' description in 'xfs_btree_sblock_v5hdr_verify'

Fixes: c5ab131ba0df ("libxfs: refactor short btree block verification")
Signed-off-by: zhengbin <zhengbin13@huawei.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>
5 years agoxfs: add kmem allocation trace points
Dave Chinner [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
xfs: add kmem allocation trace points

Source kernel commit: 0ad95687c3adb91e762d0f6ea50a6b1137300e19

When trying to correlate XFS kernel allocations to memory reclaim
behaviour, it is useful to know what allocations XFS is actually
attempting. This information is not directly available from
tracepoints in the generic memory allocation and reclaim
tracepoints, so these new trace points provide a high level
indication of what the XFS memory demand actually is.

There is no per-filesystem context in this code, so we just trace
the type of allocation, the size and the allocation constraints.
The kmem code also doesn't include much of the common XFS headers,
so there are a few definitions that need to be added to the trace
headers and a couple of types that need to be made common to avoid
needing to include the whole world in the kmem code.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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>
5 years agofs: xfs: Remove KM_NOSLEEP and KM_SLEEP.
Tetsuo Handa [Fri, 13 Dec 2019 00:54:33 +0000 (19:54 -0500)]
fs: xfs: Remove KM_NOSLEEP and KM_SLEEP.

Source kernel commit: 707e0ddaf67e8942448ebdd16b523e409ebe40ce

Since no caller is using KM_NOSLEEP and no callee branches on KM_SLEEP,
we can remove KM_NOSLEEP and replace KM_SLEEP with 0.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
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>
5 years agoxfsprogs: Release v5.3.0 v5.3.0
Eric Sandeen [Fri, 15 Nov 2019 17:32:05 +0000 (12:32 -0500)]
xfsprogs: Release v5.3.0

Update all the necessary files for a 5.3.0 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: Release v5.3.0-rc2 v5.3.0-rc2
Eric Sandeen [Mon, 11 Nov 2019 16:31:17 +0000 (11:31 -0500)]
xfsprogs: Release v5.3.0-rc2

Update all the necessary files for a 5.3.0-rc2 prerelease.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_io: fix memory leak in add_enckey
Eric Sandeen [Mon, 11 Nov 2019 16:22:34 +0000 (11:22 -0500)]
xfs_io: fix memory leak in add_enckey

Invalid arguments to add_enckey will leak the "arg" allocation,
so fix that.

Fixes: ba71de04 ("xfs_io/encrypt: add 'add_enckey' command")
Fixes-coverity-id: 1454644
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
[sandeen: incorporate improvements from Eric Biggers]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_scrub: fix complaint about uninitialized ret
Darrick J. Wong [Mon, 11 Nov 2019 15:06:46 +0000 (10:06 -0500)]
xfs_scrub: fix complaint about uninitialized ret

Coverity complained about the uninitialized ret in run_scrub_phases.
It's not sophisticated enough to realize that phase 1 and 7 are both
marked mustrun and are never the repair or datascan dummies and that
therefore ret is always initialized by the end of the for loop, but
OTOH there's no reason not to fix a trivial logic bomb if that ever
changes.

Coverity-id: 1455255
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>
5 years agolibfrog: convert workqueue.c functions to negative error codes
Darrick J. Wong [Wed, 6 Nov 2019 22:32:33 +0000 (17:32 -0500)]
libfrog: convert workqueue.c functions to negative error codes

Convert libfrog functions to return negative error codes like libxfs
does.

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>
5 years agolibfrog: convert scrub.c functions to negative error codes
Darrick J. Wong [Wed, 6 Nov 2019 22:32:33 +0000 (17:32 -0500)]
libfrog: convert scrub.c functions to negative error codes

Convert libfrog functions to return negative error codes like libxfs
does.

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>
5 years agolibfrog: convert ptvar.c functions to negative error codes
Darrick J. Wong [Wed, 6 Nov 2019 22:32:33 +0000 (17:32 -0500)]
libfrog: convert ptvar.c functions to negative error codes

Convert libfrog functions to return negative error codes like libxfs
does.

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>
5 years agolibfrog: convert bulkstat.c functions to negative error codes
Darrick J. Wong [Wed, 6 Nov 2019 22:32:33 +0000 (17:32 -0500)]
libfrog: convert bulkstat.c functions to negative error codes

Convert libfrog functions to return negative error codes like libxfs
does.

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>
5 years agolibfrog: convert fsgeom.c functions to negative error codes
Darrick J. Wong [Wed, 6 Nov 2019 22:32:33 +0000 (17:32 -0500)]
libfrog: convert fsgeom.c functions to negative error codes

Convert libfrog functions to return negative error codes like libxfs
does.

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>
5 years agolibfrog: convert bitmap.c to negative error codes
Darrick J. Wong [Wed, 6 Nov 2019 22:32:33 +0000 (17:32 -0500)]
libfrog: convert bitmap.c to negative error codes

Convert libfrog functions to return negative error codes like libxfs
does.

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>
5 years agolibfrog: print library errors
Darrick J. Wong [Wed, 6 Nov 2019 22:31:06 +0000 (17:31 -0500)]
libfrog: print library errors

Add a libfrog library function that will print tagged error messages.
This will eliminate the need for a lot of open-coded:

errno = ret;
perror("...");

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>
5 years agoxfs_scrub: remove moveon from main program
Darrick J. Wong [Wed, 6 Nov 2019 22:30:57 +0000 (17:30 -0500)]
xfs_scrub: remove moveon from main program

Replace the moveon returns in xfs_scrub.c to e with a direct integer
error return.

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>
5 years agoxfs_scrub: remove XFS_ITERATE_INODES_ABORT from inode iterator
Darrick J. Wong [Wed, 6 Nov 2019 22:30:36 +0000 (17:30 -0500)]
xfs_scrub: remove XFS_ITERATE_INODES_ABORT from inode iterator

Remove the _ABORT code since nobody uses it and we're slowly moving to
ECANCELED anyway.

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>
5 years agoxfs_scrub: remove moveon from phase 1 functions
Darrick J. Wong [Wed, 6 Nov 2019 22:30:29 +0000 (17:30 -0500)]
xfs_scrub: remove moveon from phase 1 functions

Replace the moveon returns in the phase 1 code with a direct integer
error return.

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>
5 years agoxfs_scrub: remove moveon from phase 2 functions
Darrick J. Wong [Wed, 6 Nov 2019 22:30:22 +0000 (17:30 -0500)]
xfs_scrub: remove moveon from phase 2 functions

Replace the moveon returns in the phase 2 code with a direct integer
error return.

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>
5 years agoxfs_scrub: remove moveon from phase 3 functions
Darrick J. Wong [Wed, 6 Nov 2019 22:30:16 +0000 (17:30 -0500)]
xfs_scrub: remove moveon from phase 3 functions

Replace the moveon returns in the phase 3 code with a direct integer
error return.

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>
5 years agoxfs_scrub: remove moveon from phase 4 functions
Darrick J. Wong [Wed, 6 Nov 2019 22:30:09 +0000 (17:30 -0500)]
xfs_scrub: remove moveon from phase 4 functions

Replace the moveon returns in the phase 4 code with a direct integer
error return.

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>
5 years agoxfs_scrub: remove moveon from phase 5 functions
Darrick J. Wong [Wed, 6 Nov 2019 22:30:03 +0000 (17:30 -0500)]
xfs_scrub: remove moveon from phase 5 functions

Replace the moveon returns in the phase 5 code with a direct integer
error return.

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>
5 years agoxfs_scrub: remove moveon from phase 6 functions
Darrick J. Wong [Wed, 6 Nov 2019 22:29:55 +0000 (17:29 -0500)]
xfs_scrub: remove moveon from phase 6 functions

Replace the moveon returns in the phase 6 code with a direct integer
error return.

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>
5 years agoxfs_scrub: remove moveon from phase 7 functions
Darrick J. Wong [Wed, 6 Nov 2019 22:29:47 +0000 (17:29 -0500)]
xfs_scrub: remove moveon from phase 7 functions

Replace the moveon returns in the phase 7 code with a direct integer
error return.

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>
5 years agoxfs_scrub: remove moveon from repair action list helpers
Darrick J. Wong [Wed, 6 Nov 2019 22:29:29 +0000 (17:29 -0500)]
xfs_scrub: remove moveon from repair action list helpers

Replace the moveon returns in the repair action list processing
functions with a direct integer error return.

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>
5 years agoxfs_scrub: remove moveon from scrub ioctl wrappers
Darrick J. Wong [Wed, 6 Nov 2019 22:29:22 +0000 (17:29 -0500)]
xfs_scrub: remove moveon from scrub ioctl wrappers

Replace the moveon returns in the scrub ioctl wrapper functions
with a direct integer error return.

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>
5 years agoxfs_scrub: remove moveon from progress report helpers
Darrick J. Wong [Wed, 6 Nov 2019 22:29:15 +0000 (17:29 -0500)]
xfs_scrub: remove moveon from progress report helpers

Replace the moveon returns in the scrub process reporting helpers
with a direct integer error return.

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>