]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/log
thirdparty/xfsprogs-dev.git
6 years agomkfs: factor block subopts parser
Dave Chinner [Wed, 6 Dec 2017 23:14:27 +0000 (17:14 -0600)] 
mkfs: factor block subopts parser

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: add generic subopt parsing table
Dave Chinner [Wed, 6 Dec 2017 23:14:27 +0000 (17:14 -0600)] 
mkfs: add generic subopt parsing table

Abstract out the common subopt parsing code into a common function
and type table so we can factor the parsing code. Add the function
stubs in preparation for factoring.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: introduce a structure to hold CLI options
Dave Chinner [Wed, 6 Dec 2017 23:14:27 +0000 (17:14 -0600)] 
mkfs: introduce a structure to hold CLI options

We need to hold the values set from command line options so they can
later be validated and discriminated from the default values that
might be set. This structure will form a connector between the input
parsing and the rest of the mkfs code.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: make subopt table const
Dave Chinner [Wed, 6 Dec 2017 23:14:27 +0000 (17:14 -0600)] 
mkfs: make subopt table const

Use const for all the tables to remove most of the (char **) casts.
This adds a couple of temporary (const char **) casts that go away
as the input parsing is factored.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: disallow specifying the sector size of internal log
Dave Chinner [Wed, 6 Dec 2017 23:14:27 +0000 (17:14 -0600)] 
mkfs: disallow specifying the sector size of internal log

If the log is on the data device (i.e. internal) then it should
match the sector size the data device is using. If they don't match,
then one or the other doesn't have atomic sector writes and we could
have crash consistency problems. Not to mention that it's simply
wrong to have two different sector sizes for the same device.

Hence enforce the requirement that an internal log device always has
the same sector size as the data device.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_db: add missing padding fields
Darrick J. Wong [Wed, 6 Dec 2017 15:17:08 +0000 (09:17 -0600)] 
xfs_db: add missing padding fields

Several data structures are missing padding fields from their field
definitions.  Add them so that they can be printed out if explicitly
requested.

Fix the AGI field order to be consistent with the structure
definition while we're at it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
[sandeen: make them available but not printed by default]
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_db: print structure padding fields consistently
Darrick J. Wong [Wed, 6 Dec 2017 15:17:08 +0000 (09:17 -0600)] 
xfs_db: print structure padding fields consistently

We are very inconsistent about how we print padding fields in on-disk
structures -- sometimes we hide it from printall, sometimes we deviate
from unsigned hex values, etc.  Make this all consistent -- always hide
padding values when printing the whole structure, always print them as
unsigned hex integers when explicitly requested.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
[sandeen: switch to never-print instead of always-print]
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_repair: remove old workqueue stuff in favor of libfrog code
Darrick J. Wong [Wed, 6 Dec 2017 15:17:08 +0000 (09:17 -0600)] 
xfs_repair: remove old workqueue stuff in favor of libfrog code

Now that we've made a generic workqueue in libfrog, we can remove the
implementation in xfs_repair and turn the old functions into wrappers
that call do_error if they fail.  There are no functional changes in
this patch, though some of the names and types have changed.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibhandle: add missing destructor
Darrick J. Wong [Wed, 6 Dec 2017 15:17:08 +0000 (09:17 -0600)] 
libhandle: add missing destructor

Make it so that we can tear down the file descriptor hash table.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibfrog: add missing function fs_table_destroy
Darrick J. Wong [Wed, 6 Dec 2017 15:17:08 +0000 (09:17 -0600)] 
libfrog: add missing function fs_table_destroy

Add a function to tear down the fs_table when we're done
messing with paths.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibfrog: move paths.c out of libxcmd
Darrick J. Wong [Wed, 6 Dec 2017 15:17:08 +0000 (09:17 -0600)] 
libfrog: move paths.c out of libxcmd

Move the fs_table code into libfrog since it's not really a command.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibfrog: move conversion factors out of libxcmd
Darrick J. Wong [Wed, 6 Dec 2017 15:17:08 +0000 (09:17 -0600)] 
libfrog: move conversion factors out of libxcmd

Move all the conversion functions out of libxcmd since they'll be used
by scrub, which doesn't have a commandline.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibfrog: move topology code out of libxcmd
Darrick J. Wong [Wed, 6 Dec 2017 15:17:08 +0000 (09:17 -0600)] 
libfrog: move topology code out of libxcmd

Move the filesystem topology code out of libxcmd.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibfrog: create a threaded workqueue
Darrick J. Wong [Wed, 6 Dec 2017 15:17:08 +0000 (09:17 -0600)] 
libfrog: create a threaded workqueue

Create a thread pool that queues and runs discrete work items.  This
will be a namespaced version of the pool in repair/threads.c; a
subsequent patch will switch repair over.  xfs_scrub will use the
generic thread pool.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibfrog: promote avl64 code from xfs_repair
Darrick J. Wong [Wed, 6 Dec 2017 15:17:08 +0000 (09:17 -0600)] 
libfrog: promote avl64 code from xfs_repair

xfs_scrub will make use of the avl64 code, so promote it out of repair
and into libfrog.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibfrog: move list_sort out of libxfs
Darrick J. Wong [Wed, 6 Dec 2017 15:17:07 +0000 (09:17 -0600)] 
libfrog: move list_sort out of libxfs

List operations aren't really a part of libxfs, so move them to libfrog.
This is purely a directory tree restructuring; no functional changes,
though some indentation fixes are included.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibfrog: add bit manipulation functions
Darrick J. Wong [Wed, 6 Dec 2017 15:17:07 +0000 (09:17 -0600)] 
libfrog: add bit manipulation functions

