]> www.infradead.org Git - users/hch/xfsprogs.git/log
users/hch/xfsprogs.git
6 years agoxfsprogs: Release v5.2.0-rc0 libxfs-5.2-sync
Eric Sandeen [Tue, 23 Jul 2019 18:49:28 +0000 (14:49 -0400)]
xfsprogs: Release v5.2.0-rc0

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

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: don't reserve per-AG space for an internal log
Darrick J. Wong [Fri, 19 Jul 2019 20:05:30 +0000 (16:05 -0400)]
xfs: don't reserve per-AG space for an internal log

Source kernel commit: 5cd213b0fec640a46adc5e6e4dfc7763aa54b3b2

It turns out that the log can consume nearly all the space in an AG, and
when this happens this it's possible that there will be less free space
in the AG than the reservation would try to hide.  On a debug kernel
this can trigger an ASSERT in xfs/250:

XFS: Assertion failed: xfs_perag_resv(pag, XFS_AG_RESV_METADATA)->ar_reserved + xfs_perag_resv(pag, XFS_AG_RESV_RMAPBT)->ar_reserved <= pag->pagf_freeblks + pag->pagf_flcount, file: fs/xfs/libxfs/xfs_ag_resv.c, line: 319

The log is permanently allocated, so we know we're never going to have
to expand the btrees to hold any records associated with the log space.
We therefore can treat the space as if it doesn't exist.

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>
6 years agoxfs: change some error-less functions to void types
Eric Sandeen [Fri, 19 Jul 2019 20:05:30 +0000 (16:05 -0400)]
xfs: change some error-less functions to void types

Source kernel commit: 910832697cf85536c7fe26edb8bc6f830c4b9bb6

There are several functions which have no opportunity to return
an error, and don't contain any ASSERTs which could be argued
to be better constructed as error cases.  So, make them voids
to simplify the callers.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
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>
6 years agoxfs: add online scrub for superblock counters
Darrick J. Wong [Fri, 19 Jul 2019 20:05:30 +0000 (16:05 -0400)]
xfs: add online scrub for superblock counters

Source kernel commit: 75efa57d0bf5fcf650a183f0ce0dc011ba8c4bc8

Teach online scrub how to check the filesystem summary counters.  We use
the incore delalloc block counter along with the incore AG headers to
compute expected values for fdblocks, icount, and ifree, and then check
that the percpu counter is within a certain threshold of the expected
value.  This is done to avoid having to freeze or otherwise lock the
filesystem, which means that we're only checking that the counters are
fairly close, not that they're exactly correct.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: always rejoin held resources during defer roll
Darrick J. Wong [Fri, 19 Jul 2019 20:05:30 +0000 (16:05 -0400)]
xfs: always rejoin held resources during defer roll

Source kernel commit: 710d707d2fa9cf4c2aa9def129e71e99513466ea

During testing of xfs/141 on a V4 filesystem, I observed some
inconsistent behavior with regards to resources that are held (i.e.
remain locked) across a defer roll.  The transaction roll always gives
the defer roll function a new transaction, even if committing the old
transaction fails.  However, the defer roll function only rejoins the
held resources if the transaction commit succeedied.  This means that
callers of defer roll have to figure out whether the held resources are
attached to the transaction being passed back.

Worse yet, if the defer roll was part of a defer finish call, we have a
third possibility: the defer finish could pass back a dirty transaction
with dirty held resources and an error code.

The only sane way to handle all of these scenarios is to require that
the code that held the resource either cancel the transaction before
unlocking and releasing the resources, or use functions that detach
resources from a transaction properly (e.g.  xfs_trans_brelse) if they
need to drop the reference before committing or cancelling the
transaction.

In order to make this so, change the defer roll code to join held
resources to the new transaction unconditionally and fix all the bhold
callers to release the held buffers correctly.

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>
6 years agoxfs: track delayed allocation reservations across the filesystem
Darrick J. Wong [Fri, 19 Jul 2019 20:05:30 +0000 (16:05 -0400)]
xfs: track delayed allocation reservations across the filesystem

Source kernel commit: 9fe82b8c422b5d9e9011bc08e27b9044936d945f

Add a percpu counter to track the number of blocks directly reserved for
delayed allocations on the data device.  This counter (in contrast to
i_delayed_blks) does not track allocated CoW staging extents or anything
going on with the realtime device.  It will be used in the upcoming
summary counter scrub function to check the free block counts without
having to freeze the filesystem or walk all the inodes to find the
delayed allocations.

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>
6 years agoxfs: assert that we don't enter agfl freeing with a non-permanent transaction
Brian Foster [Fri, 19 Jul 2019 20:05:30 +0000 (16:05 -0400)]
xfs: assert that we don't enter agfl freeing with a non-permanent transaction

Source kernel commit: 362f5e745ae2ee2be9cf181b3a22917d619b81a1

Block allocation requires a permanent transaction for deferred AGFL
frees.  Add an assert in the block allocation path to make explicit and
obvious to future callers the requirement of a transaction with a
permanent reservation.

Reported-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[darrick: split this out from the previous patch per hch request]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: make tr_growdata a permanent transaction
Brian Foster [Fri, 19 Jul 2019 20:05:30 +0000 (16:05 -0400)]
xfs: make tr_growdata a permanent transaction

Source kernel commit: 945c941fcd82bac3a8ea2b89c635651f323bd609

The growdata transaction is used by growfs operations to increase
the data size of the filesystem. Part of this sequence involves
extending the size of the last preexisting AG in the fs, if
necessary. This is implemented by freeing the newly available
physical range to the AG.

tr_growdata is not a permanent transaction, however, and block
allocation transactions must be permanent to handle deferred frees
of AGFL blocks. If the grow operation extends an existing AG that
requires AGFL fixing, assert failures occur due to a populated dfops
list on a non-permanent transaction and the AGFL free does not
occur. This is reproduced (rarely) by xfs/104.

Change tr_growdata to a permanent transaction with a default log
count. This increases initial transaction reservation size, but
growfs is an infrequent and non-performance critical operation and
so should have minimal impact.

Reported-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[darrick: add a comment to the assert]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: report inode health via bulkstat
Darrick J. Wong [Fri, 19 Jul 2019 20:05:29 +0000 (16:05 -0400)]
xfs: report inode health via bulkstat

Source kernel commit: 89d139d5ad465e35a9c602421eb1a1ff08ea530d

Use space in the bulkstat ioctl structure to report any problems
observed with the inode.

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>
6 years agoxfs: report AG health via AG geometry ioctl
Darrick J. Wong [Fri, 19 Jul 2019 20:05:29 +0000 (16:05 -0400)]
xfs: report AG health via AG geometry ioctl

Source kernel commit: 1302c6a24fd952555aa6dc811cec5b2a22ac386a

Use the AG geometry info ioctl to report health status too.

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>
6 years agoxfs: report fs and rt health via geometry structure
Darrick J. Wong [Fri, 19 Jul 2019 20:05:29 +0000 (16:05 -0400)]
xfs: report fs and rt health via geometry structure

