]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/log
thirdparty/xfsprogs-dev.git
6 years agometadump/restore: don't use errno after fwrite/fread failures
Eric Sandeen [Tue, 27 Mar 2018 02:27:31 +0000 (21:27 -0500)] 
metadump/restore: don't use errno after fwrite/fread failures

fread/fwrite don't set errno, so printing out strerror(errno)
after a failure leads to incorrect and confusing messages:

# xfs_mdrestore pre_repair.meta pre_repair.img
xfs_mdrestore: error reading from file: Success

Don't return unset errno from write_index, either.

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 agomkfs: enable sparse inodes by default
Darrick J. Wong [Tue, 27 Mar 2018 02:27:31 +0000 (21:27 -0500)] 
mkfs: enable sparse inodes by default

Enable the sparse inode feature by default.

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_fsr: refactor mountpoint finding to use libfrog paths functions
Darrick J. Wong [Tue, 27 Mar 2018 02:27:31 +0000 (21:27 -0500)] 
xfs_fsr: refactor mountpoint finding to use libfrog paths functions

Refactor the mount-point finding code in fsr to use the libfrog helpers
instead of open-coding yet another routine.

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: fs_table_lookup_mount should realpath the argument
Darrick J. Wong [Tue, 27 Mar 2018 02:27:28 +0000 (21:27 -0500)] 
libfrog: fs_table_lookup_mount should realpath the argument

Call realpath on the dir argument so that we're comparing canonical
paths when looking for the mountpoint.  This fixes the problem where
'/home/' doesn't match '/home' even though they refer to the same thing.

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_repair: use custom ifork verifier in mv_orphanage
Eric Sandeen [Tue, 27 Mar 2018 02:27:28 +0000 (21:27 -0500)] 
xfs_repair: use custom ifork verifier in mv_orphanage

Now that we have a custom verifier which can ignore parent
inode numbers, use it in mv_orphanage() as well; orphan inodes
may have invalid parents, and we're about to reconnect
them anyway, so override that test when we get them off disk.

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_repair: implement custom ifork verifiers
Darrick J. Wong [Tue, 27 Mar 2018 02:27:28 +0000 (21:27 -0500)] 
xfs_repair: implement custom ifork verifiers

There are a few cases where an early stage of xfs_repair will write an
invalid inode fork buffer to signal to a later stage that it needs to
correct the value.  This happens in phase 4 when we detect an inline
format directory with an invalid .. pointer.  To avoid triggering the
ifork verifiers on this, inject a custom verifier for phase 6 that lets
this pass for now.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_scrub: add missing paths header
Baruch Siach [Tue, 27 Mar 2018 02:27:28 +0000 (21:27 -0500)] 
xfs_scrub: add missing paths header

Fix the following build failure with musl libc:

xfs_scrub.c: In function ‘main’:
xfs_scrub.c:670:11: error: ‘_PATH_MOUNTED’ undeclared (first use in this function)
    mtab = _PATH_MOUNTED;
           ^~~~~~~~~~~~~

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoworkqueue: add missing pthreads header
Baruch Siach [Tue, 27 Mar 2018 02:27:28 +0000 (21:27 -0500)] 
workqueue: add missing pthreads header

Fix the following build failure with musl libc:

In file included from read_verify.c:25:0:
../include/workqueue.h:39:2: error: unknown type name 'pthread_t'
  pthread_t  *threads;
  ^~~~~~~~~
../include/workqueue.h:42:2: error: unknown type name 'pthread_mutex_t'
  pthread_mutex_t  lock;
  ^~~~~~~~~~~~~~~
../include/workqueue.h:43:2: error: unknown type name 'pthread_cond_t'
  pthread_cond_t  wakeup;
  ^~~~~~~~~~~~~~

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_io: fix operation time reporting
Dave Chinner [Tue, 27 Mar 2018 02:27:28 +0000 (21:27 -0500)] 
xfs_io: fix operation time reporting

CUrrently the 100th/sec units always report zero, such as:

32 MiB, 8192 ops; 0:00:21.00 (1.476 MiB/sec and 377.9260 ops/sec)
                          ^^

This is incorrect. Fix the maths that is wrong by removing all the
unnecesary floating point maths and just using basic integer
division...

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_repair: don't fail directory repairs when grabbing inodes
Darrick J. Wong [Fri, 9 Mar 2018 02:35:23 +0000 (20:35 -0600)] 
xfs_repair: don't fail directory repairs when grabbing inodes

There are a few places where xfs_repair needs to be able to load a
damaged directory inode to perform repairs.  Since inline data fork
verifiers can now be customized, refactor libxfs_iget to enable
repair to get at this so that we don't crash in phase 6.

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_db: print transaction reservation type information
Darrick J. Wong [Fri, 9 Mar 2018 02:35:23 +0000 (20:35 -0600)] 
xfs_db: print transaction reservation type information

Create a new xfs_db command to print the transaction reservation info for
a given filesystem.  This will make it easier to compare the calculations
made by the kernel and xfsprogs in case there is a discrepancy.

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_scrub: don't try to scan xattrs if bstat says there aren't any
Darrick J. Wong [Fri, 9 Mar 2018 02:35:23 +0000 (20:35 -0600)] 
xfs_scrub: don't try to scan xattrs if bstat says there aren't any

Only try to scan the extended attributes of a file if bstat says that
the file actually has any.  Surprisingly, this reduces the phase 5
runtime by 40% if most of the files don't have attrs.

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_scrub: fix #include ordering to avoid build failure
Darrick J. Wong [Fri, 9 Mar 2018 02:35:23 +0000 (20:35 -0600)] 
xfs_scrub: fix #include ordering to avoid build failure

Fix the ordering of the header includes in all the scrub source.  We put
xfs.h first so that it will pull in include/linux.h which pulls in
linux/fs.h + whatever overrides are necessary (currently limited to
struct fsxattr) to make things work on this platform, and then we remove
the #includes for anything that will get pulled (directly or indirectly)
by xfs.h for cleanliness.  Without this, a user compiling new xfsprogs
on a system with a 4.7 kernel gets this:

Building scrub
    [CC]     disk.o
In file included from ../include/xfs.h:37:0,
                 from disk.c:40:
