]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/log
thirdparty/xfsprogs-dev.git
5 years agoxfsprogs: Release v4.19.0 v4.19.0
Eric Sandeen [Fri, 9 Nov 2018 20:31:04 +0000 (14:31 -0600)] 
xfsprogs: Release v4.19.0

Update all the necessary files for a 4.19.0 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agomake: don't spray static check failures all over the subdir build
Darrick J. Wong [Fri, 9 Nov 2018 19:43:17 +0000 (13:43 -0600)] 
make: don't spray static check failures all over the subdir  build

Debian package building is special -- it directly calls make -C libxfs
when building the debian-installer packages.  This means that any
variables we define in the top level Makefile don't get passed down to
subdir make processes.

This means that the new static checker support effectively runs the
first argument in $(CFLAGS) as a command, which is surprising.  Fix up
buildrules to patch out CHECK_CMD if nobody's defined it, so that direct
subdir make works again.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: Release v4.19.0-rc1 v4.19.0-rc1
Eric Sandeen [Fri, 2 Nov 2018 15:02:13 +0000 (10:02 -0500)] 
xfsprogs: Release v4.19.0-rc1

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

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_repair: don't dirty inodes unconditionally when testing unlinked state
Dave Chinner [Tue, 30 Oct 2018 23:24:08 +0000 (18:24 -0500)] 
xfs_repair: don't dirty inodes unconditionally when testing unlinked state

I noticed phase 4 writing back lots of inode buffers during recent
testing. The recent rework of clear_inode() in commit 0724d0f4cb53
("xfs_repair: clear_dinode should simply clear, not check contents")
accidentally caught a call to clear_inode_unlinked() as well,
resulting in all inodes being marked dirty whether then needed
updating or not.

Fix it by making clear_inode_unlinked unconditionally do the clear
(as was done for clear_inode), and move the test to the caller.
Add warnings as well so that this corruption is no longer silently
fixed.

Fixes: 0724d0f ("xfs_repair: clear_dinode should simply clear, ...")
Signed-off-by: Dave Chinner <dchinner@redhat.com>
[sandeen: rework so clear_inode_unlinked is unconditional]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoRevert "xfs_repair: treat zero da btree pointers as corruption"
Dave Chinner [Tue, 30 Oct 2018 21:54:59 +0000 (16:54 -0500)] 
Revert "xfs_repair: treat zero da btree pointers as corruption"

This reverts commit 67a79e2cc9320aaf269cd00e9c8d16892931886d.

A root LEAFN block can exist in a directory. When we convert from
leaf format (LEAF1 - internal free list) to node format (LEAFN -
external free list) the only change to the single root leaf block is
that it's magic number is changed from LEAF1 to LEAFN.

We don't actually end up with DA nodes in the tree until the LEAFN
node is split, and that requires a couple more dirents to be added
to the directory to fill the LEAFN block up completely. Then it will
split and create a DA node root block pointing to multiple LEAFN
leaf blocks.

Hence restore the old behaviour where we skip the DA node tree
rebuild if there is a LEAFN root block found as there is no tree to
rebuild.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_io: add crc32 self test
Darrick J. Wong [Tue, 30 Oct 2018 21:53:59 +0000 (16:53 -0500)] 
xfs_io: add crc32 self test

Add a self test for crc32c into xfs_io so that xfstests can check the
operation of the (potentially cross-compiled) package binaries by
isolating the self test code to a header file that can be included by
the build system self test and xfs_io.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: add missing agfl free deferred op type
Darrick J. Wong [Tue, 30 Oct 2018 21:52:59 +0000 (16:52 -0500)] 
libxfs: add missing agfl free deferred op type

When we added a new defer op type for agfl block freeing to the kernel,
we forgot to add that type to the userspace side of things.  This will
cause spontaneous combustion in xfs_repair if we try to rebuild
directories.

Fixes: d5c1b462232 ("xfs: defer agfl block frees when dfops is available")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_db: print freecount in xfs_inobt_rec as unsigned
Eric Sandeen [Tue, 30 Oct 2018 21:51:59 +0000 (16:51 -0500)] 
xfs_db: print freecount in xfs_inobt_rec as unsigned

"freecount" in the xfs_inobt_rec is unsigned, so xfs_db should
print it as such.

Not doing so tickles a bug in getbitval() where we try to handle
sign extension for signed fields and fail badly on big endian
machines, causing us to incorrectly report negative numbers when
printing structures even when the number is nowhere near the
signed maximum value.

So this fix works around that bug by properly marking this field
as unsigned, because I have yet to convince myself of the proper
fix for the underlying bug.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201453
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_repair: kick processing thread if ra_count is at limit
Eric Sandeen [Tue, 30 Oct 2018 21:51:58 +0000 (16:51 -0500)] 
xfs_repair: kick processing thread if ra_count is at limit

Zorro hit an xfs_repair hang on a 500T filesystem where
all the prefetch threads were sleeping and nothing progressed.

The problem is that if every buffer we tried to read ahead in
phase6 was already up to date, pf_start_io_workers has no effect;
there is no io to do, and the sem_wait in pf_queuing_worker waits
forever.

Kick the processing thread to avoid this situation.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201173
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_repair: continue after xfs_bunmapi deadlock avoidance
Eric Sandeen [Tue, 30 Oct 2018 21:51:57 +0000 (16:51 -0500)] 
xfs_repair: continue after xfs_bunmapi deadlock avoidance

xfs_bunmapi can legitimately return before all work is done, to
avoid deadlocks across AGs.