Source kernel commit: c23232d409355091502a362e99ed06f800765961

Use our newly expanded geometry structure to report the overall fs and
realtime health status.

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>
6 years agoxfs: add a new ioctl to describe allocation group geometry
Darrick J. Wong [Fri, 19 Jul 2019 20:05:29 +0000 (16:05 -0400)]
xfs: add a new ioctl to describe allocation group geometry

Source kernel commit: 7cd5006bdb6f6d9d9d7e68aa1d96b6e4a8b68bc5

Add a new ioctl to describe an allocation group's geometry.

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>
6 years agoxfs: bump XFS_IOC_FSGEOMETRY to v5 structures
Dave Chinner [Fri, 19 Jul 2019 20:05:16 +0000 (16:05 -0400)]
xfs: bump XFS_IOC_FSGEOMETRY to v5 structures

Source kernel commit: 1b6d968de22bffd85a60538d2628185b17228291

Unfortunately, the V4 XFS_IOC_FSGEOMETRY structure is out of space so we
can't just add a new field to it. Hence we need to bump the definition
to V5 and and treat the V4 ioctl and structure similar to v1 to v3.

While doing this, clean up all the definitions associated with the
XFS_IOC_FSGEOMETRY ioctl.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[darrick: forward port to 5.1, expand structure size to 256 bytes]
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>
6 years agoxfs: clear BAD_SUMMARY if unmounting an unhealthy filesystem
Darrick J. Wong [Fri, 19 Jul 2019 18:24:47 +0000 (14:24 -0400)]
xfs: clear BAD_SUMMARY if unmounting an unhealthy filesystem

Source kernel commit: 519841c207de9926418d2f39e162097088478781

If we know the filesystem metadata isn't healthy during unmount, we want
to encourage the administrator to run xfs_repair right away.  We can't
do this if BAD_SUMMARY will cause an unclean log unmount to force
summary recalculation, so turn it off if the fs is bad.

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>
6 years agoxfs: replace the BAD_SUMMARY mount flag with the equivalent health code
Darrick J. Wong [Fri, 19 Jul 2019 18:23:47 +0000 (14:23 -0400)]
xfs: replace the BAD_SUMMARY mount flag with the equivalent health code

Source kernel commit: 39353ff6e96fb623230341ca89b0f4ef3a04998f

Replace the BAD_SUMMARY mount flag with calls to the equivalent health
tracking code.

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>
6 years agoxfs: track metadata health status
Darrick J. Wong [Fri, 19 Jul 2019 18:22:47 +0000 (14:22 -0400)]
xfs: track metadata health status

Source kernel commit: 6772c1f11206f270af56d62bc26737864a63608a

Add the necessary in-core metadata fields to keep track of which parts
of the filesystem have been observed and which parts were observed to be
unhealthy, and print a warning at unmount time if we have unfixed
problems.

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>
6 years agoxfs: don't account extra agfl blocks as available
Brian Foster [Fri, 19 Jul 2019 18:21:47 +0000 (14:21 -0400)]
xfs: don't account extra agfl blocks as available

Source kernel commit: 1ca89fbc48e1ea5044997328e403f8a13513e8c3

The block allocation AG selection code has parameters that allow a
caller to perform multiple allocations from a single AG and
transaction (under certain conditions). The parameters specify the
total block allocation count required by the transaction and the AG
selection code selects and locks an AG that will be able to satisfy
the overall requirement. If the available block accounting
calculation turns out to be inaccurate and a subsequent allocation
call fails with -ENOSPC, the resulting transaction cancel leads to
filesystem shutdown because the transaction is dirty.

This exact problem can be reproduced with a highly parallel space
consumer and fsstress workload running long enough to a large
filesystem against -ENOSPC conditions. A bmbt block allocation
request made for inode extent to bmap format conversion after an
extent allocation is expected to be satisfied by the same AG and the
same transaction as the extent allocation. The bmbt block allocation
fails, however, because the block availability of the AG has changed
since the AG was selected (outside of the blocks used for the extent
itself).

The inconsistent block availability calculation is caused by the
deferred block freeing behavior of the AGFL. This immediately
removes extra blocks from the AGFL to free up AGFL slots, but rather
than immediately freeing such blocks as was done in the past, the
block free is deferred such that said blocks are not available for
allocation until the current transaction commits. The AG selection
logic currently considers all AGFL blocks as available and executes
shortly before any extra AGFL blocks are freed. This means the block
availability of the current AG can change before the first
allocation even occurs, but in practice a failure is more likely to
manifest via a subsequent allocation because extent allocation
usually has a contiguity requirement larger than a single block that
can't be satisfied from the AGFL.

In general, XFS prefers operational robustness to absolute
allocation efficiency. In other words, we prefer to return -ENOSPC
slightly earlier at the expense of not being able to allocate every
last block in an AG to avoid this kind of problem. As such, update
the AG block availability calculation to consider extra AGFL blocks
as unavailable since they are immediately removed following the
calculation and will not become available until the current
transaction commits.

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>
6 years agoxfsprogs: Release v5.1.0 v5.1.0
Eric Sandeen [Fri, 19 Jul 2019 18:19:47 +0000 (13:19 -0500)]
xfsprogs: Release v5.1.0

Update all the necessary files for a 5.1.0 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfsprogs: Release v5.1.0-rc1 v5.1.0-rc1
Eric Sandeen [Fri, 12 Jul 2019 01:16:43 +0000 (21:16 -0400)]
xfsprogs: Release v5.1.0-rc1

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

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs.xfs.8: Fix an inconsistency between the code and the man page.
Alvin Zheng [Wed, 10 Jul 2019 21:51:13 +0000 (17:51 -0400)]
mkfs.xfs.8: Fix an inconsistency between the code and the man page.

The man page currently states that block and sector size units cannot
be used for other option values unless they are explicitly specified,
when in fact the default sizes will be used in that case.

Change the man page to clarify this.

Signed-off-by: Alvin Zheng <Alvin@linux.alibaba.com>
[sandeen: sector/block values do not need to be specified first]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoman: create a separate xfs shutdown ioctl manpage
Darrick J. Wong [Wed, 10 Jul 2019 21:16:36 +0000 (17:16 -0400)]
man: create a separate xfs shutdown ioctl manpage

Create a separate manual page for the xfs shutdown ioctl so we can
document how it works.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: minor edits]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoman: create a separate GETBMAPX/GETBMAPA/GETBMAP ioctl manpage
Darrick J. Wong [Wed, 10 Jul 2019 21:16:36 +0000 (17:16 -0400)]
man: create a separate GETBMAPX/GETBMAPA/GETBMAP ioctl manpage

Create a separate manual page for the xfs BMAP ioctls so we can document
how they work.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: minor edits]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoman: create a separate RESBLKS ioctl manpage
Darrick J. Wong [Wed, 10 Jul 2019 21:16:36 +0000 (17:16 -0400)]
man: create a separate RESBLKS ioctl manpage

