]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/log
thirdparty/xfsprogs-dev.git
4 years agoxfs_scrub: promote some of the str_info to str_error calls
Darrick J. Wong [Fri, 1 Nov 2019 21:55:06 +0000 (17:55 -0400)] 
xfs_scrub: promote some of the str_info to str_error calls

Now that str_error is only for runtime errors, we can promote a few of
the str_info calls that report runtime errors to str_error.

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_scrub: explicitly track corruptions, not just errors
Darrick J. Wong [Fri, 1 Nov 2019 21:55:06 +0000 (17:55 -0400)] 
xfs_scrub: explicitly track corruptions, not just errors

Rename the @errors_found variable to @corruptions_found to make it
more explicit that we're tracking fs corruption issues.  Add a new
str_corrupt() function to handle communications that fall under this new
corruption classification.  str_error() now exists to log runtime errors
that do not have an associated errno 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_scrub: clean up error level table
Darrick J. Wong [Fri, 1 Nov 2019 21:55:06 +0000 (17:55 -0400)] 
xfs_scrub: clean up error level table

Rework the error levels table in preparation for adding a few more error
categories that won't fit on a single line.

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_scrub: simplify post-run reporting logic
Darrick J. Wong [Fri, 1 Nov 2019 21:55:06 +0000 (17:55 -0400)] 
xfs_scrub: simplify post-run reporting logic

Simplify the post-run error and warning reporting logic so that in
subsequent patches we can be more specific about what types of things
went wrong.

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_scrub: fix misclassified error reporting
Darrick J. Wong [Fri, 1 Nov 2019 21:55:06 +0000 (17:55 -0400)] 
xfs_scrub: fix misclassified error reporting

Fix a few places where we assign error reports to the wrong
classification.

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_scrub: refactor xfs_iterate_inodes_range_check
Darrick J. Wong [Fri, 1 Nov 2019 20:55:28 +0000 (16:55 -0400)] 
xfs_scrub: refactor xfs_iterate_inodes_range_check

Move all the bulkstat action into a single helper function.  This gets
rid of the awkward name and increases cohesion.

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_scrub: clean out the nproc global variable
Darrick J. Wong [Fri, 1 Nov 2019 20:54:20 +0000 (16:54 -0400)] 
xfs_scrub: clean out the nproc global variable

Get rid of this global variable since we already have a libfrog function
that does exactly what it does.

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: take over platform headers
Darrick J. Wong [Fri, 1 Nov 2019 20:38:35 +0000 (16:38 -0400)] 
libfrog: take over platform headers

Move all the declarations for platform-specific functions into
libfrog/platform.h, since they're a part of libfrog now.

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 agolibxfs: remove libxfs_physmem
Darrick J. Wong [Fri, 1 Nov 2019 20:38:35 +0000 (16:38 -0400)] 
libxfs: remove libxfs_physmem

Remove this thin wrapper too.

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 agolibxfs: remove libxfs_nproc
Darrick J. Wong [Fri, 1 Nov 2019 20:38:35 +0000 (16:38 -0400)] 
libxfs: remove libxfs_nproc

Remove libxfs_nproc since it's a wrapper around a libfrog 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: clean up platform_nproc
Darrick J. Wong [Fri, 1 Nov 2019 20:38:35 +0000 (16:38 -0400)] 
libfrog: clean up platform_nproc

The platform_nproc function should check for error returns and obviously
garbage values and deal with them appropriately.  Fix the header
declaration since it's part of the libfrog platform support code, not
libxfs.  xfs_scrub will make use of it in the next patch.

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_scrub: fix media verification thread pool size calculations
Darrick J. Wong [Fri, 1 Nov 2019 20:32:45 +0000 (16:32 -0400)] 
xfs_scrub: fix media verification thread pool size calculations

The read verifier pool deals with two different thread counts -- there's
the submitter thread count that enables us to perform per-thread verify
request aggregation, and then there's the io thread pool count which is
the maximum number of IO requests we want to send to the disk at any
given time.

The io thread pool count should be derived from disk_heads() but instead
we bungle it by measuring and modifying(!) the nproc global variable.
Fix the derivation to use global variables correctly.

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_scrub: request fewer bmaps when we can
Darrick J. Wong [Fri, 1 Nov 2019 20:32:45 +0000 (16:32 -0400)] 
xfs_scrub: request fewer bmaps when we can