Duplicate the libxfs bit manipulation functions -- this is for programs
that don't need libxfs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibfrog: move libxfs_log2_roundup to libfrog
Darrick J. Wong [Wed, 6 Dec 2017 15:17:07 +0000 (09:17 -0600)] 
libfrog: move libxfs_log2_roundup to libfrog

Move libxfs_log2_roundup to libfrog and remove the 'libxfs_' prefix.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibfrog: move all the userspace support stuff into a new library
Darrick J. Wong [Wed, 6 Dec 2017 15:17:07 +0000 (09:17 -0600)] 
libfrog: move all the userspace support stuff into a new library

This library is meant to contain all the Funny Random Other Gunk that
the xfsprogs utilities rely on.  Move all that stuff into this library
to reduce the pollution in the other libraries.

Ribbit!  Ribbit!

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoman: describe the metadata scrubbing ioctl
Darrick J. Wong [Wed, 6 Dec 2017 15:17:07 +0000 (09:17 -0600)] 
man: describe the metadata scrubbing ioctl

Document the XFS-specific metadata scrub/repair ioctl's behavior,
arguments, and side effects.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_io: provide an interface to the scrub ioctls
Darrick J. Wong [Wed, 6 Dec 2017 15:17:07 +0000 (09:17 -0600)] 
xfs_io: provide an interface to the scrub ioctls

Create a new xfs_io command to call the new XFS metadata scrub ioctl.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_io: add buf_lru_ref tag to inject table
Eric Sandeen [Wed, 6 Dec 2017 15:17:07 +0000 (09:17 -0600)] 
xfs_io: add buf_lru_ref tag to inject table

And catch it at build time if we get out of sync again.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_io: pull xfs errortag definitions from libxfs
Darrick J. Wong [Wed, 6 Dec 2017 15:17:07 +0000 (09:17 -0600)] 
xfs_io: pull xfs errortag definitions from libxfs

Use the libxfs definitions, don't provide our own.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_io: implement ranged fiemap query
Nikolay Borisov [Wed, 6 Dec 2017 15:17:07 +0000 (09:17 -0600)] 
xfs_io: implement ranged fiemap query

Currently the fiemap implementation of xfs_io doesn't support making
ranged queries. This patch implements two optional arguments which
take the starting offset and the length of the region to be queried.

When the end of the requested region falls within an extent boundary
then we print the whole extent (i.e. return all the information that
the kernel has given us). When the end offset falls within a hole
then the printed hole range is truncated to the requested one since
we do not have information how long the hole is.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
[sandeen: simplify/rewrite ranged logic]
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_io: fix gcc-7 related printf warnings
Dave Chinner [Wed, 6 Dec 2017 15:17:07 +0000 (09:17 -0600)] 
xfs_io: fix gcc-7 related printf warnings

New compiler, new checks, new warnings.

Fix the new [-Wformat-truncation=] warnings that io/fsmap.c is
throwing w/ gcc-7.2 because "%lld..%lld" requires a buffer 40
characters long, not 32.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@sandeen.net>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoMerge branch 'libxfs-4.15-sync' into for-next
Eric Sandeen [Mon, 27 Nov 2017 20:45:45 +0000 (14:45 -0600)] 
Merge branch 'libxfs-4.15-sync' into for-next

6 years agoxfs: abstract out dev_t conversions
Christoph Hellwig [Mon, 27 Nov 2017 20:23:38 +0000 (14:23 -0600)] 
xfs: abstract out dev_t conversions

Source kernel commit: 274e0a1f4777b9362fc03a34e86358cc36003e48

And move them to xfs_linux.h so that xfsprogs can stub them out more
easily.

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>
[sandeen: stub them out in xfsprogs]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: fix memory leak in xfs_iext_free_last_leaf
Shu Wang [Mon, 27 Nov 2017 17:47:07 +0000 (11:47 -0600)] 
xfs: fix memory leak in xfs_iext_free_last_leaf

Source kernel commit: 6818caa4cdc95d9ec5642a4439f8271a80189b48

found the issue by kmemleak.
unreferenced object 0xffff8800674611c0 (size 16):
xfs_iext_insert+0x82a/0xa90 [xfs]
xfs_bmap_add_extent_hole_delay+0x1e5/0x5b0 [xfs]
xfs_bmapi_reserve_delalloc+0x483/0x530 [xfs]
xfs_file_iomap_begin+0xac8/0xd40 [xfs]
iomap_apply+0xb8/0x1b0
iomap_file_buffered_write+0xac/0xe0
xfs_file_buffered_aio_write+0x198/0x420 [xfs]
xfs_file_write_iter+0x23f/0x2a0 [xfs]
__vfs_write+0x23e/0x340
vfs_write+0xe9/0x240
SyS_write+0xa1/0x120
do_syscall_64+0xda/0x260

Signed-off-by: Shu Wang <shuwang@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: fix type usage
Darrick J. Wong [Mon, 27 Nov 2017 17:46:31 +0000 (11:46 -0600)] 
xfs: fix type usage

Source kernel commit: 2015a63dce8d73a439232a0d5162c88d8513101e

Be consistent about using uint32_t/uint8_t instead of u32/u8.  This is
more so that we don't have to maintain /those/ types in xfsprogs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfsprogs: Release v4.14.0 v4.14.0
Eric Sandeen [Mon, 27 Nov 2017 16:56:21 +0000 (10:56 -0600)] 
xfsprogs: Release v4.14.0