Create a separate manual page for the xfs RESBLKS ioctls so we can
document how it works.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: minor edits]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoman: create a separate FSCOUNTS ioctl manpage
Darrick J. Wong [Wed, 10 Jul 2019 21:16:36 +0000 (17:16 -0400)]
man: create a separate FSCOUNTS ioctl manpage

Create a separate manual page for the xfs FSCOUNTS ioctl so we can
document how it works.

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>
6 years agoman: create a separate INUMBERS ioctl manpage
Darrick J. Wong [Wed, 10 Jul 2019 21:16:36 +0000 (17:16 -0400)]
man: create a separate INUMBERS ioctl manpage

Create a separate manual page for the xfs INUMBERS ioctl so we can
document how it works.

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>
6 years agoman: link to the SCRUB_METADATA ioctl manpage from xfsctl.3
Darrick J. Wong [Wed, 10 Jul 2019 21:16:36 +0000 (17:16 -0400)]
man: link to the SCRUB_METADATA ioctl manpage from xfsctl.3

Link to the scrub ioctl documentation from xfsctl.

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>
6 years agoman: create a separate FSBULKSTAT ioctl manpage
Darrick J. Wong [Wed, 10 Jul 2019 21:16:36 +0000 (17:16 -0400)]
man: create a separate FSBULKSTAT ioctl manpage

Break out the xfs bulkstat ioctl into a separate manpage so that we can
document how it works.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: minor edits]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoman: create a separate GEOMETRY ioctl manpage
Darrick J. Wong [Wed, 10 Jul 2019 21:16:36 +0000 (17:16 -0400)]
man: create a separate GEOMETRY ioctl manpage

Break out the xfs geometry ioctl into a separate manpage so that we can
document how it works.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: minor edits]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoman: create a separate GETXATTR/SETXATTR ioctl manpage
Darrick J. Wong [Wed, 10 Jul 2019 21:16:32 +0000 (17:16 -0400)]
man: create a separate GETXATTR/SETXATTR ioctl manpage

Break out the xfs file attribute get and set ioctls into a separate
manpage to reduce clutter in xfsctl.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: minor edits]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfsprogs: Fix uninitialized cfg->lsunit
Allison Collins [Wed, 10 Jul 2019 15:38:04 +0000 (11:38 -0400)]
xfsprogs: Fix uninitialized cfg->lsunit

While investigating another mkfs bug, noticed that cfg->lsunit is sometimes
left uninitialized when it should not.  This is because calc_stripe_factors
in some cases needs cfg->loginternal to be set first.  This is done in
validate_logdev. So move calc_stripe_factors below validate_logdev while
parsing configs.

Signed-off-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_io: reorganize source file handling in copy_range
Eric Sandeen [Wed, 10 Jul 2019 15:37:25 +0000 (11:37 -0400)]
xfs_io: reorganize source file handling in copy_range

Rename and rearrange some of the vars related to using an open
file number as the source file, so that we don't temporarily
store a non-fd number in a var called "fd," and do the fd
assignment in a consistent code location.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_io: allow passing an open file to copy_range
Amir Goldstein [Wed, 10 Jul 2019 15:36:25 +0000 (11:36 -0400)]
xfs_io: allow passing an open file to copy_range

Commit 1a05efba ("io: open pipes in non-blocking mode")
addressed a specific copy_range issue with pipes by always opening
pipes in non-blocking mode.

This change takes a different approach and allows passing any
open file as the source file to copy_range.  Besides providing
more flexibility to the copy_range command, this allows xfstests
to check if xfs_io supports passing an open file to copy_range.

The intended usage is:
$ mkfifo fifo
$ xfs_io -f -n -r -c "open -f dst" -C "copy_range -f 0" fifo

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: remove useless log options in usage
Yang Xu [Wed, 10 Jul 2019 15:35:25 +0000 (11:35 -0400)]
mkfs: remove useless log options in usage

Since commit 2cf637cf(mkfs: remove logarithm based CLI options),
xfsprogs has discarded log options in node_options, remove it in usage.

Fixes: 2cf637cf ("mkfs: remove logarithm based CLI options")
Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: don't use xfs_verify_fsbno() before m_sb is fully set up
Eric Sandeen [Wed, 10 Jul 2019 15:35:07 +0000 (11:35 -0400)]
mkfs: don't use xfs_verify_fsbno() before m_sb is fully set up

Commit 8da5298 mkfs: validate start and end of aligned logs stopped
open-coding log end block checks, and used xfs_verify_fsbno() instead.
It also used xfs_verify_fsbno() to validate the log start.  This
seemed to make sense, but then xfs/306 started failing on 4k sector
filesystems, which leads to a log striep unite being set on a single
AG filesystem.

As it turns out, if xfs_verify_fsbno() is testing a block in the
last AG, it needs to have mp->m_sb.sb_dblocks set, which isn't done
until later.  With sb_dblocks unset we can't know how many blocks
are in the last AG, and hence can't validate it.

To fix all this, go back to open-coding the checks; note that this
/does/ rely on m_sb.sb_agblklog being set, but that /is/ already
done in the early call to start_superblock_setup().

Fixes: 8da5298 ("mkfs: validate start and end of aligned logs")
Reported-by: Dave Chinner <david@fromorbit.com>
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>
6 years agoxfs_quota: fix built-in help for project setup
Eric Sandeen [Tue, 25 Jun 2019 21:04:42 +0000 (17:04 -0400)]
xfs_quota: fix built-in help for project setup

-s is used to set up a new project, not -c.

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>
6 years agoxfs_io: repair_f should use its own name
Darrick J. Wong [Tue, 25 Jun 2019 21:04:42 +0000 (17:04 -0400)]
xfs_io: repair_f should use its own name

If the repair command fails, it should tag the error message with its
own name ("repair").

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>
6 years agomkfs: validate start and end of aligned logs
Darrick J. Wong [Tue, 25 Jun 2019 21:04:42 +0000 (17:04 -0400)]
mkfs: validate start and end of aligned logs

Validate that the start and end of the log stay within a single AG if
we adjust either end to align to stripe units.

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>
6 years agolibfrog: cvt_u64 should use strtoull, not strtoll
Darrick J. Wong [Tue, 25 Jun 2019 21:04:42 +0000 (17:04 -0400)]
libfrog: cvt_u64 should use strtoull, not strtoll

cvt_u64 converts a string to an unsigned 64-bit number, so it should use
strtoull, not strtoll because we don't want negative numbers here.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibfrog: don't set negative errno in conversion functions
Darrick J. Wong [Tue, 25 Jun 2019 21:04:42 +0000 (17:04 -0400)]
libfrog: don't set negative errno in conversion functions

Don't set errno to a negative value when we're converting integers.
That's a kernel thing; this is userspace.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_info: limit findmnt to find mounted xfs filesystems
Amir Goldstein [Tue, 25 Jun 2019 21:04:42 +0000 (17:04 -0400)]
xfs_info: limit findmnt to find mounted xfs filesystems