In xfs_iterate_filemaps, we query the number of bmaps for a given file
that we're going to iterate, so feed that information to bmap so that
the kernel won't waste time allocating in-kernel memory unnecessarily.

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_scrub: reduce fsmap activity for media errors
Darrick J. Wong [Fri, 1 Nov 2019 20:29:57 +0000 (16:29 -0400)] 
xfs_scrub: reduce fsmap activity for media errors

Right now we rather foolishly query the fsmap data for every single
media error that we find.  This is a silly waste of time since we
have yet to combine adjacent bad blocks into bad extents, so move the
rmap query until after we've constructed the bad block bitmap data.

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_scrub: don't report media errors on unwritten extents
Darrick J. Wong [Fri, 1 Nov 2019 20:16:40 +0000 (16:16 -0400)] 
xfs_scrub: don't report media errors on unwritten extents

Don't report media errors for unwritten extents since no data has been
lost.

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_scrub: improve reporting of file metadata media errors
Darrick J. Wong [Fri, 1 Nov 2019 20:16:40 +0000 (16:16 -0400)] 
xfs_scrub: improve reporting of file metadata media errors

Report media errors that map to data and attr fork extent maps.

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_scrub: better reporting of metadata media errors
Darrick J. Wong [Fri, 1 Nov 2019 20:16:40 +0000 (16:16 -0400)] 
xfs_scrub: better reporting of metadata media errors

When we report bad metadata, we inexplicably report the physical address
in units of sectors, whereas for file data we report file offsets in
units of bytes.  Fix the metadata reporting units to match the file data
units (i.e. bytes) and skip the printf for all other cases.

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_scrub: improve reporting of file data media errors
Darrick J. Wong [Fri, 1 Nov 2019 20:16:40 +0000 (16:16 -0400)] 
xfs_scrub: improve reporting of file data media errors

When we report media errors, we should tell the administrator the file
offset and length of the bad region, not just the offset of the entire
file extent record that overlaps a bad region.

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_scrub: separate media error reporting for attribute forks
Darrick J. Wong [Fri, 1 Nov 2019 20:16:40 +0000 (16:16 -0400)] 
xfs_scrub: separate media error reporting for attribute forks

Use different functions to warn about media errors that were detected in
underlying xattr data because logical offsets for attribute fork extents
have no meaning to users.

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/xfs_scrub: improve iteration function documentation
Darrick J. Wong [Fri, 1 Nov 2019 20:16:40 +0000 (16:16 -0400)] 
libfrog/xfs_scrub: improve iteration function documentation

Between libfrog and xfs_scrub, we have several item collection iteration
functions that take a pointer to a function that will be called for
every item in that collection.  They're not well documented, so improve
the description of when they'll be called and what kinds of return
values they expect.

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: fix incorrect error message
Darrick J. Wong [Fri, 1 Nov 2019 19:49:08 +0000 (15:49 -0400)] 
mkfs: fix incorrect error message

If we encounter a failure while fixing the freelist during mkfs, we
shouldn't print a misleading message about space reservation.  Fix it so
that we print something about what we were trying to do when the error
happened.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibxfs: fix typo in message about write verifier
Darrick J. Wong [Fri, 1 Nov 2019 19:49:01 +0000 (15:49 -0400)] 
libxfs: fix typo in message about write verifier

Fix a silly typo.

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: print better information when metadata updates fail
Darrick J. Wong [Fri, 1 Nov 2019 19:48:56 +0000 (15:48 -0400)] 
xfs_repair: print better information when metadata updates fail

If a metadata update fails during phase 6, we should print an error
message that can be traced back to a specific line of code.  Also,
res_failed spits out a general message about "xfs_trans_reserve failed",
which is probably not where the failure happened.  Fix two incorrect
call sites.

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_add error out
Darrick J. Wong [Fri, 1 Nov 2019 19:48:52 +0000 (15:48 -0400)] 
libfrog: fix workqueue_add error out

Don't forget to unlock before erroring out.

