]> www.infradead.org Git - users/hch/xfsprogs.git/log
users/hch/xfsprogs.git
4 years agoxfsprogs: remove the libxfs_* API redirections libxfs-api
Christoph Hellwig [Fri, 10 Jul 2020 06:49:37 +0000 (08:49 +0200)]
xfsprogs: remove the libxfs_* API redirections

For historical reasons xfsprogs tries to renamed xfs_* symbols used
by tools (but not those used inside libxfs) to libxfs_.  Remove this
indirection to make it clear what function is being called, and to
avoid having to keep the renaming header uptodate.

Signed-off-by: Christoph Hellwig <hch@lst.de>
5 years agometadump: remove redundant bracket and show right SYNOPSIS for-next
Kaixu Xia [Tue, 26 May 2020 18:42:40 +0000 (14:42 -0400)]
metadump: remove redundant bracket and show right SYNOPSIS

The bracket is meaningless, so remove it and show right SYNOPSIS.

Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agomkfs: simplify the configured sector sizes setting in validate_sectorsize
Kaixu Xia [Tue, 26 May 2020 18:42:30 +0000 (14:42 -0400)]
mkfs: simplify the configured sector sizes setting in validate_sectorsize

There are two places that set the configured sector sizes in
validate_sectorsize, actually we can simplify them and combine into one
if statement. Use the default value structure to set the topology sectors
when probing fails.

Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_quota: allow individual timer extension
Eric Sandeen [Tue, 26 May 2020 18:36:26 +0000 (14:36 -0400)]
xfs_quota: allow individual timer extension

The only grace period which can be set via xfs_quota today is for id 0,
i.e. the default grace period for all users.  However, setting an
individual grace period is useful; for example:

 Alice has a soft quota of 100 inodes, and a hard quota of 200 inodes
 Alice uses 150 inodes, and enters a short grace period
 Alice really needs to use those 150 inodes past the grace period
 The administrator extends Alice's grace period until next Monday

vfs quota users such as ext4 can do this today, with setquota -T

xfs_quota can now accept an optional user id or name (symmetric with
how warn limits are specified), in which case that user's grace period
is extended to expire the given amount of time from now().

To maintain compatibility with old command lines, if none of
[-d|id|name] are specified, default limits are set as before.

(kernelspace requires updates to enable all this as well.)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_quota: refactor code to generate id from name
Eric Sandeen [Tue, 26 May 2020 18:36:04 +0000 (14:36 -0400)]
xfs_quota: refactor code to generate id from name

There's boilerplate for setting limits and warnings, where we have
a case statement for each of the 3 quota types, and from there call
3 different functions to configure each of the 3 types, each of which
calls its own version of id to string function...

Refactor this so that the main function can call a generic id to string
conversion routine, and then call a common action.  This save a lot of
LOC.

I was looking at allowing xfs to bump out individual grace periods like
setquota can do, and this refactoring allows us to add new actions like
that without copying all the boilerplate again.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_repair: fix progress reporting
Eric Sandeen [Tue, 26 May 2020 18:36:04 +0000 (14:36 -0400)]
xfs_repair: fix progress reporting

The Fixes: commit tried to avoid a segfault in case the progress timer
went off before the first message type had been set up, but this
had the net effect of short-circuiting the pthread start routine,
and so the timer didn't get set up at all and we lost all fine-grained
progress reporting.

The initial problem occurred when log zeroing took more time than the
timer interval.

So, make a new log zeroing progress item and initialize it when we first
set up the timer thread, to be sure that if the timer goes off while we
are still zeroing the log, it will be initialized and correct.

(We can't offer fine-grained status on log zeroing, so it'll go from
zero to $LOGBLOCKS with nothing in between, but it's unlikely that log
zeroing will take so long that this really matters.)

Reported-by: Leonardo Vaz <lvaz@redhat.com>
Fixes: 7f2d6b811755 ("xfs_repair: avoid segfault if reporting progre...")
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Donald Douwsma <ddouwsma@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agodebian: replace libreadline with libedit
Darrick J. Wong [Tue, 26 May 2020 18:36:03 +0000 (14:36 -0400)]
debian: replace libreadline with libedit

Now that upstream has dropped libreadline support entirely, switch the
debian package over to libedit.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_db: fix rdbmap_boundscheck
Darrick J. Wong [Tue, 26 May 2020 18:36:03 +0000 (14:36 -0400)]
xfs_db: fix rdbmap_boundscheck

This predicate should check the a rt block number against number of
rtblocks, not the number of AG blocks.  Ooops.

Fixes: 7161cd21b3ed ("xfs_db: bounds-check access to the dbmap array")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_db: don't crash if el_gets returns null
Darrick J. Wong [Tue, 26 May 2020 18:36:03 +0000 (14:36 -0400)]
xfs_db: don't crash if el_gets returns null

el_gets returns NULL if it fails to read any characters (due to EOF or
errors occurred).  strdup will crash if it is fed a NULL string, so
check the return value to avoid segfaulting.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoscrub: remove xfs_ prefixes from various function
Christoph Hellwig [Tue, 26 May 2020 18:36:03 +0000 (14:36 -0400)]
scrub: remove xfs_ prefixes from various function

Don't prefix tool private functions.  We'll use the xfs_* namespace for
the shared libxfs functions soon, and want to be able to easily verify
that the callers handle return negative errors for them.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_db: fix crc invalidation segfault
Anthony Iliopoulos [Tue, 26 May 2020 18:35:51 +0000 (14:35 -0400)]
xfs_db: fix crc invalidation segfault

The nowrite_ops var is declared within nested block scope but used
outside that scope, causing xfs_db to crash while trying to defererence
the verify_write pointer. Fix it by lifting the declaration to the outer
scope, where it is accessed.

Fixes: b64af2c48220c8 ("xfs_db: add crc manipulation commands")
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs-apply: use git am instead of patch
Christoph Hellwig [Mon, 11 May 2020 20:48:55 +0000 (16:48 -0400)]
libxfs-apply: use git am instead of patch

