]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/log
thirdparty/xfsprogs-dev.git
4 years agolibfrog: move workqueue.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:07 +0000 (15:37 -0400)] 
libfrog: move workqueue.h to libfrog/

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibfrog: move path.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:07 +0000 (15:37 -0400)] 
libfrog: move path.h to libfrog/

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibfrog: move crc32c.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:07 +0000 (15:37 -0400)] 
libfrog: move crc32c.h to libfrog/

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibfrog: move workqueue.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:06 +0000 (15:37 -0400)] 
libfrog: move workqueue.h to libfrog/

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibfrog: move radix-tree.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:06 +0000 (15:37 -0400)] 
libfrog: move radix-tree.h to libfrog/

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibfrog: move ptvar.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:06 +0000 (15:37 -0400)] 
libfrog: move ptvar.h to libfrog/

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibfrog: move fsgeom.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:06 +0000 (15:37 -0400)] 
libfrog: move fsgeom.h to libfrog/

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibfrog: move convert.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:06 +0000 (15:37 -0400)] 
libfrog: move convert.h to libfrog/

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibfrog: move bitmap.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:06 +0000 (15:37 -0400)] 
libfrog: move bitmap.h to libfrog/

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibfrog: move avl64.h to libfrog/
Darrick J. Wong [Mon, 9 Sep 2019 19:37:06 +0000 (15:37 -0400)] 
libfrog: move avl64.h to libfrog/

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibxfs: move topology declarations into separate header
Darrick J. Wong [Mon, 9 Sep 2019 19:37:05 +0000 (15:37 -0400)] 
libxfs: move topology declarations into separate header

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibfrog: refactor open-coded INUMBERS calls
Darrick J. Wong [Mon, 9 Sep 2019 19:37:05 +0000 (15:37 -0400)] 
libfrog: refactor open-coded INUMBERS calls

Refactor all the INUMBERS ioctl callsites into helper functions.

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

Create a helper to open a file and initialize the xfd structure.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibfrog: refactor open-coded bulkstat calls
Darrick J. Wong [Mon, 9 Sep 2019 19:37:05 +0000 (15:37 -0400)] 
libfrog: refactor open-coded bulkstat calls

Refactor the BULKSTAT_SINGLE and BULKSTAT ioctl callsites into helper
functions.

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfsprogs: Release v5.3.0-rc1 v5.3.0-rc1
Eric Sandeen [Wed, 28 Aug 2019 16:12:12 +0000 (12:12 -0400)] 
xfsprogs: Release v5.3.0-rc1

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

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

Source kernel commit: 8612de3f7ba6e900465e340516b8313806d27b2d

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

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

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

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

Source kernel commit: 858b44dc62a1018312fd9cbd15db24237a897e0e

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

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