../include/xfs/linux.h:185:8: error: redefinition of 'struct fsxattr'
 struct fsxattr {
        ^~~~~~~
In file included from disk.c:31:0:
/usr/include/linux/fs.h:155:8: note: originally defined here
 struct fsxattr {
        ^~~~~~~
gmake[2]: *** [../include/buildrules:60: disk.o] Error 1
gmake[1]: *** [include/buildrules:36: scrub] Error 2
make: *** [Makefile:77: default] Error 2

Reported-by: Mikael Magnusson <mikachu@gmail.com>
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_scrub: don't ask user to run xfs_repair for only warnings
Darrick J. Wong [Fri, 9 Mar 2018 02:35:23 +0000 (20:35 -0600)] 
xfs_scrub: don't ask user to run xfs_repair for only warnings

Don't advise the user to run xfs_repair on a filesystem that triggers
warnings but no errors; there's no corruption for it to fix.

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_scrub: log operational messages when interactive
Darrick J. Wong [Fri, 9 Mar 2018 02:35:23 +0000 (20:35 -0600)] 
xfs_scrub: log operational messages when interactive

Record the summary of an interactive session in the system log so that
future support requests can get a better picture of what happened.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_db: don't crash in ablock if there's no inode
Darrick J. Wong [Fri, 9 Mar 2018 02:35:23 +0000 (20:35 -0600)] 
xfs_db: don't crash in ablock if there's no inode

Make sure we actually have an inode selected before trying to unwrap its
attribute fork.  Found via a crash in xfs/288 with project quotas
enabled.

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 agomisc: fix gcc 7.3 warnings
Darrick J. Wong [Fri, 9 Mar 2018 02:35:22 +0000 (20:35 -0600)] 
misc: fix gcc 7.3 warnings

Fix various compiler warnings that pop up in 7.3.

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: new libxfs-apply option for Signed-off-by: tag
Eric Sandeen [Fri, 9 Mar 2018 02:35:22 +0000 (20:35 -0600)] 
xfsprogs: new libxfs-apply option for Signed-off-by: tag

Technically when a maintainer moves a patch from another project,
they should add their Signed-off-by: tag.  Get that info automatically
from git-config, and add an option to to override it if desired,
to make that easy when cross-porting libxfs patches

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 agoxfsprogs: call libxfs_destroy from other utilities
Eric Sandeen [Fri, 9 Mar 2018 02:35:22 +0000 (20:35 -0600)] 
xfsprogs: call libxfs_destroy from other utilities

Call libxfs_destroy() from xfs_copy, xfs_db, mkfs.xfs, and
xfs_repair to allow us to detect leaked items in these
utilities as well.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agolibxfs: Catch non-empty zones on destroy
Eric Sandeen [Fri, 9 Mar 2018 02:35:22 +0000 (20:35 -0600)] 
libxfs: Catch non-empty zones on destroy

Create and use a kmem_zone_destroy which warns if we are
releasing a non-empty zone when the LIBXFS_LEAK_CHECK
environment variable is set, wire this into libxfs_destroy(),
and call that when various tools exit.

The LIBXFS_LEAK_CHECK environment variable also causes
the program to exit with failure when a leak is detected,
useful for failing automated tests if leaks are encountered.

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 agolibxfs: move xfs_inode_zone to rdwr.c
Eric Sandeen [Fri, 9 Mar 2018 02:35:22 +0000 (20:35 -0600)] 
libxfs: move xfs_inode_zone to rdwr.c

The zone itself is created in rdwr.c, so define it there as
well, and add it to the list of externs in manage_zones along
with all the rest, for consistency.

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 agolibxfs: add function to free all buffers in bcache
Eric Sandeen [Fri, 9 Mar 2018 02:35:22 +0000 (20:35 -0600)] 
libxfs: add function to free all buffers in bcache

libxfs_bcache_purge simply moves all "free" buffers
onto the xfs_buf_freelist mru list; add a new function to
actually free them when we tear everything down, so leak
checkers don't go nuts about lots of unfreed xfs_bufs
at exit.

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 agolibxfs: Replace XFS_BUF_SET_PTR with xfs_buf_associate_memory
Eric Sandeen [Fri, 9 Mar 2018 02:35:22 +0000 (20:35 -0600)] 
libxfs: Replace XFS_BUF_SET_PTR with xfs_buf_associate_memory

We test the return value of the macro, but it returns
returns a side-effect which looks like failure.  Write
a userspace-libxfs-specific version of xfs_buf_associate_memory
to make this code a tad more like the kernel, with a proper
return value to boot.

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: add RWF_DSYNC support to pwrite
Dave Chinner [Fri, 9 Mar 2018 02:35:22 +0000 (20:35 -0600)] 
xfs_io: add RWF_DSYNC support to pwrite

Enable testing write behaviour with the per-io RWF_DSYNC flag.

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_scrub: make interpreter explicit to python3
Luis R. Rodriguez [Fri, 9 Mar 2018 02:35:22 +0000 (20:35 -0600)] 
xfs_scrub: make interpreter explicit to python3

Using #!/usr/bin/env makes some package dependency tools
such as rpm complain given that it cannot verify package
dependencies. Making it explicit resolves this lint rant.

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_repair: Add missing braces to allow zeroing of corrupt log
Xiao Yang [Fri, 9 Mar 2018 02:35:20 +0000 (20:35 -0600)] 
xfs_repair: Add missing braces to allow zeroing of corrupt log

When xlog_find_tail() fails to find the head or the tail, the missing
braces leads that an unparseable log always exits with status 2, even
if we've asked for -n or -L which should proceed.  We can expose this
issue by xfstests case xfs/098.

Fixes: commit b04647edea32 ("xfs_repair: exit with status 2 if log dirtiness is unknown")
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_io: support a basic extent swap command
Brian Foster [Fri, 9 Mar 2018 02:35:20 +0000 (20:35 -0600)] 
xfs_io: support a basic extent swap command

Extent swap is a low level mechanism exported by XFS to facilitate
filesystem defragmentation. It is typically invoked by xfs_fsr under
conditions that will atomically adjust inode extent state without
loss of file data.

While xfs_fsr provides some debug capability to tailor its behavior,
it is not flexible enough to facilitate low level tests of the
extent swap mechanism. For example, xfs_fsr may skip swaps between
inodes that consist solely of preallocated extents because it
considers such files already 100% defragmented. Further, xfs_fsr
copies data between files where doing so may be unnecessary and thus
inefficient for lower level tests.

Add a basic swapext command to xfs_io that allows userspace
invocation of the command under more controlled conditions. This
facilites targeted tests without interference from xfs_fsr policy,
such as using files with only preallocated extents, known/expected
failure cases, etc. This command makes no effort to retain data
across the operation. As such, it is for testing purposes only.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-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_io: Add missing perror for write_once (-O)
Goldwyn Rodrigues [Fri, 9 Mar 2018 02:35:20 +0000 (20:35 -0600)] 
xfs_io: Add missing perror for write_once (-O)

This got missed in the last set of patches.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomisc: enable link time optimization, if requested
Darrick J. Wong [Fri, 9 Mar 2018 02:35:20 +0000 (20:35 -0600)] 
misc: enable link time optimization, if requested

Enable link time optimization (LTO) if the builder requests it.  The
extra link optimization results in smaller binaries.

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 agomisc: enable retpolines across all xfsprogs utilities
Darrick J. Wong [Fri, 9 Mar 2018 02:35:20 +0000 (20:35 -0600)] 
misc: enable retpolines across all xfsprogs utilities

Detect and enable retpolines for all code, to mitigate Spectre v2
(branch target injection) on x86.

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: fix u32 type usage in sb validation function libxfs-4.16-sync
Darrick J. Wong [Wed, 28 Feb 2018 19:46:11 +0000 (13:46 -0600)] 
xfs: fix u32 type usage in sb validation function

Source kernel commit: 131fa58d391fc0939f6c66b23776ad5df5db20f9

Don't use u32, use uint32_t, because this won't work in xfsprogs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
[sandeen: no-op commit, fixed previously to keep build working]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: don't screw up direct writes when freesp is fragmented
Darrick J. Wong [Tue, 27 Feb 2018 04:43:19 +0000 (22:43 -0600)] 
xfs: don't screw up direct writes when freesp is fragmented

Source kernel commit: 6d8a45ce29c7d67cc4fc3016dc2a07660c62482a

xfs_bmap_btalloc is given a range of file offset blocks that must be
allocated to some data/attr/cow fork.  If the fork has an extent size
hint associated with it, the request will be enlarged on both ends to
try to satisfy the alignment hint.  If free space is fragmentated,
sometimes we can allocate some blocks but not enough to fulfill any of
the requested range.  Since bmapi_allocate always trims the new extent
mapping to match the originally requested range, this results in
bmapi_write returning zero and no mapping.

The consequences of this vary -- buffered writes will simply re-call
bmapi_write until it can satisfy at least one block from the original
request.  Direct IO overwrites notice nmaps == 0 and return -ENOSPC
through the dio mechanism out to userspace with the weird result that
writes fail even when we have enough space because the ENOSPC return
overrides any partial write status.  For direct CoW writes the situation
was disastrous because nobody notices us returning an invalid zero-length
wrong-offset mapping to iomap and the write goes off into space.

Therefore, if free space is so fragmented that we managed to allocate
some space but not enough to map into even a single block of the
original allocation request range, we should break the alignment hint in
order to guarantee at least some forward progress for the direct write.
If we return a short allocation to iomap_apply it'll call back about the
remaining blocks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: treat CoW fork operations as delalloc for quota accounting
Darrick J. Wong [Tue, 27 Feb 2018 04:43:19 +0000 (22:43 -0600)] 
xfs: treat CoW fork operations as delalloc for quota accounting

Source kernel commit: 4b4c1326fd7c7210d23d9dd3bfc51f2b6477bb9e

Since the CoW fork only exists in memory, it is incorrect to update the
on-disk quota block counts when we modify the CoW fork.  Unlike the data
fork, even real extents in the CoW fork are only delalloc-style
reservations (on-disk they're owned by the refcountbt) so they must not
be tracked in the on disk quota info.  Ensure the i_delayed_blks
accounting reflects this too.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: refactor accounting updates out of xfs_bmap_btalloc
Darrick J. Wong [Tue, 27 Feb 2018 04:43:19 +0000 (22:43 -0600)] 
xfs: refactor accounting updates out of xfs_bmap_btalloc

Source kernel commit: 751f3767c245f9adf4f0a4f8f04aae9ae1d675a0

Move all the inode and quota accounting updates out of xfs_bmap_btalloc
in preparation for fixing some quota accounting problems with copy on
write.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: refactor inode verifier corruption error printing
Darrick J. Wong [Tue, 27 Feb 2018 04:43:19 +0000 (22:43 -0600)] 
xfs: refactor inode verifier corruption error printing

Source kernel commit: 22431bf3dfbf44d7356933776eb486a6a01dea6f

Refactor inode verifier error reporting into a non-libxfs function so
that we aren't encoding the message format in libxfs.  This also
changes the kernel dmesg output to resemble buffer verifier errors
more closely.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: bmap code cleanup
Shan Hai [Tue, 27 Feb 2018 04:43:19 +0000 (22:43 -0600)] 
xfs: bmap code cleanup

Source kernel commit: 6ca30729c206d62d88730a904af7d543a56273d8

Remove the extent size hint and realtime inode relevant code from
the xfs_bmapi_reserve_delalloc since it is not called on the inode
with extent size hint set or on a realtime inode.

Signed-off-by: Shan Hai <shan.hai@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>
6 years agoSplit buffer's b_fspriv field
Carlos Maiolino [Tue, 27 Feb 2018 04:43:19 +0000 (22:43 -0600)] 
Split buffer's b_fspriv field

Source kernel commit: fb1755a645972ed096047583600838f6cf414e2b

By splitting the b_fspriv field into two different fields (b_log_item
and b_li_list). It's possible to get rid of an old ABI workaround, by
using the new b_log_item field to store xfs_buf_log_item separated from
the log items attached to the buffer, which will be linked in the new
b_li_list field.

This way, there is no more need to reorder the log items list to place
the buf_log_item at the beginning of the list, simplifying a bit the
logic to handle buffer IO.

This also opens the possibility to change buffer's log items list into a
proper list_head.

b_log_item field is still defined as a void *, because it is still used
by the log buffers to store xlog_in_core structures, and there is no
need to add an extra field on xfs_buf just for xlog_in_core.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[darrick: minor style changes]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: b_li_list unused in userspace]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: convert to new i_version API
Jeff Layton [Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)] 
xfs: convert to new i_version API

Source kernel commit: f0e28280629e0ec7921f3179409a179b1ea41f24

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Acked-by: Darrick J. Wong <darrick.wong@oracle.com>
Acked-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: check sb_agblocks and sb_agblklog when validating superblock
Darrick J. Wong [Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)] 
xfs: check sb_agblocks and sb_agblklog when validating superblock