If neither guilt or stgit are used default to git am instead of patch
so that all the commit information is properly propagated.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Sandeen <sandeen@sandeen.net>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agometadump: small cleanup for process_inode
Christoph Hellwig [Mon, 11 May 2020 20:48:45 +0000 (16:48 -0400)]
metadump: small cleanup for process_inode

Shorten a conditional to a single line.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agorepair: cleanup build_agf_agfl
Christoph Hellwig [Mon, 11 May 2020 20:48:40 +0000 (16:48 -0400)]
repair: cleanup build_agf_agfl

No need to have two variables for the AGFL block number array.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agodb: ensure that create and replace are exclusive in attr_set_f
Christoph Hellwig [Mon, 11 May 2020 20:48:25 +0000 (16:48 -0400)]
db: ensure that create and replace are exclusive in attr_set_f

Clear the other flag when applying the create or replace option,
as the low-level libxfs can't handle both at the same time.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agodb: validate name and namelen in attr_set_f and attr_remove_f
Christoph Hellwig [Mon, 11 May 2020 19:00:18 +0000 (15:00 -0400)]
db: validate name and namelen in attr_set_f and attr_remove_f

libxfs has stopped validating these parameters internally, so do it
in the xfs_db commands.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agodb: cleanup attr_set_f and attr_remove_f
Christoph Hellwig [Mon, 11 May 2020 18:59:37 +0000 (14:59 -0400)]
db: cleanup attr_set_f and attr_remove_f

Don't use local variables for information that is set in the da_args
structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agodb: add a comment to agfl_crc_flds
Christoph Hellwig [Sat, 9 May 2020 19:51:59 +0000 (15:51 -0400)]
db: add a comment to agfl_crc_flds

Explain the bno field that is not actually part of the structure
anymore.

Signed-off-by: Christoph Hellwig <hch@lst.de>
[sandeen: tweak the commentper djwong's suggestion]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agodb: fix a comment in scan_freelist
Christoph Hellwig [Sat, 9 May 2020 17:29:37 +0000 (13:29 -0400)]
db: fix a comment in scan_freelist

XFS_BUF_TO_AGFL_BNO has been renamed to open coded xfs_buf_to_agfl_bno.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: use tabs instead of spaces in div_u64
Christoph Hellwig [Sat, 9 May 2020 17:29:37 +0000 (13:29 -0400)]
libxfs: use tabs instead of spaces in div_u64

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_db: bounds-check access to the dbmap array
Darrick J. Wong [Sat, 9 May 2020 17:11:59 +0000 (13:11 -0400)]
xfs_db: bounds-check access to the dbmap array

Try to check the array boundaries of the dbmap array so that we don't
just segfault.

Found by fuzzing xfs/358 with recs[1].blockcount = ones.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agofind_api_violations: fix sed expression
Darrick J. Wong [Sat, 9 May 2020 17:11:42 +0000 (13:11 -0400)]
find_api_violations: fix sed expression

Apparently, GNU grep version 3.4 is pickier about requiring '(' to be
escaped inside range expressions.  This causes a regression in xfs/437,
so fix it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
[sandeen: note grep version not OS version]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxcmd: don't crash if el_gets returns null
Darrick J. Wong [Sat, 9 May 2020 17:09:44 +0000 (13:09 -0400)]
libxcmd: don't crash if el_gets returns null

el_gets returns NULL if it fails to read any characters (due to EOF or
errors occurred).  strdup will crash if it is fed a NULL string, so
check the return value to avoid segfaulting.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_io: copy_range can take up to 8 arguments
Eric Sandeen [Sat, 9 May 2020 17:09:38 +0000 (13:09 -0400)]
xfs_io: copy_range can take up to 8 arguments

If we use the "-f N" variant for the source file specification, we will
have up to 8 total arguments.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: remove xfs_dir_ops
Christoph Hellwig [Sat, 9 May 2020 17:09:31 +0000 (13:09 -0400)]
xfsprogs: remove xfs_dir_ops

The xfs_dir_ops infrastructure has been removed a while ago.  Remove
a few always empty members in xfsprogs to finish the cleanup.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: remove libreadline support
Christoph Hellwig [Sat, 9 May 2020 17:08:44 +0000 (13:08 -0400)]
xfsprogs: remove libreadline support

libreadline has been relicensed to GPLv3 and thus incompatible to
xfsprogs many years ago, and all the distros have dropped or are
in the stages of dropping the last GPLv2 version.  As the BSD
licensed libeditline provides the same functionality there is no
need to keep the obsolete libreadline support around.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: Release v5.7.0-rc0 libxfs-5.7-sync v5.7.0-rc0
Eric Sandeen [Thu, 7 May 2020 18:10:37 +0000 (14:10 -0400)]
xfsprogs: Release v5.7.0-rc0

Update all the necessary files for a 5.7.0-rc0 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: validate the realtime geometry in xfs_validate_sb_common
Darrick J. Wong [Sat, 2 May 2020 03:33:23 +0000 (23:33 -0400)]
xfs: validate the realtime geometry in xfs_validate_sb_common

Source kernel commit: f8e566c0f5e1fd8de33ccec6eb1ff815cd4b0dc3

Validate the geometry of the realtime geometry when we mount the
filesystem, so that we don't abruptly shut down the filesystem later on.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove the di_version field from struct icdinode
Christoph Hellwig [Sat, 2 May 2020 03:33:22 +0000 (23:33 -0400)]
xfs: remove the di_version field from struct icdinode

Source kernel commit: 6471e9c5e7a109a952be8e3e80b8d9e262af239d

We know the version is 3 if on a v5 file system.   For earlier file
systems formats we always upgrade the remaining v1 inodes to v2 and
thus only use v2 inodes.  Use the xfs_sb_version_has_large_dinode
helper to check if we deal with small or large dinodes, and thus
remove the need for the di_version field in struct icdinode.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: only check the superblock version for dinode size calculation
Christoph Hellwig [Fri, 1 May 2020 21:37:10 +0000 (17:37 -0400)]
xfs: only check the superblock version for dinode size calculation

Source kernel commit: e9e2eae89ddb658ea332295153fdca78c12c1e0d

The size of the dinode structure is only dependent on the file system
version, so instead of checking the individual inode version just use
the newly added xfs_sb_version_has_large_dinode helper, and simplify
various calling conventions.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: add a new xfs_sb_version_has_v3inode helper
Christoph Hellwig [Fri, 1 May 2020 21:37:10 +0000 (17:37 -0400)]
xfs: add a new xfs_sb_version_has_v3inode helper

Source kernel commit: b81b79f4eda2ea98ae5695c0b6eb384c8d90b74d

Add a new wrapper to check if a file system supports the v3 inode format
with a larger dinode core.  Previously we used xfs_sb_version_hascrc for
that, which is technically correct but a little confusing to read.

Also move xfs_dinode_good_version next to xfs_sb_version_has_v3inode
so that we have one place that documents the superblock version to
inode version relationship.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: add support for rmap btree staging cursors
Darrick J. Wong [Fri, 1 May 2020 21:37:10 +0000 (17:37 -0400)]
xfs: add support for rmap btree staging cursors

Source kernel commit: 59d677127cf1543b2978aca3be8c8395f3a17973

Add support for btree staging cursors for the rmap btrees.  This is
needed both for online repair and also to convert xfs_repair to use
btree bulk loading.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: add support for refcount btree staging cursors
Darrick J. Wong [Fri, 1 May 2020 21:37:10 +0000 (17:37 -0400)]
xfs: add support for refcount btree staging cursors

Source kernel commit: 56e98164ffea2a9ee577e5e4f368c6d5182ed8eb

Add support for btree staging cursors for the refcount btrees.  This
is needed both for online repair and also to convert xfs_repair to use
btree bulk loading.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: add support for inode btree staging cursors
Darrick J. Wong [Fri, 1 May 2020 21:37:10 +0000 (17:37 -0400)]
xfs: add support for inode btree staging cursors

Source kernel commit: c29ce8f48e219d10644f402ec5d738cadf20666e

Add support for btree staging cursors for the inode btrees.  This
is needed both for online repair and also to convert xfs_repair to use
btree bulk loading.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: add support for free space btree staging cursors
Darrick J. Wong [Fri, 1 May 2020 21:37:10 +0000 (17:37 -0400)]
xfs: add support for free space btree staging cursors

Source kernel commit: e6eb33d905c287eb07ee1c69d38871276db154dd

Add support for btree staging cursors for the free space btrees.  This
is needed both for online repair and also to convert xfs_repair to use
btree bulk loading.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: support bulk loading of staged btrees
Darrick J. Wong [Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)]
xfs: support bulk loading of staged btrees