Source kernel commit: 2c3b83d7ca6d73b9478afc86c89377c15a90b9ed

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: allow single bulkstat of special inodes
Darrick J. Wong [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: allow single bulkstat of special inodes

Source kernel commit: bf3cb394479210a9ebcf8fef7a7f8fcabc7b9928

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

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

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

Source kernel commit: 13d59a2a61cbbb4cda13a0cba6d4d1fc537f5dd4

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

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

Source kernel commit: fba9760a433634067ec01e7d4cdd581d17b149e0

Wire up the v5 INUMBERS ioctl.

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

Source kernel commit: 0448b6f488fa66e353a9e00022441cd4aca7f2cf

Wire up the new v5 BULKSTAT ioctl.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: introduce v5 inode group structure
Darrick J. Wong [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: introduce v5 inode group structure

Source kernel commit: 5f19c7fc6873351a3d81bbbb98c928343902d8d6

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: introduce new v5 bulkstat structure
Darrick J. Wong [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: introduce new v5 bulkstat structure

Source kernel commit: 7035f9724f8497c709077c08df2073bfcde9c2f5

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

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

Source kernel commit: 6f71fb683879c78ba356ca78f2972289443f26eb

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

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

Source kernel commit: a211432c27ffa32d9978f6c18f5af0c3f8ad2ad1

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

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

Source kernel commit: 5bb46e3e180d28c7ee6715f47c344be366a3fcc8

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: remove XFS_TRANS_NOFS
Christoph Hellwig [Wed, 28 Aug 2019 16:08:09 +0000 (12:08 -0400)] 
xfs: remove XFS_TRANS_NOFS

Source kernel commit: 73d30d48749f883fbaaf68ef5d774e99ffafda5d

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

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

Source kernel commit: 250d4b4c409778bc44577dfc59909935c92fd006

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

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

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

Source kernel commit: f327a00745fffd9159d54b442cb75c0266fb89d6

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

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

Source kernel commit: 8d90857cff445f176a591d01c0999e8d563217bf

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

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

Source kernel commit: 7e36a3a63d3e480e75b4991aa983d4059ca5d401

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

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

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: skip small alloc cntbt logic on NULL cursor
Brian Foster [Wed, 28 Aug 2019 16:08:08 +0000 (12:08 -0400)] 
xfs: skip small alloc cntbt logic on NULL cursor

Source kernel commit: 6691cd9267c1c588d1f8e097c175d7c9670c7fc1

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

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

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

Source kernel commit: c63cdd4fc9cc6a22d6e0bd0dcba4a28d18eab723

Move the small allocation helper further up in the file to avoid the
need for a function declaration. The remaining declarations will be
removed by followup patches. No functional changes.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: clean up small allocation helper
Brian Foster [Wed, 28 Aug 2019 16:08:08 +0000 (12:08 -0400)] 
xfs: clean up small allocation helper

Source kernel commit: 2a4f35f984f0be5b839be157b50f69ee73c67ef1

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

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: add struct xfs_mount pointer to struct xfs_buf
Christoph Hellwig [Wed, 28 Aug 2019 16:08:08 +0000 (12:08 -0400)] 
xfs: add struct xfs_mount pointer to struct xfs_buf

Source kernel commit: dbd329f1e44ed48de8a1c19da5eb1218f5e1b4a5

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

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: move xfs_ino_geometry to xfs_shared.h
Darrick J. Wong [Wed, 28 Aug 2019 16:08:08 +0000 (12:08 -0400)] 
xfs: move xfs_ino_geometry to xfs_shared.h

Source kernel commit: 5467b34bd1e81c8e719ae968ba6561723fdc15b8

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

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

Source kernel commit: f5b999c03f4c178d151e79803a95f8482a26521e

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

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: remove unused flags arg from getsb interfaces
Eric Sandeen [Wed, 28 Aug 2019 16:08:08 +0000 (12:08 -0400)] 
xfs: remove unused flags arg from getsb interfaces

Source kernel commit: 8c9ce2f707a1571782b4d3d100af627b6d147357

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

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: finish converting to inodes_per_cluster
Darrick J. Wong [Wed, 28 Aug 2019 16:08:08 +0000 (12:08 -0400)] 
xfs: finish converting to inodes_per_cluster

Source kernel commit: 4b4d98cca32053ec8993e836cb8cb7c8098959dc

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

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

Source kernel commit: 490d451fa5188975c21246f7f8f4914cd3f2d6f2

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

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

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

Source kernel commit: 494dba7b276e12bc3f6ff2b9b584b6e9f693af45

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

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

Source kernel commit: ef325959993edd53e3ce7c818b18f776ac0740a6

Separate the inode geometry information into a distinct structure.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfsprogs: Release v5.2.1 v5.2.1
Eric Sandeen [Wed, 21 Aug 2019 15:45:11 +0000 (11:45 -0400)] 
xfsprogs: Release v5.2.1

Update all the necessary files for a 5.2.1 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfsprogs: fix geometry calls on older kernels for 5.2.1
Eric Sandeen [Wed, 21 Aug 2019 15:41:03 +0000 (11:41 -0400)] 
xfsprogs: fix geometry calls on older kernels for 5.2.1

I didn't think 5.2.0 through; the udpate of the geometry ioctl means
that the tools won't work on older kernels that don't support the
v5 ioctls, since I failed to merge Darrick's wrappers.

As a very quick one-off I'd like to merge this to just revert every
geometry call back to the original ioctl, so it keeps working on
older kernels and I'll release 5.2.1.  This hack can go away when
Darrick's wrappers get merged.

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>
4 years agoxfsprogs: Release v5.2.0 v5.2.0
Eric Sandeen [Fri, 9 Aug 2019 19:05:31 +0000 (14:05 -0500)] 
xfsprogs: Release v5.2.0

Update all the necessary files for a 5.2.0 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibxfs: don't use enum for buffer flags
Eric Sandeen [Wed, 24 Jul 2019 21:28:26 +0000 (17:28 -0400)] 
libxfs: don't use enum for buffer flags

This roughly mirrors

  807cbbdb xfs: do not use emums for flags used in tracing

and lets us use the xfs_buf_flags_t type in function calls as is
done in the kernel.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibxfs: trivial changes to libxfs/trans.c
Eric Sandeen [Wed, 24 Jul 2019 21:28:25 +0000 (17:28 -0400)] 
libxfs: trivial changes to libxfs/trans.c

Make some mostly trivial changes to libxfs/trans.c to more
closely match kernelspace xfs_trans.c, including:

- add tracepoint calls
- add comments
- add braces
- change tests for null
- reorder some tests and initializations

This /should/ be no functional changes.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibxfs: cosmetic changes to libxfs/trans.c
Eric Sandeen [Wed, 24 Jul 2019 21:28:21 +0000 (17:28 -0400)] 
libxfs: cosmetic changes to libxfs/trans.c

Make some completely trivial changes to libxfs/trans.c to more
closely match kernelspace xfs_trans.c:

- remove some typedefs
- alter whitespace
- rename some variables

No functional changes.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibxfs: reorder functions in libxfs/trans.c
Eric Sandeen [Wed, 24 Jul 2019 21:28:18 +0000 (17:28 -0400)] 
libxfs: reorder functions in libxfs/trans.c

This puts these functions in libxfs/trans.c in the same order as
they appear in kernelspace xfs_trans_buf.c for easier comparison.

No functional changes.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfsprogs: Release v5.2.0-rc0 v5.2.0-rc0
Eric Sandeen [Wed, 24 Jul 2019 19:54:07 +0000 (15:54 -0400)] 
xfsprogs: Release v5.2.0-rc0

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

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: don't reserve per-AG space for an internal log
Darrick J. Wong [Wed, 24 Jul 2019 19:54:07 +0000 (15:54 -0400)] 
xfs: don't reserve per-AG space for an internal log

Source kernel commit: 5cd213b0fec640a46adc5e6e4dfc7763aa54b3b2

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

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

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: change some error-less functions to void types
Eric Sandeen [Wed, 24 Jul 2019 19:54:07 +0000 (15:54 -0400)] 
xfs: change some error-less functions to void types

Source kernel commit: 910832697cf85536c7fe26edb8bc6f830c4b9bb6

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

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: add online scrub for superblock counters
Darrick J. Wong [Wed, 24 Jul 2019 19:54:07 +0000 (15:54 -0400)] 
xfs: add online scrub for superblock counters

Source kernel commit: 75efa57d0bf5fcf650a183f0ce0dc011ba8c4bc8

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

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

Source kernel commit: 710d707d2fa9cf4c2aa9def129e71e99513466ea

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

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

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

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: track delayed allocation reservations across the filesystem
Darrick J. Wong [Wed, 24 Jul 2019 19:54:06 +0000 (15:54 -0400)] 
xfs: track delayed allocation reservations across the filesystem

Source kernel commit: 9fe82b8c422b5d9e9011bc08e27b9044936d945f

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: assert that we don't enter agfl freeing with a non-permanent transaction
Brian Foster [Wed, 24 Jul 2019 19:54:06 +0000 (15:54 -0400)] 
xfs: assert that we don't enter agfl freeing with a non-permanent transaction

Source kernel commit: 362f5e745ae2ee2be9cf181b3a22917d619b81a1

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

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

Source kernel commit: 945c941fcd82bac3a8ea2b89c635651f323bd609

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

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

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

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

Source kernel commit: 89d139d5ad465e35a9c602421eb1a1ff08ea530d

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: report AG health via AG geometry ioctl
Darrick J. Wong [Wed, 24 Jul 2019 19:54:06 +0000 (15:54 -0400)] 
xfs: report AG health via AG geometry ioctl

Source kernel commit: 1302c6a24fd952555aa6dc811cec5b2a22ac386a

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: report fs and rt health via geometry structure
Darrick J. Wong [Wed, 24 Jul 2019 19:54:06 +0000 (15:54 -0400)] 
xfs: report fs and rt health via geometry structure

Source kernel commit: c23232d409355091502a362e99ed06f800765961

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: add a new ioctl to describe allocation group geometry
Darrick J. Wong [Wed, 24 Jul 2019 19:54:06 +0000 (15:54 -0400)] 
xfs: add a new ioctl to describe allocation group geometry

Source kernel commit: 7cd5006bdb6f6d9d9d7e68aa1d96b6e4a8b68bc5

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: bump XFS_IOC_FSGEOMETRY to v5 structures
Dave Chinner [Wed, 24 Jul 2019 19:53:56 +0000 (15:53 -0400)] 
xfs: bump XFS_IOC_FSGEOMETRY to v5 structures

Source kernel commit: 1b6d968de22bffd85a60538d2628185b17228291

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

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

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[darrick: forward port to 5.1, expand structure size to 256 bytes]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: clear BAD_SUMMARY if unmounting an unhealthy filesystem
Darrick J. Wong [Wed, 24 Jul 2019 19:53:56 +0000 (15:53 -0400)] 
xfs: clear BAD_SUMMARY if unmounting an unhealthy filesystem

Source kernel commit: 519841c207de9926418d2f39e162097088478781

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: replace the BAD_SUMMARY mount flag with the equivalent health code
Darrick J. Wong [Wed, 24 Jul 2019 19:53:56 +0000 (15:53 -0400)] 
xfs: replace the BAD_SUMMARY mount flag with the equivalent health code

Source kernel commit: 39353ff6e96fb623230341ca89b0f4ef3a04998f

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: track metadata health status
Darrick J. Wong [Wed, 24 Jul 2019 19:53:56 +0000 (15:53 -0400)] 
xfs: track metadata health status

Source kernel commit: 6772c1f11206f270af56d62bc26737864a63608a

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: don't account extra agfl blocks as available
Brian Foster [Wed, 24 Jul 2019 19:53:56 +0000 (15:53 -0400)] 
xfs: don't account extra agfl blocks as available

Source kernel commit: 1ca89fbc48e1ea5044997328e403f8a13513e8c3

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

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

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

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

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfsprogs: Release v5.1.0 v5.1.0
Eric Sandeen [Fri, 19 Jul 2019 18:19:47 +0000 (13:19 -0500)] 
xfsprogs: Release v5.1.0

Update all the necessary files for a 5.1.0 release.

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

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

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

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

Change the man page to clarify this.

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoman: link to the SCRUB_METADATA ioctl manpage from xfsctl.3
Darrick J. Wong [Wed, 10 Jul 2019 21:16:36 +0000 (17:16 -0400)] 
man: link to the SCRUB_METADATA ioctl manpage from xfsctl.3

Link to the scrub ioctl documentation from xfsctl.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fixes: 8da5298 ("mkfs: validate start and end of aligned logs")
Reported-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_quota: fix built-in help for project setup
Eric Sandeen [Tue, 25 Jun 2019 21:04:42 +0000 (17:04 -0400)] 
xfs_quota: fix built-in help for project setup

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

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_io: repair_f should use its own name
Darrick J. Wong [Tue, 25 Jun 2019 21:04:42 +0000 (17:04 -0400)] 
xfs_io: repair_f should use its own name

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agomkfs: validate start and end of aligned logs
Darrick J. Wong [Tue, 25 Jun 2019 21:04:42 +0000 (17:04 -0400)] 
mkfs: validate start and end of aligned logs

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibfrog: cvt_u64 should use strtoull, not strtoll
Darrick J. Wong [Tue, 25 Jun 2019 21:04:42 +0000 (17:04 -0400)] 
libfrog: cvt_u64 should use strtoull, not strtoll

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_repair: refactor namecheck functions
Darrick J. Wong [Thu, 6 Jun 2019 13:58:55 +0000 (08:58 -0500)] 
xfs_repair: refactor namecheck functions

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibfrog: fix bitmap return values
Darrick J. Wong [Thu, 6 Jun 2019 13:58:55 +0000 (08:58 -0500)] 
libfrog: fix bitmap return values

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agomisc: remove all use of xfs_fsop_geom_t
Darrick J. Wong [Thu, 6 Jun 2019 13:58:55 +0000 (08:58 -0500)] 
misc: remove all use of xfs_fsop_geom_t

Remove all the uses of the old xfs_fsop_geom_t typedef.

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