Update all the necessary files for a 4.14.0 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfsprogs: Release v4.14.0-rc2 v4.14.0-rc2
Eric Sandeen [Mon, 20 Nov 2017 19:56:10 +0000 (13:56 -0600)] 
xfsprogs: Release v4.14.0-rc2

Update all the necessary files for a 4.14.0-rcw release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_io: stat: treat statfs.f_flags as optional
Jeff Mahoney [Mon, 20 Nov 2017 19:54:02 +0000 (13:54 -0600)] 
xfs_io: stat: treat statfs.f_flags as optional

Kernels prior to 2.6.36 didn't contain statfs.f_flags.  Distros with
initial releases with kernels prior to this may not have updated
headers with this member.  Only attempt to print it if we have the
header with the member defined.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
[sandeen: define HAVE_STATFS_FLAGS in io/Makefile]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_io: stat: fix typo in statfs->f_flags
Jeff Mahoney [Mon, 20 Nov 2017 19:54:02 +0000 (13:54 -0600)] 
xfs_io: stat: fix typo in statfs->f_flags

The field name is f_flags.

Fixes: b4056fed "xfs_io: Print filesystem statfs flags in 'statfs' command"
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_copy: don't hang if /all/ the targets hit write errors
Darrick J. Wong [Mon, 20 Nov 2017 19:53:56 +0000 (13:53 -0600)] 
xfs_copy: don't hang if /all/ the targets hit write errors

If xfs_copy is told to copy a filesystem and /all/ the writer threads
hit an write error, there won't be any threads to unlock mainwait, which
means that write_wbuf will deadlock with itself trying to lock mainwait.
Therefore, if we discover that all the writer threads are dead, just
bail out.

Discovered by running xfs/073 with a tiny test device.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfsprogs: fix wrong do_pwritev definition
Zirong Lang [Mon, 20 Nov 2017 19:53:56 +0000 (13:53 -0600)] 
xfsprogs: fix wrong do_pwritev definition

In io/pwrite.c, if not define HAVE_PWRITEV, we will use:
  #define do_pwritev(fd, offset, count, buffer_size) (0)

But the real do_pwritev() function is:
  do_pwritev(fd, offset, count, buffer_size, pwritev2_flags);

There's one more 'pwritev2_flags' argument.

Fixes: c5deeac9 "xfs_io: Add support for pwritev2()"
Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfsprogs: fix wrong variable types in pwrite/pread code
Zirong Lang [Mon, 20 Nov 2017 19:53:56 +0000 (13:53 -0600)] 
xfsprogs: fix wrong variable types in pwrite/pread code

The 'Coverity Scan' found a problem in new write_once() function:

272             size_t bytes;
273             bytes = do_pwrite(file->fd, offset, count, count, pwritev2_flags);
>>>     CID 1420710:  Control flow issues  (NO_EFFECT)
>>>     This less-than-zero comparison of an unsigned value is never true. "bytes < 0UL".
274             if (bytes < 0)
275                     return -1;

That's unreasonable. do_pwrite return 'ssize_t' type value, which can
be less than zero, but we use a 'size_t' to get the return value. So
change the size_t to ssize_t for it can store the return value
correctly.

By the chance, correct all 'ssize_t' type problems in pwrite/pread
related functions.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
[sandeen: modify commit summary]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfsprogs: Release v4.14.0-rc1
Eric Sandeen [Mon, 20 Nov 2017 19:53:56 +0000 (13:53 -0600)] 
xfsprogs: Release v4.14.0-rc1

Update all the necessary files for a 4.14.0-rc1 release.
(A while after the actual release)

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: remove u_int* type usage
Darrick J. Wong [Fri, 17 Nov 2017 04:11:35 +0000 (22:11 -0600)] 
xfs: remove u_int* type usage

Source kernel commit: 65a7935ddc9a1f0c723842776259d76394b4bd11

Use the uint* types instead of the u_int* types.  This will (hopefully)
pair with an xfsprogs cleanup.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
[sandeen: no-op commit, libxfs was already fixed in userspace]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: handle zero entries case in xfs_iext_rebalance_leaf
Christoph Hellwig [Fri, 17 Nov 2017 04:11:35 +0000 (22:11 -0600)] 
xfs: handle zero entries case in xfs_iext_rebalance_leaf

Source kernel commit: ae82968ee9b404b9fc101f9d75e171c78797a4d1

And also rename fill to nr_entries to match the rest of the code.

Reported-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: add comments documenting the rebalance algorithm
Christoph Hellwig [Fri, 17 Nov 2017 04:11:35 +0000 (22:11 -0600)] 
xfs: add comments documenting the rebalance algorithm

Source kernel commit: 3e27c418a7a13b8dbf33f6eb49b0e461f011bdcd

Reported-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: trivial indentation fixup for xfs_iext_remove_node
Christoph Hellwig [Fri, 17 Nov 2017 04:11:35 +0000 (22:11 -0600)] 
xfs: trivial indentation fixup for xfs_iext_remove_node

Source kernel commit: b9aee1d5fe58160a44556224b5479bd151a3e1a5

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: remove a superflous assignment in xfs_iext_remove_node
Christoph Hellwig [Fri, 17 Nov 2017 04:11:35 +0000 (22:11 -0600)] 
xfs: remove a superflous assignment in xfs_iext_remove_node

Source kernel commit: f1be313697f2d2ee925bd559a53d58312dec8b5a