When running xfstests with -overlay, the xfs mount point
(a.k.a $OVL_BASE_SCRATCH_MNT) is used as the $SCRATCH_DEV argument
to the overlay mount, like this:

/dev/vdf /vdf xfs rw,relatime,attr2,inode64,noquota 0 0
/vdf /vdf/ovl-mnt overlay rw,lowerdir=/vdf/lower,upperdir=/vdf/upper...

Ever since commit bbb43745, when xfs_info started using findmnt,
when calling the helper `_supports_filetype /vdf` it returns false,
and reports: "/vdf/ovl-mnt: Not on a mounted XFS filesystem".

Fix this ambiguity by preferring to query a mounted XFS filesystem,
if one can be found.

Fixes: bbb43745 ("xfs_info: use findmnt to handle mounted block devices")
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: enable reflink by default
Darrick J. Wong [Thu, 6 Jun 2019 13:58:55 +0000 (08:58 -0500)]
mkfs: enable reflink by default

Data block sharing (a.k.a. reflink) has been stable for a while, so turn
it on by default.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
[sandeen: update comments & man page]
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>
6 years agoxfs_scrub: fix background-mode sleep throttling
Darrick J. Wong [Thu, 6 Jun 2019 13:58:55 +0000 (08:58 -0500)]
xfs_scrub: fix background-mode sleep throttling

The comment preceding background_sleep() is wrong -- the function sleeps
100us, not 100ms, for every '-b' passed in after the first one.  This is
really not obvious from the magic numbers, so fix the comment and use
symbolic constants for easier reading.

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>
6 years agoxfs_repair: refactor namecheck functions
Darrick J. Wong [Thu, 6 Jun 2019 13:58:55 +0000 (08:58 -0500)]
xfs_repair: refactor namecheck functions

Now that we have name check functions in libxfs, use them instead of our
custom versions.

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>
6 years agolibfrog: fix bitmap return values
Darrick J. Wong [Thu, 6 Jun 2019 13:58:55 +0000 (08:58 -0500)]
libfrog: fix bitmap return values

Fix the return types of non-predicate bitmap functions to return the
usual negative error codes instead of the "moveon" boolean.

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>
6 years agomisc: remove all use of xfs_fsop_geom_t
Darrick J. Wong [Thu, 6 Jun 2019 13:58:55 +0000 (08:58 -0500)]
misc: remove all use of xfs_fsop_geom_t

Remove all the uses of the old xfs_fsop_geom_t typedef.

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>
6 years agolibxfs: set m_finobt_nores when initializing library
Darrick J. Wong [Thu, 6 Jun 2019 13:58:50 +0000 (08:58 -0500)]
libxfs: set m_finobt_nores when initializing library

We don't generally set up per-ag reservations in userspace, so set this
flag to true to force transactions to set up block reservations.  This
isn't necessary for userspace (since we never touch the finobt) but we
shouldn't leave a logic bomb.

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>
6 years agolibxfs: fix attr include mess
Darrick J. Wong [Thu, 6 Jun 2019 13:58:30 +0000 (08:58 -0500)]
libxfs: fix attr include mess

Remove all the userspace xfs_attr shim cruft so that we have one
definition of ATTR_* macros so that we can actually use xfs_attr.c
routines and include xfs_attr.h without problems.

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>
6 years agolibxfs: share kernel's xfs_trans_inode.c
Eric Sandeen [Tue, 21 May 2019 16:04:02 +0000 (11:04 -0500)]
libxfs: share kernel's xfs_trans_inode.c

Now that the majority of cosmetic changes and compat shims
are in place, we can directly share kernelspace's
xfs_trans_inode.c with just a couple more small tweaks.
In addition to the file move,

* ili_fsync_fields is added to xfs_inode_log_item (but not used)
* test_and_set_bit() helper is created

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibxfs: create current_time helper and sync xfs_trans_ichgtime
Eric Sandeen [Tue, 21 May 2019 16:03:43 +0000 (11:03 -0500)]
libxfs: create current_time helper and sync xfs_trans_ichgtime

Make xfs_trans_ichgtime() almost match kernelspace by creating a
new current_time() helper to match the kernel utility.

This reduces still more cosmetic change.  We may want to sync the
creation flag over to the kernel even though it's not used today.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: factor log item initialisation
Dave Chinner [Tue, 21 May 2019 16:03:36 +0000 (11:03 -0500)]
xfs: factor log item initialisation

Each log item type does manual initialisation of the log item.
Delayed logging introduces new fields that need initialisation, so
factor all the open coded initialisation into a common function
first.

Source kernel commit: 43f5efc5b59db1b66e39fe9fdfc4ba6a27152afa

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
[sandeen: merge to userspace]
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibxfs: fix argument to xfs_trans_add_item
Eric Sandeen [Tue, 21 May 2019 16:03:21 +0000 (11:03 -0500)]
libxfs: fix argument to xfs_trans_add_item

The hack of casting an inode_log_item or buf_log_item to a
xfs_log_item_t is pretty gross; yes it's the first member in the
structure, but yuk.  Pass in the correct structure member.

This was fixed in the kernel with commit e98c414f9
("xfs: simplify log item descriptor tracking")

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibxfs: factor common xfs_trans_bjoin code
Christoph Hellwig [Tue, 21 May 2019 16:03:14 +0000 (11:03 -0500)]
libxfs: factor common xfs_trans_bjoin code

Most of xfs_trans_bjoin is duplicated in xfs_trans_get_buf_map,
xfs_trans_getsb and xfs_trans_read_buf_map.  Add a new
_xfs_trans_bjoin which can be called by all three functions.

Source kernel commit: d7e84f413726876c0ec66bbf90770f69841f7663

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Alex Elder <aelder@sgi.com>
[sandeen: merge to userspace]
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibxfs: rename bli_format to avoid confusion with bli_formats
Eric Sandeen [Tue, 21 May 2019 16:03:03 +0000 (11:03 -0500)]
libxfs: rename bli_format to avoid confusion with bli_formats

Rename the bli_format structure to __bli_format to avoid
accidently confusing them with the bli_formats pointer.

(nb: userspace currently has no bli_formats pointer)

Source kernel commit: b94381737e9c4d014a4003e8ece9ba88670a2dd4

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibxfs: Remove XACT_DEBUG #ifdefs
Eric Sandeen [Tue, 21 May 2019 16:02:52 +0000 (11:02 -0500)]
libxfs: Remove XACT_DEBUG #ifdefs

Remove XACT_DEBUG #ifdefs to reduce more cosmetic differences
between userspace & kernelspace libxfs.  Add in some corresponding
(stubbed-out) tracepoint calls.

If these are felt to be particularly useful, the tracepoint calls
could be fleshed out to provide similar information.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibxfs: rename bp_transp to b_transp in ASSERTs
Eric Sandeen [Thu, 16 May 2019 17:05:39 +0000 (13:05 -0400)]
libxfs: rename bp_transp to b_transp in ASSERTs