Source kernel commit: 60e3d7070749554227fbb636a69a4282ab930f86

Add a new btree function that enables us to bulk load a btree cursor.
This will be used by the upcoming online repair patches to generate new
btrees.  This avoids the programmatic inefficiency of calling
xfs_btree_insert in a loop (which generates a lot of log traffic) in
favor of stamping out new btree blocks with ordered buffers, and then
blocks in a single transaction commit.

The design of this new generic code is based off the btree rebuilding
code in xfs_repair's phase 5 code, with the explicit goal of enabling us
to share that code between scrub and repair.  It has the additional
feature of being able to control btree block loading factors.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: introduce fake roots for inode-rooted btrees
Darrick J. Wong [Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)]
xfs: introduce fake roots for inode-rooted btrees

Source kernel commit: 349e1c0380dbb7f552e4ea61b479c293eb076b3f

Create an in-core fake root for inode-rooted btree types so that callers
can generate a whole new btree using the upcoming btree bulk load
function without making the new tree accessible from the rest of the
filesystem.  It is up to the individual btree type to provide a function
to create a staged cursor (presumably with the appropriate callouts to
update the fakeroot) and then commit the staged root back into the
filesystem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: introduce fake roots for ag-rooted btrees
Darrick J. Wong [Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)]
xfs: introduce fake roots for ag-rooted btrees

Source kernel commit: e06536a692e032470130af5b2136b519595809da

Create an in-core fake root for AG-rooted btree types so that callers
can generate a whole new btree using the upcoming btree bulk load
function without making the new tree accessible from the rest of the
filesystem.  It is up to the individual btree type to provide a function
to create a staged cursor (presumably with the appropriate callouts to
update the fakeroot) and then commit the staged root back into the
filesystem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: fix incorrect test in xfs_alloc_ag_vextent_lastblock
Darrick J. Wong [Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)]
xfs: fix incorrect test in xfs_alloc_ag_vextent_lastblock

Source kernel commit: 77ca1eed5a7d2bf0905562eb1a15aac76bc19fe4

When I lifted the code in xfs_alloc_ag_vextent_lastblock out of a loop,
I forgot to convert all the accesses to len to be pointer dereferences.

Coverity-id: 1457918
Fixes: 5113f8ec3753ed ("xfs: clean up weird while loop in xfs_alloc_ag_vextent_near")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: xfs_dabuf_map should return ENOMEM when map allocation fails
Darrick J. Wong [Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)]
xfs: xfs_dabuf_map should return ENOMEM when map allocation fails

Source kernel commit: faf8ee8476c19b30fd16079ad616b2b0f56eaff4

If the xfs_buf_map array allocation in xfs_dabuf_map fails for whatever
reason, we bail out with error code zero.  This will confuse callers, so
make sure that we return ENOMEM.  Allocation failure should never happen
with the small size of the array, but code defensively anyway.

Fixes: 45feef8f50b94d ("xfs: refactor xfs_dabuf_map")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: make the btree ag cursor private union anonymous
Dave Chinner [Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)]
xfs: make the btree ag cursor private union anonymous

Source kernel commit: c4aa10d041968f55f00fe8ca768b6f45f4066a69

This is much less widely used than the bc_private union was, so this
is done as a single patch. The named union xfs_btree_cur_private
goes away and is embedded into the struct xfs_btree_cur_ag as an
anonymous union, and the code is modified via this script:

$ sed -i 's/priv\.\([abt|refc]\)/\1/g' fs/xfs/*[ch] fs/xfs/*/*[ch]

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: make the btree cursor union members named structure
Dave Chinner [Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)]
xfs: make the btree cursor union members named structure

Source kernel commit: 68422d90dad4fe98f99d6e414aeec9a58d5185d5

we need to name the btree cursor private structures to be able
to pull them out of the deeply nested structure definition they are
in now.

Based on code extracted from a patchset by Darrick Wong.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: make btree cursor private union anonymous
Dave Chinner [Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)]
xfs: make btree cursor private union anonymous

Source kernel commit: 352890735e52343b1690f6d5d32224e2aa88a56a

Rename the union and it's internal structures to the new name and
remove the temporary defines that facilitated the change.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: rename btree cursor private btree member flags
Dave Chinner [Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)]
xfs: rename btree cursor private btree member flags

Source kernel commit: 8ef547976a18e3d672194d8c944c19b345ef6bfc

BPRV is not longer appropriate because bc_private is going away.
Script:

$ sed -i 's/BTCUR_BPRV/BTCUR_BMBT/g' fs/xfs/*[ch] fs/xfs/*/*[ch]

With manual cleanup to the definitions in fs/xfs/libxfs/xfs_btree.h

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[darrick: change "BC_BT" to "BTCUR_BMBT", fix subject line typo]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: convert btree cursor inode-private member names
Dave Chinner [Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)]
xfs: convert btree cursor inode-private member names

Source kernel commit: 92219c292af8ddfb64d75bdffcbdd9baf80ac0aa

bc_private.b -> bc_ino conversion via script:

$ sed -i 's/bc_private\.b/bc_ino/g' fs/xfs/*[ch] fs/xfs/*/*[ch]

And then revert the change to the bc_ino #define in
fs/xfs/libxfs/xfs_btree.h manually.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[darrick: tweak the subject line slightly]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: convert btree cursor ag-private member name
Dave Chinner [Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)]
xfs: convert btree cursor ag-private member name

Source kernel commit: 576af7322807601d5ef366597645a69471570e10

bc_private.a -> bc_ag conversion via script:

`sed -i 's/bc_private\.a/bc_ag/g' fs/xfs/*[ch] fs/xfs/*/*[ch]`

And then revert the change to the bc_ag #define in
fs/xfs/libxfs/xfs_btree.h manually.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: introduce new private btree cursor names
Dave Chinner [Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)]
xfs: introduce new private btree cursor names

Source kernel commit: 7cace18ab576ef65d16498d3a9e2170fff5f5c93

Just the defines of the new names - the conversion will be in
scripted commits after this.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[darrick: change "bc_bt" to "bc_ino"]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: check owner of dir3 blocks
Darrick J. Wong [Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)]
xfs: check owner of dir3 blocks

Source kernel commit: 1b2c1a63b678d63e9c98314d44413f5af79c9c80

Check the owner field of dir3 block headers.  If it's corrupt, release
the buffer and return EFSCORRUPTED.  All callers handle this properly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: check owner of dir3 data blocks
Darrick J. Wong [Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)]
xfs: check owner of dir3 data blocks

Source kernel commit: a10c21ed5d5241d11cf1d5a4556730840572900b

Check the owner field of dir3 data block headers.  If it's corrupt,
release the buffer and return EFSCORRUPTED.  All callers handle this
properly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: check owner of dir3 free blocks
Darrick J. Wong [Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)]
xfs: check owner of dir3 free blocks

Source kernel commit: 6fb5aac73310d030be13eb3481fdb7c7cc7c0f00

Check the owner field of dir3 free block headers and reject the metadata
if there's something wrong with it.

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>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: don't ever return a stale pointer from __xfs_dir3_free_read
Darrick J. Wong [Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)]
xfs: don't ever return a stale pointer from __xfs_dir3_free_read

Source kernel commit: 1cb5deb5bc095c070c09a4540c45f9c9ba24be43

If we decide that a directory free block is corrupt, we must take care
not to leak a buffer pointer to the caller.  After xfs_trans_brelse
returns, the buffer can be freed or reused, which means that we have to
set *bpp back to NULL.

Callers are supposed to notice the nonzero return value and not use the
buffer pointer, but we should code more defensively, even if all current
callers handle this situation correctly.

Fixes: de14c5f541e7 ("xfs: verify free block header fields")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: fix buffer corruption reporting when xfs_dir3_free_header_check fails
Darrick J. Wong [Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)]
xfs: fix buffer corruption reporting when xfs_dir3_free_header_check fails

Source kernel commit: ce99494c9699df58b31d0a839e957f86cd58c755

xfs_verifier_error is supposed to be called on a corrupt metadata buffer
from within a buffer verifier function, whereas xfs_buf_mark_corrupt
is the function to be called when a piece of code has read a buffer and
catches something that a read verifier cannot.  The first function sets
b_error anticipating that the low level buffer handling code will see
the nonzero b_error and clear XBF_DONE on the buffer, whereas the second
function does not.

Since xfs_dir3_free_header_check examines fields in the dir free block
header that require more context than can be provided to read verifiers,
we must call xfs_buf_mark_corrupt when it finds a problem.

Switching the calls has a secondary effect that we no longer corrupt the
buffer state by setting b_error and leaving XBF_DONE set.  When /that/
happens, we'll trip over various state assertions (most commonly the
b_error check in xfs_buf_reverify) on a subsequent attempt to read the
buffer.

Fixes: bc1a09b8e334bf5f ("xfs: refactor verifier callers to print address of failing 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>
5 years agoxfs: xfs_buf_corruption_error should take __this_address
Darrick J. Wong [Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)]
xfs: xfs_buf_corruption_error should take __this_address

Add a xfs_failaddr_t parameter to this function so that callers can
potentially pass in (and therefore report) the exact point in the code
where we decided that a metadata buffer was corrupt.  This enables us to
wire it up to checking functions that have to run outside of verifiers.