Reported-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: add some comments to xfs_iext_insert/xfs_iext_insert_node
Christoph Hellwig [Fri, 17 Nov 2017 04:11:35 +0000 (22:11 -0600)] 
xfs: add some comments to xfs_iext_insert/xfs_iext_insert_node

Source kernel commit: fc258f4b8bb578c39223ff572b4dec8d56a2ed81

Reported-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: fix number of records handling in xfs_iext_split_leaf
Christoph Hellwig [Fri, 17 Nov 2017 04:11:35 +0000 (22:11 -0600)] 
xfs: fix number of records handling in xfs_iext_split_leaf

Source kernel commit: 43d193aa0212691254d574b8d207609ef22018b8

Fix to check the correct value, and remove a duplicate handling of the
uneven record number split algorith,

Reported-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: mark xfs_btree_check_lblock and xfs_btree_check_ptr static
Christoph Hellwig [Fri, 17 Nov 2017 04:11:35 +0000 (22:11 -0600)] 
xfs: mark xfs_btree_check_lblock and xfs_btree_check_ptr static

Source kernel commit: 4483eb566b2c045f69f2fa01629aca7772cdf95e

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: move xfs_bmbt_irec and xfs_exntst_t to xfs_types.h
Christoph Hellwig [Fri, 17 Nov 2017 04:11:35 +0000 (22:11 -0600)] 
xfs: move xfs_bmbt_irec and xfs_exntst_t to xfs_types.h

Source kernel commit: 866d7826c966d0d17cb31eaf394728a163ad7227

Neither defines an on-disk format, so move them out of xfs_format.h.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: pass struct xfs_bmbt_irec to xfs_bmbt_validate_extent
Christoph Hellwig [Fri, 17 Nov 2017 04:11:35 +0000 (22:11 -0600)] 
xfs: pass struct xfs_bmbt_irec to xfs_bmbt_validate_extent

Source kernel commit: dac9c9b137950421a87c1d9ba29f3a6ee54d0e8a

This removed an unaligned load per extent, as well as the manual poking
into the on-disk extent format.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: remove the nr_extents argument to xfs_iext_remove
Christoph Hellwig [Fri, 17 Nov 2017 04:11:35 +0000 (22:11 -0600)] 
xfs: remove the nr_extents argument to xfs_iext_remove

Source kernel commit: c38ccf599022e7454a861145ce1a94c5b5d7e658

We only have two places that remove 2 extents at the same time, so unroll
the loop there.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: remove the nr_extents argument to xfs_iext_insert
Christoph Hellwig [Fri, 17 Nov 2017 04:11:35 +0000 (22:11 -0600)] 
xfs: remove the nr_extents argument to xfs_iext_insert

Source kernel commit: 0254c2f253d6fe11ea2ce5046ed6acfddbe4ee17

We only have two places that insert 2 extents at the same time, so unroll
the loop there.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: use a b+tree for the in-core extent list
Christoph Hellwig [Fri, 17 Nov 2017 04:11:35 +0000 (22:11 -0600)] 
xfs: use a b+tree for the in-core extent list

Source kernel commit: 6bdcf26ade8825ffcdc692338e715cd7ed0820d8

Replace the current linear list and the indirection array for the in-core
extent list with a b+tree to avoid the need for larger memory allocations
for the indirection array when lots of extents are present.  The current
extent list implementations leads to heavy pressure on the memory
allocator when modifying files with a high extent count, and can lead
to high latencies because of that.

The replacement is a b+tree with a few quirks.  The leaf nodes directly
store the extent record in two u64 values.  The encoding is a little bit
different from the existing in-core extent records so that the start
offset and length which are required for lookups can be retreived with
simple mask operations.  The inner nodes store a 64-bit key containing
the start offset in the first half of the node, and the pointers to the
next lower level in the second half.  In either case we walk the node
from the beginninig to the end and do a linear search, as that is more
efficient for the low number of cache lines touched during a search
(2 for the inner nodes, 4 for the leaf nodes) than a binary search.
We store termination markers (zero length for the leaf nodes, an
otherwise impossible high bit for the inner nodes) to terminate the key
list / records instead of storing a count to use the available cache
lines as efficiently as possible.

One quirk of the algorithm is that while we normally split a node half and
half like usual btree implementations we just spill over entries added at
the very end of the list to a new node on its own.  This means we get a
100% fill grade for the common cases of bulk insertion when reading an
inode into memory, and when only sequentially appending to a file.  The
downside is a slightly higher chance of splits on the first random
insertions.

Both insert and removal manually recurse into the lower levels, but
the bulk deletion of the whole tree is still implemented as a recursive
function call, although one limited by the overall depth and with very
little stack usage in every iteration.

For the first few extents we dynamically grow the list from a single
extent to the next powers of two until we have a first full leaf block
and that building the actual tree.

The code started out based on the generic lib/btree.c code from Joern
Engel based on earlier work from Peter Zijlstra, but has since been
rewritten beyond recognition.

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>
[sandeen: use uint32_t for rec_len, update trace macros & repair/]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: allow unaligned extent records in xfs_bmbt_disk_set_all
Christoph Hellwig [Fri, 17 Nov 2017 04:11:35 +0000 (22:11 -0600)] 
xfs: allow unaligned extent records in xfs_bmbt_disk_set_all

Source kernel commit: 135dcc10d6ebf6184686042ec8b098e376252fff

