]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/log
thirdparty/xfsprogs-dev.git
4 years agolibfrog: fix bitmap error communication problems
Darrick J. Wong [Thu, 17 Oct 2019 02:35:25 +0000 (22:35 -0400)] 
libfrog: fix bitmap error communication problems

Convert all the libfrog code and callers away from the libc-style
indirect errno returns to directly returning error codes to callers.

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>
4 years agolibfrog: add missing per-thread variable error handling
Darrick J. Wong [Thu, 17 Oct 2019 02:35:24 +0000 (22:35 -0400)] 
libfrog: add missing per-thread variable error handling

Add missing return value checks for everything that the per-thread
variable code calls.

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>
4 years agolibfrog: fix per-thread variable error communication problems
Darrick J. Wong [Thu, 17 Oct 2019 02:35:08 +0000 (22:35 -0400)] 
libfrog: fix per-thread variable error communication problems

Convert all the per-thread variable functions away from the libc-style
indirect errno return to return error values directly to callers.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: initialize ret in ptvar_foreach]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_scrub: redistribute read verify pool flush and destroy responsibilities
Darrick J. Wong [Tue, 15 Oct 2019 16:55:05 +0000 (12:55 -0400)] 
xfs_scrub: redistribute read verify pool flush and destroy responsibilities

Since workqueues now have separate primitives for "wait for all queued
work" and "destroy workqueue", it makes more sense for the read verify
pool code to call the workqueue destructor from its own destructor
function.

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>
4 years agolibfrog: split workqueue destroy functions
Darrick J. Wong [Tue, 15 Oct 2019 16:54:37 +0000 (12:54 -0400)] 
libfrog: split workqueue destroy functions

Split the workqueue destroy function into two parts -- one to signal all
the threads to exit and wait for them, and a second one that actually
destroys all the memory associated with the workqueue.  This mean we can
report latent workqueue errors independent of the freeing function.

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>
4 years agolibfrog: fix missing error checking in workqueue code
Darrick J. Wong [Tue, 15 Oct 2019 16:54:35 +0000 (12:54 -0400)] 
libfrog: fix missing error checking in workqueue code

Fix all the places in the workqueue code where we fail to check return
values and blindly keep going when we shouldn't.

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>
4 years agolibfrog: fix workqueue error communication problems
Darrick J. Wong [Tue, 15 Oct 2019 16:54:20 +0000 (12:54 -0400)] 
libfrog: fix workqueue error communication problems

Convert workqueue functions to return errno errors from the C library,
then convert the callers to use str_liberror to report the runtime
error.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: udpate commit log]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_scrub: batch inumbers calls during fscounters calculation
Darrick J. Wong [Mon, 30 Sep 2019 20:17:07 +0000 (16:17 -0400)] 
xfs_scrub: batch inumbers calls during fscounters calculation

Improve the efficiency of the phase 7 inode counts by batching requests,
now that we have per-AG inumbers wrappers.

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>
4 years agoxfs_scrub: convert to per-ag inode bulkstat operations
Darrick J. Wong [Mon, 30 Sep 2019 20:17:06 +0000 (16:17 -0400)] 
xfs_scrub: convert to per-ag inode bulkstat operations

Now that we're done reworking the xfrog bulkstat wrapper functions, we
can adapt xfs_scrub to use the per-ag iteration functionality.

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>
4 years agoxfs_spaceman: remove open-coded per-ag bulkstat
Darrick J. Wong [Mon, 30 Sep 2019 20:17:04 +0000 (16:17 -0400)] 
xfs_spaceman: remove open-coded per-ag bulkstat

Now that xfrog_bulkstat supports per-AG bulkstat, we can get rid of the
open coded one in spaceman.

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>
4 years agoxfs_io: add a bulkstat command
Darrick J. Wong [Mon, 30 Sep 2019 20:17:02 +0000 (16:17 -0400)] 
xfs_io: add a bulkstat command

Add a bulkstat command to xfs_io so that we can test our new xfrog code.

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>
4 years agoxfs_io/encrypt: add 'enckey_status' command
Eric Biggers [Mon, 30 Sep 2019 19:32:39 +0000 (15:32 -0400)] 
xfs_io/encrypt: add 'enckey_status' command

Add an 'enckey_status' command to xfs_io, to provide a command-line
interface to the FS_IOC_GET_ENCRYPTION_KEY_STATUS ioctl.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_io/encrypt: add 'rm_enckey' command
Eric Biggers [Mon, 30 Sep 2019 19:28:13 +0000 (15:28 -0400)] 
xfs_io/encrypt: add 'rm_enckey' command

Add a 'rm_enckey' command to xfs_io, to provide a command-line interface
to the FS_IOC_REMOVE_ENCRYPTION_KEY and
FS_IOC_REMOVE_ENCRYPTION_KEY_ALL_USERS ioctls.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_io/encrypt: add 'add_enckey' command
Eric Biggers [Mon, 30 Sep 2019 19:27:46 +0000 (15:27 -0400)] 
xfs_io/encrypt: add 'add_enckey' command

Add an 'add_enckey' command to xfs_io, to provide a command-line
interface to the FS_IOC_ADD_ENCRYPTION_KEY ioctl.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_io/encrypt: extend 'set_encpolicy' to support v2 policies
Eric Biggers [Mon, 30 Sep 2019 19:27:40 +0000 (15:27 -0400)] 
xfs_io/encrypt: extend 'set_encpolicy' to support v2 policies