xfs_buf no longer has a bp_transp member; it's b_transp now.
These ASSERTs get #defined away, but it's still best to not have
invalid structure members cluttering up the code.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibxfs: remove unused cruft
Eric Sandeen [Thu, 16 May 2019 17:05:38 +0000 (13:05 -0400)]
libxfs: remove unused cruft

Remove many unused #defines and functions.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibxfs: remove xfs_inode_log_item ili_flags
Eric Sandeen [Thu, 16 May 2019 17:05:37 +0000 (13:05 -0400)]
libxfs: remove xfs_inode_log_item ili_flags

ili_flags is only set to zero and asserted to be zero; it serves
no purpose, so remove it.

(it was renamed to ili_lock_flags in the kernel in commit 898621d5,
for some reason userspace had both, with ili_flags ~unused)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibxfs: remove i_transp
Eric Sandeen [Thu, 16 May 2019 17:05:36 +0000 (13:05 -0400)]
libxfs: remove i_transp

i_transp was removed from kernel code back in 2011, but it was left
in userspace.  It's only used in a few asserts in transaction code
(as it was in the kernel) so there doesnt' seem to be a compelling
reason to carry it around anymore.

Source kernel commit: f3ca87389dbff0a3dc1a7cb2fa7c62e25421c66c

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfsprogs: Release v5.1.0-rc0 v5.1.0-rc0
Eric Sandeen [Wed, 8 May 2019 02:47:09 +0000 (21:47 -0500)]
xfsprogs: Release v5.1.0-rc0

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

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: always init bma in xfs_bmapi_write libxfs-5.1-sync
Darrick J. Wong [Mon, 6 May 2019 22:00:29 +0000 (18:00 -0400)]
xfs: always init bma in xfs_bmapi_write

Source kernel commit: 4b0bce30f39b7733420bb8b28e340aa91c219bc1

Always init the tp/ip fields of bma in xfs_bmapi_write so that the
bmapi_finish at the bottom never trips over null transaction or inode
pointers.

Coverity-id: 1443964
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>
6 years agoxfs: don't trip over uninitialized buffer on extent read of corrupted inode
Brian Foster [Mon, 6 May 2019 22:00:29 +0000 (18:00 -0400)]
xfs: don't trip over uninitialized buffer on extent read of corrupted inode

Source kernel commit: 6958d11f77d45db80f7e22a21a74d4d5f44dc667

We've had rather rare reports of bmap btree block corruption where
the bmap root block has a level count of zero. The root cause of the
corruption is so far unknown. We do have verifier checks to detect
this form of on-disk corruption, but this doesn't cover a memory
corruption variant of the problem. The latter is a reasonable
possibility because the root block is part of the inode fork and can
reside in-core for some time before inode extents are read.

If this occurs, it leads to a system crash such as the following:

BUG: unable to handle kernel paging request at ffffffff00000221
PF error: [normal kernel read fault]
...
RIP: 0010:xfs_trans_brelse+0xf/0x200 [xfs]
...
Call Trace:
xfs_iread_extents+0x379/0x540 [xfs]
xfs_file_iomap_begin_delay+0x11a/0xb40 [xfs]
? xfs_attr_get+0xd1/0x120 [xfs]
? iomap_write_begin.constprop.40+0x2d0/0x2d0
xfs_file_iomap_begin+0x4c4/0x6d0 [xfs]
? __vfs_getxattr+0x53/0x70
? iomap_write_begin.constprop.40+0x2d0/0x2d0
iomap_apply+0x63/0x130
? iomap_write_begin.constprop.40+0x2d0/0x2d0
iomap_file_buffered_write+0x62/0x90
? iomap_write_begin.constprop.40+0x2d0/0x2d0
xfs_file_buffered_aio_write+0xe4/0x3b0 [xfs]
__vfs_write+0x150/0x1b0
vfs_write+0xba/0x1c0
ksys_pwrite64+0x64/0xa0
do_syscall_64+0x5a/0x1d0
entry_SYSCALL_64_after_hwframe+0x49/0xbe

The crash occurs because xfs_iread_extents() attempts to release an
uninitialized buffer pointer as the level == 0 value prevented the
buffer from ever being allocated or read. Change the level > 0
assert to an explicit error check in xfs_iread_extents() to avoid
crashing the kernel in the event of localized, in-core inode
corruption.

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>
6 years agoxfs: clean up xfs_dir2_leaf_addname
Darrick J. Wong [Mon, 6 May 2019 22:00:29 +0000 (18:00 -0400)]
xfs: clean up xfs_dir2_leaf_addname

Source kernel commit: 6ef50fe9afae63d11220f3f66b5f4c75d09c8bf0

Remove typedefs and consolidate local variable initialization.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: zero initialize highstale and lowstale in xfs_dir2_leaf_addname
Darrick J. Wong [Mon, 6 May 2019 22:00:29 +0000 (18:00 -0400)]
xfs: zero initialize highstale and lowstale in xfs_dir2_leaf_addname

Source kernel commit: f51fac68926235ef5bc482eb759d2c60b86fa358

Smatch complains about the following:

fs/xfs/libxfs/xfs_dir2_leaf.c:848 xfs_dir2_leaf_addname() error:
uninitialized symbol 'lowstale'.

fs/xfs/libxfs/xfs_dir2_leaf.c:849 xfs_dir2_leaf_addname() error:
uninitialized symbol 'highstale'.

I don't think there's any incorrect behavior associated with the
uninitialized variable, but as the author of the previous zero-init
patch points out, it's best not to be passing around pointers to
uninitialized stack areas.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: clean up xfs_dir2_leafn_add
Darrick J. Wong [Mon, 6 May 2019 22:00:29 +0000 (18:00 -0400)]
xfs: clean up xfs_dir2_leafn_add

Source kernel commit: 79622c7ce6879c25ce121ee0db91c0ac4c7b137c

Remove typedefs and consolidate local variable initialization.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: Zero initialize highstale and lowstale in xfs_dir2_leafn_add
Nathan Chancellor [Mon, 6 May 2019 22:00:29 +0000 (18:00 -0400)]
xfs: Zero initialize highstale and lowstale in xfs_dir2_leafn_add

Source kernel commit: 7be73fa1c1b0b6aaf15d590320f2c5c1108cb87a

When building with -Wsometimes-uninitialized, Clang warns:

fs/xfs/libxfs/xfs_dir2_node.c:481:6: warning: variable 'lowstale' is
used uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]
fs/xfs/libxfs/xfs_dir2_node.c:481:6: warning: variable 'highstale' is
used uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]

While it isn't technically wrong, it isn't a problem in practice because
highstale and lowstale are only initialized in xfs_dir2_leafn_add when
compact is not zero then they are passed to xfs_dir3_leaf_find_entry,
where they are initialized before use when compact is zero. Regardless,
it's better not to be passing around uninitialized stack memory so zero
initialize these variables, which silences this warning.

