]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/log
thirdparty/xfsprogs-dev.git
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>
5 years agoxfs: pack holes in xfs_defer_ops and xfs_trans
Brian Foster [Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)] 
xfs: pack holes in xfs_defer_ops and xfs_trans

Source kernel commit: 44fd294681de73990da656294e3dacaa7878f577

Both structures have holes due to member alignment. Move dop_low to
the end of xfs_defer ops to sanitize the cache line alignment and
move t_flags to save 8 bytes in xfs_trans.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bill O'Donnell <billodo@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: reset dfops to initial state after finish
Brian Foster [Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)] 
xfs: reset dfops to initial state after finish

Source kernel commit: 509308b413c9e4e3140b4bc524522255d126787e

xfs_defer_init() is currently used in two particular situations. The
first and most obvious case is raw initialization of an
xfs_defer_ops struct. The other case is partial reinit of
xfs_defer_ops on reuse due to iteration.

Most instances of the first case will be replaced by a single init
of a dfops embedded in the transaction. Init calls are still
technically required for the second case because the dfops may have
low space mode enabled or have joined items that need to be reset
before the dfops should be reused.

Since the current dfops usage expects either a final transaction
be reused, we can shift some of the init logic into
xfs_defer_finish() such that the latter returns with a reinitialized
dfops. This eliminates the second dependency noted above such that a
dfops is immediately ready for reuse after an xfs_defer_finish()
without the need to change any calling code.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove unused deferred ops committed field
Brian Foster [Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)] 
xfs: remove unused deferred ops committed field

Source kernel commit: 83200bfac6082a46cc962366478d050052e50450

dop_committed is set when deferred item processing rolls the
transaction at least once, but is only ever accessed in tracepoints.
The transaction roll/commit events are already available via
independent tracepoints, so remove the otherwise unused field.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bill O'Donnell <billodo@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: make deferred processing safe for embedded dfops
Brian Foster [Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)] 
xfs: make deferred processing safe for embedded dfops

Source kernel commit: 03f4e4b26cd5f6eed728f82d90039a19d1b51ce3

xfs_defer_finish() has a couple quirks that are not safe with
respect to the upcoming internal dfops functionality. First,
xfs_defer_finish() attaches the passed in dfops structure to
->t_dfops and caches and restores the original value. Second, it
continues to use the initial dfops reference before and after the
transaction roll.

These behaviors assume that dop is an independent memory allocation
from the transaction itself, which may not always be true once
transactions begin to use an embedded dfops structure. In the latter
model, dfops processing creates a new xfs_defer_ops structure with
each transaction and the associated state is migrated across to the
new transaction.

Fix up xfs_defer_finish() to handle the possibility of the current
dfops changing after a transaction roll. Since ->t_dfops is used
unconditionally in this path, it is no longer necessary to
attach/restore ->t_dfops and pass it explicitly down to
xfs_defer_trans_roll(). Update dop in the latter function and the
caller to ensure that it always refers to the current dfops
structure.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bill O'Donnell <billodo@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: fix transaction leak on remote attr set/remove failure
Brian Foster [Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)] 
xfs: fix transaction leak on remote attr set/remove failure

Source kernel commit: dcbd44f79986e55691600b969c14db004d741883

The xattr remote value set/remove handlers both clear args.trans in
the error path without having cancelled the transaction. This leaks
the transaction, causes warnings around returning to userspace with
locks held and leads to system lockups or other general problems.

The higher level xfs_attr_[set|remove]() functions already detect
and cancel args.trans when set in the error path. Drop the NULL
assignments from the rmtval handlers and allow the callers to clean
up the transaction correctly.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bill O'Donnell <billodo@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: force summary counter recalc at next mount
Darrick J. Wong [Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)] 
xfs: force summary counter recalc at next mount

Source kernel commit: f467cad95f5e3814fda408dea76eb962ab19685d

Use the "bad summary count" mount flag from the previous patch to skip
writing the unmount record to force log recovery at the next mount,
which will recalculate the summary counters for us.

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

Source kernel commit: 53235f22151ea7229e1251e46e68098bcf74922d

Refactor the writing of the unmount record into a separate helper.  No
functionality changes.

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

Source kernel commit: 2e9e6481e2a78de3a85083beccfbf6eda2689922