Source kernel commit: 4bb73d014785cc55225686f9f46e7192fb59d26b

Currently, we don't check sb_agblocks or sb_agblklog when we validate
the superblock, which means that we can fuzz garbage values into those
values and the mount succeeds.  This leads to all sorts of UBSAN
warnings in xfs/350 since we can then coerce other parts of xfs into
shifting by ridiculously large values.

Once we've validated agblocks, make sure the agcount makes sense.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
[sandeen: fix up u32 usage now so we keep building]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: recheck reflink / dirty page status before freeing CoW reservations
Darrick J. Wong [Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)] 
xfs: recheck reflink / dirty page status before freeing CoW reservations

Source kernel commit: be78ff0e72778eb4df4aac66edb9e97462bfe00d

Eryu Guan reported seeing occasional hangs when running generic/269 with
a new fsstress that supports clonerange/deduperange.  The cause of this
hang is an infinite loop when we convert the CoW fork extents from
unwritten to real just prior to writing the pages out; the infinite
loop happens because there's nothing in the CoW fork to convert, and so
it spins forever.

The fundamental issue here is that when we go to perform these CoW fork
conversions, we're supposed to have an extent waiting for us, but the
low space CoW reaper has snuck in and blown them away!  There are four
conditions that can dissuade the reaper from touching our file -- no
reflink iflag; dirty page cache; writeback in progress; or directio in
progress.  We check the four conditions prior to taking the locks, but
we neglect to recheck them once we have the locks, which is how we end
up whacking the writeback that's in progress.