Coverity-id: 1454843
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_scrub: don't allow zero or negative error injection interval
Darrick J. Wong [Fri, 1 Nov 2019 19:48:48 +0000 (15:48 -0400)] 
xfs_scrub: don't allow zero or negative error injection interval

Don't allow zero or negative values from XFS_SCRUB_DISK_ERROR_INTERVAL
to slip into the system.  This is a debugging knob so we don't need to
be rigorous, but we can at least take care of obvious garbage values.

Coverity-id: 1454842
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
[sandeen: fix patch title]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_scrub: report repair activities on stdout, not stderr
Darrick J. Wong [Fri, 1 Nov 2019 19:48:16 +0000 (15:48 -0400)] 
xfs_scrub: report repair activities on stdout, not stderr

Reduce the severity of reports about successful metadata repairs.  We
fixed the problem, so there's no action necessary on the part of the
system admin.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
[sandeen: put err_levels in enum order]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_db: btheight should check geometry more carefully
Darrick J. Wong [Fri, 1 Nov 2019 19:46:12 +0000 (15:46 -0400)] 
xfs_db: btheight should check geometry more carefully

The btheight command needs to check user-supplied geometry more
carefully so that we don't hit floating point exceptions.

Coverity-id: 14536611453659
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: always report sick metadata, checked or not
Darrick J. Wong [Fri, 1 Nov 2019 19:46:12 +0000 (15:46 -0400)] 
xfs_spaceman: always report sick metadata, checked or not

If the kernel thinks a piece of metadata is bad, we must always report
it.  This will happen with an upcoming series to mark things sick
whenever we return EFSCORRUPTED at runtime.

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_scrub: simulate errors in the read-verify phase
Darrick J. Wong [Thu, 17 Oct 2019 02:35:26 +0000 (22:35 -0400)] 
xfs_scrub: simulate errors in the read-verify phase

Add a debugging hook so that we can simulate disk errors during the
media scan to test that the code 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>
4 years agoxfs_scrub: fix read verify disk error handling strategy
Darrick J. Wong [Thu, 17 Oct 2019 02:35:26 +0000 (22:35 -0400)] 
xfs_scrub: fix read verify disk error handling strategy

The error handling strategy for media errors is totally bogus.  First of
all, short reads are entirely unhandled -- when we encounter a short
read, we know the disk was able to feed us the beginning of what we
asked for, so we need to single-step through the remainder to try to
capture the exact error that we hit.

Second, an actual IO error causes the entire region to be marked bad
even though it could be just a few MB of a multi-gigabyte extent that's
bad.  Therefore, single-step each block in the IO request until we stop
getting IO errors to find out if all the blocks are bad or if it's just
that extent.

Third, fix the fact that the loop updates its own counter variables with
the length fed to read(), which doesn't necessarily have anything to do
with the amount of data that the read actually produced.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: change "io_error" to "read_error"]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_scrub: return bytes verified from a SCSI VERIFY command
Darrick J. Wong [Thu, 17 Oct 2019 02:35:26 +0000 (22:35 -0400)] 
xfs_scrub: return bytes verified from a SCSI VERIFY command

Since disk_scsi_verify and pread are interchangeably called from
disk_read_verify(), we must return the number of bytes verified (or -1)
just like what pread returns.  This doesn't matter now due to bugs in
scrub, but we're about to fix those bugs.

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_scrub: enforce read verify pool minimum io size
Darrick J. Wong [Thu, 17 Oct 2019 02:35:26 +0000 (22:35 -0400)] 
xfs_scrub: enforce read verify pool minimum io size

Make sure we always issue media verification requests aligned to the
minimum IO size that the caller cares about.  Concretely, this means
that we only care about doing IO in filesystem block-sized chunks.

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_scrub: record disk LBA size
Darrick J. Wong [Thu, 17 Oct 2019 02:35:26 +0000 (22:35 -0400)] 
xfs_scrub: record disk LBA size

Remember the size (in bytes) of a logical block on the disk.  We'll use
this in subsequent patches to improve the ability of media scans to
report on which files are corrupt.

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_scrub: refactor inode prefix rendering code
Darrick J. Wong [Thu, 17 Oct 2019 02:35:26 +0000 (22:35 -0400)] 
xfs_scrub: refactor inode prefix rendering code