To make life a little simpler make xfs_bmbt_set_all unaligned access
aware so that we can use it directly on the destination buffer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: remove support for inlining data/extents into the inode fork
Christoph Hellwig [Fri, 17 Nov 2017 04:11:35 +0000 (22:11 -0600)] 
xfs: remove support for inlining data/extents into the inode fork

Source kernel commit: 43518812d297179ae1e432d5cd640ec168596283

Supporting a small bit of data inside the inode fork blows up the fork size
a lot, removing the 32 bytes of inline data halves the effective size of
the inode fork (and it still has a lot of unused padding left), and the
performance of a single kmalloc doesn't show up compared to the size to read
an inode or create one.

It also simplifies the fork management code a lot.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: simplify xfs_reflink_convert_cow
Christoph Hellwig [Fri, 17 Nov 2017 04:11:35 +0000 (22:11 -0600)] 
xfs: simplify xfs_reflink_convert_cow

Source kernel commit: b121459c7a56d2fb5a8ca6727bf9f87982738b01

Instead of looking up extents to convert and calling xfs_bmapi_write on
each of them just let xfs_bmapi_write handle the full range.  To make
this robust add a new XFS_BMAPI_CONVERT_ONLY that only converts ranges
and never allocates blocks.

[darrick: shorten the stringified CONVERT_ONLY trace 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>
6 years agoxfs: introduce the xfs_iext_cursor abstraction
Christoph Hellwig [Fri, 17 Nov 2017 04:11:34 +0000 (22:11 -0600)] 
xfs: introduce the xfs_iext_cursor abstraction

Source kernel commit: b2b1712a640824e7c131bfdd2585d57bf8ccb39a

Add a new xfs_iext_cursor structure to hide the direct extent map
index manipulations. In addition to the existing lookup/get/insert/
remove and update routines new primitives to get the first and last
extent cursor, as well as moving up and down by one extent are
provided.  Also new are convenience to increment/decrement the
cursor and retreive the new extent, as well as to peek into the
previous/next extent without updating the cursor and last but not
least a macro to iterate over all extents in a fork.

[darrick: rename for_each_iext to for_each_xfs_iext]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: use cursor in xfs_repair code as well]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: iterate over extents in xfs_bmap_extents_to_btree
Christoph Hellwig [Fri, 17 Nov 2017 04:11:34 +0000 (22:11 -0600)] 
xfs: iterate over extents in xfs_bmap_extents_to_btree

Source kernel commit: 906abed501bf5a2103946deb7a4a40b31c56f027

This actually makes the function very slightly less efficient for now as we
detour through the expanded irect format between the in-core extent format
and the on-disk one instead of just endian swapping them.  But with the
incore extent btree the in-core one will use a different format and the
representation will be entirely hidden.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: iterate over extents in xfs_iextents_copy
Christoph Hellwig [Fri, 17 Nov 2017 04:11:34 +0000 (22:11 -0600)] 
xfs: iterate over extents in xfs_iextents_copy

Source kernel commit: 71565f4b92048321ba3078877dd1a1149a23550d

This actually makes the function very slightly less efficient for now as we
detour through the expanded irect format between the in-core extent format
and the on-disk one instead of just endian swapping them.  But with the
incore extent btree the in-core one will use a different format and the
representation will be entirely hidden.  It also happens to make the
function a whole more readable.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: pass an on-disk extent to xfs_bmbt_validate_extent
Christoph Hellwig [Fri, 17 Nov 2017 04:11:34 +0000 (22:11 -0600)] 
xfs: pass an on-disk extent to xfs_bmbt_validate_extent

Source kernel commit: f36bc228e1b94d9994915cba67588104ebe763ae

This prepares for getting rid of the current in-memory extent format.
At the end of the series we will change the calling convention again
to pass the xfs_bmbt_irec structure once it is available everywhere.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: treat idx as a cursor in xfs_bmap_collapse_extents
Christoph Hellwig [Fri, 17 Nov 2017 04:11:34 +0000 (22:11 -0600)] 
xfs: treat idx as a cursor in xfs_bmap_collapse_extents

Source kernel commit: 42630361003461edd7607c1d459ab9d66ef97813

Stop poking before and after the index and just increment or decrement
it while doing our operations on it to prepare for a new extent list
implementation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: treat idx as a cursor in xfs_bmap_del_extent_*
Christoph Hellwig [Fri, 17 Nov 2017 04:11:34 +0000 (22:11 -0600)] 
xfs: treat idx as a cursor in xfs_bmap_del_extent_*

Source kernel commit: 657fcb23362c9e8a72593b3e4755135f003a7a74

Stop poking before and after the index and just increment or decrement
it while doing our operations on it to prepare for a new extent list
implementation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: treat idx as a cursor in xfs_bmap_add_extent_unwritten_real
Christoph Hellwig [Fri, 17 Nov 2017 04:11:34 +0000 (22:11 -0600)] 
xfs: treat idx as a cursor in xfs_bmap_add_extent_unwritten_real

Source kernel commit: a681847796df31c036810bce97003f687e1db5f4

Stop poking before and after the index and just increment or decrement
it while doing our operations on it to prepare for a new extent list
implementation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: treat idx as a cursor in xfs_bmap_add_extent_hole_real
Christoph Hellwig [Fri, 17 Nov 2017 04:11:34 +0000 (22:11 -0600)] 
xfs: treat idx as a cursor in xfs_bmap_add_extent_hole_real

Source kernel commit: 1d2e0089e16642928c76f032c1dbd0eb6da22935