Therefore, refactor the four checks into a helper function and call it
once again once we have the locks to make sure we really want to reap
the inode.  While we're at it, add an ASSERT for this weird condition so
that we'll fail noisily if we ever screw this up again.

Reported-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Tested-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: btree format ifork loader should check for zero numrecs
Darrick J. Wong [Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)] 
xfs: btree format ifork loader should check for zero numrecs

Source kernel commit: 55e45429ce3e4ac9dd2bf4937b1a499a69ccc4ca

A btree format inode fork with zero records makes no sense, so reject it
if we see it, or else we can miscalculate memory allocations.  Found by
zeroes fuzzing {a,u3}.bmbt.numrecs in xfs/{374,378,412} with KASAN.

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: attr leaf verifier needs to check for obviously bad count
Darrick J. Wong [Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)] 
xfs: attr leaf verifier needs to check for obviously bad count

Source kernel commit: 79a69bf8dc240ebeb105226a8a8540df136bf987

In the attribute leaf verifier, we can check for obviously bad values of
firstused and count so that later attempts at lasthash don't run off the
end of the memory buffer.  Found by ones fuzzing hdr.count in xfs/400 with
KASAN.

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: directory scrubber must walk through data block to offset
Darrick J. Wong [Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)] 
xfs: directory scrubber must walk through data block to offset

Source kernel commit: ce92d29ddf9908d397895c46b7c78e9db8df414d

In xfs_scrub_dir_rec, we must walk through the directory block entries
to arrive at the offset given by the hash structure.  If we blindly
trust the hash address, we can end up midway into a directory entry and
stray outside the block.  Found by lastbit fuzzing lents[3].address in
xfs/390 with KASAN enabled.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: cross-reference the realtime bitmap
Darrick J. Wong [Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)] 
xfs: cross-reference the realtime bitmap

Source kernel commit: 46d9bfb5e706493777b9dfed666cd8967f69e6fd

While we're scrubbing various btrees, cross-reference the records
with the other 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>
6 years agoxfs: add scrub cross-referencing helpers for the refcount btrees
Darrick J. Wong [Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)] 
xfs: add scrub cross-referencing helpers for the refcount btrees

Source kernel commit: 49db55eca5665e32c9d3e67a7d5694bcc6c274de

Add a couple of functions to the refcount btrees that will be used
to cross-reference metadata against the refcountbt.

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: add scrub cross-referencing helpers for the rmap btrees
Darrick J. Wong [Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)] 
xfs: add scrub cross-referencing helpers for the rmap btrees

Source kernel commit: ed7c52d4bf92ac1f05b8c251a44a8bf4688f8786

Add a couple of functions to the rmap btrees that will be used
to cross-reference metadata 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: add scrub cross-referencing helpers for the inode btrees
Darrick J. Wong [Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)] 
xfs: add scrub cross-referencing helpers for the inode btrees

Source kernel commit: 2e001266b67c865ad904e1889658282d0773b207

Add a couple of functions to the inode btrees that will be used
to cross-reference metadata against the inobt.

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: add scrub cross-referencing helpers for the free space btrees
Darrick J. Wong [Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)] 
xfs: add scrub cross-referencing helpers for the free space btrees

Source kernel commit: ce1d802e6a889b8ee53b3444c6d7e8cfecadac50

Add a couple of functions to the free space btrees that will be used
to cross-reference metadata against the bnobt/cntbt, and a generic
btree function that provides the real implementation.

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: cancel tx on xfs_defer_finish() error during xattr set/remove
Brian Foster [Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)] 
xfs: cancel tx on xfs_defer_finish() error during xattr set/remove

Source kernel commit: c468562879a766de2c2fbedd41b653a7bf4c157d

Chris Dunlop reports a problem where an xattr operation fails,
reports the following error to syslog and hangs during unmount:

================================================
[ BUG: lock held when returning to user space! ]
...
------------------------------------------------
<PID> is leaving the kernel with locks still held!
1 lock held by <PID>:
#0:  (sb_internal){......}, at: [<ffffffffa07692a3>] xfs_trans_alloc+0xe3/0x130 [xfs]

The failure/shutdown occurs during deferred ops processing which
leads to an error return from xfs_defer_finish() via
xfs_attr_leaf_addname(). While the root cause of the failure is
unknown corruption, the cause of the subsequent BUG above and
unmount hang is failure to cancel the transaction before returning
to userspace.

The transaction is not cancelled because the out_defer_cancel error
handling paths in the xfs_attr_[leaf|node]_[add|remove]name()
functions clear args.trans without releasing the transaction. The
callers therefore lose the reference to the transaction and fail to
cancel it.

Since xfs_attr_[set|remove]() always cancel args.trans when != NULL
and xfs_defer_finish()->...->xfs_trans_roll() should always return
with a valid transaction, update the leaf/node xattr functions to
not reset args.trans in the error path responsible for cancelling
deferred ops.

Reported-by: Chris Dunlop <chris@onthe.net.au>
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>
6 years agoxfs: account finobt blocks properly in perag reservation
Brian Foster [Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)] 
xfs: account finobt blocks properly in perag reservation

Source kernel commit: ad90bb585c45917b6c1bb01c812fba337e689362