Refactor all the places in the code where we try to render an inode
number as a prefix for some sort of status message.  This will help make
message prefixes more consistent, which should help users to locate
broken metadata.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: rename functions, auto-add spaces, edit comments]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_scrub: only call read_verify_force_io once per pool
Darrick J. Wong [Thu, 17 Oct 2019 02:35:26 +0000 (22:35 -0400)] 
xfs_scrub: only call read_verify_force_io once per pool

There's no reason we need to call read_verify_force_io every AG; we can
just let the request aggregation code do its thing and push when we're
totally done browsing the fsmap information.

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_scrub: fix queue-and-stash of non-contiguous verify requests
Darrick J. Wong [Thu, 17 Oct 2019 02:35:26 +0000 (22:35 -0400)] 
xfs_scrub: fix queue-and-stash of non-contiguous verify requests

read_verify_schedule_io is supposed to have the ability to decide that a
retained aggregate extent verification request is not sufficiently
contiguous with the request that is being scheduled, and therefore it
needs to queue the retained request and use the new request to start
building a new aggregate request.

Unfortunately, it stupidly returns after queueing the IO, so we lose the
incoming request.  Fix the code so we only do that if there's a run time
error.

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_scrub: fix read-verify pool error communication problems
Darrick J. Wong [Thu, 17 Oct 2019 02:35:26 +0000 (22:35 -0400)] 
xfs_scrub: fix read-verify pool error communication problems

Fix all the places in the read-verify pool functions either we fail to
check for runtime errors or fail to communicate them properly to
callers.  Then fix all the callers to report the error messages instead
of hiding them.

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_scrub: abort all read verification work immediately on error
Darrick J. Wong [Thu, 17 Oct 2019 02:35:25 +0000 (22:35 -0400)] 
xfs_scrub: abort all read verification work immediately on error

Add a new abort function to the read verify pool code so that the caller
can immediately abort all pending verification work if things start
going wrong.  There's no point in waiting for queued work to run if
we've already decided to bail.

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_scrub: fix handling of read-verify pool runtime errors
Darrick J. Wong [Thu, 17 Oct 2019 02:35:25 +0000 (22:35 -0400)] 
xfs_scrub: fix handling of read-verify pool runtime errors

Fix some bogosity with how we handle runtime errors in the read verify
pool functions.  First of all, memory allocation failures shouldn't be
recorded as disk IO errors, they should just complain and abort the
phase.  Second, we need to collect any other runtime errors in the IO
thread and abort the phase instead of silently ignoring them.

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_scrub: fix error handling problems in vfs.c
Darrick J. Wong [Thu, 17 Oct 2019 02:35:25 +0000 (22:35 -0400)] 
xfs_scrub: fix error handling problems in vfs.c

Fix all the places where we drop or screw up error handling in
scan_fs_tree.

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_scrub: move all the queue_subdir error reporting to callers
Darrick J. Wong [Thu, 17 Oct 2019 02:35:25 +0000 (22:35 -0400)] 
xfs_scrub: move all the queue_subdir error reporting to callers

Change queue_subdir to return a positive error code to callers and move
the error reporting to the callers.  This continues the process of
changing internal functions to return error codes.

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_scrub: check progress bar timedwait failures
Darrick J. Wong [Thu, 17 Oct 2019 02:35:25 +0000 (22:35 -0400)] 
xfs_scrub: check progress bar timedwait failures

Check for failures in the timedwait for progressbar reporting.

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_scrub: report all progressbar creation failures
Darrick J. Wong [Thu, 17 Oct 2019 02:35:25 +0000 (22:35 -0400)] 
xfs_scrub: report all progressbar creation failures

Always report failures when creating progress bars.

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_scrub: fix per-thread counter error communication problems
Darrick J. Wong [Thu, 17 Oct 2019 02:35:25 +0000 (22:35 -0400)] 
xfs_scrub: fix per-thread counter error communication problems

Fix all the places in the per-thread counter functions either we fail to
check for runtime errors or fail to communicate them properly to
callers.  Then fix all the callers to report the error messages instead
of hiding them.

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 bitmap code
Darrick J. Wong [Thu, 17 Oct 2019 02:35:25 +0000 (22:35 -0400)] 
libfrog: fix missing error checking in bitmap code

Check library calls for error codes being returned.

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 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>