Stop poking before and after the index and just increment or decrement
it while doing our operations on it to prepare for a new extent list
implementation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: treat idx as a cursor in xfs_bmap_add_extent_hole_delay
Christoph Hellwig [Fri, 17 Nov 2017 04:11:34 +0000 (22:11 -0600)] 
xfs: treat idx as a cursor in xfs_bmap_add_extent_hole_delay

Source kernel commit: 41d196f439509fd8b09364ca1ba48194cccc6d6e

Stop poking before and after the index and just increment or decrement
it while doing our operations on it to prepare for a new extent list
implementation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: treat idx as a cursor in xfs_bmap_add_extent_delay_real
Christoph Hellwig [Fri, 17 Nov 2017 04:11:34 +0000 (22:11 -0600)] 
xfs: treat idx as a cursor in xfs_bmap_add_extent_delay_real

Source kernel commit: 0d045540ed57e68b9ddcf5c325279a7e5ede7bbf

Stop poking before and after the index and just increment or decrement
it while doing our operations on it to prepare for a new extent list
implementation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: remove a duplicate assignment in xfs_bmap_add_extent_delay_real
Christoph Hellwig [Fri, 17 Nov 2017 04:11:34 +0000 (22:11 -0600)] 
xfs: remove a duplicate assignment in xfs_bmap_add_extent_delay_real

Source kernel commit: bf99971c8200fcb3e16d880194f5d559aca09576

Reported-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: don't create overlapping extents in xfs_bmap_add_extent_delay_real
Christoph Hellwig [Fri, 17 Nov 2017 04:11:34 +0000 (22:11 -0600)] 
xfs: don't create overlapping extents in xfs_bmap_add_extent_delay_real

Source kernel commit: 1bfd7618cbf2de630c845f60f5370671c2cd1c5d

Two cases in xfs_bmap_add_extent_delay_real currently insert a new
extent before updating the existing one that is being split.  While
this works fine with a simple extent list, a more complex tree can't
easily cope with overlapping extent.  Reshuffle the code a bit to update
the slot of the existing delalloc extent to the new real extent before
inserting the shortened delalloc extent before or after it.  This
avoids the overlapping extents while still allowing to update the
br_startblock field of the delalloc extent with the updated indirect
block reservation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: convert remaining xfs_sb_version_... checks to bool
Dave Chinner [Fri, 17 Nov 2017 04:11:34 +0000 (22:11 -0600)] 
xfs: convert remaining xfs_sb_version_... checks to bool

Source kernel commit: 5d0eda0307ca20c5c58b1abd2a8ba822e0763b43

Some were missed in the pass that converted the function return
values from int to bool. Update the remaining ones for consistency.

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>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: move error injection tags into their own file
Darrick J. Wong [Fri, 17 Nov 2017 04:11:34 +0000 (22:11 -0600)] 
xfs: move error injection tags into their own file

Source kernel commit: e9e899a2a8c3c23b3084b048466f417ed92286d3

Move the error injection tag names into a libxfs header so that we can
share it between kernel and userspace.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: remove inode log format typedef
Darrick J. Wong [Fri, 17 Nov 2017 04:11:34 +0000 (22:11 -0600)] 
xfs: remove inode log format typedef

Source kernel commit: 06b1132120d446bbaf844cbbae51f0afd3baacb8

Remove xfs_inode_log_format_t now that xfs_inode_log_format is
explicitly padded and therefore is a real on-disk structure.  This
enables xfs/122 to check the size of the structure.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
[sandeen: same treatment in libxlog & logprint/ ]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: remove the inode log format from the inode log item
Christoph Hellwig [Fri, 17 Nov 2017 04:11:34 +0000 (22:11 -0600)] 
xfs: remove the inode log format from the inode log item

Source kernel commit: 2f251293b09065118d78ae4e883e5639cc22f94e

xfs: remove the inode log format from the inode log item

No need to keep the inode log format around all the time, we can
easily generate it at iop_format time.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
[sandeen: matching change in userspace xfs_trans.h]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: remove redundant assignment to variable bit
Colin Ian King [Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)] 
xfs: remove redundant assignment to variable bit

Source kernel commit: c06641169e861d6446a220cd7f0d22c6c88da8e1

Variable bit is being assigned a value that is never read, hence
the assignment is redundant and can be removed. Cleans up clang
warning:

fs/xfs/libxfs/xfs_rtbitmap.c:675:3: warning: Value stored to
'bit' is never read

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: compare btree block keys to parent block's keys during scrub
Darrick J. Wong [Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)] 
xfs: compare btree block keys to parent block's keys during scrub

Source kernel commit: 2fdbec5cbeb93349836d682b1caa5cc72d1b7018

When we're done checking all the records/keys in a btree block, compute
the low and high key of the block and compare them to the associated key
in the parent btree block.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: abort dir/attr btree operation if btree is obviously weird
Darrick J. Wong [Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)] 
xfs: abort dir/attr btree operation if btree is obviously weird

Source kernel commit: 8210f4dda2d7642cb7c882db55e53d899cced401

Abort an dir/attr btree operation if the attr btree has obvious problems
like loops back to the root or pointers don't point down the tree.
Found by fuzzing btree[0].before to zero in xfs/402, which livelocks on
the cycle in the attr btree.

Apply the same checks to xfs_da3_node_lookup_int.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: add a new xfs_iext_lookup_extent_before helper
Christoph Hellwig [Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)] 
xfs: add a new xfs_iext_lookup_extent_before helper

Source kernel commit: dc56015faff1bc9e7493c2b28302c423a02237c2