XFS started using the perag metadata reservation pool for free inode
btree blocks in commit 76d771b4cbe33 ("xfs: use per-AG reservations
for the finobt"). To handle backwards compatibility, finobt blocks
are accounted against the pool so long as the full reservation is
available at mount time. Otherwise the ->m_inotbt_nores flag is set
and the filesystem falls back to the traditional per-transaction
finobt reservation.

This commit has two problems:

- finobt blocks are always accounted against the metadata
reservation on allocation, regardless of ->m_inotbt_nores state
- finobt blocks are never returned to the reservation pool on free

The first problem affects reflink+finobt filesystems where the full
finobt reservation is not available at mount time. finobt blocks are
essentially stolen from the reflink reservation, putting refcountbt
management at risk of allocation failure. The second problem is an
unconditional leak of metadata reservation whenever finobt is
enabled.

Update the finobt block allocation callouts to consider
->m_inotbt_nores and account blocks appropriately. Blocks should be
consistently accounted against the metadata pool when
->m_inotbt_nores is false and otherwise tagged as RESV_NONE.

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>
6 years agoxfs: fix check on struct_version for versions 4 or greater
Colin Ian King [Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)] 
xfs: fix check on struct_version for versions 4 or greater

Source kernel commit: a8789a5ae28f69d7f3791a0e74f8c44222f3108b

It appears that the check for versions 4 or more is incorrect and is
off-by-one. Fix this.

Detected by CoverityScan, CID#1463775 ("Logically dead code")

Fixes: ac503a4cc9e8 ("xfs: refactor the geometry structure filling function")
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: use %px for data pointers when debugging
Darrick J. Wong [Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)] 
xfs: use %px for data pointers when debugging

Source kernel commit: c96900435fa9fdfd9702a60cd765bd85e380303e

Starting with commit 57e734423ad ("vsprintf: refactor %pK code out of
pointer"), the behavior of the raw '%p' printk format specifier was
changed to print a 32-bit hash of the pointer value to avoid leaking
kernel pointers into dmesg.  For most situations that's good.

This is /undesirable/ behavior when we're trying to debug XFS, however,
so define a PTR_FMT that prints the actual pointer when we're in debug
mode.

Note that %p for tracepoints still prints the raw pointer, so in the
long run we could consider rewriting some of these messages as
tracepoints.

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: change 0x%p -> %p in print messages
Darrick J. Wong [Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)] 
xfs: change 0x%p -> %p in print messages

Source kernel commit: 3d170aa24283568b1ed92a09daa0e05a8788c6a4

Since %p prepends "0x" to the outputted string, we can drop the prefix.

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: harden directory integrity checks some more
Darrick J. Wong [Tue, 27 Feb 2018 04:43:17 +0000 (22:43 -0600)] 
xfs: harden directory integrity checks some more

Source kernel commit: 46c59736d8090e602f960aeaf1c6b8292151bf38

If a malicious filesystem image contains a block+ format directory
wherein the directory inode's core.mode is set such that
S_ISDIR(core.mode) == 0, and if there are subdirectories of the
corrupted directory, an attempt to traverse up the directory tree will
crash the kernel in __xfs_dir3_data_check.  Running the online scrub's
parent checks will tend to do this.