Extend the 'set_encpolicy' xfs_io command to support setting v2
encryption policies, in addition to v1 encryption policies which it
currently supports.  This uses the same ioctl, where the 'version' field
at the beginning of the struct is used to determine whether the struct
is fscrypt_policy_v1 or fscrypt_policy_v2.

The command sets a v2 policy when the user either gave the longer key
specification used in such policies (a 16-byte master_key_identifier
rather than an 8-byte master_key_descriptor), or passed '-v 2'.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_io/encrypt: extend 'get_encpolicy' to support v2 policies
Eric Biggers [Mon, 30 Sep 2019 19:27:35 +0000 (15:27 -0400)] 
xfs_io/encrypt: extend 'get_encpolicy' to support v2 policies

get_encpolicy uses the FS_IOC_GET_ENCRYPTION_POLICY ioctl to retrieve
the file's encryption policy, then displays it.  But that only works for
v1 encryption policies.  A new ioctl, FS_IOC_GET_ENCRYPTION_POLICY_EX,
has been introduced which is more flexible and can retrieve both v1 and
v2 encryption policies.

Make get_encpolicy use the new ioctl if the kernel supports it and
display the resulting the v1 or v2 encryption policy.  Otherwise, fall
back to the old ioctl and display the v1 policy.

Also add new options:

  -1: Use the old ioctl only.  This will be used to test the old ioctl
      even when the kernel supports the new one.

  -t: Test whether the new ioctl is supported.  This will be useful to
      determine whether v2 policies should be tested or not.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_io/encrypt: add new encryption modes
Eric Biggers [Mon, 30 Sep 2019 19:27:27 +0000 (15:27 -0400)] 
xfs_io/encrypt: add new encryption modes

Add new encryption modes: AES-128-CBC and AES-128-CTS (supported since
Linux v4.11), and Adiantum (supported since Linux v5.0).

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_io/encrypt: generate encryption modes for 'help set_encpolicy'
Eric Biggers [Mon, 30 Sep 2019 19:27:22 +0000 (15:27 -0400)] 
xfs_io/encrypt: generate encryption modes for 'help set_encpolicy'

Print all encryption modes that are defined in the code, rather than
hardcoding the modes in the help text.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_io/encrypt: update to UAPI definitions from Linux v5.4
Eric Biggers [Mon, 30 Sep 2019 19:27:17 +0000 (15:27 -0400)] 
xfs_io/encrypt: update to UAPI definitions from Linux v5.4

Update to the latest fscrypt UAPI definitions, including:

- New names for some existing definitions (FSCRYPT_ instead of FS_).
- New ioctls.
- New encryption mode numbers and flags.

This patch doesn't make any change to the program logic itself.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_io/encrypt: remove unimplemented encryption modes
Eric Biggers [Mon, 30 Sep 2019 19:27:11 +0000 (15:27 -0400)] 
xfs_io/encrypt: remove unimplemented encryption modes

Although mode numbers were originally reserved for AES-256-GCM and
AES-256-CBC, these were never implemented in the kernel, and there are
no plans to do so anymore.  These mode numbers may be used for something
else in the future.  Also, xfstests (the only known user of the xfs_io
encryption commands) doesn't try to use them.  Finally, most of the
fscrypt constants have been given new names in the UAPI header, but the
unused constants have not been given new names since userspace should
just stop referencing them instead.

So remove them from xfs_io.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agomisc: convert from XFS_IOC_FSINUMBERS to XFS_IOC_INUMBERS
Darrick J. Wong [Mon, 30 Sep 2019 17:42:55 +0000 (13:42 -0400)] 
misc: convert from XFS_IOC_FSINUMBERS to XFS_IOC_INUMBERS

Convert all programs to use the v5 inumbers ioctl.

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>
4 years agomisc: convert xfrog_bulkstat functions to have v5 semantics
Darrick J. Wong [Mon, 30 Sep 2019 17:42:48 +0000 (13:42 -0400)] 
misc: convert xfrog_bulkstat functions to have v5 semantics

Convert xfrog_bulkstat() and xfrog_bulkstat_single() to take arguments
using v5 bulkstat semantics and return bulkstat information in v5
structures.  If the v5 ioctl is not available, the xfrog wrapper should
use the v1 ioctl to emulate v5 behaviors.  Add flags to the xfs_fd
structure to constrain emulation for debugging purposes.

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>
4 years agoman: add documentation for v5 inumbers ioctl
Darrick J. Wong [Fri, 27 Sep 2019 17:26:23 +0000 (13:26 -0400)] 
man: add documentation for v5 inumbers ioctl

Add a manpage describing the new v5 XFS_IOC_INUMBERS ioctl.

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>
4 years agoman: add documentation for v5 bulkstat ioctl
Darrick J. Wong [Fri, 27 Sep 2019 17:24:27 +0000 (13:24 -0400)] 
man: add documentation for v5 bulkstat ioctl

Add a new manpage describing the V5 XFS_IOC_BULKSTAT ioctl.

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>
4 years agomkfs: use libxfs to write out new AGs
Darrick J. Wong [Thu, 26 Sep 2019 17:46:34 +0000 (13:46 -0400)] 
mkfs: use libxfs to write out new AGs