This helper looks up the last extent the covers space before the passed
in block number.  This is useful for truncate and similar operations that
operate backwards over the extent list.  For xfs_bunmapi it also is
a slight optimization as we can return early if there are not extents
at or below the end of the to be truncated range.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: merge xfs_bmap_read_extents into xfs_iread_extents
Christoph Hellwig [Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)] 
xfs: merge xfs_bmap_read_extents into xfs_iread_extents

Source kernel commit: 211e95bbab71359e56f3d9adce1b4d6de8e18471

xfs_iread_extents is just a trivial wrapper, there is no good reason
to keep the two separate.

[darrick: minor fixups having left xfs_bmbt_validate_extent intact]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: rewrite xfs_bmap_first_unused to make better use of xfs_iext_get_extent
Christoph Hellwig [Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)] 
xfs: rewrite xfs_bmap_first_unused to make better use of xfs_iext_get_extent

Source kernel commit: 29b3e94a9c65224733fe8de49b07b7227f95f821

Look at the return value of xfs_iext_get_extent instead of figuring out
the extent count first and looping up to it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: don't rely on extent indices in xfs_bmap_insert_extents
Christoph Hellwig [Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)] 
xfs: don't rely on extent indices in xfs_bmap_insert_extents

Source kernel commit: 5936dc543cfd27de74cd34fdc928b5115cec53d1

Rewrite xfs_bmap_insert_extents so that we don't rely on extent indices
except for iterating over them.  Not being able to iterate to the previous
extent or finding the extent that stop_fsb is in are sufficient exit
conditions, and we don't need to do any extent count games given that:

a) we already flushed all delalloc extents past our start offset
before doing the operation
b) xfs_iext_count() includes delalloc extents anyway

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: don't rely on extent indices in xfs_bmap_collapse_extents
Christoph Hellwig [Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)] 
xfs: don't rely on extent indices in xfs_bmap_collapse_extents

Source kernel commit: 40591bdbccc47661050d98200ab65e77fa2324bd

Rewrite xfs_bmap_collapse_extents so that we don't rely on extent indices
except for iterating over them.  Not being able to iterate to the next
extent is a sufficient exit condition, and we don't need to do any extent
count games given that:

a) we already flushed all delalloc extents past our start offset
before doing the operation
b) xfs_iext_count() includes delalloc extents anyway

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: update got in xfs_bmap_shift_update_extent
Christoph Hellwig [Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)] 
xfs: update got in xfs_bmap_shift_update_extent

Source kernel commit: 11f75b3bbad57998d1af99391ec3a8e076ab4dd9

This way the caller gets the proper updated extent returned in got.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: remove xfs_bmse_shift_one
Christoph Hellwig [Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)] 
xfs: remove xfs_bmse_shift_one

Source kernel commit: bf8062800ad2d1ca22950c28910196bcbda89108

Instead do the actual left and right shift work in the callers, and just
keep a helper to update the bmap and rmap btrees as well as the in-core
extent list.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: split xfs_bmap_shift_extents
Christoph Hellwig [Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)] 
xfs: split xfs_bmap_shift_extents

Source kernel commit: ecfea3f0c8c64ce7375f4be4506996968958bd01

Have a separate helper for insert vs collapse, as this prepares us for
simplifying the code in the next patches.

Also changed the done output argument to a bool intead of int for both
new functions.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: remove XFS_BMAP_MAX_SHIFT_EXTENTS
Christoph Hellwig [Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)] 
xfs: remove XFS_BMAP_MAX_SHIFT_EXTENTS

Source kernel commit: 6b18af0dfd1695c1d53a2eeead838a90c27b7cb4

The define was always set to 1, which means looping until we reach is
was dead code from the start.

Also remove an initialization of next_fsb for the done case that doesn't
fit the new code flow - it was never checked by the caller in the done
case to start with.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: remove if_rdev
Christoph Hellwig [Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)] 
xfs: remove if_rdev

Source kernel commit: 66f364649d870c7541c30a2f02a32fd4c88684f0

We can simply use the i_rdev field in the Linux inode and just convert
to and from the XFS dev_t when reading or logging/writing the inode.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: add i_rdev to our mocked up inode in userspace]
[djwong: use IRIX_DEV macros, assign in i_rdev in libxfs_ialloc]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: remove the never fully implemented UUID fork format
Christoph Hellwig [Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)] 
xfs: remove the never fully implemented UUID fork format

Source kernel commit: 42b67dc6ffbf2701cfc578b3e706d560a80b6674

Remove the dead code dealing with the UUID fork format that was never
implemented in Linux (and neither in IRIX as far as I know).

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>
[sandeen: use __u8 not u8 for now, adapt xfs_logprint]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: remove XFS_BMAP_TRACE_EXLIST
Christoph Hellwig [Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)] 
xfs: remove XFS_BMAP_TRACE_EXLIST

Source kernel commit: e8e0e170e2e17b601b86edb86f58dbf7c599e4b3

Instead of looping over all extents in some debug-only helper just
insert trace points into the loops that already exist in the calling
functions.

Also split the xfs_extlist trace point into one each for reading and
writing extents from disk.

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>
[sandeen: userspace-specific tracepoint macro updates]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: move pre/post-bmap tracing into xfs_iext_update_extent
Christoph Hellwig [Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)] 
xfs: move pre/post-bmap tracing into xfs_iext_update_extent

Source kernel commit: ca5d8e5b7b9030005e38e7c43e08c0cd4eb2a78f

xfs_iext_update_extent already has basically all the information needed
to centralize the bmap pre/post tracing.  We just need to pass inode +
bmap state instead of the inode fork pointer to get all trace annotations.