Source kernel commit: e83cf875d67a6cb9ddfaa8b45d2fa93d12b5c66f

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: add a function to deal with corrupt buffers post-verifiers
Darrick J. Wong [Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)]
xfs: add a function to deal with corrupt buffers post-verifiers

Source kernel commit: 8d57c21600a514d7a9237327c2496ae159bab5bb

Add a helper function to get rid of buffers that we have decided are
corrupt after the verifiers have run.  This function is intended to
handle metadata checks that can't happen in the verifiers, such as
inter-block relationship checking.  Note that we now mark the buffer
stale so that it will not end up on any LRU and will be purged on
release.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: fix xfs_rmap_has_other_keys usage of ECANCELED
Darrick J. Wong [Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)]
xfs: fix xfs_rmap_has_other_keys usage of ECANCELED

Source kernel commit: a71e4228e6f2a4fe6519d8ed081d0a164967fa31

In e7ee96dfb8c26, we converted all ITER_ABORT users to use ECANCELED
instead, but we forgot to teach xfs_rmap_has_other_keys not to return
that magic value to callers.  Fix it now by using ECANCELED both to
abort the iteration and to signal that we found another reverse mapping.
This enables us to drop the separate boolean flag.

Fixes: e7ee96dfb8c26 ("xfs: remove all *_ITER_ABORT values")
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>
5 years agoxfs: remove XFS_BUF_TO_SBP
Christoph Hellwig [Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)]
xfs: remove XFS_BUF_TO_SBP

Source kernel commit: 3e6e8afd3abb745871ee215738a899a495c54a66

Just dereference bp->b_addr directly and make the code a little
simpler and more clear.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-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>
5 years agoxfs: remove XFS_BUF_TO_AGF
Christoph Hellwig [Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)]
xfs: remove XFS_BUF_TO_AGF

Source kernel commit: 9798f615ad2be48466a01c44ad2257ba64ab03bd

Just dereference bp->b_addr directly and make the code a little
simpler and more clear.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-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>
5 years agoxfs: remove XFS_BUF_TO_AGI
Christoph Hellwig [Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)]
xfs: remove XFS_BUF_TO_AGI

Source kernel commit: 370c782b98436bb3f9d14a7394ab126cdbeac233

Just dereference bp->b_addr directly and make the code a little
simpler and more clear.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-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>
5 years agoxfs: remove the xfs_agfl_t typedef
Christoph Hellwig [Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)]
xfs: remove the xfs_agfl_t typedef

Source kernel commit: 4b97510859b22e0db5edf104096af1132daeea9a

There is just a single user left, so remove it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-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>
5 years agoxfs: remove the agfl_bno member from struct xfs_agfl
Christoph Hellwig [Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)]
xfs: remove the agfl_bno member from struct xfs_agfl

Source kernel commit: 183606d82446110e23987d4b693f3d3fc300bd82

struct xfs_agfl is a header in front of the AGFL entries that exists
for CRC enabled file systems.  For not CRC enabled file systems the AGFL
is simply a list of agbno.  Make the CRC case similar to that by just
using the list behind the new header.  This indirectly solves a problem
with modern gcc versions that warn about taking addresses of packed
structures (and we have to pack the AGFL given that gcc rounds up
structure sizes).  Also replace the helper macro to get from a buffer
with an inline function in xfs_alloc.h to make the code easier to
read.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-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>
5 years agoxfs: embedded the attrlist cursor into struct xfs_attr_list_context
Christoph Hellwig [Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)]
xfs: embedded the attrlist cursor into struct xfs_attr_list_context

Source kernel commit: e3a19cdea84a42d44ef42ff8b5459c903992bbf2

The attrlist cursor only exists as part of an attr list context, so
embedd the structure instead of pointing to it.  Also give it a proper
xfs_ prefix and remove the obsolete typedef.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove XFS_DA_OP_INCOMPLETE
Christoph Hellwig [Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)]
xfs: remove XFS_DA_OP_INCOMPLETE

Source kernel commit: 254f800f810415cce05872c88e9ef797d81f4375

Now that we use the on-disk flags field also for the interface to the
lower level attr routines we can use the XFS_ATTR_INCOMPLETE definition
from the on-disk format directly instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: clean up the attr flag confusion
Christoph Hellwig [Fri, 1 May 2020 21:37:04 +0000 (17:37 -0400)]
xfs: clean up the attr flag confusion

Source kernel commit: d5f0f49a9bdd4206e941282dfd323c436331659b

The ATTR_* flags have a long IRIX history, where they a userspace
interface, the on-disk format and an internal interface.  We've split
out the on-disk interface to the XFS_ATTR_* values, but despite (or
because?) of that the flag have still been a mess.  Switch the
internal interface to pass the on-disk XFS_ATTR_* flags for the
namespace and the Linux XATTR_* flags for the actual flags instead.
The ATTR_* values that are actually used are move to xfs_fs.h with a
new XFS_IOC_* prefix to not conflict with the userspace version that
has the same name and must have the same value.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: clean up the ATTR_REPLACE checks
Christoph Hellwig [Fri, 1 May 2020 21:01:33 +0000 (17:01 -0400)]
xfs: clean up the ATTR_REPLACE checks

Source kernel commit: f3e93d95feef7655a980be83a3b1830e8e1711a1

Remove superflous braces, elses after return statements and use a goto
label to merge common error handling.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: rename xfs_attr_list_int to xfs_attr_list
Christoph Hellwig [Fri, 1 May 2020 21:01:33 +0000 (17:01 -0400)]
xfs: rename xfs_attr_list_int to xfs_attr_list

Source kernel commit: 17e1dd83ea21dc7aaf44590e5947338351b99bd0

The version taking the context structure is the main interface to list
attributes, so drop the _int postfix.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: move the legacy xfs_attr_list to xfs_ioctl.c
Christoph Hellwig [Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)]
xfs: move the legacy xfs_attr_list to xfs_ioctl.c

Source kernel commit: 3e7a779937a225336922ce48fe7a4a609c7db3e2