Use the libxfs AG initialization functions to write out the new
filesystem instead of open-coding everything.

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>
4 years agolibxfs: make xfs_buf_delwri_submit actually do something
Darrick J. Wong [Thu, 26 Sep 2019 17:46:27 +0000 (13:46 -0400)] 
libxfs: make xfs_buf_delwri_submit actually do something

xfs_buf_delwri_queue doesn't report errors, which means that if the
buffer write fails we have no way of knowing that something bad
happened.  In the kernel we queue and then submit buffers, and the
submit call communicates errors to callers.  Do the same here since
we're going to start using the AG header initialization functions, which
use delwri_{queue,submit} heavily.

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>
4 years agolibxfs: fix buffer refcounting in delwri_queue
Darrick J. Wong [Thu, 26 Sep 2019 17:46:21 +0000 (13:46 -0400)] 
libxfs: fix buffer refcounting in delwri_queue

In the kernel, xfs_buf_delwri_queue increments the buffer reference
count before putting the buffer on the buffer list, and the refcount is
decremented after the io completes for a net refcount change of zero.

In userspace, delwri_queue calls libxfs_writebuf, which puts the buffer.
delwri_queue is a no-op, for a net refcount change of -1.  This creates
problems for any callers that expect a net change of zero, so increment
the buffer refcount before calling writebuf.

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>
4 years agolibxfs: fix uncached buffer refcounting
Darrick J. Wong [Thu, 26 Sep 2019 17:46:11 +0000 (13:46 -0400)] 
libxfs: fix uncached buffer refcounting

Currently, uncached buffers in userspace are created with zero refcount
and are fed to cache_node_put when they're released.  This is totally
broken -- the refcount should be 1 (because the caller now holds a
reference) and we should never be dumping uncached buffers into the
cache.  Fix both of these problems.

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>
4 years agoxfs_scrub: remove unnecessary wakeup wait in scan_fs_tree
Darrick J. Wong [Thu, 26 Sep 2019 17:46:06 +0000 (13:46 -0400)] 
xfs_scrub: remove unnecessary wakeup wait in scan_fs_tree

We don't need to wait on the condition variable if directory tree
scanning has already finished by the time we've finished queueing all
the directory work items.  This is easy to trigger when the workqueue is
single-threaded, but in theory it could happen any time.

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>
4 years agoxfs_scrub: fix nr_dirs accounting problems
Darrick J. Wong [Thu, 26 Sep 2019 17:45:56 +0000 (13:45 -0400)] 
xfs_scrub: fix nr_dirs accounting problems

When we're scanning the directory tree, we bump nr_dirs every time we
think we're going to queue a new directory to process, and we decrement
it every time we're finished doing something with a directory
(successful or not).  We forgot to undo a counter increment when
workqueue_add fails, so refactor the code into helpers and call them
as necessary for correct operation.

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>
4 years agoxfs_scrub: refactor queueing of subdir scan work item
Darrick J. Wong [Thu, 26 Sep 2019 17:45:51 +0000 (13:45 -0400)] 
xfs_scrub: refactor queueing of subdir scan work item

Replace the open-coded process of queueing a subdirectory for scanning
with a single helper function.

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>
4 years agoxfs_scrub: check summary counters
Darrick J. Wong [Thu, 26 Sep 2019 17:42:04 +0000 (13:42 -0400)] 
xfs_scrub: check summary counters

Teach scrub to ask the kernel to check and repair summary counters
during phase 7.

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>
4 years agoxfs_scrub: separate internal metadata scrub functions
Darrick J. Wong [Thu, 26 Sep 2019 17:41:35 +0000 (13:41 -0400)] 
xfs_scrub: separate internal metadata scrub functions

Refactor xfs_scrub_metadata into two functions -- one to make a single
call xfs_check_metadata, and the second retains the loop logic.  The
name is a little easy to confuse with other functions, so rename it to
reflect what it actually does: scrub all internal metadata of a given
class (AG header, AG metadata, FS metadata).  No functional changes.

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>
4 years agolibfrog: add online scrub/repair for superblock counters
Darrick J. Wong [Thu, 26 Sep 2019 17:41:35 +0000 (13:41 -0400)] 
libfrog: add online scrub/repair for superblock counters

Wire up the new superblock summary counter ioctls.

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>
4 years agolibfrog: share scrub headers
Darrick J. Wong [Thu, 26 Sep 2019 17:41:35 +0000 (13:41 -0400)] 
libfrog: share scrub headers

xfs_io and xfs_scrub have nearly identical structures to describe scrub
types.  Combine them into a single header file.

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>
4 years agoxfs_scrub: remove unnecessary fd parameter from file scrubbers
Darrick J. Wong [Thu, 26 Sep 2019 17:41:35 +0000 (13:41 -0400)] 
xfs_scrub: remove unnecessary fd parameter from file scrubbers

xfs_scrub's scrub ioctl wrapper functions always take a scrub_ctx and an
fd, but we always set the fd to ctx->mnt.fd.  Remove the redundant
parameter.

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>
4 years agoxfs_spaceman: report health problems
Darrick J. Wong [Thu, 26 Sep 2019 17:41:34 +0000 (13:41 -0400)] 
xfs_spaceman: report health problems