The crash occurs because the directory inode's d_ops get set to
xfs_dir[23]_nondir_ops (it's not a directory) but the parent pointer
scrubber's indiscriminate call to xfs_readdir proceeds past the ASSERT
if we have non fatal asserts configured.

Fix the null pointer dereference crash in __xfs_dir3_data_check by
looking for S_ISDIR or wrong d_ops; and teach the parent scrubber
to bail out if it is fed a non-directory "parent".

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: refactor the geometry structure filling function
Darrick J. Wong [Tue, 27 Feb 2018 04:43:17 +0000 (22:43 -0600)] 
xfs: refactor the geometry structure filling function

Source kernel commit: ac503a4cc9e8ab574032e3e217ffb555f5bf2341

Refactor the geometry structure filling function to use the superblock
to fill the fields.  While we're at it, make the function less indenty
and use some whitespace to make the function easier to read.

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: hoist xfs_fs_geometry to libxfs
Darrick J. Wong [Tue, 27 Feb 2018 04:43:17 +0000 (22:43 -0600)] 
xfs: hoist xfs_fs_geometry to libxfs

Source kernel commit: c368ebcd4cc3bbc08602adce083ad3cc76a15258

Move xfs_fs_geometry to libxfs so that we can clean up the fs geometry
reporting in xfsprogs.

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: trace log reservations at mount time
Darrick J. Wong [Tue, 27 Feb 2018 04:43:17 +0000 (22:43 -0600)] 
xfs: trace log reservations at mount time

Source kernel commit: b872af2c8700e9d64af8e13811b7679ede26ca00

At each mount, emit the transaction reservation type information via
tracepoints.  This makes it easier to compare the log reservation info
calculated by the kernel and xfsprogs so that we can more easily diagnose
minimum log size failures on freshly formatted filesystems.

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: standardize quota verification function outputs
Darrick J. Wong [Tue, 27 Feb 2018 04:43:17 +0000 (22:43 -0600)] 
xfs: standardize quota verification function outputs

Source kernel commit: eebf3cab9c5eac7fdb54fb9e9fb38c06f46f17f3

Rename xfs_dqcheck to xfs_dquot_verify and make it return an
xfs_failaddr_t like every other structure verifier function.
This enables us to check on-disk quotas in the same way that we check
everything else.  Callers are now responsible for logging errors, as
XFS_QMOPT_DOWARN goes away.

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: separate dquot repair into a separate function
Darrick J. Wong [Tue, 27 Feb 2018 04:43:17 +0000 (22:43 -0600)] 
xfs: separate dquot repair into a separate function

Source kernel commit: eeea79802871fef82a8ca6ab1220515855e5cdcc

Move the dquot repair code into a separate function and remove
XFS_QMOPT_DQREPAIR in favor of calling the helper directly.  Remove
other dead code because quotacheck is the only caller of DQREPAIR.

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: create a new buf_ops pointer to verify structure metadata
Darrick J. Wong [Tue, 27 Feb 2018 04:43:17 +0000 (22:43 -0600)] 
xfs: create a new buf_ops pointer to verify structure metadata

Source kernel commit: b55725974c9d3a5afcdf83daff6fba7d3f91ffca

Expose all metadata structure buffer verifier functions via buf_ops.
These will be used by the online scrub mechanism to look for problems
with buffers that are already sitting around in memory.

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: fail out of xfs_attr3_leaf_lookup_int if it looks corrupt
Darrick J. Wong [Tue, 27 Feb 2018 04:43:17 +0000 (22:43 -0600)] 
xfs: fail out of xfs_attr3_leaf_lookup_int if it looks corrupt

Source kernel commit: 8ba92d43d499f4920af983a7c16e02304dd36932

If the xattr leaf block looks corrupt, return -EFSCORRUPTED to userspace
instead of ASSERTing on debug kernels or running off the end of the
buffer on regular kernels.

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: provide a centralized method for verifying inline fork data
Darrick J. Wong [Tue, 27 Feb 2018 04:43:17 +0000 (22:43 -0600)] 
xfs: provide a centralized method for verifying inline fork data

Source kernel commit: 9cfb9b47479e237d217dbcfafe034cbf98f45909

Replace the current haphazard dir2 shortform verifier callsites with a
centralized verifier function that can be called either with the default
verifier functions or with a custom set.  This helps us strengthen
integrity checking while providing us with flexibility for repair tools.

xfs_repair wants this to be able to supply its own verifier functions
when trying to fix possibly corrupt 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>
6 years agoxfs: refactor short form directory structure verifier function
Darrick J. Wong [Tue, 27 Feb 2018 04:43:17 +0000 (22:43 -0600)] 
xfs: refactor short form directory structure verifier function

Source kernel commit: dc042c2d8ff629dd411e9a60bce9c379e2f8aaf8

Change the short form directory structure verifier function to return
the instruction pointer of a failing check or NULL if everything's ok.

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: create structure verifier function for short form symlinks
Darrick J. Wong [Tue, 27 Feb 2018 04:43:17 +0000 (22:43 -0600)] 
xfs: create structure verifier function for short form symlinks

Source kernel commit: 0795e004fd4f2723f3dbf09a195cd7ccf3c74c58

Create a function to check the structure of short form symlink targets.

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: create structure verifier function for shortform xattrs
Darrick J. Wong [Tue, 27 Feb 2018 04:43:17 +0000 (22:43 -0600)] 
xfs: create structure verifier function for shortform xattrs

Source kernel commit: 1e1bbd8e7ee0624034e9bf1e91ac11a7aaa2f8a6

Create a function to perform structure verification for short form
extended attributes.

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: move inode fork verifiers to xfs_dinode_verify
Darrick J. Wong [Tue, 27 Feb 2018 04:43:17 +0000 (22:43 -0600)] 
xfs: move inode fork verifiers to xfs_dinode_verify

Source kernel commit: 71493b839e294065ba63bd6f8d07263f3afee8c6

Consolidate the fork size and format verifiers to xfs_dinode_verify so
that we can reject bad inodes earlier and in a single place.

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: verify dinode header first
Darrick J. Wong [Tue, 27 Feb 2018 04:43:17 +0000 (22:43 -0600)] 
xfs: verify dinode header first

Source kernel commit: 50aa90ef03007beca2c9108993f5b4f2bb4f0a66

Move the v3 inode integrity information (crc, owner, metauuid) before we
look at anything else in the inode so that we don't waste time on a torn
write or a totally garbled block.  This makes xfs_dinode_verify more
consistent with the other verifiers.

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: refactor verifier callers to print address of failing check
Darrick J. Wong [Tue, 27 Feb 2018 04:43:17 +0000 (22:43 -0600)] 
xfs: refactor verifier callers to print address of failing check

Source kernel commit: bc1a09b8e334bf5fca1d6727aec538dcff957961

Refactor the callers of verifiers to print the instruction address of a
failing check.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: have buffer verifier functions report failing address
Darrick J. Wong [Tue, 27 Feb 2018 04:43:16 +0000 (22:43 -0600)] 
xfs: have buffer verifier functions report failing address

Source kernel commit: a6a781a58befcbd467ce843af4eaca3906aa1f08

Modify each function that checks the contents of a metadata buffer to
return the instruction address of the failing test so that we can report
more precise failure errors to the log.

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: refactor xfs_verifier_error and xfs_buf_ioerror
Darrick J. Wong [Tue, 27 Feb 2018 04:43:16 +0000 (22:43 -0600)] 
xfs: refactor xfs_verifier_error and xfs_buf_ioerror

Source kernel commit: 31ca03c92c329525ee3a97d99c47f1ebbaed5d63

Since all verification errors also mark the buffer as having an error,
we can combine these two calls.  Later we'll add a xfs_failaddr_t
parameter to promote the idea of reporting corruption errors and the
address of the failing check to enable better debugging reports.

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 XFS_WANT_CORRUPTED_RETURN from dir3 data verifiers
Darrick J. Wong [Tue, 27 Feb 2018 04:43:16 +0000 (22:43 -0600)] 
xfs: remove XFS_WANT_CORRUPTED_RETURN from dir3 data verifiers

Source kernel commit: 9101d3707b9acae8bbb0d82d47e99cf5c60b3ee5

Since __xfs_dir3_data_check verifies on-disk metadata, we can't have it
noisily blowing asserts and hanging the system on corrupt data coming in
off the disk.  Instead, have it return a boolean like all the other
checker functions, and only have it noisily fail if we fail in debug
mode.

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: refactor short form btree pointer verification
Darrick J. Wong [Tue, 27 Feb 2018 04:43:16 +0000 (22:43 -0600)] 
xfs: refactor short form btree pointer verification

Source kernel commit: e1e55aaf1cc646b736439cbd5af229759029ae34

Now that we have xfs_verify_agbno, use it to verify short form btree
pointers instead of open-coding them.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: refactor long-format btree header verification routines
Darrick J. Wong [Tue, 27 Feb 2018 04:43:16 +0000 (22:43 -0600)] 
xfs: refactor long-format btree header verification routines

Source kernel commit: 8368a6019d5bbb8b56c140029dcf5ea570b638f1

Create two helper functions to verify the headers of a long format
btree block.  We'll use this later for the realtime 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: remove XFS_FSB_SANITY_CHECK
Darrick J. Wong [Tue, 27 Feb 2018 04:43:16 +0000 (22:43 -0600)] 
xfs: remove XFS_FSB_SANITY_CHECK

Source kernel commit: 59f6fec3bdb2aafc84d39f34000819d232182d71

We already have a function to verify fsb pointers, so get rid of the
last users of the (less robust) macro.

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: eliminate duplicate icreate tx reservation functions
Brian Foster [Tue, 27 Feb 2018 04:43:16 +0000 (22:43 -0600)] 
xfs: eliminate duplicate icreate tx reservation functions

Source kernel commit: c017cb5ddfd6326032570d5eba83308c8a9c13a9

The create transaction reservation calculation has two different
branches of code depending on whether the filesystem is a v5 format
fs or older. Each branch considers the max reservation between the
allocation case (new chunk allocation + record insert) and the
modify case (chunk exists, record modification) of inode allocation.

The modify case is the same for both superblock versions with the
exception of the finobt. The finobt helper checks the feature bit,
however, and so the modify case already shares the same code.

Now that inode chunk allocation has been refactored into a helper
that checks the superblock version to calculate the appropriate
reservation for the create transaction, the only remaining
difference between the create and icreate branches is the call to
the finobt helper. As noted above, the finobt helper is a no-op when
the feature is not enabled. Therefore, these branches are
effectively duplicate and can be condensed.

Remove the xfs_calc_create_*() branch of functions and update the
various callers to use the xfs_calc_icreate_*() variant. The latter
creates the same reservation size for v4 create transactions as the
removed branch. As such, this patch does not result in transaction
reservation changes.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: refactor inode chunk alloc/free tx reservation
Brian Foster [Tue, 27 Feb 2018 04:43:15 +0000 (22:43 -0600)] 
xfs: refactor inode chunk alloc/free tx reservation

Source kernel commit: 57af33e451b73f56feb428f5856cdf6e4e0c60cd

The reservation for the various forms of inode allocation is
scattered across several different functions. This includes two
variants of chunk allocation (v5 icreate transactions vs. older
create transactions) and the inode free transaction.

To clean up some of this code and clarify the purpose of specific
allocfree reservations, continue the pattern of defining helper
functions for smaller operational units of broader transactions.
Refactor the reservation into an inode chunk alloc/free helper that
considers the various conditions based on filesystem format.

An inode chunk free involves an extent free and buffer
invalidations. The latter requires reservation for log headers only.
An inode chunk allocation modifies the free space btrees and logs
the chunk on v4 supers. v5 supers initialize the inode chunk using
ordered buffers and so do not log the chunk.

As a side effect of this refactoring, add one more allocfree res to
the ifree transaction. Technically this does not serve a specific
purpose because inode chunks are freed via deferred operations and
thus occur after a transaction roll. tr_ifree has a bit of a history
of tx overruns caused by too many agfl fixups during sustained file
deletion workloads, so add this extra reservation as a form of
padding nonetheless.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: include an allocfree res for inobt modifications
Brian Foster [Tue, 27 Feb 2018 04:43:15 +0000 (22:43 -0600)] 
xfs: include an allocfree res for inobt modifications

Source kernel commit: f03c78f39710995d2766236f229295d91b8de9dd

Analysis of recent reports of log reservation overruns and code
inspection has uncovered that the reservations associated with inode
operations may not cover the worst case scenarios. In particular,
many cases only include one allocfree res. for a particular
operation even though said operations may also entail AGFL fixups
and inode btree block allocations in addition to the actual inode
chunk allocation. This can easily turn into two or three block
allocations (or frees) per operation.

In theory, the only way to define the worst case reservation is to
include an allocfree res for each individual allocation in a
transaction. Since that is impractical (we can perform multiple agfl
fixups per tx and not every allocation results in a full tree
operation), we need to find a reasonable compromise that addresses
the deficiency in practice without blowing out the size of the
transactions.

Since the inode btrees are not filled by the AGFL, record insertion
and removal can directly result in block allocations and frees
depending on the shape of the tree. These allocations and frees
occur in the same transaction context as the inobt update itself,
but are separate from the allocation/free that might be required for
an inode chunk. Therefore, it makes sense to assume that an [f]inobt
insert/remove can directly result in one or more block allocations
on behalf of the tree.

Refactor the inode transaction reservations to include one allocfree
res. per inode btree modification to cover allocations required by
the tree itself. This separates the reservation required to allocate
the inode chunk from the reservation required for inobt record
insertion/removal. Apply the same logic to the finobt. This results
in killing off the finobt modify condition because we no longer
assume that the broader transaction reservation will cover finobt
block allocations and finobt shape changes can occur in either of
the inobt allocation or modify situations.

Suggested-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: truncate transaction does not modify the inobt
Brian Foster [Tue, 27 Feb 2018 04:43:15 +0000 (22:43 -0600)] 
xfs: truncate transaction does not modify the inobt

Source kernel commit: a606ebdb859e78beb757dfefa08001df366e2ef5

The truncate transaction does not ever modify the inode btree, but
includes an associated log reservation. Update
xfs_calc_itruncate_reservation() to remove the reservation
associated with inobt updates.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: fix up agi unlinked list reservations
Brian Foster [Tue, 27 Feb 2018 04:43:15 +0000 (22:43 -0600)] 
xfs: fix up agi unlinked list reservations

Source kernel commit: e8341d9f6348640dff01d8c4a33695dc82bab5a3

The current AGI unlinked list addition and removal reservations do
not reflect the worst case log usage. An unlinked list removal can
log up to two on-disk inode clusters but only includes reservation
for one. An unlinked list addition logs the on-disk cluster but
includes reservation for an in-core inode.

Update the AGI unlinked list reservation helpers to calculate the
correct worst case reservation for the associated operations.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: include inobt buffers in ifree tx log reservation
Brian Foster [Tue, 27 Feb 2018 04:43:15 +0000 (22:43 -0600)] 
xfs: include inobt buffers in ifree tx log reservation

Source kernel commit: a6f485908d5210a5662f7a031bd1deeb3867e466

The tr_ifree transaction handles inode unlinks and inode chunk
frees. The current transaction calculation does not accurately
reflect worst case changes to the inode btree, however. The inobt
portion of the current transaction reservation only covers
modification of a single inobt buffer (for the particular inode
record). This is a historical artifact from the days before XFS
supported full inode chunk removal.

When support for inode chunk removal was added in commit
254f6311ed1b ("Implement deletion of inode clusters in XFS."), the
additional log reservation required for chunk removal was not added
correctly. The new reservation only considered the header overhead
of associated buffers rather than the full contents of the btrees
and AGF and AGFL buffers affected by the transaction. The
reservation for the free space btrees was subsequently fixed up in
ITRUNCATE log reservation"), but the res. for full inobt joins has
never been added.

Further review of the ifree reservation uncovered a couple more
problems:

- The undocumented +2 blocks are intended for the AGF and AGFL, but
are also not sized correctly and should be logged as full sectors
(not FSBs).
- The additional single block header is undocumented and serves no
apparent purpose.

Update xfs_calc_ifree_reservation() to include a full inobt join in
the reservation calculation. Refactor the undocumented blocks
appropriately and fix up the comments to reflect the current
calculation.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfsprogs: Release v4.15.1 v4.15.1
Eric Sandeen [Tue, 27 Feb 2018 01:50:56 +0000 (19:50 -0600)] 
xfsprogs: Release v4.15.1

Update all the necessary files for a 4.15.1 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agopo/pl.po: update Polish translation for 4.15.0
Jakub Bogusz [Tue, 27 Feb 2018 01:44:01 +0000 (19:44 -0600)] 
po/pl.po: update Polish translation for 4.15.0

Polish translation update for xfsprogs 4.15.0

Signed-off-by: Jakub Bogusz <qboosh@pld-linux.org>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agodebian: don't fail postinst when upgrading chroot
Darrick J. Wong [Tue, 27 Feb 2018 01:43:58 +0000 (19:43 -0600)] 
debian: don't fail postinst when upgrading chroot

If we're upgrading a systemd-enabled chroot we'll fail because systemctl
can't connect to a running systemd (nor should it).  We don't need to
issue daemon-reload inside a chroot that doesn't have a running systemd,
so we can ignore the return value.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Nathan Scott <nathans@debian.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agodebian: add build-depends on pkg-config
Darrick J. Wong [Tue, 27 Feb 2018 01:43:58 +0000 (19:43 -0600)] 
debian: add build-depends on pkg-config

Since the configure scripts now depend on pkg-config to autodetect where
systemd service files go, we need to list pkg-config as a build
dependency.

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 agoxfsprogs: Release v4.15.0 v4.15.0
Eric Sandeen [Fri, 23 Feb 2018 19:09:31 +0000 (13:09 -0600)] 
xfsprogs: Release v4.15.0

Update all the necessary files for a 4.15.0 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoFix spelling mistake in mkfs lazy superblock diagnostic
Nathan Scott [Fri, 23 Feb 2018 19:05:20 +0000 (13:05 -0600)] 
Fix spelling mistake in mkfs lazy superblock diagnostic

Signed-off-by: <nathans@debian.org>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoFix grammar and spelling in strings and man pages
Nathan Scott [Fri, 23 Feb 2018 19:05:17 +0000 (13:05 -0600)] 
Fix grammar and spelling in strings and man pages

Signed-off-by: Nathan Scott <nathans@debian.org>
Reviewed-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 agoAdd xfs_scrub_fail systemd service file docs entry
Nathan Scott [Fri, 23 Feb 2018 19:05:15 +0000 (13:05 -0600)] 
Add xfs_scrub_fail systemd service file docs entry

Signed-off-by: Nathan Scott <nathans@debian.org>
Reviewed-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 agoUpdate .gitignore list for generated scrub cron file
Nathan Scott [Fri, 23 Feb 2018 19:05:13 +0000 (13:05 -0600)] 
Update .gitignore list for generated scrub cron file

Signed-off-by: Nathan Scott <nathans@debian.org>
Reviewed-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 agoSeveral updates to use more modern Debian packaging
Nathan Scott [Fri, 23 Feb 2018 19:05:07 +0000 (13:05 -0600)] 
Several updates to use more modern Debian packaging

Switch to Debian packaging features available in more
recent years to resolve some long-standing issues.

In particular, using the quilt format gives non-native
package builds finally, while keeping the ability for
developers to do upstream deb builds.  Also split the
binary-arch and binary-indep debian/rules targets as
is now mandated, and update to latest standard version.
Mark a bunch of long-resolved bugs as fixed in the deb
changelog so they are automatically closed by the next
update.

Signed-off-by: Nathan Scott <nathans@debian.org>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfsprogs: Release v4.15.0-rc1 v4.15.0-rc1
Eric Sandeen [Tue, 13 Feb 2018 19:57:05 +0000 (13:57 -0600)] 
xfsprogs: Release v4.15.0-rc1

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

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_scrub: refactor outcome display into a separate helper
Darrick J. Wong [Tue, 13 Feb 2018 19:46:42 +0000 (13:46 -0600)] 
xfs_scrub: refactor outcome display into a separate helper

Move all the printing of the scrub outcome into a separate helper to
declutter the main function.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: put "Unmount ..." on its own line]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_scrub: always init phase information
Darrick J. Wong [Mon, 12 Feb 2018 21:47:56 +0000 (15:47 -0600)] 
xfs_scrub: always init phase information