Sadly nobody told xfs_repair, so it fires an assert if this happens:

 phase6.c:1410: longform_dir2_rebuild: Assertion `done' failed.

Fix this by calling back in until all work is done, as we do
in the kernel.

Fixes: 5a8bcc ("xfs: fix multi-AG deadlock in xfs_bunmapi")
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1641116
Reported-by: Tomasz Torcz <tomek@pipebreaker.pl>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_repair: initialize realloced bplist in longform_dir2_entry_check
Eric Sandeen [Tue, 30 Oct 2018 21:51:55 +0000 (16:51 -0500)] 
xfs_repair: initialize realloced bplist in longform_dir2_entry_check

If we need to realloc the bplist[] array holding buffers for a given
directory, we don't initialize the new slots.  This causes a problem
if the directory has holes, because those slots never get filled in.

At the end of the function we call libxfs_putbuf for every non-null
slot, and any uninitialized slots are segfault landmines.

Make sure we initialize all new slots to NULL for this reason.

Reported-by: Oleg Davydov <burunduk3@gmail.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_scrub: lack of kernel support is not a service failure
Darrick J. Wong [Tue, 30 Oct 2018 21:51:36 +0000 (16:51 -0500)] 
xfs_scrub: lack of kernel support is not a service failure

Don't treat a lack of kernel support for scrubbing as an automated
service failure because we have not actually determined that there's
anything wrong with the filesystem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agomisc: only build with lto if explicitly enabled
Darrick J. Wong [Tue, 30 Oct 2018 21:50:28 +0000 (16:50 -0500)] 
misc: only build with lto if explicitly enabled

Change the LTO default to off from probe because it wastes build time on
developer machines.  Anyone who really wants it for release builds or
whatever can still turn it on.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: remove retpoline support
Eric Sandeen [Tue, 30 Oct 2018 21:47:11 +0000 (16:47 -0500)] 
xfsprogs: remove retpoline support

When it came up that xfsprogs was using retpolines by default,
the gcc folks inside Red Hat expressed ... alarm.  I'm not sure
of all the details, but I think the concern was that userspace
support for this is not really quite baked.

Unless/until there is a demonstrated side-channel which would
warrant retpolines here, let's just remove it for now.

Cc: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: enable sparse checking with make C=2
Eric Sandeen [Wed, 17 Oct 2018 18:27:44 +0000 (13:27 -0500)] 
xfsprogs: enable sparse checking with make C=2

Enable "make C=2" sparse checking of all files without rebuilding them.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: enable sparse checking with make C=1
Eric Sandeen [Wed, 17 Oct 2018 18:25:11 +0000 (13:25 -0500)] 
xfsprogs: enable sparse checking with make C=1

Enable "make C=1" sparse checking when files get rebuilt.  To check
all files, run "make clean" first.

This is a bit simpler than redefining CC for the whole build, which
requires extra commandline definitions and apparently is enough of a
barrier that nobody's doing sparse checking.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibfrog: change project entity variable scope to local/static.
Eric Sandeen [Wed, 17 Oct 2018 18:25:11 +0000 (13:25 -0500)] 
libfrog: change project entity variable scope to local/static.

The project quota code used a global variable "p" for getprent() and
getprpathent(), presumably to keep the interface analogous to getpwent()
etc.  However, other functions had their own local "p" which led to shadow
variable warnings from sparse.

Rather than a global, make it a static variable within the project
functions.  Same behavior, same interface, less confusion, and retains an
interface similar that of getpwent etc.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_metadump: remove shadow variable
Eric Sandeen [Wed, 17 Oct 2018 18:25:11 +0000 (13:25 -0500)] 
xfs_metadump: remove shadow variable

"length" is used in 2 nested inner scopes, which is fairly unclear and
generates a sparse warning.  Rename the inner scope variable for clarity.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_scrub: remove shadow var from run_scrub_phases()
Eric Sandeen [Wed, 17 Oct 2018 18:25:11 +0000 (13:25 -0500)] 
xfs_scrub: remove shadow var from run_scrub_phases()

The local nr_threads shadows a global var of the same name.
Use a local variable to avoid confusion (even though estimate_work()
may simply fill in the value of the global...)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_repair: fix 'bno' shadow vars in scan.c
Eric Sandeen [Wed, 17 Oct 2018 18:25:11 +0000 (13:25 -0500)] 
xfs_repair: fix 'bno' shadow vars in scan.c

scan.c has 3 functions which accept 'bno' as an argument, but then use a
local variable of the same name for a different purpose in an inner scope,
which causes sparse warnings.
Rename these inner-scope loop variables 'agbno' to fix this.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_logprint: fix shadow var in xlog_print_trans_buffer
Eric Sandeen [Wed, 17 Oct 2018 18:25:10 +0000 (13:25 -0500)] 
xfs_logprint: fix shadow var in xlog_print_trans_buffer

xlog_print_trans_buffer takes 'i' as an argument, but then uses it later
as a local byte counter.  Give the local var more useful, non-shadow
name of "byte"

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_io: rename global buffer variable
Eric Sandeen [Wed, 17 Oct 2018 18:25:10 +0000 (13:25 -0500)] 
xfs_io: rename global buffer variable

"buffer" is a pretty poor name for a global variable, and leads to
shadow variable warnings from sparse when other functions (reasonably)
think it's a nice local variable name.

Rename it to io_buffer for less namespace pollution, and rename
buffersize to io_buffersize to go with it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: don't shadow global libxfs_init x variable
Eric Sandeen [Wed, 17 Oct 2018 18:25:10 +0000 (13:25 -0500)] 
xfsprogs: don't shadow global libxfs_init x variable

We use the variable 'x' for the global libxfs_init structure, but several
other functions think 'x' is a nice convenient local var too, and sparse
complains.  Rename these local variables (or in some cases re-use existing
loop counter vars when x was used for this purpose).

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: misc static function warning fixes
Eric Sandeen [Wed, 17 Oct 2018 18:25:10 +0000 (13:25 -0500)] 
xfsprogs: misc static function warning fixes

The last handful of static symbol warning cleanups for misc remaining
issues.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoavl64: export avl64_firstino / avl64_firstino from avl64.h
Eric Sandeen [Wed, 17 Oct 2018 18:25:10 +0000 (13:25 -0500)] 
avl64: export avl64_firstino / avl64_firstino from avl64.h

These are flagged by the sparse checker as possibly static.
They are actually not used at this point; avl64.c has a few unused
functions and/or ones that could be made static, but for now just silence
the warnings, and save deeper surgery for later.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: silence sparse static function warnings in util.c
Eric Sandeen [Wed, 17 Oct 2018 18:25:10 +0000 (13:25 -0500)] 
libxfs: silence sparse static function warnings in util.c

libxfs.h exports functions defined in util.c, so include that file to
silence sparse warnings about potential static functions.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_io: include io.h to silence static function warnings
Eric Sandeen [Wed, 17 Oct 2018 18:25:10 +0000 (13:25 -0500)] 
xfs_io: include io.h to silence static function warnings

io.h exports functions from io/getrusage.c and io/log_writes.c, so include
it from these files to silence warnings about potentially static functions
(getrusage_init, log_writes_init) in sparse.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: silence static warnings about platform_* functions
Eric Sandeen [Wed, 17 Oct 2018 18:25:10 +0000 (13:25 -0500)] 
libxfs: silence static warnings about platform_* functions

Add all platform_* prototypes to init.h and include it in linux.c
to silence sparse warnings about static functions.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: add several zone extern declarations to libxfs_priv.h
Eric Sandeen [Wed, 17 Oct 2018 18:25:10 +0000 (13:25 -0500)] 
libxfs: add several zone extern declarations to libxfs_priv.h

Several zones have extern declarations in kernelspace headers we don't
have in userspace.

Adding these to the libxfs_priv.h header silences sparse warnings about
whether these should be static vars.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: include headers for extern variables
Eric Sandeen [Wed, 17 Oct 2018 18:25:10 +0000 (13:25 -0500)] 
xfsprogs: include headers for extern variables

Include headers which export functions for their matching C files so that
they don't appear to be static to the sparse checker.

Fixes sparse warnings about this.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: avoid redefinition of NBBY
Eric Sandeen [Wed, 17 Oct 2018 18:25:10 +0000 (13:25 -0500)] 
xfsprogs: avoid redefinition of NBBY

Include sys/param.h for NBBY definition.  Do this before our local
guarded definition which is for platforms like android that don't have it,
see commit:

c9a90185 xfsprogs: define NBBY if not defined by the system header files

Fixes sparse warnings about this redefinition.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: minor endian annotation fixes
Eric Sandeen [Wed, 17 Oct 2018 18:24:56 +0000 (13:24 -0500)] 
xfsprogs: minor endian annotation fixes

No actual bugs, just quiet the sparse checker.

Fixes sparse warnings about this.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_db: convert single-bit bitfields to bools
Eric Sandeen [Wed, 17 Oct 2018 18:24:56 +0000 (13:24 -0500)] 
xfs_db: convert single-bit bitfields to bools

Sparse doesn't like signed single-bit bitfields, and they may as well
just be booleans.

Fixes sparse warnings about this.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: don't include all xfs headers just for crc32
Eric Sandeen [Wed, 17 Oct 2018 18:24:56 +0000 (13:24 -0500)] 
xfsprogs: don't include all xfs headers just for crc32

Brian Norris reported that "The $BUILD_CC toolchain might have an
older set of Linux headers than the $CC toolchain. It's generally
unsafe to try to build both with the same definitions, but in
particular, this one can cause compilation failures in the local
crc32selftest build: [failure to find fsmap.h]"

It seems like the most straightforward thing to do here is include
a specific set of system headers, instead of pulling in the whole
xfs.h header chain which has multiple tests and definitions in
place for headers that may or may not be there during the build.

Reported-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Tested-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_scrub_all: fix systemd escaping again
Darrick J. Wong [Wed, 10 Oct 2018 19:35:48 +0000 (14:35 -0500)] 
xfs_scrub_all: fix systemd escaping again

Apparently newer versions of systemd than the one on this author's
laptop <cough> now complain about lack of (path) escaping in unit instance
variable contents:

 # xfs_scrub_all
 Scrubbing /home...
  Invalid unit name "xfs_scrub@/home" was escaped as "xfs_scrub@-home"
 (maybe you should use systemd-escape?)
 Starting Online XFS Metadata Check for /home...

So change the systemd_escape() function to escape paths unconditionally
to make the warning go away.

Reported-by: Matthias Bodenbinder <matthias@bodenbinder.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: remove unused functions
Dave Chinner [Wed, 10 Oct 2018 19:35:47 +0000 (14:35 -0500)] 
xfsprogs: remove unused functions

Clean up build warnings about defined but not used functions by
removing them.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: document changes for 4.19.0-rc0
Dave Chinner [Wed, 10 Oct 2018 19:35:45 +0000 (14:35 -0500)] 
xfsprogs: document changes for 4.19.0-rc0

Because 'make deb' breaks without them.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: export unused nonstatic functions to quiet static checkers
Eric Sandeen [Tue, 9 Oct 2018 16:49:48 +0000 (11:49 -0500)] 
libxfs: export unused nonstatic functions to quiet static checkers

libxfs functions which aren't used or exported get flagged as
"should be static" but we stay in sync with kernelspace, which has other
headers which export them.  Export the lot of them in libxfs_priv.h to
shut up sparse.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: kill EXTERN macro
Eric Sandeen [Tue, 9 Oct 2018 16:49:48 +0000 (11:49 -0500)] 
xfsprogs: kill EXTERN macro

The EXTERN macro was a too-clever hack to allow a header file to both
declare global variables and export them.  Get rid of the hack and do
things the predictable way.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: make static things static
Eric Sandeen [Tue, 9 Oct 2018 16:49:48 +0000 (11:49 -0500)] 
xfsprogs: make static things static

There are tons of functions which can be static, make them so.

Fixes many sparse warnings about this.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: remove write-only variables
Eric Sandeen [Tue, 9 Oct 2018 16:49:47 +0000 (11:49 -0500)] 
xfsprogs: remove write-only variables

Fixes sparse warnings about this.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: avoid redefinitions of macros in mount.h
Eric Sandeen [Tue, 9 Oct 2018 16:49:47 +0000 (11:49 -0500)] 
libxfs: avoid redefinitions of macros in mount.h

MS_* (MS_NOSUID ... etc) get redefined in <sys/mount.h> after we include
<linux/fs.h>, at least on my fairly old set of headers.  Fix this by
simply removing the inclusion of mount.h, which isn't needed.

Fixes sparse warnings about this.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: don't use 0 as pointer
Eric Sandeen [Tue, 9 Oct 2018 16:49:47 +0000 (11:49 -0500)] 
xfsprogs: don't use 0 as pointer

Use NULL as appropriate.

Fixes sparse warnings about this.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agomkfs.xfs: include full parser prototype in subopts definition
Eric Sandeen [Tue, 9 Oct 2018 16:49:47 +0000 (11:49 -0500)] 
mkfs.xfs: include full parser prototype in subopts definition

Fixes sparse warnings about this.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: use ANSI declarations of void-arg functions
Eric Sandeen [Tue, 9 Oct 2018 16:49:47 +0000 (11:49 -0500)] 
xfsprogs: use ANSI declarations of void-arg functions

Fixes sparse warnings about this.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: minor sparse fixes
Eric Sandeen [Tue, 9 Oct 2018 16:49:47 +0000 (11:49 -0500)] 
xfsprogs: minor sparse fixes

Remove stray semicolon, add missing return.

Fixes sparse warnings about this.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_io: remove useless do_preadv and do_pwritev arguments
Zorro Lang [Tue, 9 Oct 2018 16:49:47 +0000 (11:49 -0500)] 
xfs_io: remove useless do_preadv and do_pwritev arguments

do_preadv and do_pwritev all have a 'buffer_size' argument, but they
never used it. Instead of it, they use global 'buffersize' variable,
which is initialized in alloc_buffer(). As the 'buffer_size' is
useless, so remove it for clear code.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: define xfs_stack_trace() for debug builds
Eric Sandeen [Tue, 9 Oct 2018 16:49:47 +0000 (11:49 -0500)] 
xfsprogs: define xfs_stack_trace() for debug builds

Building with -DDEBUG fails due to lack of an xfs_stack_trace def'n.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agomkfs: move 'mounted' check before 'existing fs' check
Jan Tulak [Tue, 9 Oct 2018 16:49:47 +0000 (11:49 -0500)] 
mkfs: move 'mounted' check before 'existing fs' check

Check if a device is mounted (and issue an error about that) before
asking for -f flag.

Example of the old behaviour I'm changing:
$ mkfs.xfs /dev/sda1
mkfs.xfs: /dev/sda1 appears to contain an existing filesystem (xfs).
mkfs.xfs: Use the -f option to force overwrite.

$ mkfs.xfs -f /dev/sda1
mkfs.xfs: /dev/sda1 contains a mounted filesystem

Signed-off-by: Jan Tulak <jtulak@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agomkfs: discard only after all validations
Jan Tulak [Tue, 9 Oct 2018 16:49:47 +0000 (11:49 -0500)] 
mkfs: discard only after all validations

Discard should happen only when everything has been validated, just
before we start writing to the device. If it happens earlier, it is
possible that mkfs will abort, but managed to already wipe data. This
patch moves the discard to the latest possible moment.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: make scrub build config-optional
Eric Sandeen [Tue, 9 Oct 2018 16:49:47 +0000 (11:49 -0500)] 
xfsprogs: make scrub build config-optional

This lets us do:

# ./configure --enable-scrub=no
or
# ./configure --disable-scrub

for any distros that may not want to ship the experimental scrub utility.

The default is still to build scrub.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: document environment variables
Eric Sandeen [Tue, 9 Oct 2018 16:49:47 +0000 (11:49 -0500)] 
xfsprogs: document environment variables

Document the various environment variables used in the code,
almost all are for debugging.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoscrub: remove redundant debug test
Eric Sandeen [Tue, 9 Oct 2018 16:49:47 +0000 (11:49 -0500)] 
scrub: remove redundant debug test

debug_tweak_on() already tests for debug.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: remove PKG_PLATFORM macro
Eric Sandeen [Tue, 9 Oct 2018 16:49:47 +0000 (11:49 -0500)] 
xfsprogs: remove PKG_PLATFORM macro

Now that there is only one supported platform (Linux), remove
the PKG_PLATFORM macro.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: remove darwin platform files
Eric Sandeen [Tue, 9 Oct 2018 16:49:47 +0000 (11:49 -0500)] 
xfsprogs: remove darwin platform files

As promised in April 2018 with:
a8502cc libxfs: warn about deprecation of irix, freebsd, darwin
remove the darwin platform files.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: remove bsd platform files
Eric Sandeen [Tue, 9 Oct 2018 16:49:47 +0000 (11:49 -0500)] 
xfsprogs: remove bsd platform files

As promised in April 2018 with:
a8502cc libxfs: warn about deprecation of irix, freebsd, darwin
remove the bsd platform files.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: remove irix platform files
Eric Sandeen [Tue, 9 Oct 2018 16:49:47 +0000 (11:49 -0500)] 
xfsprogs: remove irix platform files

As promised in April 2018 with:
a8502cc libxfs: warn about deprecation of irix, freebsd, darwin
remove the irix platform files.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: clean up IRELE/iput callsites
Darrick J. Wong [Tue, 9 Oct 2018 16:49:46 +0000 (11:49 -0500)] 
libxfs: clean up IRELE/iput callsites

Replace the IRELE macro with a proper function so that we can do proper
typechecking.  This is the userspace cleanup in the same vein as the
kernel patch with the same subject.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: check libxfs_trans_commit return values
Darrick J. Wong [Tue, 9 Oct 2018 16:49:46 +0000 (11:49 -0500)] 
libxfs: check libxfs_trans_commit return values

Check the return value from libxfs_trans_commit since it can now return
error codes.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: fix error handling in xfs_bmap_extents_to_btree
Dave Chinner [Tue, 9 Oct 2018 16:49:46 +0000 (11:49 -0500)] 
xfs: fix error handling in xfs_bmap_extents_to_btree

Source kernel commit: e55ec4ddbef9897199c307dfb23167e3801fdaf5

Commit 01239d77b9dd ("xfs: fix a null pointer dereference in
xfs_bmap_extents_to_btree") attempted to fix a null pointer
dreference when a fuzzing corruption of some kind was found.
This fix was flawed, resulting in assert failures like:

XFS: Assertion failed: ifp->if_broot == NULL, file: fs/xfs/libxfs/xfs_bmap.c, line: 715
.....
Call Trace:
xfs_bmap_extents_to_btree+0x6b9/0x7b0
__xfs_bunmapi+0xae7/0xf00
? xfs_log_reserve+0x1c8/0x290
xfs_reflink_remap_extent+0x20b/0x620
xfs_reflink_remap_blocks+0x7e/0x290
xfs_reflink_remap_range+0x311/0x530
vfs_dedupe_file_range_one+0xd7/0xe0
vfs_dedupe_file_range+0x15b/0x1a0
do_vfs_ioctl+0x267/0x6c0

The problem is that the error handling code now asserts that the
inode fork is not in btree format before the error handling code
undoes the modifications that put the fork back in extent format.
Fix this by moving the assert back to after the xfs_iroot_realloc()
call that returns the fork to extent format, and clean up the jump
labels to be meaningful.

Also, returning ENOSPC when xfs_btree_get_bufl() fails to
instantiate the buffer that was allocated (the actual fix in the
an invalid block address or a filesystem shutdown can result in
failing to get a buffer here.

Hence change this to EFSCORRUPTED so that the higher layer knows
this was a corruption related failure and should not treat it as an
ENOSPC error.  This should result in a shutdown (via cancelling a
dirty transaction) which is necessary as we do not attempt to clean
up the (invalid) block that we have already allocated.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: validate inode di_forkoff
Eric Sandeen [Tue, 9 Oct 2018 16:49:46 +0000 (11:49 -0500)] 
xfs: validate inode di_forkoff

Source kernel commit: 339e1a3fcdd1990e5ec115325ccb4c6f4cc5ee16

Verify the inode di_forkoff, lifted from xfs_repair's
process_check_inode_forkoff().

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: don't treat unknown di_flags2 as corruption in scrub
Eric Sandeen [Tue, 9 Oct 2018 16:49:42 +0000 (11:49 -0500)] 
xfs: don't treat unknown di_flags2 as corruption in scrub

Source kernel commit: f369a13cead821e679c7415dc66a17ec48cc26bf

xchk_inode_flags2() currently treats any di_flags2 values that the
running kernel doesn't recognize as corruption, and calls
xchk_ino_set_corrupt() if they are set.  However, it's entirely possible
that these flags were set in some newer kernel and are quite valid,
but ignored in this kernel.

(Validators don't care one bit about unknown di_flags2.)

Call xchk_ino_set_warning instead, because this may or may not actually
indicate a problem.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove last of unnecessary xfs_defer_cancel() callers
Brian Foster [Tue, 9 Oct 2018 16:44:34 +0000 (11:44 -0500)] 
xfs: remove last of unnecessary xfs_defer_cancel() callers

Source kernel commit: d5a2e2893da0d62c3888c91ae2da798adc17a9b9

Now that deferred operations are completely managed via
transactions, it's no longer necessary to cancel the dfops in error
paths that already cancel the associated transaction. There are a
few such calls lingering throughout the codebase.

Remove all remaining unnecessary calls to xfs_defer_cancel(). This
leaves xfs_defer_cancel() calls in two places. The first is the call
in the transaction cancel path itself, which facilitates this patch.
The second is made via the xfs_defer_finish() error path to provide
consistent error semantics with transaction commit. For example,
xfs_trans_commit() expects an xfs_defer_finish() failure to clean up
the dfops structure before it returns.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: Release v4.19.0-rc0 v4.19.0-rc0
Eric Sandeen [Fri, 5 Oct 2018 20:46:18 +0000 (15:46 -0500)] 
xfsprogs: Release v4.19.0-rc0

Update all the necessary files for a 4.19.0-rc0 release.
This is primarily only a libxfs sync with linux-4.19

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: fix a null pointer dereference in xfs_bmap_extents_to_btree libxfs-4.19-sync
Shan Hai [Fri, 5 Oct 2018 02:36:12 +0000 (21:36 -0500)] 
xfs: fix a null pointer dereference in xfs_bmap_extents_to_btree

Source kernel commit: 01239d77b9dd978863d1a75f0d095ab942a1fe66

Fuzzing tool reports a write to null pointer error in the
xfs_bmap_extents_to_btree, fix it by bailing out on encountering
a null pointer.

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>
5 years agoxfs: use WRITE_ONCE to update if_seq
Christoph Hellwig [Fri, 5 Oct 2018 02:36:12 +0000 (21:36 -0500)] 
xfs: use WRITE_ONCE to update if_seq

Source kernel commit: 2ba090d521c5e09f32316c179d25bb6f699d3568

This adds ordering of the updates and makes sure we always see the if_seq
update before the extent tree is modified.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: fold dfops into the transaction
Brian Foster [Fri, 5 Oct 2018 02:36:12 +0000 (21:36 -0500)] 
xfs: fold dfops into the transaction

Source kernel commit: 9d9e6233859706875c392707efd6d516cfb764fb

struct xfs_defer_ops has now been reduced to a single list_head. The
external dfops mechanism is unused and thus everywhere a (permanent)
transaction is accessible the associated dfops structure is as well.

Remove the xfs_defer_ops structure and fold the list_head into the
transaction. Also remove the last remnant of external dfops in
xfs_trans_dup().

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: always defer agfl block frees
Brian Foster [Fri, 5 Oct 2018 02:36:12 +0000 (21:36 -0500)] 
xfs: always defer agfl block frees

Source kernel commit: c03edc9e49b6a3c1f4b27f505a04093ab333b245

The AGFL fixup code conditionally defers block frees from the free
list based on whether the current transaction has an associated
xfs_defer_ops structure. Now that dfops is embedded in the
transaction and the internal dfops is used unconditionally, this
invariant is always true.

Remove the now dead logic to check for ->t_dfops in
xfs_alloc_fix_freelist() and unconditionally defer AGFL block frees.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: pass transaction to xfs_defer_add()
Brian Foster [Fri, 5 Oct 2018 02:36:12 +0000 (21:36 -0500)] 
xfs: pass transaction to xfs_defer_add()

Source kernel commit: 0f37d1780c3d864599fb377dcb47ad1aa0686b4e

The majority of remaining references to struct xfs_defer_ops in XFS
are associated with xfs_defer_add(). At this point, there are no
more external xfs_defer_ops users left. All instances of
xfs_defer_ops are embedded in the transaction, which means we can
safely pass the transaction down to the dfops add interface.

Update xfs_defer_add() to receive the transaction as a parameter.
Various subsystems implement wrappers to allocate and construct the
context specific data structures for the associated deferred
operation type. Update these to also carry the transaction down as
needed and clean up unused dfops parameters along the way.

This removes most of the remaining references to struct
xfs_defer_ops throughout the code and facilitates removal of the
structure.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
[darrick: fix unused variable warnings with ftrace disabled]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: replace xfs_defer_ops ->dop_pending with on-stack list
Brian Foster [Fri, 5 Oct 2018 02:36:12 +0000 (21:36 -0500)] 
xfs: replace xfs_defer_ops ->dop_pending with on-stack list

Source kernel commit: 1ae093cbea3d1ef04e1344b9e3996a9e1763a91b

The xfs_defer_ops ->dop_pending list is used to track active
deferred operations once intents are logged. These items must be
aborted in the event of an error. The list is populated as intents
are logged and items are removed as they complete (or are aborted).

Now that xfs_defer_finish() cancels on error, there is no need to
ever access ->dop_pending outside of xfs_defer_finish(). The list is
only ever populated after xfs_defer_finish() begins and is either
completed or cancelled before it returns.

Remove ->dop_pending from xfs_defer_ops and replace it with a local
list in the xfs_defer_finish() path. Pass the local list to the
various helpers now that it is not accessible via dfops. Note that
we have to check for NULL in the abort case as the final tx roll
occurs outside of the scope of the new local list (once the dfops
has completed and thus drained the list).

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: cancel dfops on xfs_defer_finish() error
Brian Foster [Fri, 5 Oct 2018 02:36:12 +0000 (21:36 -0500)] 
xfs: cancel dfops on xfs_defer_finish() error

Source kernel commit: 9b1f4e9831df29776031e86e112e68784f1fc079

The current semantics of xfs_defer_finish() require the caller to
call xfs_defer_cancel() on error. This is slightly inconsistent with
transaction commit error handling where a failed commit cleans up
the transaction before returning.

More significantly, the only requirement for exposure of
->dop_pending outside of xfs_defer_finish() is so that
xfs_defer_cancel() can drain it on error. Since the only recourse of
xfs_defer_finish() errors is cancellation, mirror the transaction
logic and cancel remaining dfops before returning from
xfs_defer_finish() with an error.

Beside simplifying xfs_defer_finish() semantics, this ensures that
xfs_defer_finish() always returns with an empty ->dop_pending and
thus facilitates removal of the list from xfs_defer_ops.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: clean out superfluous dfops dop params/vars
Brian Foster [Fri, 5 Oct 2018 02:36:12 +0000 (21:36 -0500)] 
xfs: clean out superfluous dfops dop params/vars

Source kernel commit: 60f31a609ed3d28791acb2bc24188cb7e2259176

The dfops code still passes around the xfs_defer_ops pointer
superfluously in a few places. Clean this up wherever the
transaction will suffice.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: drop dop param from xfs_defer_op_type ->finish_item() callback
Brian Foster [Fri, 5 Oct 2018 02:36:12 +0000 (21:36 -0500)] 
xfs: drop dop param from xfs_defer_op_type ->finish_item() callback

Source kernel commit: 7dbddbaccd189e63c39c9e22c728c4548b9893bb

The dfops infrastructure ->finish_item() callback passes the
transaction and dfops as separate parameters. Since dfops is always
part of a transaction, the latter parameter is no longer necessary.
Remove it from the various callbacks.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: automatic dfops inode relogging
Brian Foster [Fri, 5 Oct 2018 02:36:12 +0000 (21:36 -0500)] 
xfs: automatic dfops inode relogging

Source kernel commit: a8198666fb755e129c2fe92819774256ec26c79c

Inodes that are held across deferred operations are explicitly
joined to the dfops structure to ensure appropriate relogging.
While inodes are currently joined explicitly, we can detect the
conditions that require relogging at dfops finish time by inspecting
the transaction item list for inodes with ili_lock_flags == 0.

Replace the xfs_defer_ijoin() infrastructure with such detection and
automatic relogging of held inodes. This eliminates the need for the
per-dfops inode list, replaced by an on-stack variant in
xfs_defer_trans_roll().

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: automatic dfops buffer relogging
Brian Foster [Fri, 5 Oct 2018 02:36:12 +0000 (21:36 -0500)] 
xfs: automatic dfops buffer relogging

Source kernel commit: 82ff27bc52a88cb5cc400bfa64e210d3ec8dfebd

Buffers that are held across deferred operations are explicitly
joined to the dfops structure to ensure appropriate relogging.
While buffers are currently joined explicitly, we can detect the
conditions that require relogging at dfops finish time by inspecting
the transaction item list for held buffers.

Replace the xfs_defer_bjoin() infrastructure with such detection and
automatic relogging of held buffers. This eliminates the need for
the per-dfops buffer list, replaced by an on-stack variant in
xfs_defer_trans_roll().

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: add missing defer ijoins for held inodes
Brian Foster [Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)] 
xfs: add missing defer ijoins for held inodes

Source kernel commit: 488c919a5bec3be4b8613898de6958043edbb8d9

Log items that require relogging during deferred operations
processing are explicitly joined to the associated dfops via the
xfs_defer_*join() helpers. These calls imply that the associated
object is "held" by the transaction such that when rolled, the item
can be immediately joined to a follow up transaction. For buffers,
this means the buffer remains locked and held after each roll. For
inodes, this means that the inode remains locked.

Failure to join a held item to the dfops structure means the
associated object pins the tail of the log while dfops processing
completes, because the item never relogs and is not unlocked or
released until deferred processing completes.

Currently, all buffers that are held in transactions (XFS_BLI_HOLD)
with deferred operations are explicitly joined to the dfops. This is
not the case for inodes, however, as various contexts defer
operations to transactions with held inodes without explicit joins
to the associated dfops (and thus not relogging).

While this is not a catastrophic problem, it is not ideal. Given
that we want to eventually relog such items automatically during
dfops processing, start by explicitly adding these missing
xfs_defer_ijoin() calls. A call is added everywhere an inode is
joined to a transaction without transferring lock ownership and
said transaction runs deferred operations.

All xfs_defer_ijoin() calls will eventually be replaced by automatic
dfops inode relogging. This patch essentially implements the
behavior change that would otherwise occur due to automatic inode
dfops relogging.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: replace dop_low with transaction flag
Brian Foster [Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)] 
xfs: replace dop_low with transaction flag

Source kernel commit: 1214f1cf663b0939fbb8f1bccdc74c1d1e452d53

The dop_low field enables the low free space allocation mode when a
previous allocation has detected difficulty allocating blocks. It
has historically been part of the xfs_defer_ops structure, which
means if enabled, it remains enabled across a set of transactions
until the deferred operations have completed and the dfops is reset.

Now that the dfops is embedded in the transaction, we can save a bit
more space by using a transaction flag rather than a standalone
boolean. Drop the ->dop_low field and replace it with a transaction
flag that is set at the same points, carried across rolling
transactions and cleared on completion of deferred operations. This
essentially emulates the behavior of ->dop_low and so should not
change behavior.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: pass transaction to dfops reset/move helpers
Brian Foster [Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)] 
xfs: pass transaction to dfops reset/move helpers

Source kernel commit: ce356d64772f920f26cd6c1b02878a737a275638

All callers pass ->t_dfops of the associated transactions. Refactor
the helpers to receive the transactions and facilitate further
cleanups between xfs_defer_ops and xfs_trans.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove unused __xfs_defer_cancel() internal helper
Brian Foster [Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)] 
xfs: remove unused __xfs_defer_cancel() internal helper

Source kernel commit: 7279aa13b8fb954f50073a672f912898198efd14

With no more external dfops users, there is no need for an
xfs_defer_ops cancel wrapper.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: refactor internal dfops initialization
Brian Foster [Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)] 
xfs: refactor internal dfops initialization

Source kernel commit: 98719051e75ccf9eca18bd2b569de4ea637b4479

The current transaction allocation code conditionally initializes
the ->t_dfops indirection pointer. Transaction commit/cancel check
the validity of the pointer to determine whether to finish/cancel
the internal dfops.

This disallows the ability to use the internal dfops list as a
temporary container (via xfs_trans_alloc_empty()). Refactor
transaction allocation to always initialize ->t_dfops and check
permanent reservation state on transaction commit/cancel.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: check da node magic in _node_lookup_int
Darrick J. Wong [Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)] 
xfs: check da node magic in _node_lookup_int

Source kernel commit: 56830d6cc114f76f656d5e65ab355b070d5a695e

Before we start processing what we /think/ is a da3 node block, actually
check the magic to make sure that we're looking at a node block.  This
way we won't blow the asserts in _node_hdr_from_disk on corrupted
metadata.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: use a local variable for magic number in xfs_da3_node_lookup_int
Darrick J. Wong [Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)] 
xfs: use a local variable for magic number in xfs_da3_node_lookup_int

Source kernel commit: 611995db2ce210d20d51c5270639b750476534e5

Use a local variable for the block magic number checks instead of
abusing blk->magic.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: refactor log recovery check
Darrick J. Wong [Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)] 
xfs: refactor log recovery check

Source kernel commit: 0c60d3aa0e2d007e7f79c96c118da25f594afe02

Add a predicate to decide if the log is actively in recovery and use
that instead of open-coding a pagf_init check in the attr leaf verifier.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: move extent busy tree initialization to xfs_initialize_perag
Darrick J. Wong [Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)] 
xfs: move extent busy tree initialization to xfs_initialize_perag

Source kernel commit: ff23f4af7efd86cbb1bda42fe2171e0790f9cb5a

Move the per-AG busy extent tree initialization to the per-ag structure
initialization since we don't want online repair to leak the old tree.
We only deconstruct the tree at unmount time, so this should be safe.
This also enables us to eliminate the commented out initialization in
the xfsprogs libxfs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: maintain a sequence count for inode fork manipulations
Christoph Hellwig [Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)] 
xfs: maintain a sequence count for inode fork manipulations

Source kernel commit: 745b3f76d1c889d738a1c4537a3c491bc1ecac4d

Add a simple 32-bit unsigned integer as the sequence count for
modifications to the extent list in the inode fork.  This will be
used to optimize away extent list lookups in the writeback code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: check for unknown v5 feature bits in superblock write verifier
Darrick J. Wong [Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)] 
xfs: check for unknown v5 feature bits in superblock write verifier

Source kernel commit: 9e037cb7972fab5a9f55bca4ebe6e4dbf7e160bc

Make sure we never try to write the superblock with unknown feature bits
set.  We checked those at mount time, so if they're set now then memory
is corrupt.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: only validate summary counts on primary superblock
Darrick J. Wong [Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)] 
xfs: only validate summary counts on primary superblock

Source kernel commit: 1f31c98d650ca342e2f54cb17c4554ad110c5a11

Skip the summary counter checks for secondary superblocks and inprogress
primary superblocks because mkfs has always written those out with
zeroed summary counters.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: verify icount in superblock write
Darrick J. Wong [Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)] 
xfs: verify icount in superblock write

Source kernel commit: 69775fd15dc78e0547af45fb3e375d5423cb21b1

Add a helper predicate to check the inode count for sanity, then use it
in the superblock write verifier to inspect sb_icount.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: add more bounds checking to sb sanity checks
Bill O'Donnell [Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)] 
libxfs: add more bounds checking to sb sanity checks

Source kernel commit: 8756a5af18191a471e670cc577aea60b652fea4c

Current sb verifier doesn't check bounds on sb_fdblocks and sb_ifree.
Add sanity checks for these parameters.

Signed-off-by: Bill O'Donnell <billodo@redhat.com>
[darrick: port to refactored sb validation predicates]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: refactor superblock verifiers
Darrick J. Wong [Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)] 
xfs: refactor superblock verifiers

Source kernel commit: eca383fcd63b452cf533505154135da2a1f70227

Split the superblock verifier into the common checks, the read-time
checks, and the write-time check functions.  No functional changes, but
we're setting up to add more write-only checks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove the xfs_ifork_t typedef
Christoph Hellwig [Fri, 5 Oct 2018 02:36:11 +0000 (21:36 -0500)] 
xfs: remove the xfs_ifork_t typedef

Source kernel commit: 3ba738df25239f877f6a98ce1cc925fa7e924cd3

We only have a few more callers left, so seize the opportunity and kill
it off.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: simplify xfs_idata_realloc
Christoph Hellwig [Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)] 
xfs: simplify xfs_idata_realloc

Source kernel commit: 1216b58b353fbf5529454b442cebb3c8f14d93da

Streamline the code and take advantage of the fact that kmem_realloc
through krealloc will be have like a normal allocation if passing in a
NULL old pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove if_real_bytes
Christoph Hellwig [Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)] 
xfs: remove if_real_bytes

Source kernel commit: fcacbc3f511338842dd177e2d53d457f9741543b

The field is only used for asserts, and to track if we really need to do
realloc when growing the inode fork data.  But the krealloc function
already performs this check internally, so there is no need to keep track
of the real allocation size.

This will free space in the inode fork for keeping a sequence counter of
changes to the 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>
5 years agoxfs: pass transaction lock while setting up agresv on cyclic metadata
Darrick J. Wong [Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)] 
xfs: pass transaction lock while setting up agresv on cyclic metadata

Source kernel commit: ebcbef3a61a6081ffe20b0b684f18ebbf23f1dfb

Pass a tranaction pointer through to all helpers that calculate the
per-AG block reservation.  Online repair will use this to reinitialize
per-ag reservations while it still holds all the AG headers locked to
the repair transaction.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: bypass final dfops roll in trans commit path
Brian Foster [Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)] 
xfs: bypass final dfops roll in trans commit path

Source kernel commit: b277c37f43dd387f7430a2186deda0e58c943087

Once xfs_defer_finish() has completed all deferred operations, it
checks the dirty state of the transaction and rolls it once more to
return a clean transaction for the caller. This primarily to cover
the case where repeated xfs_defer_finish() calls are made in a loop
and we need to make sure that the caller starts the next iteration
with a clean transaction. Otherwise we risk transaction reservation
overrun.

This final transaction roll is not required in the transaction
into a separate helper such that we can avoid it in the transaction
until after the last call to xfs_defer_trans_roll(). The reset is
also unnecessary in the transaction commit path because the
transaction is about to complete.

This eliminates unnecessary regrants of transactions where the
associated transaction roll can be replaced by a transaction commit.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@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>
5 years agoxfs: drop unnecessary xfs_defer_finish() dfops parameter
Brian Foster [Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)] 
xfs: drop unnecessary xfs_defer_finish() dfops parameter

Source kernel commit: 9e28a242be65b8274742425ca5d146f366205a90

Every caller of xfs_defer_finish() now passes the transaction and
its associated ->t_dfops. The xfs_defer_ops parameter is therefore
no longer necessary and can be removed.

Since most xfs_defer_finish() callers also have to consider
xfs_defer_cancel() on error, update the latter to also receive the
transaction for consistency. The log recovery code contains an
outlier case that cancels a dfops directly without an available
transaction. Retain an internal wrapper to support this outlier case
for the time being.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@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>
5 years agoxfs: remove unnecessary dfops init calls in xattr code
Brian Foster [Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)] 
xfs: remove unnecessary dfops init calls in xattr code

Source kernel commit: d5cca7eb244d276177a57e42494d479742bbba37

Each xfs_defer_init() call in the xattr code uses the internal dfops
reference. In addition, a successful xfs_defer_finish() always
returns with a reset xfs_defer_ops structure.

Given that along with the fact that every xfs_defer_init() call in
the xattr code is followed up by an xfs_defer_finish(), the former
calls are no longer necessary and can be removed.

Note that the xfs_defer_init() call in the remote value copy loop of
xfs_attr_rmtval_set() is not followed by a finish, but the dfops is
unused in this instance.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@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>
5 years agoxfs: remove all boilerplate defer init/finish code
Brian Foster [Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)] 
xfs: remove all boilerplate defer init/finish code

Source kernel commit: c8eac49ef798a7d00240847f63902caa1388241a

At this point, the transaction subsystem completely manages deferred
items internally such that the common and boilerplate
xfs_trans_alloc() -> xfs_defer_init() -> xfs_defer_finish() ->
xfs_trans_commit() sequence can be replaced with a simple
transaction allocation and commit.

Remove all such boilerplate deferred ops code. In doing so, we
change each case over to use the dfops in the transaction and
specifically eliminate:

- The on-stack dfops and associated xfs_defer_init() call, as the
internal dfops is initialized on transaction allocation.
- xfs_bmap_finish() calls that precede a final xfs_trans_commit() of
a transaction.
- xfs_defer_cancel() calls in error handlers that precede a
transaction cancel.

The only deferred ops calls that remain are those that are
non-deterministic with respect to the final commit of the associated
transaction or are open-coded due to special handling.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@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>
5 years agoxfs: use internal dfops in attr code
Brian Foster [Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)] 
xfs: use internal dfops in attr code

Source kernel commit: 9c6bb0cf7ba318767107328f39aac880344ddd2e

Remove the unnecessary on-stack dfops structure and use the internal
transaction dfops instead. The lower level xattr code already
appropriately accesses ->t_dfops throughout.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@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>
5 years agoxfs: support embedded dfops in transaction
Brian Foster [Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)] 
xfs: support embedded dfops in transaction

Source kernel commit: e021a2e5fc520d930f949f303e7307038e258645

The dfops structure used by multi-transaction operations is
typically stored on the stack and carried around by the associated
transaction. The lifecycle of dfops does not quite match that of the
transaction, but they are tightly related in that the former depends
on the latter.

The relationship of these objects is tight enough that we can avoid
the cumbersome boilerplate code required in most cases to manage
them separately by just embedding an xfs_defer_ops in the
transaction itself. This means that a transaction allocation returns
with an initialized dfops, a transaction commit finishes pending
deferred items before the tx commit, a transaction cancel cancels
the dfops before the transaction and a transaction dup operation
transfers the current dfops state to the new transaction.

The dup operation is slightly complicated by the fact that we can no
longer just copy a dfops pointer from the old transaction to the new
transaction. This is solved through a dfops move helper that
transfers the pending items and other dfops state across the
transactions. This also requires that transaction rolling code
always refer to the transaction for the current dfops reference.

Finally, to facilitate incremental conversion to the internal dfops
and continue to support the current external dfops mode of
operation, create the new ->t_dfops_internal field with a layer of
indirection. On allocation, ->t_dfops points to the internal dfops.
This state is overridden by callers who re-init a local dfops on the
transaction. Once ->t_dfops is overridden, the external dfops
reference is maintained as the transaction rolls.

This patch adds the fundamental ability to support an internal
dfops. All codepaths that perform deferred processing continue to
override the internal dfops until they are converted over in
subsequent patches.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@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>