The old xfs_attr_list code is only used by the attrlist by handle
ioctl.  Move it to xfs_ioctl.c with its user.  Also move the
attrlist and attrlist_ent structure to xfs_fs.h, as they are exposed
user ABIs.  They are used through libattr headers with the same name
by at least xfsdump.  Also document this relation so that it doesn't
require a research project to figure out.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove the unused ATTR_ENTRY macro
Christoph Hellwig [Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)]
xfs: remove the unused ATTR_ENTRY macro

Source kernel commit: fe960087121a9fccaead3de44c64fcf356f3410d

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: cleanup struct xfs_attr_list_context
Christoph Hellwig [Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)]
xfs: cleanup struct xfs_attr_list_context

Source kernel commit: a9c8c69b496117912162cdc38dcae953a07b87f7

Replace the alist char pointer with a void buffer given that different
callers use it in different ways.  Use the chance to remove the typedef
and reduce the indentation of the struct definition so that it doesn't
overflow 80 char lines all over.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: factor out a xfs_attr_match helper
Christoph Hellwig [Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)]
xfs: factor out a xfs_attr_match helper

Source kernel commit: 377f16ac67237c8cda05daf363bcbea95212b000

Factor out a helper that compares an on-disk attr vs the name, length and
flags specified in struct xfs_da_args.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: replace ATTR_KERNOTIME with XFS_DA_OP_NOTIME
Christoph Hellwig [Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)]
xfs: replace ATTR_KERNOTIME with XFS_DA_OP_NOTIME

Source kernel commit: 1d7330199400404512b44734d3c792aa4ad82322

op_flags with the XFS_DA_OP_* flags is the usual place for in-kernel
only flags, so move the notime flag there.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove ATTR_ALLOC and XFS_DA_OP_ALLOCVAL
Christoph Hellwig [Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)]
xfs: remove ATTR_ALLOC and XFS_DA_OP_ALLOCVAL

Source kernel commit: d49db18b247d8e7e16f2178cd713f4621d1d7ade

Use a NULL args->value as the indicator to lazily allocate a buffer
instead, and let the caller always free args->value instead of
duplicating the cleanup.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove ATTR_KERNOVAL
Christoph Hellwig [Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)]
xfs: remove ATTR_KERNOVAL

Source kernel commit: e513e25c380ab98d401714077c8b8ff4dae9f98b

We can just pass down the Linux convention of a zero valuelen to just
query for the existance of an attribute to the low-level code instead.
The use in the legacy xfs_attr_list code only used by the ioctl
interface was already dead code, as the callers check that the flag
is not present.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove the xfs_inode argument to xfs_attr_get_ilocked
Christoph Hellwig [Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)]
xfs: remove the xfs_inode argument to xfs_attr_get_ilocked

Source kernel commit: c36f533f14075fee35f8beeb1729d0975fb2e137

The inode can easily be derived from the args structure.  Also
don't bother with else statements after early returns.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: pass an initialized xfs_da_args to xfs_attr_get
Christoph Hellwig [Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)]
xfs: pass an initialized xfs_da_args to xfs_attr_get

Source kernel commit: e5171d7e989479fe6298f8aedbd94e0aec23f5fc

Instead of converting from one style of arguments to another in
xfs_attr_set, pass the structure from higher up in the call chain.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: pass an initialized xfs_da_args structure to xfs_attr_set
Christoph Hellwig [Fri, 1 May 2020 21:01:30 +0000 (17:01 -0400)]
xfs: pass an initialized xfs_da_args structure to xfs_attr_set

Source kernel commit: a25446224353a773c7f4ba9ee5ae137515204efe

Instead of converting from one style of arguments to another in
xfs_attr_set, pass the structure from higher up in the call chain.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: turn xfs_da_args.value into a void pointer
Christoph Hellwig [Wed, 29 Apr 2020 20:08:34 +0000 (16:08 -0400)]
xfs: turn xfs_da_args.value into a void pointer

Source kernel commit: ead189adb8abebc1555bf2776954131ba00c7619

The xattr values are blobs and should not be typed.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove the MAXNAMELEN check from xfs_attr_args_init
Christoph Hellwig [Wed, 29 Apr 2020 20:08:34 +0000 (16:08 -0400)]
xfs: remove the MAXNAMELEN check from xfs_attr_args_init

Source kernel commit: 4df28c64e4388ac5fa59cd58f9fd6592aae533a2

All the callers already check the length when allocating the
in-kernel xattrs buffers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove the name == NULL check from xfs_attr_args_init
Christoph Hellwig [Wed, 29 Apr 2020 20:08:34 +0000 (16:08 -0400)]
xfs: remove the name == NULL check from xfs_attr_args_init

Source kernel commit: 79f2280b9bfd54aa37b3fa4a80b0037bd29b4f0e

All callers provide a valid name pointer, remove the redundant check.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: merge xfs_attr_remove into xfs_attr_set
Christoph Hellwig [Wed, 29 Apr 2020 20:08:34 +0000 (16:08 -0400)]
xfs: merge xfs_attr_remove into xfs_attr_set

Source kernel commit: 0eb81a5f5c34429f0d86329260b3b07e2d4c5e22

The Linux xattr and acl APIs use a single call for set and remove.
Modify the high-level XFS API to match that and let xfs_attr_set handle
removing attributes as well.  With a little bit of reordering this
removes a lot of code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove the ATTR_INCOMPLETE flag
Christoph Hellwig [Wed, 29 Apr 2020 20:08:34 +0000 (16:08 -0400)]
xfs: remove the ATTR_INCOMPLETE flag

Source kernel commit: 5e81357435cc0ef6b2ba4a9dcfca52be4e471cf5

Replace the ATTR_INCOMPLETE flag with a new boolean field in struct
xfs_attr_list_context.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: open code insert range extent split helper
Brian Foster [Wed, 29 Apr 2020 20:08:34 +0000 (16:08 -0400)]
xfs: open code insert range extent split helper

Source kernel commit: b73df17e4c5ba977205253fb7ef54267717a3cba