Use the fs and ag geometry ioctls to report health problems to users.

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>
4 years agoxfs_io: copy_range don't truncate dst_file, and add smart length
Jianhong Yin [Thu, 26 Sep 2019 17:41:17 +0000 (13:41 -0400)] 
xfs_io: copy_range don't truncate dst_file, and add smart length

1. copy_range should be a simple wrapper for copy_file_range(2)
and nothing else. and there's already -t option for truncate.
so here we remove the truncate action in copy_range.
see: https://patchwork.kernel.org/comment/22863587/#1

2. improve the default length value generation:
if -l option is omitted use the length that from src_offset to end
(src_file's size - src_offset) instead.
if src_offset is greater than file size, length is 0.

3. update manpage

4. rename var name from 'src, dst' to 'src_off, dst_off'

and have confirmed that this change will not affect xfstests.

Signed-off-by: Jianhong Yin <yin-jianhong@163.com>
[sandeen: fix long line]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_repair: add AG btree rmaps into the filesystem after syncing sb
Darrick J. Wong [Mon, 9 Sep 2019 19:37:08 +0000 (15:37 -0400)] 
xfs_repair: add AG btree rmaps into the filesystem after syncing sb

In rmap_store_ag_btree_rec(), we try to reserve 16 blocks to handle
adding all the AG btree rmaps to the rmap record.  Unfortunately, at
that point in phase5 we haven't yet reinitialied sb_fdblocks, so
reserving blocks can fail if repair reconstructed the primary sb from a
secondary sb.  Even if the function succeeds, this still leads to
incorrect fdblocks because phase 5 resets sb_fdblocks after running the
rmap transactions.

To avoid all this, move the rmap_store_ag_btree_rec call to after the sb
has been reset.  xfs/350 was helpful in finding cases where xfs_repair
errored out while repairing the filesystem.

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>
4 years agoxfs_repair: reduce the amount of "clearing reflink flag" messages
Darrick J. Wong [Mon, 9 Sep 2019 19:37:08 +0000 (15:37 -0400)] 
xfs_repair: reduce the amount of "clearing reflink flag" messages

Clearing the reflink flag on files that don't share blocks is an
optimization, not a repair, so it's not critical to log a message every
single time we clear a flag.  Only log one message that we're clearing
these flags unless verbose mode is enabled.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_repair: use precomputed inode geometry values
Darrick J. Wong [Mon, 9 Sep 2019 19:37:08 +0000 (15:37 -0400)] 
xfs_repair: use precomputed inode geometry values

Use the precomputed inode geometry values instead of open-coding them.

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>
4 years agoxfs_db: use precomputed inode geometry values
Darrick J. Wong [Mon, 9 Sep 2019 19:37:08 +0000 (15:37 -0400)] 
xfs_db: use precomputed inode geometry values

Use the precomputed inode geometry values instead of open-coding them.

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>
4 years agoxfs_db: add a function to compute btree geometry
Darrick J. Wong [Mon, 9 Sep 2019 19:37:08 +0000 (15:37 -0400)] 
xfs_db: add a function to compute btree geometry

Add a new command to xfs_db that uses a btree type and a record count
to report the best and worst case height and level size.  This can be
used to estimate how much overhead a metadata index will add to a
filesystem.

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>
4 years agoxfs_db: remove db/convert.h
Darrick J. Wong [Mon, 9 Sep 2019 19:37:08 +0000 (15:37 -0400)] 
xfs_db: remove db/convert.h

db/convert.h conflicts with include/convert.h and since the former only
has one declaration in it anyway, just get rid of it.  We'll need this
in the next patch to avoid an ugly include mess.

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>
4 years agoman: document the new health reporting fields in various ioctls
Darrick J. Wong [Mon, 9 Sep 2019 19:37:08 +0000 (15:37 -0400)] 
man: document the new health reporting fields in various ioctls

Update the manpages to conver the new health reporting fields in the
fs geometry, ag geometry, and bulkstat ioctls.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: fix sick/checked description to reference inodes]
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoman: document the new allocation group geometry ioctl
Darrick J. Wong [Mon, 9 Sep 2019 19:37:08 +0000 (15:37 -0400)] 
man: document the new allocation group geometry ioctl

Document the new ioctl to describe an allocation group's geometry.

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>
4 years agoman: document new fs summary counter scrub command
Darrick J. Wong [Mon, 9 Sep 2019 19:37:08 +0000 (15:37 -0400)] 
man: document new fs summary counter scrub command

Update the scrub ioctl documentation to include the new fs summary
counter scrubber.

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>
4 years agoman: document the new v5 fs geometry ioctl structures
Darrick J. Wong [Mon, 9 Sep 2019 19:37:08 +0000 (15:37 -0400)] 
man: document the new v5 fs geometry ioctl structures

Amend the fs geometry ioctl documentation to cover the new v5 structure.

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>
4 years agoxfs_spaceman: convert open-coded unit conversions to helpers
Darrick J. Wong [Mon, 9 Sep 2019 19:37:08 +0000 (15:37 -0400)] 
xfs_spaceman: convert open-coded unit conversions to helpers

Create xfrog analogues of the libxfs byte/sector/block conversion
functions and convert spaceman to use them instead of open-coded
arithmatic we do now.

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>
4 years agoxfs_spaceman: embed struct xfs_fd in struct fileio
Darrick J. Wong [Mon, 9 Sep 2019 19:37:07 +0000 (15:37 -0400)] 
xfs_spaceman: embed struct xfs_fd in struct fileio