Link: https://github.com/ClangBuiltLinux/linux/issues/393
Signed-off-by: Nathan Chancellor <natechancellor@gmail.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>
6 years agoxfs: fix uninitialized error variables
Darrick J. Wong [Mon, 6 May 2019 22:00:29 +0000 (18:00 -0400)]
xfs: fix uninitialized error variables

Source kernel commit: c1a4447f5e6ae8fb1f34a474f3083fb91cc4da90

smatch complained about some uninitialized error returns, so fix those.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: make COW fork unwritten extent conversions more robust
Christoph Hellwig [Mon, 6 May 2019 22:00:29 +0000 (18:00 -0400)]
xfs: make COW fork unwritten extent conversions more robust

Source kernel commit: 26b91c728b2d15952432371dc2b6ba1dda1fb61f

If we have racing buffered and direct I/O COW fork extents under
writeback can have been moved to the data fork by the time we call
xfs_reflink_convert_cow from xfs_submit_ioend.  This would be mostly
harmless as the block numbers don't change by this move, except for
the fact that xfs_bmapi_write will crash or trigger asserts when
not finding existing extents, even despite trying to paper over this
with the XFS_BMAPI_CONVERT_ONLY flag.

Instead of special casing non-transaction conversions in the already
way too complicated xfs_bmapi_write just add a new helper for the much
simpler non-transactional COW fork case, which simplify ignores not
found extents.

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>
6 years agoxfs: fix xfs_buf magic number endian checks
Darrick J. Wong [Mon, 6 May 2019 22:00:29 +0000 (18:00 -0400)]
xfs: fix xfs_buf magic number endian checks

Source kernel commit: 15baadf72cedc2a09ea792c1fc59451502b55da2

Create a separate magic16 check function so that we don't run afoul of
static checkers.

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>
6 years agoxfs: move stat accounting to xfs_bmapi_convert_delalloc
Christoph Hellwig [Mon, 6 May 2019 22:00:29 +0000 (18:00 -0400)]
xfs: move stat accounting to xfs_bmapi_convert_delalloc

Source kernel commit: 125851ac92d62b966df851c6f34147121020af2f

This way we can actually count how many bytes got converted and how many
calls we need, unlike in the caller which doesn't have the detailed
view.

Note that this includes a slight change in behavior as the
xs_xstrat_quick is now bumped for every allocation instead of just the
one covering the requested writeback offset, which makes a lot more
sense.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-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>
6 years agoxfs: move transaction handling to xfs_bmapi_convert_delalloc
Christoph Hellwig [Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)]
xfs: move transaction handling to xfs_bmapi_convert_delalloc

Source kernel commit: 491ce61e939f76399e344b0414dc5a4c08c1f0cf

No need to deal with the transaction and the inode locking in the
caller. Note that we also switch to passing whichfork as the second
paramter, matching what most related functions do.

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>
6 years agoxfs: split XFS_BMAPI_DELALLOC handling from xfs_bmapi_write
Christoph Hellwig [Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)]
xfs: split XFS_BMAPI_DELALLOC handling from xfs_bmapi_write

Source kernel commit: d8ae82e394bd5d836a32864b1ca22757ef8bb8ee

Delalloc conversion has traditionally been part of our function to
allocate blocks on disk (first xfs_bmapi, then xfs_bmapi_write), but
delalloc conversion is a little special as we really do not want
to allocate blocks over holes, for which we don't have reservations.

Split the delalloc conversions into a separate helper to keep the
code simple and structured.

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>
6 years agoxfs: factor out two helpers from xfs_bmapi_write
Christoph Hellwig [Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)]
xfs: factor out two helpers from xfs_bmapi_write

Source kernel commit: c8b54673b30a9668d626a9e48d1659c21300f2a4

We want to be able to reuse them for the upcoming dedidcated delalloc
convert routine.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-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>
6 years agoxfs: simplify the xfs_bmap_btree_to_extents calling conventions
Christoph Hellwig [Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)]
xfs: simplify the xfs_bmap_btree_to_extents calling conventions

Source kernel commit: b101e3342a34404f2cc2daaad569afcae68452b0

Move boilerplate code from the callers into xfs_bmap_btree_to_extents:

- exit early without failure if we don't need to convert to the
extent format
- assert that we have a btree cursor
- don't reinitialize the passed in logflags argument

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-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>
6 years agoxfs: rename m_inotbt_nores to m_finobt_nores
Darrick J. Wong [Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)]
xfs: rename m_inotbt_nores to m_finobt_nores

Source kernel commit: e1f6ca11381588e3ef138c10de60eeb34cb8466a

Rename this flag variable to imply more strongly that it's related to
the free inode btree (finobt) operation.  No functional changes.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: add magic numbers to dquot buffer ops
Darrick J. Wong [Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)]
xfs: add magic numbers to dquot buffer ops

Source kernel commit: 4260baac629e15723574f42c5c9ba13cb037db8e

Add dquot magic numbers to the buffer ops type, in case we ever want to
use them.

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>
6 years agoxfs: add inode magic to inode verifier
Darrick J. Wong [Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)]
xfs: add inode magic to inode verifier

Source kernel commit: 2bfe7069f71e56a301976d08eae3027b1eebc30d

Use xfs_verify_magic to check the magic numbers of inodes.

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>
6 years agoxfs: factor xfs_da3_blkinfo verification into common helper
Brian Foster [Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)]
xfs: factor xfs_da3_blkinfo verification into common helper

Source kernel commit: 8764f98351fa561296f70c3435a5cb1eb6272c39

With the verifier magic value helper in place, we've left a bit more
duplicate code across the verifiers that involve struct
xfs_da3_blkinfo. This includes the da node, xattr leaf and dir leaf
verifiers, all of which perform similar checks for v4 and v5
filesystems.

Create a common helper to verify an xfs_da3_blkinfo structure,
taking care to only access v5 fields where appropriate, and refactor
the aforementioned verifiers to use the helper. 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>
6 years agoxfs: miscellaneous verifier magic value fixups
Brian Foster [Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)]
xfs: miscellaneous verifier magic value fixups

Source kernel commit: 39708c20ab51337c3eb282a824eb0aaff7ebe2e1

Most buffer verifiers have hardcoded magic value checks
conditionalized on the version of the filesystem. The magic value
field of the verifier structure facilitates abstraction of some of
this code. Populate the ->magic field of various verifiers to take
advantage of this abstraction. 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>
6 years agoxfs: use verifier magic field in dir2 leaf verifiers
Brian Foster [Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)]
xfs: use verifier magic field in dir2 leaf verifiers

Source kernel commit: 09f420197d7ced360b4809606efd7a65f842c2c0

The dir2 leaf verifiers share the same underlying structure
verification code, but implement six accessor functions to multiplex
the code across the two verifiers. Further, the magic value isn't
sufficiently abstracted such that the common helper has to manually
fix up the magic from the caller on v5 filesystems.