Filippo Giunchedi complained that xfs doesn't even perform basic sanity
checks of the fs summary counters at mount time.  Therefore, recalculate
the summary counters from the AGFs after log recovery if the counts were
bad (or we had to recover the fs).  Enhance the recalculation routine to
fail the mount entirely if the new values are also obviously incorrect.

We use a mount state flag to record the "bad summary count" state so
that the (subsequent) online fsck patches can detect subtlely incorrect
counts and set the flag; clear it userspace asks for a repair; or force
a recalculation at the next mount if nobody fixes it by unmount time.

Reported-by: Filippo Giunchedi <fgiunchedi@wikimedia.org>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: clean up xfs_btree_del_cursor callers
Darrick J. Wong [Fri, 5 Oct 2018 02:36:09 +0000 (21:36 -0500)] 
xfs: clean up xfs_btree_del_cursor callers

Source kernel commit: ef97ef26d263fb65f0c7446a10cf93201dc0388c

Less trivial cleanups of the error argument to xfs_btree_del_cursor;
these require some minor code refactoring.

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: trivial xfs_btree_del_cursor cleanups
Darrick J. Wong [Fri, 5 Oct 2018 02:36:09 +0000 (21:36 -0500)] 
xfs: trivial xfs_btree_del_cursor cleanups

Source kernel commit: 0b04b6b875b32f2b32263ba46d54d001e05724f9

The error argument to xfs_btree_del_cursor already understands the
"nonzero for error" semantics, so remove pointless error testing in the
callers and pass it directly.

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: return from _defer_finish with a clean transaction
Darrick J. Wong [Fri, 5 Oct 2018 02:36:09 +0000 (21:36 -0500)] 
xfs: return from _defer_finish with a clean transaction

Source kernel commit: 81b549aa626b650bbf00423c084c0fd5581169b9

The following assertion was seen on generic/051:

XFS: Assertion failed: tp->t_firstblock == NULLFSBLOCK, file: fs/xfs/libxfs5
------------[ cut here ]------------
kernel BUG at fs/xfs/xfs_message.c:102!
invalid opcode: 0000 [#1] SMP PTI
CPU: 2 PID: 20757 Comm: fsstress Not tainted 4.18.0-rc4+ #3969
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.1-1 04/01/4
RIP: 0010:assfail+0x23/0x30
Code: c3 66 0f 1f 44 00 00 48 89 f1 41 89 d0 48 c7 c6 88 e0 8c 82 48 89 fa
RSP: 0018:ffff88012dc43c08 EFLAGS: 00010202
RAX: 0000000000000000 RBX: ffff88012dc43ca0 RCX: 0000000000000000
RDX: 00000000ffffffc0 RSI: 000000000000000a RDI: ffffffff828480eb
RBP: ffff88012aa92758 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: f000000000000000 R12: 0000000000000000
R13: ffff88012dc43d48 R14: ffff88013092e7e8 R15: 0000000000000014
FS:  00007f8d689b8e80(0000) GS:ffff88013fd00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f8d689c7000 CR3: 000000012ba6a000 CR4: 00000000000006e0
Call Trace:
xfs_defer_init+0xff/0x160
xfs_reflink_remap_extent+0x31b/0xa00
xfs_reflink_remap_blocks+0xec/0x4a0
xfs_reflink_remap_range+0x3a1/0x650
xfs_file_dedupe_range+0x39/0x50
vfs_dedupe_file_range+0x218/0x260
do_vfs_ioctl+0x262/0x6a0
? __se_sys_newfstat+0x3c/0x60
ksys_ioctl+0x35/0x60
__x64_sys_ioctl+0x11/0x20
do_syscall_64+0x4b/0x190
entry_SYSCALL_64_after_hwframe+0x49/0xbe

The root cause of the assertion failure is that xfs_defer_finish doesn't
roll the transaction after processing all the deferred items.  Therefore
it returns a dirty transaction to the caller, which leaves the caller at
risk of exceeding the transaction reservation if it logs more items.

Brian Foster's patchset to move the defer_ops firstblock into the
transaction requires t_firstblock == NULLFSBLOCK upon defer_ops
initialization, which is how this was noticed at all.

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

Source kernel commit: 65cfcc3897d7715a878b9f59736e7527ca27514f

Check the leaf attribute freemap when we're verifying the block.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: Fix a couple of sparse complaintis
Carlos Maiolino [Fri, 5 Oct 2018 02:36:09 +0000 (21:36 -0500)] 
libxfs: Fix a couple of sparse complaintis

Source kernel commit: 5089eafffba2ed444789e5d25c7c0dfd62595713

No significant changes, just silence a couple of sparse errors.

Using cpu_to_be32(NULLAGINO), the NULLAGINO constant will be encoded in
BE as a constant, avoiding a BE -> CPU conversion every iteraction of
the loop, if be32_to_cpu(agi->agi_unlinked[i]) was used instead.

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>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: use swap macro in xfs_dir2_leafn_rebalance
Gustavo A. R. Silva [Fri, 5 Oct 2018 02:36:09 +0000 (21:36 -0500)] 
xfs: use swap macro in xfs_dir2_leafn_rebalance

Source kernel commit: e4e542a683c16945533d700339a0aec261d39f34

Make use of the swap macro and remove unnecessary variable *tmp*. This
makes the code easier to read and maintain. Also, slightly refactor some
code.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.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_attr_leaf: use swap macro in xfs_attr3_leaf_rebalance
Gustavo A. R. Silva [Fri, 5 Oct 2018 02:36:09 +0000 (21:36 -0500)] 
xfs_attr_leaf: use swap macro in xfs_attr3_leaf_rebalance

Source kernel commit: 1d5bebbafc73d82e5af003cdd2bf8ee5741cd1df

Make use of the swap macro and remove some unnecessary variables.
This makes the code easier to read and maintain. Also, reduces the
stack usage.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.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: don't assume a left rmap when allocating a new rmap
Darrick J. Wong [Fri, 5 Oct 2018 02:36:09 +0000 (21:36 -0500)] 
xfs: don't assume a left rmap when allocating a new rmap

Source kernel commit: fa248de98a6beb9ceaec5059041d65f87ac438b4

The original rmap code assumed that there would always be at least one
rmap in the rmapbt (the AG sb/agf/agi) and so errored out if it didn't
find one.  This assumption isn't true for the rmapbt repair function
(and it won't be true for realtime rmap either), so remove the check and
just deal with the situation.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove xfs_defer_init() firstblock param
Brian Foster [Fri, 5 Oct 2018 02:36:09 +0000 (21:36 -0500)] 
xfs: remove xfs_defer_init() firstblock param

Source kernel commit: 5fdd97944ee5ae0fcdd88227224d0c2c87aa6db9

All but one caller of xfs_defer_init() passes in the ->t_firstblock
of the associated transaction. The one outlier is
xlog_recover_process_intents(), which simply passes a dummy value
because a valid pointer is required. This firstblock variable can
simply be removed.

At this point we could remove the xfs_defer_init() firstblock
parameter and initialize ->t_firstblock directly. Even that is not
necessary, however, because ->t_firstblock is automatically
reinitialized in the new transaction on a transaction roll. Since
xfs_defer_init() should never occur more than once on a particular
transaction (since the corresponding finish will roll it), replace
the reinit from xfs_defer_init() with an assert that verifies the
transaction has a NULLFSBLOCK firstblock.

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: replace no-op firstblock init with ->t_firstblock
Brian Foster [Fri, 5 Oct 2018 02:36:09 +0000 (21:36 -0500)] 
xfs: replace no-op firstblock init with ->t_firstblock

Source kernel commit: fb91f4b5d6187996796f4a9989decdf6ead12851

xfs_refcount_recover_cow_leftovers() has no need for a firstblock
variable and so passes an unrelated xfs_fsblock_t to
xfs_defer_init() to avoid declaring one. Replace this no-op
initialization with ->t_firstblock. This will be optimized away by
the removal of the xfs_defer_init() firstblock param.

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: remove xfs_alloc_arg firstblock field
Brian Foster [Fri, 5 Oct 2018 02:36:09 +0000 (21:36 -0500)] 
xfs: remove xfs_alloc_arg firstblock field

Source kernel commit: 64396ff2c25b2cd8156948a64ae0da5ff962e3f2

The xfs_alloc_arg.firstblock field is used to control the starting
agno for an allocation. The structure already carries a pointer to
the transaction, which carries the current firstblock value.

Remove the field and access ->t_firstblock directly in the
allocation code.

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: remove xfs_btree_cur private firstblock field
Brian Foster [Fri, 5 Oct 2018 02:36:09 +0000 (21:36 -0500)] 
xfs: remove xfs_btree_cur private firstblock field

Source kernel commit: cf612de732cb6ef626019ca085406d183f0a055a

The bmbt cursor private structure has a firstblock field that is
used to maintain locking order on bmbt allocations. The field holds
an actual firstblock value (as opposed to a pointer), so it is
initialized on cursor creation, updated on allocation and then the
value is transferred back to the source before the cursor is
destroyed.

This value is always transferred from and back to the ->t_firstblock
field. Since xfs_btree_cur already carries a reference to the
transaction, we can remove this field from xfs_btree_cur and the
associated copying. The bmbt allocations will update the value in
the transaction directly.

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: remove bmap format helpers firstblock params
Brian Foster [Fri, 5 Oct 2018 02:36:09 +0000 (21:36 -0500)] 
xfs: remove bmap format helpers firstblock params

Source kernel commit: 280253d213fb735b565532be2836f94cf574260d

The bmap format helpers receive firstblock via ->t_firstblock. Drop
the param and access it directly.

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: remove bmap extent add helper firstblock params
Brian Foster [Fri, 5 Oct 2018 02:36:09 +0000 (21:36 -0500)] 
xfs: remove bmap extent add helper firstblock params

Source kernel commit: 92f9da30f57bdb653ee46f26df2d51484b27c7f0

The add extent helpers all receive firstblock via ->t_firstblock.
Drop the parameter and access it directly.

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: remove xfs_bmalloca firstblock field
Brian Foster [Fri, 5 Oct 2018 02:36:09 +0000 (21:36 -0500)] 
xfs: remove xfs_bmalloca firstblock field

Source kernel commit: 94c07b4dba01481740ce893d05a71578150b8f0b

The xfs_bmalloca.firstblock field carries the firstblock value from
the transaction into the bmap infrastructure. It's initialized in
one place from ->t_firstblock, so drop the field and access
->t_firstblock directly throughout the bmap code.

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: use ->t_firstblock in bmap extent split
Brian Foster [Fri, 5 Oct 2018 02:36:09 +0000 (21:36 -0500)] 
xfs: use ->t_firstblock in bmap extent split

Source kernel commit: 4b77a088d781b53d263c37e75222439297b410e5

Also remove the unnecessary xfs_bmap_split_extent_at() parameter.

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: remove bmap insert/collapse firstblock param
Brian Foster [Fri, 5 Oct 2018 02:36:08 +0000 (21:36 -0500)] 
xfs: remove bmap insert/collapse firstblock param

Source kernel commit: 333f950c89a17018f812eae13daaa2a404c413c1

The only callers pass ->t_firstblock.

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: remove xfs_bunmapi() firstblock param
Brian Foster [Fri, 5 Oct 2018 02:36:08 +0000 (21:36 -0500)] 
xfs: remove xfs_bunmapi() firstblock param

Source kernel commit: 2af528425342dc8f696b28693c5e61587cd72b43

All callers pass ->t_firstblock from the current transaction.

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: remove xfs_bmapi_write() firstblock param
Brian Foster [Fri, 5 Oct 2018 02:36:08 +0000 (21:36 -0500)] 
xfs: remove xfs_bmapi_write() firstblock param

Source kernel commit: a7beabeae221db2118a51f6948239d63b84499ca

All callers pass ->t_firstblock from the current transaction.

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: use ->t_firstblock in xfs_bmapi_remap()
Brian Foster [Fri, 5 Oct 2018 02:36:08 +0000 (21:36 -0500)] 
xfs: use ->t_firstblock in xfs_bmapi_remap()

Source kernel commit: 580c4ff9484ac3395ad48b1118b269a6d68c9318

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: use ->t_firstblock for all xfs_bunmapi() callers
Brian Foster [Fri, 5 Oct 2018 02:36:08 +0000 (21:36 -0500)] 
xfs: use ->t_firstblock for all xfs_bunmapi() callers

Source kernel commit: 372837978d90d1c563315192196735c09623a5d6

Convert all xfs_bunmapi() callers to ->t_firstblock.

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: use ->t_firstblock in xattr ops
Brian Foster [Fri, 5 Oct 2018 02:36:08 +0000 (21:36 -0500)] 
xfs: use ->t_firstblock in xattr ops

Source kernel commit: 766139032f95bb41031f6de9c2ee0538bd035229

Similar to the dirops code, the xattr code uses an on-stack
firstblock variable for the various operations. This code rolls the
underlying transaction in various places, however, which means we
cannot simply replace the local firstblock vars with ->t_firstblock.
Doing so (without further changes) would invalidate the memory
pointed to by xfs_da_args.firstblock as soon as the first
transaction rolls.

To avoid this problem, remove xfs_da_args.firstblock and replace all
such accesses with ->t_firstblock at the same time. This ensures
that accesses to the current firstblock always occur through the
current transaction rather than a potentially invalid xfs_da_args
pointer.

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: use ->t_firstblock in attrfork add
Brian Foster [Fri, 5 Oct 2018 02:36:08 +0000 (21:36 -0500)] 
xfs: use ->t_firstblock in attrfork add

Source kernel commit: 825d75cd8c1b53883dd8c2fe1d8833c371b08074

Note that this codepath is a user of struct xfs_da_args. Switch it
over to ->t_firstblock in preparation to remove
xfs_da_args.firstblock.

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: remove firstblock param from xfs dir ops
Brian Foster [Fri, 5 Oct 2018 02:36:08 +0000 (21:36 -0500)] 
xfs: remove firstblock param from xfs dir ops

Source kernel commit: 381eee69f862d38bef468e91517e37fc53f60885

All callers of the xfs_dir_*() functions pass ->t_firstblock as the
firstblock parameter. Drop the parameter and access ->t_firstblock
directly.

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 firstblock field to xfs_trans
Brian Foster [Fri, 5 Oct 2018 02:35:54 +0000 (21:35 -0500)] 
xfs: add firstblock field to xfs_trans

Source kernel commit: bba59c5e4b38e160c6be25b2f4fe36ebc84f53df

A firstblock var is typically allocated and initialized along with
xfs_defer_ops structures and passed around independent from the
associated transaction. To facilitate combining the two, add an
optional ->t_firstblock field to xfs_trans that can be used in place
of an on-stack variable.

The firstblock value follows the lifetime of the transaction, so
initialize it on allocation and when a transaction rolls.

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: allow null firstblock in xfs_bmapi_write() when tp is null
Brian Foster [Thu, 4 Oct 2018 19:40:01 +0000 (14:40 -0500)] 
xfs: allow null firstblock in xfs_bmapi_write() when tp is null

Source kernel commit: 3ae2d89174e4ba581093320afb48421ca95191d2

xfs_bmapi_write() always expects a valid firstblock pointer. It
immediately dereferences the pointer to help determine how to
initialize the bma.minleft field. The remaining accesses are
related to modifying btree format forks, which is only relevant for
!COW fork callers.

The reflink code passes a NULL transaction to xfs_bmapi_write() in a
couple places that do COW fork unwritten conversion. The purpose of
the firstblock field is to track the first block allocation in the
current transaction, so technically firstblock should not be
required for these callers either.

Tweak xfs_bmapi_write() to initialize the bma correctly without
accessing the firstblock pointer if no transaction is provided in
the first place. Update the reflink callers to pass NULL instead of
otherwise unused firstblock references.

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: refactor dfops init to attach to transaction
Brian Foster [Thu, 4 Oct 2018 19:39:01 +0000 (14:39 -0500)] 
xfs: refactor dfops init to attach to transaction

Source kernel commit: bcd2c9f33559764e0d306e226a8aa88bc2e1e6fb

Most callers of xfs_defer_init() immediately attach the dfops
structure to a transaction. Add a transaction parameter to eliminate
much of this boilerplate code. This also helps self-document the
fact that many codepaths now expect a dfops pointer implicitly via
xfs_trans->t_dfops.

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: use ->t_dfops in reflink cow recover path
Brian Foster [Thu, 4 Oct 2018 19:38:01 +0000 (14:38 -0500)] 
xfs: use ->t_dfops in reflink cow recover path

Source kernel commit: d5669ed58175f85d2c13e914c5c4e2bd3647d893

Use ->t_dfops of the leftover COW reservation cleanup transaction.

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: remove unused btree cursor bc_private.a.dfops field
Brian Foster [Thu, 4 Oct 2018 19:37:01 +0000 (14:37 -0500)] 
xfs: remove unused btree cursor bc_private.a.dfops field

Source kernel commit: ed7ef8e55c6f24ae4347b5bda89e00af475ebc89

The xfs_btree_cur.bc_private.a.dfops field is only ever initialized
by the refcountbt cursor init function. The only caller of that
function with a non-NULL dfops is from deferred completion context,
which already has attached to ->t_dfops.

In addition to that, the only actual reference of a.dfops is the
cursor duplication function, which means the field is effectively
unused.

Remove the dfops field from the bc_private.a union. Any future users
can acquire the dfops from the transaction. This patch does not
change behavior.

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: remove xfs_btree_cur bmbt dfops field
Brian Foster [Thu, 4 Oct 2018 19:36:01 +0000 (14:36 -0500)] 
xfs: remove xfs_btree_cur bmbt dfops field

Source kernel commit: 42b394a92562b464e9ef81954ca93930c037a51b

All assignments of xfs_btree_cur.bc_private.b.dfops originate from
->t_dfops. Replace accesses of the former with the latter and remove
the unnecessary field. This patch does not change behavior.

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: remove dfops param from internal bmap extent helpers
Brian Foster [Thu, 4 Oct 2018 19:35:01 +0000 (14:35 -0500)] 
xfs: remove dfops param from internal bmap extent helpers

Source kernel commit: 81ba8f3e947c3c53beb535c7f29fe402429cae37

All callers of the various bmap extent helpers now use ->t_dfops.
Remove the unnecessary dfops params and access ->t_dfops directly.
This patch does not change behavior.

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: use ->t_dfops for collapse/insert range operations
Brian Foster [Thu, 4 Oct 2018 19:34:01 +0000 (14:34 -0500)] 
xfs: use ->t_dfops for collapse/insert range operations

Source kernel commit: f4a9cf97faf4adb27e4e105beda420bb5253c502

Use ->t_dfops for the collapse and insert range transactions. These
are the only callers of the respective bmap helpers, so replace the
unnecessary dfops parameters with direct accesses to ->t_dfops.

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: remove struct xfs_bmalloca dfops field
Brian Foster [Thu, 4 Oct 2018 19:33:01 +0000 (14:33 -0500)] 
xfs: remove struct xfs_bmalloca dfops field

Source kernel commit: 3e3673e3029c1dedf75a1688a5203d9550adf490

Now that bma.dfops is only assigned from ->t_dfops, replace all
accesses to the former with the latter and remove the unnecessary
field. This patch does not change behavior.

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: remove xfs_bmapi_remap() dfops param
Brian Foster [Thu, 4 Oct 2018 19:32:01 +0000 (14:32 -0500)] 
xfs: remove xfs_bmapi_remap() dfops param

Source kernel commit: ff3edf255da7a1ceb0fb2cb7f195fc27edd0091d

All xfs_bmapi_remap() callers already use ->t_dfops. Note that
deferred completion context unconditionally sets ->t_dfops if it
hasn't already been set by the caller. Remove the unnecessary
parameter and access ->t_dfops directly.

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: remove xfs_bunmapi() dfops param
Brian Foster [Thu, 4 Oct 2018 19:31:01 +0000 (14:31 -0500)] 
xfs: remove xfs_bunmapi() dfops param

Source kernel commit: ccd9d91148780a5e979ac00bce67c2155fb6378f

Now that all xfs_bunmapi() callers use ->t_dfops, remove the
unnecessary parameter and access ->t_dfops directly. This patch does
not change behavior.

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: remove xfs_bmapi_write() dfops param
Brian Foster [Thu, 4 Oct 2018 19:30:01 +0000 (14:30 -0500)] 
xfs: remove xfs_bmapi_write() dfops param

Source kernel commit: 6e702a5dcbe1d38cf479931dd2e2a3da884143f0

Now that all callers use ->t_dfops, the xfs_bmapi_write() dfops
parameter is no longer necessary. Remove it and access ->t_dfops
directly. This patch does not change behavior.

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: replace xfs_da_args->dfops accesses with ->t_dfops and remove
Brian Foster [Thu, 4 Oct 2018 19:29:01 +0000 (14:29 -0500)] 
xfs: replace xfs_da_args->dfops accesses with ->t_dfops and remove

Source kernel commit: 32a9b7c65cfc7d9283055fc9d61e6393ee2aa984

Now that xfs_da_args->dfops is always assigned from a ->t_dfops
pointer (or one that is immediately attached), replace all
downstream accesses of the former with the latter and remove the
field from struct xfs_da_args.

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: use ->t_dfops in extent split tx and remove param
Brian Foster [Thu, 4 Oct 2018 19:28:01 +0000 (14:28 -0500)] 
xfs: use ->t_dfops in extent split tx and remove param

Source kernel commit: d76e6ce8ed6943941c0c964d8ae43fdaefdcbb5a

Attach the local dfops to ->t_dfops of the extent split transaction.
Since this is the only caller of xfs_bmap_split_extent_at(), remove
the dfops parameter as well.

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: remove dfops param in attr fork add path
Brian Foster [Thu, 4 Oct 2018 19:27:01 +0000 (14:27 -0500)] 
xfs: remove dfops param in attr fork add path

Source kernel commit: 0bd6207f836446f9d472f342a0ba3c21fe5e986f

Now that the attribute fork add tx carries dfops along with the
transaction, it is unnecessary to pass it down the stack. Remove the
dfops parameter and access ->t_dfops directly where necessary. This
patch does not change behavior.

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: use ->t_dfops for attr set/remove operations
Brian Foster [Thu, 4 Oct 2018 19:26:01 +0000 (14:26 -0500)] 
xfs: use ->t_dfops for attr set/remove operations

Source kernel commit: 40d03ac6aa2bebe05190462734690472310167e4

Attach the local dfops to the transaction allocated for xattr add
and remove operations. Add an earlier initialization in
xfs_attr_remove() to ensure the structure is valid if it remains
unused at transaction commit time.

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: remove dfops param from high level dirname calls
Brian Foster [Thu, 4 Oct 2018 19:25:01 +0000 (14:25 -0500)] 
xfs: remove dfops param from high level dirname calls

Source kernel commit: c9cfdb381172174ade2445e7b468f1be550b1a44

All callers of the directory create, rename and remove interfaces
already associate the dfops with the transaction. Drop the dfops
parameters in these calls in preparation for further cleanups in the
layers below. This patch does not change behavior.

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: remove dfops parameter from ifree call stack
Brian Foster [Thu, 4 Oct 2018 19:24:01 +0000 (14:24 -0500)] 
xfs: remove dfops parameter from ifree call stack

Source kernel commit: 0e0417f3e54668cec9f677850130e6fbb64edcf2

The inode free callchain starting in xfs_inactive_ifree() already
associates its dfops with the transaction. It still passes the dfops
on the stack down through xfs_difree_inobt(), however.

Clean up the call stack and reference dfops directly from the
transaction. This patch does not change behavior.

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: rename xfs_trans ->t_agfl_dfops to ->t_dfops
Brian Foster [Thu, 4 Oct 2018 19:23:01 +0000 (14:23 -0500)] 
xfs: rename xfs_trans ->t_agfl_dfops to ->t_dfops

Source kernel commit: 6aa6718439ac6907b3c34cbe7ac2c71408f84f6e

The ->t_agfl_dfops field is currently used to defer agfl block frees
from associated transaction contexts. While all known problematic
contexts have already been updated to use ->t_agfl_dfops, the
broader goal is defer agfl frees from all callers that already use a
deferred operations structure. Further, the transaction field
facilitates a good amount of code clean up where the transaction and
dfops have historically been passed down through the stack
separately.

Rename the field to something more generic to prepare to use it as
such throughout XFS. This patch does not change behavior.
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: remove the now unused XFS_BMAPI_IGSTATE flag
Christoph Hellwig [Thu, 4 Oct 2018 19:22:01 +0000 (14:22 -0500)] 
xfs: remove the now unused XFS_BMAPI_IGSTATE flag

Source kernel commit: c3a2f9fff1bbe3cfc2070b2e9f1f0ad0d5ccda91

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: track transaction block reservation usage like the kernel
Darrick J. Wong [Thu, 4 Oct 2018 19:21:01 +0000 (14:21 -0500)] 
libxfs: track transaction block reservation usage like the kernel

Currently, block reservations in userspace transactions are not carried
over across transaction rolls.  This will lead to ENOSPC failures inside
libxfs code which checks for reservation overruns in an upcoming patch
that borrows the bmbt repair code from the kernel because it makes
extensive use of transaction rolling.

Therefore, port t_blk_res_used from the kernel so that block
reservations work the same way in userspace.

[sandeen: tweaks to backport before libxfs updates]
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: fix xfs_trans_alloc reservation abuse
Darrick J. Wong [Thu, 4 Oct 2018 19:19:01 +0000 (14:19 -0500)] 
libxfs: fix xfs_trans_alloc reservation abuse

Various xfsprogs tools have been abusing the transaction reservation
system by allocating the transaction with zero reservation.  This has
always worked in the past because userspace transactions do not require
reservations.  However, once we merge deferred ops into the transaction
structure, we will need to use a permanent reservation type to set up
any transaction that can roll.  tr_itruncate has all we need, so use
that as the reservation dummy.

[sandeen: tweaks to backport before libxfs updates]
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_repair: fix block reservation in mk_rsumino
Darrick J. Wong [Thu, 4 Oct 2018 19:18:01 +0000 (14:18 -0500)] 
xfs_repair: fix block reservation in mk_rsumino

The functions mk_rsumino and rtinit both allocate transactions to create
the realtime summary inode.  In order to allocate and map blocks to the
rtsummary file, these transactions require a block reservation.
However, despite the comments in mk_rsumino about lifting the code from
mkfs, it doesn't actually copy the same reservation calculation that
mkfs uses in rtinit().  Practically speaking this has no effect since
userspace doesn't care about transaction block reservations, but fix
this logic bomb anyway.

[sandeen: tweaks to backport before libxfs updates]
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: fix libxfs_trans_alloc callsite problems
Darrick J. Wong [Thu, 4 Oct 2018 19:17:01 +0000 (14:17 -0500)] 
libxfs: fix libxfs_trans_alloc callsite problems

Fix some incorrect libxfs_trans_alloc callers to check return values
correctly.

[sandeen: tweaks to backport before libxfs updates]
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: port kernel transaction code
Darrick J. Wong [Thu, 4 Oct 2018 19:16:01 +0000 (14:16 -0500)] 
libxfs: port kernel transaction code

Restructure the userspace transaction code to resemble the kernel code
more closely.  This will make deferred operations behave the same (with
respect to transaction lifetimes) as the kernel.

[sandeen: tweaks to backport before libxfs updates]
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.18.0 v4.18.0
Eric Sandeen [Fri, 24 Aug 2018 19:47:25 +0000 (14:47 -0500)] 
xfsprogs: Release v4.18.0

Update all the necessary files for a 4.18.0 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: fix spdx tag in xfs_cksum.h
Darrick J. Wong [Fri, 24 Aug 2018 19:45:22 +0000 (14:45 -0500)] 
libxfs: fix spdx tag in xfs_cksum.h

Change the SPDX tag style to match the kernel.

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.18.0-rc1 v4.18.0-rc1
Eric Sandeen [Wed, 1 Aug 2018 22:06:45 +0000 (17:06 -0500)] 
xfsprogs: Release v4.18.0-rc1

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

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agomisc: remove COPYING from doc/ Makefile
Eric Sandeen [Wed, 1 Aug 2018 22:06:45 +0000 (17:06 -0500)] 
misc: remove COPYING from doc/ Makefile

COPYING is gone now, so make doc-install breaks.

Fixes: 959ef98 ("xfsprogs: convert to SPDX license tags")
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 agomkfs: avoid divide-by-zero when hardware reports optimal i/o size as 0
Jeff Mahoney [Wed, 1 Aug 2018 22:06:45 +0000 (17:06 -0500)] 
mkfs: avoid divide-by-zero when hardware reports optimal i/o size as 0

Commit 051b4e37f5e (mkfs: factor AG alignment) factored out the
AG alignment code into a separate function.  It got rid of
redundant checks for dswidth != 0 since calc_stripe_factors was
supposed to guarantee that if dsunit is non-zero dswidth will be
as well.  Unfortunately, there's hardware out there that reports its
optimal i/o size as larger than the maximum i/o size, which the kernel
treats as broken and zeros out the optimal i/o size.

To resolve this we can check the topology before consuming it, and
ignore the bad stripe geometry.

Fixes: 051b4e37f5e (mkfs: factor AG alignment)
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
[sandeen: remove guessing heuristic, just warn and ignore bad data.]
Reviewed-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: add debian initramfs hook to package
Darrick J. Wong [Wed, 1 Aug 2018 22:06:45 +0000 (17:06 -0500)] 
xfs: add debian initramfs hook to package

In Debian bug 904086, the reporter complained that xfs_repair wasn't
present in the initramfs, which prevented him from using shutdown -F to
force a filesystem fsck after a reboot.  Add a hook to put the xfs
utilities in the initramfs if xfs is the root filesystem.

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>