Replace the open-coded fd and geometry fields of struct fileio with a
single xfs_fd, which will enable us to use it natively throughout
xfs_spaceman in upcoming patches.

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>
4 years agoxfs_spaceman: remove unnecessary test in openfile()
Darrick J. Wong [Mon, 9 Sep 2019 19:37:07 +0000 (15:37 -0400)] 
xfs_spaceman: remove unnecessary test in openfile()

xfs_spaceman always records fs_path information for an open file because
spaceman requires running on XFS and it always passes a non-null fs_path
to openfile.  Therefore, openfile doesn't need the fs_path null check.

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>
4 years agoxfs_spaceman: remove typedef usage
Darrick J. Wong [Mon, 9 Sep 2019 19:37:07 +0000 (15:37 -0400)] 
xfs_spaceman: remove typedef usage

Kill off the struct typedefs inside spaceman.

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>
4 years agolibfrog: move libfrog.h to libfrog/util.h
Darrick J. Wong [Mon, 9 Sep 2019 19:37:07 +0000 (15:37 -0400)] 
libfrog: move libfrog.h to libfrog/util.h

Move this header to libfrog since the code is there already.

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>
4 years agolibfrog: move workqueue.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:07 +0000 (15:37 -0400)] 
libfrog: move workqueue.h to libfrog/

Move this header to libfrog since the code is there already.

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>
4 years agolibfrog: move path.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:07 +0000 (15:37 -0400)] 
libfrog: move path.h to libfrog/

Move this header to libfrog since the code is there already.

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>
4 years agolibfrog: move crc32c.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:07 +0000 (15:37 -0400)] 
libfrog: move crc32c.h to libfrog/

Move this header to libfrog since the code is there already.

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>
4 years agolibfrog: move workqueue.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:06 +0000 (15:37 -0400)] 
libfrog: move workqueue.h to libfrog/

Move this header to libfrog since the code is there already.

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>
4 years agolibfrog: move radix-tree.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:06 +0000 (15:37 -0400)] 
libfrog: move radix-tree.h to libfrog/

Move this header to libfrog since the code is there already.

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>
4 years agolibfrog: move ptvar.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:06 +0000 (15:37 -0400)] 
libfrog: move ptvar.h to libfrog/

Move this header to libfrog since the code is there already.

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>
4 years agolibfrog: move fsgeom.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:06 +0000 (15:37 -0400)] 
libfrog: move fsgeom.h to libfrog/

Move this header to libfrog since the code is there already.

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>
4 years agolibfrog: move convert.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:06 +0000 (15:37 -0400)] 
libfrog: move convert.h to libfrog/

Move this header to libfrog since the code is there already.

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>
4 years agolibfrog: move bitmap.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:06 +0000 (15:37 -0400)] 
libfrog: move bitmap.h to libfrog/

Move this header to libfrog since the code is there already.

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>
4 years agolibfrog: move avl64.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:06 +0000 (15:37 -0400)] 
libfrog: move avl64.h to libfrog/

Move this header to libfrog since the code is there already.

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>
4 years agolibxfs: move topology declarations into separate header
Darrick J. Wong [Mon, 9 Sep 2019 19:37:05 +0000 (15:37 -0400)] 
libxfs: move topology declarations into separate header

The topology functions live in libfrog now, which means their
declarations don't belong in libxcmd.h.  Create new header file for
them.

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>
4 years agolibfrog: refactor open-coded INUMBERS calls
Darrick J. Wong [Mon, 9 Sep 2019 19:37:05 +0000 (15:37 -0400)] 
libfrog: refactor open-coded INUMBERS calls

Refactor all the INUMBERS ioctl callsites into helper functions.

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>
4 years agolibfrog: create xfd_open function
Darrick J. Wong [Mon, 9 Sep 2019 19:37:05 +0000 (15:37 -0400)] 
libfrog: create xfd_open function

Create a helper to open a file and initialize the xfd 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>
4 years agolibfrog: refactor open-coded bulkstat calls
Darrick J. Wong [Mon, 9 Sep 2019 19:37:05 +0000 (15:37 -0400)] 
libfrog: refactor open-coded bulkstat calls

Refactor the BULKSTAT_SINGLE and BULKSTAT ioctl callsites into helper
functions.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibfrog: create online fs geometry converters
Darrick J. Wong [Mon, 9 Sep 2019 19:37:05 +0000 (15:37 -0400)] 
libfrog: create online fs geometry converters

Create helper functions to perform unit conversions against a runtime
filesystem, then remove the open-coded versions in scrub.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibfrog: store more inode and block geometry in struct xfs_fd
Darrick J. Wong [Mon, 9 Sep 2019 19:37:05 +0000 (15:37 -0400)] 
libfrog: store more inode and block geometry in struct xfs_fd

Move the extra AG geometry fields out of scrub and into the libfrog code
so that we can consolidate the geoemtry code in one place.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibfrog: introduce xfs_fd to wrap an fd to a file on an xfs filesystem
Darrick J. Wong [Mon, 9 Sep 2019 19:37:04 +0000 (15:37 -0400)] 
libfrog: introduce xfs_fd to wrap an fd to a file on an xfs filesystem