The insert range operation currently splits the extent at the target
offset in a separate transaction and lock cycle from the one that
shifts extents. In preparation for reworking insert range into an
atomic operation, lift the code into the caller so it can be easily
condensed to a single rolling transaction and lock cycle and
eliminate the helper. No functional changes.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: fix an undefined behaviour in _da3_path_shift
Qian Cai [Wed, 29 Apr 2020 20:08:34 +0000 (16:08 -0400)]
xfs: fix an undefined behaviour in _da3_path_shift

Source kernel commit: 4982bff1ace1196843f55536fcd4cc119738fe39

In xfs_da3_path_shift() "blk" can be assigned to state->path.blk[-1] if
state->path.active is 1 (which is a valid state) when it tries to add an
entry to a single dir leaf block and then to shift forward to see if
there's a sibling block that would be a better place to put the new
entry. This causes a UBSAN warning given negative array indices are
undefined behavior in C. In practice the warning is entirely harmless
given that "blk" is never dereferenced in this case, but it is still
better to fix up the warning and slightly improve the code.

UBSAN: Undefined behaviour in fs/xfs/libxfs/xfs_da_btree.c:1989:14
index -1 is out of range for type 'xfs_da_state_blk_t [5]'
Call trace:
dump_backtrace+0x0/0x2c8
show_stack+0x20/0x2c
dump_stack+0xe8/0x150
__ubsan_handle_out_of_bounds+0xe4/0xfc
xfs_da3_path_shift+0x860/0x86c [xfs]
xfs_da3_node_lookup_int+0x7c8/0x934 [xfs]
xfs_dir2_node_addname+0x2c8/0xcd0 [xfs]
xfs_dir_createname+0x348/0x38c [xfs]
xfs_create+0x6b0/0x8b4 [xfs]
xfs_generic_create+0x12c/0x1f8 [xfs]
xfs_vn_mknod+0x3c/0x4c [xfs]
xfs_vn_create+0x34/0x44 [xfs]
do_last+0xd4c/0x10c8
path_openat+0xbc/0x2f4
do_filp_open+0x74/0xf4
do_sys_openat2+0x98/0x180
__arm64_sys_openat+0xf8/0x170
do_el0_svc+0x170/0x240
el0_sync_handler+0x150/0x250
el0_sync+0x164/0x180

Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Qian Cai <cai@lca.pw>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove the kuid/kgid conversion wrappers
Christoph Hellwig [Wed, 29 Apr 2020 20:08:34 +0000 (16:08 -0400)]
xfs: remove the kuid/kgid conversion wrappers

Source kernel commit: ba8adad5d036733d240fa8a8f4d055f3d4490562

Remove the XFS wrappers for converting from and to the kuid/kgid types.
Mostly this means switching to VFS i_{u,g}id_{read,write} helpers, but
in a few spots the calls to the conversion functions is open coded.
To match the use of sb->s_user_ns in the helpers and other file systems,
sb->s_user_ns is also used in the quota code.  The ACL code already does
the conversion in a grotty layering violation in the VFS xattr code,
so it keeps using init_user_ns for the identity mapping.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove the icdinode di_uid/di_gid members
Christoph Hellwig [Wed, 29 Apr 2020 20:08:30 +0000 (16:08 -0400)]
xfs: remove the icdinode di_uid/di_gid members

Source kernel commit: 542951592c99ff7b15c050954c051dd6dd6c0f97

Use the Linux inode i_uid/i_gid members everywhere and just convert
from/to the scalar value when reading or writing the on-disk inode.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: ensure that the inode uid/gid match values match the icdinode ones
Christoph Hellwig [Wed, 29 Apr 2020 18:10:49 +0000 (14:10 -0400)]
xfs: ensure that the inode uid/gid match values match the icdinode ones

Source kernel commit: 3d8f2821502d0b60bac2789d0bea951fda61de0c

Instead of only synchronizing the uid/gid values in xfs_setup_inode,
ensure that they always match to prepare for removing the icdinode
fields.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: add agf freeblocks verify in xfs_agf_verify
Zheng Bin [Wed, 29 Apr 2020 18:10:49 +0000 (14:10 -0400)]
xfs: add agf freeblocks verify in xfs_agf_verify

Source kernel commit: d0c7feaf87678371c2c09b3709400be416b2dc62

We recently used fuzz(hydra) to test XFS and automatically generate
tmp.img(XFS v5 format, but some metadata is wrong)

xfs_repair information(just one AG):
agf_freeblks 0, counted 3224 in ag 0
agf_longest 536874136, counted 3224 in ag 0
sb_fdblocks 613, counted 3228

Test as follows:
mount tmp.img tmpdir
cp file1M tmpdir
sync

In 4.19-stable, sync will stuck, the reason is:
xfs_mountfs
xfs_check_summary_counts
if ((!xfs_sb_version_haslazysbcount(&mp->m_sb) ||
XFS_LAST_UNMOUNT_WAS_CLEAN(mp)) &&
!xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS))
return 0;  -->just return, incore sb_fdblocks still be 613
xfs_initialize_perag_data