Use the magic field in the verifier structure to eliminate the
duplicate code and clean this all up. No functional change.

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>
6 years agoxfs: distinguish between bnobt and cntbt magic values
Brian Foster [Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)]
xfs: distinguish between bnobt and cntbt magic values

Source kernel commit: b8f89801664f8413a88cf2c7539d1aeae07dd3c5

The allocation btree verifiers share code that is unable to detect
cross-tree magic value corruptions such as a bnobt block with a
cntbt magic value. Populate the b_ops->magic field of the associated
verifier structures such that the structure verifier can check the
magic value against the expected value based on tree type.

The btree level check requires knowledge of the tree type to
determine the appropriate maximum value. This was previously part of
the hardcoded magic value checks. With that code removed, peek at
the first magic value in the verifier to determine the expected tree
type of the current block.

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>
6 years agoxfs: split up allocation btree verifier
Brian Foster [Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)]
xfs: split up allocation btree verifier

Source kernel commit: 27df4f5045fc68766980c4dfba5ffc9ad1f71ebb

Similar to the inode btree verifier, the same allocation btree
verifier structure is shared between the by-bno (bnobt) and by-size
(cntbt) btrees. This prevents the ability to distinguish magic
values between them. Separate the verifier into two, one for each
tree, and assign them appropriately. 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>
6 years agoxfs: distinguish between inobt and finobt magic values
Brian Foster [Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)]
xfs: distinguish between inobt and finobt magic values

Source kernel commit: 8473fee340e37711b9ac6a5cc591305ccaaa4778

The inode btree verifier code is shared between the inode btree and
free inode btree because the underlying metadata formats are
essentially equivalent. A side effect of this is that the verifier
cannot determine whether a particular btree block should have an
inobt or finobt magic value.

This logic allows an unfortunate xfs_repair bug to escape detection
where certain level > 0 nodes of the finobt are stamped with inobt
magic by xfs_repair finobt reconstruction. This is fortunately not a
severe problem since the inode btree magic values do not contribute
to any changes in kernel behavior, but we do need a means to detect
and prevent this problem in the future.

Add a field to xfs_buf_ops to store the v4 and v5 superblock magic
values expected by a particular verifier. Add a helper to check an
on-disk magic value against the value expected by the verifier. Call
the helper from the shared [f]inobt verifier code for magic value
verification. This ensures that the inode btree blocks each have the
appropriate magic value based on specific tree type and superblock
version.

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>
6 years agoxfs: create a separate finobt verifier
Brian Foster [Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)]
xfs: create a separate finobt verifier

Source kernel commit: 01e68f40bf7846b58d2734aa11b0cbcaadbeaa3e

The inobt verifier is reused for the inobt and finobt, which
prevents the ability to distinguish between magic values on a
per-tree basis. Create a separate finobt structure in preparation
for changes to enforce the appropriate magic value for the
associated tree. This patch has no functional change.

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>
6 years agoxfs: always check magic values in on-disk byte order
Brian Foster [Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)]
xfs: always check magic values in on-disk byte order

Source kernel commit: e34d3e74eb8f6eb020312cec747ff55ee1d1ca18

Most verifiers that check on-disk magic values convert the CPU
endian magic value constant to disk endian to facilitate compile
time optimization of the byte swap and reduce the need for runtime
byte swaps in buffer verifiers. Several buffer verifiers do not
follow this pattern. Update those verifiers for consistency.

Also fix up a random typo in the inode readahead verifier name.

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>
6 years agoxfs: cache unlinked pointers in an rhashtable
Darrick J. Wong [Mon, 6 May 2019 22:00:28 +0000 (18:00 -0400)]
xfs: cache unlinked pointers in an rhashtable

Source kernel commit: 9b2471797942a5947664818cfe2c6de93b43f37a

Use a rhashtable to cache the unlinked list incore.  This should speed
up unlinked processing considerably when there are a lot of inodes on
the unlinked list because iunlink_remove no longer has to traverse an
entire bucket list to find which inode points to the one being removed.

The incore list structure records "X.next_unlinked = Y" relations, with
the rhashtable using Y to index the records.  This makes finding the
inode X that points to a inode Y very quick.  If our cache fails to find
anything we can always fall back on the old method.

FWIW this drastically reduces the amount of time it takes to remove
inodes from the unlinked list.  I wrote a program to open a lot of
O_TMPFILE files and then close them in the same order, which takes
a very long time if we have to traverse the unlinked lists.  With the
ptach, I see:

+ /d/t/tmpfile/tmpfile
Opened 193531 files in 6.33s.
Closed 193531 files in 5.86s

real    0m12.192s
user    0m0.064s
sys     0m11.619s
+ cd /
+ umount /mnt

real    0m0.050s
user    0m0.004s
sys     0m0.030s

And without the patch:

+ /d/t/tmpfile/tmpfile
Opened 193588 files in 6.35s.
Closed 193588 files in 751.61s

real    12m38.853s
user    0m0.084s
sys     12m34.470s
+ cd /
+ umount /mnt

real    0m0.086s
user    0m0.000s
sys     0m0.060s

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>
6 years agoxfs: add xfs_verify_agino_or_null helper
Darrick J. Wong [Mon, 6 May 2019 22:00:27 +0000 (18:00 -0400)]
xfs: add xfs_verify_agino_or_null helper

Source kernel commit: 7d36c19538d38f9ff6b93d2a3d23ee879b076dc6

Add a new helper to check that a per-AG inode pointer is either null or
points somewhere valid within that AG.

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>
6 years agoxfs: use the latest extent at writeback delalloc conversion time
Brian Foster [Mon, 6 May 2019 22:00:27 +0000 (18:00 -0400)]
xfs: use the latest extent at writeback delalloc conversion time

Source kernel commit: c2b3164320b51a535d7c7a6acdcee255edbb22cf

The writeback delalloc conversion code is racy with respect to
changes in the currently cached file mapping outside of the current
page. This is because the ilock is cycled between the time the
caller originally looked up the mapping and across each real
allocation of the provided file range. This code has collected
various hacks over the years to help combat the symptoms of these
races (i.e., truncate race detection, allocation into hole
detection, etc.), but none address the fundamental problem that the
imap may not be valid at allocation time.

Rather than continue to use race detection hacks, update writeback
delalloc conversion to a model that explicitly converts the delalloc
extent backing the current file offset being processed. The current
file offset is the only block we can trust to remain once the ilock
is dropped because any operation that can remove the block
(truncate, hole punch, etc.) must flush and discard pagecache pages
first.

Modify xfs_iomap_write_allocate() to use the xfs_bmapi_delalloc()
mechanism to request allocation of the entire delalloc extent
backing the current offset instead of assuming the extent passed by
the caller is unchanged. Record the range specified by the caller
and apply it to the resulting allocated extent so previous checks by
the caller for COW fork overlap are not lost. Finally, overload the
bmapi delalloc flag with the range reval flag behavior since this is
the only use case for both.