Introduce a new "xfs_fd" context structure where we can store a file
descriptor and all the runtime fs context (geometry, which ioctls work,
etc.) that goes with it.  We're going to create wrappers for the
bulkstat and inumbers ioctls in subsequent patches; and when we
introduce the v5 bulkstat/inumbers ioctls we'll need all that context to
downgrade gracefully on old kernels.  Start the transition by adopting
xfs_fd natively in scrub.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibfrog: refactor online geometry queries
Darrick J. Wong [Mon, 9 Sep 2019 19:36:57 +0000 (15:36 -0400)] 
libfrog: refactor online geometry queries

Refactor all the open-coded XFS_IOC_FSGEOMETRY queries into a single
helper that we can use to standardize behaviors across mixed xfslibs
versions.  This is the prelude to introducing a new FSGEOMETRY version
in 5.2 and needing to fix the (relatively few) client programs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
[sandeen: remove 5.2.1 compat hack now that we have the wrapper]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfsprogs: update spdx tags in LICENSES/
Darrick J. Wong [Fri, 6 Sep 2019 21:59:13 +0000 (17:59 -0400)] 
xfsprogs: update spdx tags in LICENSES/

Update the GPL related SPDX tags in LICENSES to reflect the SPDX 3.0
tagging formats.

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>
4 years agoxfsprogs: Release v5.3.0-rc1 v5.3.0-rc1
Eric Sandeen [Wed, 28 Aug 2019 16:12:12 +0000 (12:12 -0400)] 
xfsprogs: Release v5.3.0-rc1

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

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: don't crash on null attr fork xfs_bmapi_read
Darrick J. Wong [Wed, 28 Aug 2019 16:08:10 +0000 (12:08 -0400)] 
xfs: don't crash on null attr fork xfs_bmapi_read

Source kernel commit: 8612de3f7ba6e900465e340516b8313806d27b2d

Zorro Lang reported a crash in generic/475 if we try to inactivate a
corrupt inode with a NULL attr fork (stack trace shortened somewhat):

RIP: 0010:xfs_bmapi_read+0x311/0xb00 [xfs]
RSP: 0018:ffff888047f9ed68 EFLAGS: 00010202
RAX: dffffc0000000000 RBX: ffff888047f9f038 RCX: 1ffffffff5f99f51
RDX: 0000000000000002 RSI: 0000000000000008 RDI: 0000000000000012
RBP: ffff888002a41f00 R08: ffffed10005483f0 R09: ffffed10005483ef
R10: ffffed10005483ef R11: ffff888002a41f7f R12: 0000000000000004
R13: ffffe8fff53b5768 R14: 0000000000000005 R15: 0000000000000001
FS:  00007f11d44b5b80(0000) GS:ffff888114200000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000ef6000 CR3: 000000002e176003 CR4: 00000000001606e0
Call Trace:
xfs_dabuf_map.constprop.18+0x696/0xe50 [xfs]
xfs_da_read_buf+0xf5/0x2c0 [xfs]
xfs_da3_node_read+0x1d/0x230 [xfs]
xfs_attr_inactive+0x3cc/0x5e0 [xfs]
xfs_inactive+0x4c8/0x5b0 [xfs]
xfs_fs_destroy_inode+0x31b/0x8e0 [xfs]
destroy_inode+0xbc/0x190
xfs_bulkstat_one_int+0xa8c/0x1200 [xfs]
xfs_bulkstat_one+0x16/0x20 [xfs]
xfs_bulkstat+0x6fa/0xf20 [xfs]
xfs_ioc_bulkstat+0x182/0x2b0 [xfs]
xfs_file_ioctl+0xee0/0x12a0 [xfs]
do_vfs_ioctl+0x193/0x1000
ksys_ioctl+0x60/0x90
__x64_sys_ioctl+0x6f/0xb0
do_syscall_64+0x9f/0x4d0
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f11d39a3e5b

The "obvious" cause is that the attr ifork is null despite the inode
claiming an attr fork having at least one extent, but it's not so
obvious why we ended up with an inode in that state.