cp file1M tmpdir -->ok(write file to pagecache)
sync -->stuck(write pagecache to disk)
xfs_map_blocks
xfs_iomap_write_allocate
while (count_fsb != 0) {
nimaps = 0;
while (nimaps == 0) { --> endless loop
nimaps = 1;
xfs_bmapi_write(..., &nimaps) --> nimaps becomes 0 again
xfs_bmapi_write
xfs_bmap_alloc
xfs_bmap_btalloc
xfs_alloc_vextent
xfs_alloc_fix_freelist
xfs_alloc_space_available -->fail(agf_freeblks is 0)

In linux-next, sync not stuck, cause commit c2b3164320b5 ("xfs:
use the latest extent at writeback delalloc conversion time") remove
the above while, dmesg is as follows:
[   55.250114] XFS (loop0): page discard on page ffffea0008bc7380, inode 0x1b0c, offset 0.

Users do not know why this page is discard, the better soultion is:
1. Like xfs_repair, make sure sb_fdblocks is equal to counted
(xfs_initialize_perag_data did this, who is not called at this mount)
2. Add agf verify, if fail, will tell users to repair

This patch use the second soultion.

Signed-off-by: Zheng Bin <zhengbin13@huawei.com>
Signed-off-by: Ren Xudong <renxudong1@huawei.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: Release v5.6.0 master v5.6.0
Eric Sandeen [Tue, 14 Apr 2020 19:29:59 +0000 (15:29 -0400)]
xfsprogs: Release v5.6.0

Update all the necessary files for a 5.6.0 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_scrub: don't set WorkingDirectory= in systemd job
Darrick J. Wong [Tue, 14 Apr 2020 16:56:20 +0000 (12:56 -0400)]
xfs_scrub: don't set WorkingDirectory= in systemd job

Somewhere between systemd 237 and 245, they changed the order in which a
job has its uid/gid set; capabilities applied; and working directory
set.  Whereas before they did it in an order such that you could set the
working directory to a path inaccessible to 'nobody' (either because
they did it before changing the uid or after adding capabilities), now
they don't and users instead get a service failure:

xfs_scrub@-boot.service: Changing to the requested working directory failed: Permission denied
xfs_scrub@-boot.service: Failed at step CHDIR spawning /usr/sbin/xfs_scrub: Permission denied
xfs_scrub@-boot.service: Main process exited, code=exited, status=200/CHDIR

Regardless, xfs_scrub works just fine with PWD set to /, so remove that
directive.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: Release v5.6.0-rc1 v5.6.0-rc1
Eric Sandeen [Wed, 8 Apr 2020 13:48:54 +0000 (09:48 -0400)]
xfsprogs: Release v5.6.0-rc1

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

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: remove libxfs_iomove
Christoph Hellwig [Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)]
libxfs: remove libxfs_iomove

This function has been removed in the kernel already.  Replace the only
user that want to zero buffers with a straight call to memset.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove XFS_BUF_SET_BDSTRAT_FUNC
Christoph Hellwig [Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)]
xfs: remove XFS_BUF_SET_BDSTRAT_FUNC

This function doesn't exist in the kernel and is purely a stub in
xfsprogs, so remove it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: turn the xfs_buf_incore stub into an inline function
Christoph Hellwig [Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)]
libxfs: turn the xfs_buf_incore stub into an inline function

Replace the macro with an inline function to avoid compiler warnings with new
backports of kernel code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_scrub: fix type error in render_ino_from_handle
Darrick J. Wong [Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)]
xfs_scrub: fix type error in render_ino_from_handle

render_ino_from_handle is passed a struct xfs_bulkstat, not xfs_bstat.
Fix this.

Fixes: 4cca629d6ae3807 ("misc: convert xfrog_bulkstat functions to have v5 semantics")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_repair: fix dir_read_buf use of libxfs_da_read_buf
Darrick J. Wong [Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)]
xfs_repair: fix dir_read_buf use of libxfs_da_read_buf

xfs_da_read_buf dropped the 'mappedbno' argument in favor of a flags
argument.  Foolishly, we're passing that parameter (which is -1 in all
callers) to xfs_da_read_buf, which gets us the wrong behavior.

Since mappedbno == -1 meant "complain if we fall into a hole" (which is
the default behavior of xfs_da_read_buf) we can fix this by passing a
zero flags argument and getting rid of mappedbno entirely.

Coverity-id: 1457898
Fixes: 5f356ae6d ("xfs: remove the mappedbno argument to xfs_da_read_buf")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_db: clean up the salvage read callsites in set_cur()
Darrick J. Wong [Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)]
xfs_db: clean up the salvage read callsites in set_cur()

Clean up the LIBXFS_READBUF_SALVAGE call sites in set_cur so that we
use the return value directly instead of scraping it out later.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: check return value of device flush when closing device
Darrick J. Wong [Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)]
libxfs: check return value of device flush when closing device

Although the libxfs_umount function flushes all devices when unmounting
the incore filesystem, the libxfs io code will flush the device again
when the application close them.  Check and report any errors that might
happen, though this is unlikely.

Coverity-id: 1460464
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: don't barf in libxfs_bwrite on a null buffer ops name
Darrick J. Wong [Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)]
libxfs: don't barf in libxfs_bwrite on a null buffer ops name

Don't crash if we failed to write a buffer that had no buffer verifier.
This should be rare in practice, but coverity found a valid bug.

Coverity-id: 1460462
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_io: set exitcode on failure appropriately
Dave Chinner [Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)]
xfs_io: set exitcode on failure appropriately

Many operations don't set the exitcode when they fail, resulting
in xfs_io exiting with a zero (no failure) exit code despite the
command failing and returning an error. The command return code is
really a boolean to tell the libxcmd command loop whether to
continue processing or not, while exitcode is the actual xfs_io exit
code returned to the parent on exit.

This patchset just makes the code do the right thing. It's not the
nicest code, but it's a start at producing correct behaviour.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: fix silently broken option parsing
Dave Chinner [Wed, 8 Apr 2020 13:48:04 +0000 (09:48 -0400)]
xfsprogs: fix silently broken option parsing

When getopt() is passed an option string like "-m -n" and the
parameter m is defined as "m:", getopt returns a special error
to indication that the optstring started with a "-". Any getopt()
caller that is just catching the "?" error character will not
not catch this special error, so it silently eats the parameter
following -m.

Lots of getopt loops in xfsprogs have this issue. Convert them all
to just use a "default:" to catch anything unexpected.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: LDFLAGS comes from configure, not environment
Dave Chinner [Tue, 7 Apr 2020 18:29:39 +0000 (14:29 -0400)]
xfsprogs: LDFLAGS comes from configure, not environment

When doing:

$ LDFLAGS=foo make

bad things happen because we don't initialise LDFLAGS to an empty
string in include/builddefs.in and hence make takes wahtever is in
the environment and runs with it. This causes problems with linker
options specified correctly through configure.

We don't support overriding build flags (like CFLAGS) though the
make environment, so it was an oversight 13 years ago to allow
LDFLAGS to be overridden when adding support to custom LDFLAGS being
passed from the the configure script. This ensures we only ever use
linker flags from configure, not the make environment.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>