In addition to covering all the existing trace points this gives us
tracing coverage for the extent shifting operations for free.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: remove post-bmap tracing in xfs_bmap_local_to_extents
Christoph Hellwig [Fri, 17 Nov 2017 04:11:32 +0000 (22:11 -0600)] 
xfs: remove post-bmap tracing in xfs_bmap_local_to_extents

Source kernel commit: d138604fb1a6500064b50e75f220e6cbce785493

Now that we use xfs_iext_insert this is already covered by the tracing
in that function.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: make better use of the 'state' variable in xfs_bmap_del_extent_real
Christoph Hellwig [Fri, 17 Nov 2017 04:11:32 +0000 (22:11 -0600)] 
xfs: make better use of the 'state' variable in xfs_bmap_del_extent_real

Source kernel commit: 35e62da55f4b2450cbb51c9734d745a799e2a793

We already have all the information about the fork a=D1=95 well as additional
tracing information, so pass that to xfs_iext_remove().

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: add a xfs_bmap_fork_to_state helper
Christoph Hellwig [Fri, 17 Nov 2017 04:11:32 +0000 (22:11 -0600)] 
xfs: add a xfs_bmap_fork_to_state helper

Source kernel commit: 060ea65b39409f3b9952dfa6db5fbe4355e6888a

This creates the right initial bmap state from the passed in inode
fork enum.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: scrub quota information
Darrick J. Wong [Fri, 17 Nov 2017 04:11:32 +0000 (22:11 -0600)] 
xfs: scrub quota information

Source kernel commit: c2fc338c87a31f557b57f5143602444ba3cf2c3e

Perform some quick sanity testing of the disk quota information.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: scrub realtime bitmap/summary
Darrick J. Wong [Fri, 17 Nov 2017 04:11:32 +0000 (22:11 -0600)] 
xfs: scrub realtime bitmap/summary

Source kernel commit: 29b0767b8beb4c5e3fd94656d51413a4fe8d2d74

Perform simple tests of the realtime bitmap and summary.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: scrub directory parent pointers
Darrick J. Wong [Fri, 17 Nov 2017 04:11:32 +0000 (22:11 -0600)] 
xfs: scrub directory parent pointers

Source kernel commit: 0f28b25731f76feda1ec71671754a2b7179ee1ef

Scrub parent pointers, sort of.  For directories, we can ride the
'..' entry up to the parent to confirm that there's at most one
dentry that points back to this directory.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: scrub symbolic links
Darrick J. Wong [Fri, 17 Nov 2017 04:11:32 +0000 (22:11 -0600)] 
xfs: scrub symbolic links

Source kernel commit: 2a721dbbc8bf4d76581fb073aa0d9554df56da1a

Create the infrastructure to scrub symbolic link data.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: scrub extended attributes
Darrick J. Wong [Fri, 17 Nov 2017 04:11:32 +0000 (22:11 -0600)] 
xfs: scrub extended attributes

Source kernel commit: eec0482e0829eab1da1be693e524c889dc4b168c

Scrub the hash tree, keys, and values in an extended attribute structure.
Refactor the attribute code to use the transaction if the caller supplied
one to avoid buffer deadocks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: scrub directory metadata
Darrick J. Wong [Fri, 17 Nov 2017 04:11:32 +0000 (22:11 -0600)] 
xfs: scrub directory metadata

Source kernel commit: a5c46e5e8912d232b959faf511cd9a17cc829f0a

Scrub the hash tree and all the entries in a directory.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: scrub inode block mappings
Darrick J. Wong [Fri, 17 Nov 2017 04:11:32 +0000 (22:11 -0600)] 
xfs: scrub inode block mappings

Source kernel commit: 99d9d8d05da26f47aa8412397407f962bcb4713a

Scrub an individual inode's block mappings to make sure they make sense.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: scrub inodes
Darrick J. Wong [Fri, 17 Nov 2017 04:11:32 +0000 (22:11 -0600)] 
xfs: scrub inodes

Source kernel commit: 80e4e12688029e42fc6ab4cf7f229b090c61e6a7

Scrub the fields within an inode.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: scrub refcount btrees
Darrick J. Wong [Fri, 17 Nov 2017 04:11:32 +0000 (22:11 -0600)] 
xfs: scrub refcount btrees

Source kernel commit: edc09b528628afb50904106f36de182a00e7eb40

Plumb in the pieces necessary to check the refcount btree.  If rmap is
available, check the reference count by performing an interval query
against the rmapbt.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: scrub rmap btrees
Darrick J. Wong [Fri, 17 Nov 2017 04:11:32 +0000 (22:11 -0600)] 
xfs: scrub rmap btrees

Source kernel commit: c7e693d9836c003150fef80be40a06e1f2e65d0c

Check the reverse mapping records to make sure that the contents
make sense.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: scrub inode btrees
Darrick J. Wong [Fri, 17 Nov 2017 04:11:32 +0000 (22:11 -0600)] 
xfs: scrub inode btrees

Source kernel commit: 3daa664191375db6a4a0cced75183aa3ca96cbda

Check the records of the inode btrees to make sure that the values
make sense given the inode records themselves.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: scrub free space btrees
Darrick J. Wong [Fri, 17 Nov 2017 04:11:32 +0000 (22:11 -0600)] 
xfs: scrub free space btrees

Source kernel commit: efa7a99ce1f8615aca7b0ff3122a1ae14e4d1cdc

Check the extent records free space btrees to ensure that the values
look sane.

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>