Make sure we initialize the overall phase state before we start
executing any code that can end up in the report-status-and-exit paths.
Otherwise if debugging is turned on we get garbage io/cpu stat reports.

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_scrub: reclassify some of the warning messages
Darrick J. Wong [Mon, 12 Feb 2018 21:47:54 +0000 (15:47 -0600)] 
xfs_scrub: reclassify some of the warning messages

Some of the warning messages are actually runtime errors in optional
components, so turn them into informational messages.

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_scrub: reclassify runtime errors
Darrick J. Wong [Mon, 12 Feb 2018 21:47:52 +0000 (15:47 -0600)] 
xfs_scrub: reclassify runtime errors

If the program encounters runtime errors, these should be noted as
information.  Because these errors abort the execution flow (which is
counted as a runtime error), we need only call str_info to log the
event.

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_scrub: classify lack of ioctl support as a runtime error
Darrick J. Wong [Mon, 12 Feb 2018 21:47:50 +0000 (15:47 -0600)] 
xfs_scrub: classify lack of ioctl support as a runtime error

If the kernel doesn't have the SCRUB_METADATA ioctl that's a runtime
error, not a fs error.  Account it as such.

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_scrub: remove preen mode
Darrick J. Wong [Mon, 12 Feb 2018 21:47:40 +0000 (15:47 -0600)] 
xfs_scrub: remove preen mode