Reported-by: Zorro Lang <zlang@redhat.com>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204031
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: remove more ondisk directory corruption asserts
Darrick J. Wong [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: remove more ondisk directory corruption asserts

Source kernel commit: 858b44dc62a1018312fd9cbd15db24237a897e0e

Continue our game of replacing ASSERTs for corrupt ondisk metadata with
EFSCORRUPTED returns.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: attribute scrub should use seen_enough to pass error values
Darrick J. Wong [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: attribute scrub should use seen_enough to pass error values

Source kernel commit: 2c3b83d7ca6d73b9478afc86c89377c15a90b9ed

When we're iterating all the attributes using the built-in xattr
iterator, we can use the seen_enough variable to pass error codes back
to the main scrub function instead of flattening them into 0/1.  This
will be used in a more exciting fashion in upcoming patches.

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>
4 years agoxfs: allow single bulkstat of special inodes
Darrick J. Wong [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: allow single bulkstat of special inodes

Source kernel commit: bf3cb394479210a9ebcf8fef7a7f8fcabc7b9928

Create a new bulk ireq flag that enables userspace to ask us for a
special inode number instead of interpreting @ino as a literal inode
number.  This enables us to query the root inode easily.

The reason for adding the ability to query specifically the root
directory inode is that certain programs (xfsdump and xfsrestore) want
to confirm when they've been pointed to the root directory.  The
userspace code assumes the root directory is always the first result
from calling bulkstat with lastino == 0, but this isn't true if the
(initial btree roots + initial AGFL + inode alignment padding) is itself
long enough to be allocated to new inodes if all of those blocks should
happen to be free at the same time.  Rather than make userspace guess
at internal filesystem state, we provide a direct query.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: specify AG in bulk req
Darrick J. Wong [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: specify AG in bulk req

Source kernel commit: 13d59a2a61cbbb4cda13a0cba6d4d1fc537f5dd4

Add a new xfs_bulk_ireq flag to constrain the iteration to a single AG.
If the passed-in startino value is zero then we start with the first
inode in the AG that the user passes in; otherwise, we iterate only
within the same AG as the passed-in inode.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: wire up the v5 inumbers ioctl
Darrick J. Wong [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: wire up the v5 inumbers ioctl

Source kernel commit: fba9760a433634067ec01e7d4cdd581d17b149e0

Wire up the v5 INUMBERS ioctl.

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>
4 years agoxfs: wire up new v5 bulkstat ioctls
Darrick J. Wong [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: wire up new v5 bulkstat ioctls

Source kernel commit: 0448b6f488fa66e353a9e00022441cd4aca7f2cf

Wire up the new v5 BULKSTAT ioctl.

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>
4 years agoxfs: introduce v5 inode group structure
Darrick J. Wong [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: introduce v5 inode group structure

Source kernel commit: 5f19c7fc6873351a3d81bbbb98c928343902d8d6

Introduce a new "v5" inode group structure that fixes the alignment
and padding problems of the existing structure.

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>
4 years agoxfs: introduce new v5 bulkstat structure
Darrick J. Wong [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: introduce new v5 bulkstat structure

Source kernel commit: 7035f9724f8497c709077c08df2073bfcde9c2f5

Introduce a new version of the in-core bulkstat structure that supports
our new v5 format features.  This structure also fills the gaps in the
previous structure.  We leave wiring up the ioctls for the next patch.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: remove various bulk request typedef usage
Darrick J. Wong [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: remove various bulk request typedef usage

Source kernel commit: 6f71fb683879c78ba356ca78f2972289443f26eb

Remove xfs_bstat_t, xfs_fsop_bulkreq_t, xfs_inogrp_t, and similarly
named compat typedefs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: create simplified inode walk function
Darrick J. Wong [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: create simplified inode walk function

Source kernel commit: a211432c27ffa32d9978f6c18f5af0c3f8ad2ad1

Create a new iterator function to simplify walking inodes in an XFS
filesystem.  This new iterator will replace the existing open-coded
walking that goes on in various places.

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>
4 years agoxfs: create iterator error codes
Darrick J. Wong [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: create iterator error codes

Source kernel commit: 5bb46e3e180d28c7ee6715f47c344be366a3fcc8

Currently, xfs doesn't have generic error codes defined for "stop
iterating"; we just reuse the XFS_BTREE_QUERY_* return values.  This
looks a little weird if we're not actually iterating a btree index.
Before we start adding more iterators, we should create general
XFS_ITER_{CONTINUE,ABORT} return values and define the XFS_BTREE_QUERY_*
ones from that.

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>
4 years agoxfs: remove XFS_TRANS_NOFS
Christoph Hellwig [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: remove XFS_TRANS_NOFS

Source kernel commit: 73d30d48749f883fbaaf68ef5d774e99ffafda5d

Instead of a magic flag for xfs_trans_alloc, just ensure all callers
that can't relclaim through the file system use memalloc_nofs_save to
set the per-task nofs flag.

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>
4 years agoxfs: remove unused header files
Eric Sandeen [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: remove unused header files

Source kernel commit: 250d4b4c409778bc44577dfc59909935c92fd006

There are many, many xfs header files which are included but
unneeded (or included twice) in the xfs code, so remove them.

nb: xfs_linux.h includes about 9 headers for everyone, so those
explicit includes get removed by this.  I'm not sure what the
preference is, but if we wanted explicit includes everywhere,
a followup patch could remove those xfs_*.h includes from
xfs_linux.h and move them into the files that need them.
Or it could be left as-is.

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>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: account for log space when formatting new AGs
Darrick J. Wong [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: account for log space when formatting new AGs

Source kernel commit: f327a00745fffd9159d54b442cb75c0266fb89d6

When we're writing out a fresh new AG, make sure that we don't list an
internal log as free and that we create the rmap for the region.  growfs
never does this, but we will need it when we hook up mkfs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: refactor free space btree record initialization
Darrick J. Wong [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: refactor free space btree record initialization

Source kernel commit: 8d90857cff445f176a591d01c0999e8d563217bf

Refactor the code that populates the free space btrees of a new AG so
that we can avoid code duplication once things start getting
complicated.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: always update params on small allocation
Brian Foster [Wed, 28 Aug 2019 16:08:08 +0000 (12:08 -0400)] 
xfs: always update params on small allocation

Source kernel commit: 7e36a3a63d3e480e75b4991aa983d4059ca5d401

xfs_alloc_ag_vextent_small() doesn't update the output parameters in
the event of an AGFL allocation. Instead, it updates the
xfs_alloc_arg structure directly to complete the allocation.

Update both args and the output params to provide consistent
behavior for future callers.

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>
4 years agoxfs: skip small alloc cntbt logic on NULL cursor
Brian Foster [Wed, 28 Aug 2019 16:08:08 +0000 (12:08 -0400)] 
xfs: skip small alloc cntbt logic on NULL cursor

Source kernel commit: 6691cd9267c1c588d1f8e097c175d7c9670c7fc1

The small allocation helper is implemented in a way that is fairly
tightly integrated to the existing allocation algorithms. It expects
a cntbt cursor beyond the end of the tree, attempts to locate the
last record in the tree and only attempts an AGFL allocation if the
cntbt is empty.

The upcoming generic algorithm doesn't rely on the cntbt processing
of this function. It will only call this function when the cntbt
doesn't have a big enough extent or is empty and thus AGFL
allocation is the only remaining option. Tweak
xfs_alloc_ag_vextent_small() to handle a NULL cntbt cursor and skip
the cntbt logic. This facilitates use by the existing allocation
code and new code that only requires an AGFL allocation attempt.

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>
4 years agoxfs: move small allocation helper
Brian Foster [Wed, 28 Aug 2019 16:08:08 +0000 (12:08 -0400)] 
xfs: move small allocation helper

Source kernel commit: c63cdd4fc9cc6a22d6e0bd0dcba4a28d18eab723

Move the small allocation helper further up in the file to avoid the
need for a function declaration. The remaining declarations will be
removed by followup patches. 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>
4 years agoxfs: clean up small allocation helper
Brian Foster [Wed, 28 Aug 2019 16:08:08 +0000 (12:08 -0400)] 
xfs: clean up small allocation helper

Source kernel commit: 2a4f35f984f0be5b839be157b50f69ee73c67ef1

xfs_alloc_ag_vextent_small() is kind of a mess. Clean it up in
preparation for future changes. No functional changes.

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>
4 years agoxfs: add struct xfs_mount pointer to struct xfs_buf
Christoph Hellwig [Wed, 28 Aug 2019 16:08:08 +0000 (12:08 -0400)] 
xfs: add struct xfs_mount pointer to struct xfs_buf

Source kernel commit: dbd329f1e44ed48de8a1c19da5eb1218f5e1b4a5

We need to derive the mount pointer from a buffer in a lot of place.
Add a direct pointer to short cut the pointer chasing.

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>
4 years agoxfs: move xfs_ino_geometry to xfs_shared.h
Darrick J. Wong [Wed, 28 Aug 2019 16:08:08 +0000 (12:08 -0400)] 
xfs: move xfs_ino_geometry to xfs_shared.h

Source kernel commit: 5467b34bd1e81c8e719ae968ba6561723fdc15b8

The inode geometry structure isn't related to ondisk format; it's
support for the mount structure.  Move it to xfs_shared.h.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: remove unused flag arguments
Eric Sandeen [Wed, 28 Aug 2019 16:08:08 +0000 (12:08 -0400)] 
xfs: remove unused flag arguments

Source kernel commit: f5b999c03f4c178d151e79803a95f8482a26521e

There are several functions which take a flag argument that is
only ever passed as "0," so remove these arguments.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Allison Collins <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>
4 years agoxfs: remove unused flags arg from getsb interfaces
Eric Sandeen [Wed, 28 Aug 2019 16:08:08 +0000 (12:08 -0400)] 
xfs: remove unused flags arg from getsb interfaces

Source kernel commit: 8c9ce2f707a1571782b4d3d100af627b6d147357

The flags value is always passed as 0 so remove the argument.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
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>
4 years agoxfs: finish converting to inodes_per_cluster
Darrick J. Wong [Wed, 28 Aug 2019 16:08:08 +0000 (12:08 -0400)] 
xfs: finish converting to inodes_per_cluster

Source kernel commit: 4b4d98cca32053ec8993e836cb8cb7c8098959dc

Finish converting all the old inode_cluster_size >> inopblog users to
inodes_per_cluster.

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>
4 years agoxfs: fix inode_cluster_size rounding mayhem
Darrick J. Wong [Wed, 28 Aug 2019 16:08:08 +0000 (12:08 -0400)] 
xfs: fix inode_cluster_size rounding mayhem

Source kernel commit: 490d451fa5188975c21246f7f8f4914cd3f2d6f2

inode_cluster_size is supposed to represent the size (in bytes) of an
inode cluster buffer.  We avoid having to handle multiple clusters per
filesystem block on filesystems with large blocks by openly rounding
this value up to 1 FSB when necessary.  However, we never reset
inode_cluster_size to reflect this new rounded value, which adds to the
potential for mistakes in calculating geometries.

Fix this by setting inode_cluster_size to reflect the rounded-up size if
needed, and special-case the few places in the sparse inodes code where
we actually need the smaller value to validate on-disk metadata.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: refactor inode geometry setup routines
Darrick J. Wong [Wed, 28 Aug 2019 16:08:08 +0000 (12:08 -0400)] 
xfs: refactor inode geometry setup routines

Source kernel commit: 494dba7b276e12bc3f6ff2b9b584b6e9f693af45

Migrate all of the inode geometry setup code from xfs_mount.c into a
single libxfs function that we can share with xfsprogs.

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>