This ensures that writeback always picks up the correct
and current extent associated with the page, regardless of races
with other extent modifying operations. If operating on a data fork
and the COW overlap state has changed since the ilock was cycled,
the caller revalidates against the COW fork sequence number before
using the imap for the next block.

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>
6 years agoxfs: create delalloc bmapi wrapper for full extent allocation
Brian Foster [Mon, 6 May 2019 22:00:27 +0000 (18:00 -0400)]
xfs: create delalloc bmapi wrapper for full extent allocation

Source kernel commit: 627209fbcc2f0d658a5417645859a1d3053ddb59

The writeback delalloc conversion code is racy with respect to
changes in the currently cached file mapping. This stems from the
fact that the bmapi allocation code requires a file range to
allocate and the writeback conversion code assumes the range of the
currently cached mapping is still valid with respect to the fork. It
may not be valid, however, because the ilock is cycled (potentially
multiple times) between the time the cached mapping was populated
and the delalloc conversion occurs.

To facilitate a solution to this problem, create a new
xfs_bmapi_delalloc() wrapper to xfs_bmapi_write() that takes a file
(FSB) offset and attempts to allocate whatever delalloc extent backs
the offset. Use a new bmapi flag to cause xfs_bmapi_write() to set
the range based on the extent backing the bno parameter unless bno
lands in a hole. If bno does land in a hole, fall back to the
current behavior (which may result in an error or quietly skipping
holes in the specified range depending on other parameters). This
patch does not change behavior.

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>
6 years agoxfs: remove superfluous writeback mapping eof trimming
Brian Foster [Mon, 6 May 2019 22:00:20 +0000 (18:00 -0400)]
xfs: remove superfluous writeback mapping eof trimming

Source kernel commit: 3b35089807304f208419b5ad9cc3c5f731225cd9

Now that the cached writeback mapping is explicitly invalidated on
data fork changes, the EOF trimming band-aid is no longer necessary.
Remove xfs_trim_extent_eof() as well since it has no other users.

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>
6 years agoxfs: update fork seq counter on data fork changes
Brian Foster [Mon, 6 May 2019 22:00:20 +0000 (18:00 -0400)]
xfs: update fork seq counter on data fork changes

Source kernel commit: 9f9bc034b84958523689347ee2bdd9c660008e5e

The sequence counter in the xfs_ifork structure is only updated on
COW forks. This is because the counter is currently only used to
optimize out repetitive COW fork checks at writeback time.

Tweak the extent code to update the seq counter regardless of the
fork type in preparation for using this counter on data forks as
well.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Allison Henderson <allison.henderson@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>
6 years agoxfs: check attribute name validity
Darrick J. Wong [Mon, 6 May 2019 22:00:20 +0000 (18:00 -0400)]
xfs: check attribute name validity

Source kernel commit: 654805367d982cffdb9979453673aab9c3c96d07

Check extended attribute entry names for invalid characters.

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>
6 years agoxfs: check directory name validity
Darrick J. Wong [Mon, 6 May 2019 22:00:20 +0000 (18:00 -0400)]
xfs: check directory name validity

Source kernel commit: e5d7d51b340aac0f4cc56677eb8d29d4e164c58c

Check directory entry names for invalid characters.

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>
6 years agoxfs: scrub should flag dir/attr offsets that aren't mappable with xfs_dablk_t
Darrick J. Wong [Mon, 6 May 2019 22:00:20 +0000 (18:00 -0400)]
xfs: scrub should flag dir/attr offsets that aren't mappable with xfs_dablk_t

Source kernel commit: f8c1d7023e252df853efbb3566c6d47b148609fe

Teach scrub to flag extent maps that exceed the range that can be mapped
with a xfs_dablk_t.

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>
6 years agoxfsprogs: Release v5.0.0 v5.0.0
Eric Sandeen [Fri, 3 May 2019 17:14:36 +0000 (12:14 -0500)]
xfsprogs: Release v5.0.0

Update all the necessary files for a 5.0.0 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_db: scan entire file system when using 'frag'
Jorge Guerra [Fri, 3 May 2019 16:52:32 +0000 (11:52 -0500)]
xfs_db: scan entire file system when using 'frag'

While running the 'frag' command of 'xfs_db' we noticed that the
tool is not scanning all the files in the file system.  We noticed
this when we modified the tool to print the inodes of all the files
scanned.  For example:

 $ find /mnt/xfsdisk -type f | wc -l
 1782674
 $ xfs_db -r -c frag /dev/sdXX  | grep MB | awk '{print $5}' | paste -s -d+ | bc
 656818

Upon inspecting the code we noticed that the scanfunc_ino function
stops processing a given inode block once it encounters a free leaf.
However, in practice we see that inodes are necessarily always layed
out contiguously on the leaf node.  This resulted in the 'frag'
command skipping some valid inodes.

In this change we modify the scanfunc_ino function to skip freed
inodes.  With the change in place we ran the same experiment again
and noticed a more accurate file count:

 $ find /mnt/d0 -type f | wc -l
 1810442
 $ xfs_db -r -c frag /dev/sdXX  | grep MB | awk '{print $5}' | paste -s -d+ | bc
 1810442

Fixes: 2a5eb70c ("xfs_db: teach the frag command about sparse inode chunks")
Signed-off-by: Jorge Guerra <jorgeguerra@fb.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_io: rework includes for statx structures
Eric Sandeen [Fri, 3 May 2019 16:51:37 +0000 (11:51 -0500)]
xfs_io: rework includes for statx structures

Only include the kernel's linux/stat.h headers if we haven't
already picked up statx bits from glibc, to avoid redefinition.

Suggested-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Tested-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfsprogs: Release v5.0.0-rc1 v5.0.0-rc1
Eric Sandeen [Fri, 26 Apr 2019 21:50:48 +0000 (16:50 -0500)]
xfsprogs: Release v5.0.0-rc1

Update all the necessary files for a 5.0.0-rc1 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibxfs: refactor manage_zones()
Eric Sandeen [Fri, 26 Apr 2019 21:50:48 +0000 (16:50 -0500)]
libxfs: refactor manage_zones()

It's bizarre to have manage_zones() both set up and tear down zones.
It's even more bizarre to have xfs_dir_startup() buried in there.

Refactor init/destory into 2 functions, and call xfs_dir_startup()
separately from zone init similar to what kernelspace does.

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>
6 years agolibfrog: fix memory leak in bitmap_free
Darrick J. Wong [Fri, 26 Apr 2019 21:50:48 +0000 (16:50 -0500)]
libfrog: fix memory leak in bitmap_free

Free the bitmap struct before we null out the caller's pointer.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibxfs: shorten inode item lifetime
Darrick J. Wong [Fri, 26 Apr 2019 21:50:48 +0000 (16:50 -0500)]
libxfs: shorten inode item lifetime

Shorten the inode item lifetime so that we only keep them around while
the inode is joined with a transaction.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>