While it's true that the kernel can tell us whether something needs
repairs or it needs optimizing, from the admin's perspective there's
no point in having an optimize-only mode -- either fix everything, or
don't.  This is what xfs_repair does w.r.t. -n, so let's do the same
thing too.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_mdrestore: Don't rewind source file stream
Marco Benatto [Mon, 5 Feb 2018 20:43:02 +0000 (14:43 -0600)] 
xfs_mdrestore: Don't rewind source file stream

Today, xfs_mdrestore from stdin will fail if the -i flag is
specified, because it attempts to rewind the stream after
the initial read of the metablock.  This fails, and
results in an abort with "specified file is not a metadata
dump."

Read the metablock exactly once in main(), validate the magic,
print informational flags if requested, and then pass it to
perform_restore() which will then continue the restore process.

Reported-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Marco A Benatto <marco.antonio.780@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_mdrestore: Add -i option to built-in help
Marco Benatto [Mon, 5 Feb 2018 20:41:24 +0000 (14:41 -0600)] 
xfs_mdrestore: Add -i option to built-in help

Currently we are missing -i option from usage().
This patch adds it to this biult-in help.

Signed-off-by: Marco A Benatto <marco.antonio.780@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_io: fix copy_file_range symbol name collision
Darrick J. Wong [Mon, 5 Feb 2018 20:38:02 +0000 (14:38 -0600)] 
xfs_io: fix copy_file_range symbol name collision

glibc 2.27 has a copy_file_range wrapper, so we need to change our
internal function out of the way to avoid compiler warnings.

Reported-by: fredrik@crux.nu
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>