]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/log
thirdparty/xfsprogs-dev.git
6 years agoxfs: only skip rmap owner checks for unknown-owner rmap removal libxfs-4.15-sync
Darrick J. Wong [Wed, 3 Jan 2018 19:42:11 +0000 (13:42 -0600)] 
xfs: only skip rmap owner checks for unknown-owner rmap removal

Source kernel commit: 68c58e9b9a88c1a9d0c2eaf6c7acefb00f5fbbfb

For rmap removal, refactor the rmap owner checks into a separate
function, then skip the checks if we are performing an unknown-owner
removal.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: always honor OWN_UNKNOWN rmap removal requests
Darrick J. Wong [Wed, 3 Jan 2018 19:42:11 +0000 (13:42 -0600)] 
xfs: always honor OWN_UNKNOWN rmap removal requests

Source kernel commit: 33df3a9cf925183a6a169bc3eff2bd0febd1298a

Calling xfs_rmap_free with an unknown owner is supposed to remove any
rmaps covering that range regardless of owner.  This is used by the EFI
recovery code to say "we're freeing this, it mustn't be owned by
anything anymore", but for whatever reason xfs_free_ag_extent filters
them out.

Therefore, remove the filter and make xfs_rmap_unmap actually treat it
as a wildcard owner -- free anything that's already there, and if
there's no owner at all then that's fine too.

There are two existing callers of bmap_add_free that take care the rmap
deferred ops themselves and use OWN_UNKNOWN to skip the EFI-based rmap
cleanup; convert these to use OWN_NULL (via helpers), and now we really
require that an RUI (if any) gets added to the defer ops before any EFI.

Lastly, now that xfs_free_extent filters out OWN_NULL rmap free requests,
growfs will have to consult directly with the rmap to ensure that there
aren't any rmaps in the grown region.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: queue deferred rmap ops for cow staging extent alloc/free in the right order
Darrick J. Wong [Wed, 3 Jan 2018 19:42:10 +0000 (13:42 -0600)] 
xfs: queue deferred rmap ops for cow staging extent alloc/free in the right order

Source kernel commit: 0525e952dcceb9fc947c6d395de7f72220c7d081

Under the deferred rmap operation scheme, there's a certain order in
which the rmap deferred ops have to be queued to maintain integrity
during log replay.  For alloc/map operations that order is cui -> rui;
for free/unmap operations that order is cui -> rui -> efi.  However, the
initial refcount code got the ordering wrong in the free side of things
because it queued refcount free op and an EFI and the refcount free op
queued a rmap free op, resulting in the order cui -> efi -> rui.

If we fail before the efd finishes, the efi recovery will try to do a
wildcard rmap removal and the subsequent rui will fail to find the rmap
and blow up.  This didn't ever happen due to other screws up in handling
unknown owner rmap removals, but those other screw ups broke recovery in
other ways, so fix the ordering to follow the intended rules.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: move xfs_iext_insert tracepoint to report useful information
Darrick J. Wong [Wed, 3 Jan 2018 19:42:09 +0000 (13:42 -0600)] 
xfs: move xfs_iext_insert tracepoint to report useful information

Source kernel commit: c54854a437a447a6bb1dcb11f60dd01cef3fa597

Move the tracepoint in xfs_iext_insert to after the point where we've
inserted the extent because otherwise we report stale extent data in
the ftrace output.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: account for null transactions in bunmapi
Darrick J. Wong [Wed, 3 Jan 2018 19:42:09 +0000 (13:42 -0600)] 
xfs: account for null transactions in bunmapi

Source kernel commit: 8c57b88637d78a723e0854fc3d06c6d4c31a1e0c

In e1a4e37cc7b665 ("xfs: try to avoid blowing out the transaction
reservation when bunmaping a shared extent"), we try to constrain the
amount of real extents we unmap from the data fork in a given call so
that we don't blow out transaction reservations.

However, not all bunmapi operations require a transaction -- if we're
only removing a delalloc extent, no transaction is needed, so we have to
code against that.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: hold xfs_buf locked between shortform->leaf conversion and the addition of an...
Darrick J. Wong [Wed, 3 Jan 2018 19:42:08 +0000 (13:42 -0600)] 
xfs: hold xfs_buf locked between shortform->leaf conversion and the addition of an attribute

Source kernel commit: 6e643cd094de3bd0f97edcc1db0089afa24d909f

The new attribute leaf buffer is not held locked across the transaction
roll between the shortform->leaf modification and the addition of the
new entry.  As a result, the attribute buffer modification being made is
not atomic from an operational perspective.  Hence the AIL push can grab
it in the transient state of "just created" after the initial
transaction is rolled, because the buffer has been released.  This leads
to xfs_attr3_leaf_verify() asserting that hdr.count is zero, treating
this as in-memory corruption, and shutting down the filesystem.

Darrick ported the original patch to 4.15 and reworked it use the
xfs_defer_bjoin helper and hold/join the buffer correctly across the
second transaction roll.

Signed-off-by: Alex Lyakas <alex@zadarastorage.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: add the ability to join a held buffer to a defer_ops
Darrick J. Wong [Wed, 3 Jan 2018 19:42:03 +0000 (13:42 -0600)] 
xfs: add the ability to join a held buffer to a defer_ops

Source kernel commit: b7b2846fe26f2c0d7f317c874a13d3ecf22670ff

In certain cases, defer_ops callers will lock a buffer and want to hold
the lock across transaction rolls.  Similar to ijoined inodes, we want
to dirty & join the buffer with each transaction roll in defer_finish so
that afterwards the caller still owns the buffer lock and we haven't
inadvertently pinned the log.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: refactor buffer logging into buffer dirtying helper
Brian Foster [Wed, 3 Jan 2018 19:42:03 +0000 (13:42 -0600)] 
xfs: refactor buffer logging into buffer dirtying helper

Source kernel commit: 9684010d38eccda733b61106765e9357cf436f65

xfs_trans_log_buf() is responsible for logging the dirty segments of
a buffer along with setting all of the necessary state on the
transaction, buffer, bli, etc., to ensure that the associated items
are marked as dirty and prepared for I/O. We have a couple use cases
that need to to dirty a buffer in a transaction without actually
logging dirty ranges of the buffer.  One existing use case is
ordered buffers, which are currently logged with arbitrary ranges to
accomplish this even though the content of ordered buffers is never
written to the log. Another pending use case is to relog an already
dirty buffer across rolled transactions within the deferred
operations infrastructure. This is required to prevent a held
(XFS_BLI_HOLD) buffer from pinning the tail of the log.

Refactor xfs_trans_log_buf() into a new function that contains all
of the logic responsible to dirty the transaction, lidp, buffer and
bli. This new function can be used in the future for the use cases
outlined above. This patch does not introduce functional changes.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.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>
6 years agoxfs: remove "no-allocation" reservations for file creations
Christoph Hellwig [Wed, 3 Jan 2018 19:42:03 +0000 (13:42 -0600)] 
xfs: remove "no-allocation" reservations for file creations

Source kernel commit: f59cf5c29919d17b61913c3360a7bd29b72975c1

If we create a new file we will need an inode, and usually some metadata
in the parent direction.  Aiming for everything to go well despite the
lack of a reservation leads to dirty transactions cancelled under a heavy
create/delete load.  This patch removes those nospace transactions, which
will lead to slightly earlier ENOSPC on some workloads, but instead
prevent file system shutdowns due to cancelling dirty transactions for
others.

A customer could observe assertations failures and shutdowns due to
cancelation of dirty transactions during heavy NFS workloads as shown
below:

2017-05-30 21:17:06 kernel: WARNING: [ 2670.728125] XFS: Assertion failed: error != -ENOSPC, file: fs/xfs/xfs_inode.c, line: 1262

2017-05-30 21:17:06 kernel: WARNING: [ 2670.728222] Call Trace:
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728246]  [<ffffffff81795daf>] dump_stack+0x63/0x81
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728262]  [<ffffffff810a1a5a>] warn_slowpath_common+0x8a/0xc0
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728264]  [<ffffffff810a1b8a>] warn_slowpath_null+0x1a/0x20
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728285]  [<ffffffffa01bf403>] asswarn+0x33/0x40 [xfs]
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728308]  [<ffffffffa01bb07e>] xfs_create+0x7be/0x7d0 [xfs]
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728329]  [<ffffffffa01b6ffb>] xfs_generic_create+0x1fb/0x2e0 [xfs]
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728348]  [<ffffffffa01b7114>] xfs_vn_mknod+0x14/0x20 [xfs]
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728366]  [<ffffffffa01b7153>] xfs_vn_create+0x13/0x20 [xfs]
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728380]  [<ffffffff81231de5>] vfs_create+0xd5/0x140
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728390]  [<ffffffffa045ddb9>] do_nfsd_create+0x499/0x610 [nfsd]
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728396]  [<ffffffffa0465fa5>] nfsd3_proc_create+0x135/0x210 [nfsd]
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728401]  [<ffffffffa04561e3>] nfsd_dispatch+0xc3/0x210 [nfsd]
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728416]  [<ffffffffa03bfa43>] svc_process_common+0x453/0x6f0 [sunrpc]
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728423]  [<ffffffffa03bfdf3>] svc_process+0x113/0x1f0 [sunrpc]
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728427]  [<ffffffffa0455bcf>] nfsd+0x10f/0x180 [nfsd]
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728432]  [<ffffffffa0455ac0>] ? nfsd_destroy+0x80/0x80 [nfsd]
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728438]  [<ffffffff810c0d58>] kthread+0xd8/0xf0
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728441]  [<ffffffff810c0c80>] ? kthread_create_on_node+0x1b0/0x1b0
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728451]  [<ffffffff8179d962>] ret_from_fork+0x42/0x70
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728453]  [<ffffffff810c0c80>] ? kthread_create_on_node+0x1b0/0x1b0
2017-05-30 21:17:06 kernel: WARNING: [ 2670.728454] ---[ end trace f9822c842fec81d4 ]---

2017-05-30 21:17:06 kernel: ALERT: [ 2670.728477] XFS (sdb): Internal error xfs_trans_cancel at line 983 of file fs/xfs/xfs_trans.c.  Caller xfs_create+0x4ee/0x7d0 [xfs]

2017-05-30 21:17:06 kernel: ALERT: [ 2670.728684] XFS (sdb): Corruption of in-memory data detected. Shutting down filesystem
2017-05-30 21:17:06 kernel: ALERT: [ 2670.728685] XFS (sdb): Please umount the filesystem and rectify the problem(s)

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: fix leaks on corruption errors in xfs_bmap.c
Eric Sandeen [Wed, 3 Jan 2018 19:42:03 +0000 (13:42 -0600)] 
xfs: fix leaks on corruption errors in xfs_bmap.c

Source kernel commit: d41c6172bd4031979eab722c265a2e5764383c3c

Use _GOTO instead of _RETURN so we can free the allocated
cursor on error.

Fixes: bf80628 ("xfs: remove xfs_bmse_shift_one")
Fixes-coverity-id: 14238131423676
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: abstract out dev_t conversions
Christoph Hellwig [Mon, 27 Nov 2017 20:23:38 +0000 (14:23 -0600)] 
xfs: abstract out dev_t conversions

Source kernel commit: 274e0a1f4777b9362fc03a34e86358cc36003e48

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

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: stub them out in xfsprogs]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: fix memory leak in xfs_iext_free_last_leaf
Shu Wang [Mon, 27 Nov 2017 17:47:07 +0000 (11:47 -0600)] 
xfs: fix memory leak in xfs_iext_free_last_leaf

Source kernel commit: 6818caa4cdc95d9ec5642a4439f8271a80189b48

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

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

Source kernel commit: 2015a63dce8d73a439232a0d5162c88d8513101e

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

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

Source kernel commit: 65a7935ddc9a1f0c723842776259d76394b4bd11

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

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

Source kernel commit: ae82968ee9b404b9fc101f9d75e171c78797a4d1

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

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

Source kernel commit: 3e27c418a7a13b8dbf33f6eb49b0e461f011bdcd

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

Source kernel commit: b9aee1d5fe58160a44556224b5479bd151a3e1a5

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

Source kernel commit: f1be313697f2d2ee925bd559a53d58312dec8b5a

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

Source kernel commit: fc258f4b8bb578c39223ff572b4dec8d56a2ed81

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

Source kernel commit: 43d193aa0212691254d574b8d207609ef22018b8

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

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

Source kernel commit: 4483eb566b2c045f69f2fa01629aca7772cdf95e

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

Source kernel commit: 866d7826c966d0d17cb31eaf394728a163ad7227

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

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

Source kernel commit: dac9c9b137950421a87c1d9ba29f3a6ee54d0e8a

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

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

Source kernel commit: c38ccf599022e7454a861145ce1a94c5b5d7e658

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

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

Source kernel commit: 0254c2f253d6fe11ea2ce5046ed6acfddbe4ee17

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

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

Source kernel commit: 6bdcf26ade8825ffcdc692338e715cd7ed0820d8

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

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

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

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

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

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

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: use uint32_t for rec_len, update trace macros & repair/]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: allow unaligned extent records in xfs_bmbt_disk_set_all
Christoph Hellwig [Fri, 17 Nov 2017 04:11:35 +0000 (22:11 -0600)] 
xfs: allow unaligned extent records in xfs_bmbt_disk_set_all

Source kernel commit: 135dcc10d6ebf6184686042ec8b098e376252fff

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

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

Source kernel commit: 43518812d297179ae1e432d5cd640ec168596283

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

It also simplifies the fork management code a lot.

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

Source kernel commit: b121459c7a56d2fb5a8ca6727bf9f87982738b01

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

[darrick: shorten the stringified CONVERT_ONLY trace flag]

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

Source kernel commit: b2b1712a640824e7c131bfdd2585d57bf8ccb39a

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

[darrick: rename for_each_iext to for_each_xfs_iext]

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

Source kernel commit: 906abed501bf5a2103946deb7a4a40b31c56f027

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

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

Source kernel commit: 71565f4b92048321ba3078877dd1a1149a23550d

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

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

Source kernel commit: f36bc228e1b94d9994915cba67588104ebe763ae

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

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

Source kernel commit: 42630361003461edd7607c1d459ab9d66ef97813

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

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

Source kernel commit: 657fcb23362c9e8a72593b3e4755135f003a7a74

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

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

Source kernel commit: a681847796df31c036810bce97003f687e1db5f4

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

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

Source kernel commit: 1d2e0089e16642928c76f032c1dbd0eb6da22935

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

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

Source kernel commit: 41d196f439509fd8b09364ca1ba48194cccc6d6e

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

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

Source kernel commit: 0d045540ed57e68b9ddcf5c325279a7e5ede7bbf

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

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

Source kernel commit: bf99971c8200fcb3e16d880194f5d559aca09576

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

Source kernel commit: 1bfd7618cbf2de630c845f60f5370671c2cd1c5d

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

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

Source kernel commit: 5d0eda0307ca20c5c58b1abd2a8ba822e0763b43

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

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: move error injection tags into their own file
Darrick J. Wong [Fri, 17 Nov 2017 04:11:34 +0000 (22:11 -0600)] 
xfs: move error injection tags into their own file

Source kernel commit: e9e899a2a8c3c23b3084b048466f417ed92286d3

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

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

Source kernel commit: 06b1132120d446bbaf844cbbae51f0afd3baacb8

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

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

Source kernel commit: 2f251293b09065118d78ae4e883e5639cc22f94e

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

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

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

Source kernel commit: c06641169e861d6446a220cd7f0d22c6c88da8e1

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

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

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

Source kernel commit: 2fdbec5cbeb93349836d682b1caa5cc72d1b7018

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

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

Source kernel commit: 8210f4dda2d7642cb7c882db55e53d899cced401

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

Apply the same checks to xfs_da3_node_lookup_int.

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

Source kernel commit: dc56015faff1bc9e7493c2b28302c423a02237c2

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

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

Source kernel commit: 211e95bbab71359e56f3d9adce1b4d6de8e18471

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

[darrick: minor fixups having left xfs_bmbt_validate_extent intact]

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

Source kernel commit: 29b3e94a9c65224733fe8de49b07b7227f95f821

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

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

Source kernel commit: 5936dc543cfd27de74cd34fdc928b5115cec53d1

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

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

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

Source kernel commit: 40591bdbccc47661050d98200ab65e77fa2324bd

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

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

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

Source kernel commit: 11f75b3bbad57998d1af99391ec3a8e076ab4dd9

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

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

Source kernel commit: bf8062800ad2d1ca22950c28910196bcbda89108

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

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

Source kernel commit: ecfea3f0c8c64ce7375f4be4506996968958bd01

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

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

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

Source kernel commit: 6b18af0dfd1695c1d53a2eeead838a90c27b7cb4

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

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

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

Source kernel commit: 66f364649d870c7541c30a2f02a32fd4c88684f0

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

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

Source kernel commit: 42b67dc6ffbf2701cfc578b3e706d560a80b6674

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

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

Source kernel commit: e8e0e170e2e17b601b86edb86f58dbf7c599e4b3

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

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

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: userspace-specific tracepoint macro updates]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: move pre/post-bmap tracing into xfs_iext_update_extent
Christoph Hellwig [Fri, 17 Nov 2017 04:11:33 +0000 (22:11 -0600)] 
xfs: move pre/post-bmap tracing into xfs_iext_update_extent

Source kernel commit: ca5d8e5b7b9030005e38e7c43e08c0cd4eb2a78f

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

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

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

Source kernel commit: d138604fb1a6500064b50e75f220e6cbce785493

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

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

Source kernel commit: 35e62da55f4b2450cbb51c9734d745a799e2a793

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

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

Source kernel commit: 060ea65b39409f3b9952dfa6db5fbe4355e6888a

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

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

Source kernel commit: c2fc338c87a31f557b57f5143602444ba3cf2c3e

Perform some quick sanity testing of the disk quota information.

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

Source kernel commit: 29b0767b8beb4c5e3fd94656d51413a4fe8d2d74

Perform simple tests of the realtime bitmap and summary.

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

Source kernel commit: 0f28b25731f76feda1ec71671754a2b7179ee1ef

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

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

Source kernel commit: 2a721dbbc8bf4d76581fb073aa0d9554df56da1a

Create the infrastructure to scrub symbolic link data.

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

Source kernel commit: eec0482e0829eab1da1be693e524c889dc4b168c

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

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

Source kernel commit: a5c46e5e8912d232b959faf511cd9a17cc829f0a

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

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

Source kernel commit: 99d9d8d05da26f47aa8412397407f962bcb4713a

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

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

Source kernel commit: 80e4e12688029e42fc6ab4cf7f229b090c61e6a7

Scrub the fields within an inode.

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

Source kernel commit: edc09b528628afb50904106f36de182a00e7eb40

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

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

Source kernel commit: c7e693d9836c003150fef80be40a06e1f2e65d0c

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

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

Source kernel commit: 3daa664191375db6a4a0cced75183aa3ca96cbda

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

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

Source kernel commit: efa7a99ce1f8615aca7b0ff3122a1ae14e4d1cdc

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

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

Source kernel commit: a12890aebb895951720ff884eab1c99a30645b29

Add a forgotten check to the AGI verifier, then wire up the scrub
infrastructure to check the AGI contents.

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

Source kernel commit: ab9d5dc59fe6157b8035c4b605166b868f678ee4

Check the block references in the AGF and AGFL headers to make sure
they make sense.

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

Source kernel commit: 21fb4cb1981ef7e02f35a42b2a5ae619517dfe1b

Ensure that the geometry presented in the backup superblocks matches
the primary superblock so that repair can recover the filesystem if
that primary gets corrupted.

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

Source kernel commit: cc3e0948d2686f30f49166660cf85b7e0194f365

Create a function that can check the shape of a btree -- each block
passes basic inspection and all the pointers look ok.  In the next patch
we'll add the ability to check the actual keys and records stored within
the btree.  Add some helper functions so that we report detailed scrub
errors in a uniform manner in dmesg.  These are helper functions for
subsequent patches.

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

Source kernel commit: dcb660f9222fd9f607e7e05f4755b39b809ca19f

Create a probe scrubber with id 0.  This will be used by xfs_scrub to
probe the kernel's abilities to scrub (and repair) the metadata.  We do
this by validating the ioctl inputs from userspace, preparing the
filesystem for a scrub (or a repair) operation, and immediately
returning to userspace.  Userspace can use the returned errno and
structure state to decide (in broad terms) if scrub/repair are
supported by the running kernel.

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

Source kernel commit: 36fd6e863cb7329ab2e5687fdae4e4626b840adc

Create an ioctl that can be used to scrub internal filesystem metadata.
The new ioctl takes the metadata type, an (optional) AG number, an
(optional) inode number and generation, and a flags argument.  This will
be used by the upcoming XFS online scrub tool.

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

Source kernel commit: 91fb9afc0847926ef6ea7695b8125c8fbe7974d6

Create some helper functions to check that inode pointers point to
somewhere within the filesystem and not at the static AG metadata.
Move xfs_internal_inum and create a directory inode check function.
We will use these functions in scrub and elsewhere.

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

Source kernel commit: 52c732eee78b47ac2eb828b1c7fa611cd37b0090

Refactor the btree block header checks to have an internal function that
returns the address of the failing check without logging errors.  The
scrubber will call the internal function, while the external version
will maintain the current logging behavior.

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

Source kernel commit: f135761a73b18877bdfb44018fe993172c7be203

Refactor the btree pointer checks so that we can call them from the
scrub code without logging errors to dmesg.  Preserve the existing error
reporting for regular operations.

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

Source kernel commit: 21ec54168b368f1a98097dee00625ec8ec2d47f3

Create some helper functions to check that a block pointer points
within the filesystem (or AG) and doesn't point at static metadata.
We will use this for scrub.

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

Source kernel commit: f0387501652ed39f3bebc72e8a6b5abb405eb2b7

Unused after the big bmap refactor.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: remove all xfs_bmbt_set_* helpers except for xfs_bmbt_set_all
Christoph Hellwig [Fri, 17 Nov 2017 04:11:31 +0000 (22:11 -0600)] 
xfs: remove all xfs_bmbt_set_* helpers except for xfs_bmbt_set_all

Source kernel commit: 9b150709b3190719e5edf5f0ea35245cb8ae0a1a

Unused after the big bmap refactor.

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

Source kernel commit: b5cfbc2282bcd0dba460d4d4ec07fcfac9981de6

We only use xfs_bmbt_lookup_ge to look up the first bmap record in an
inode, so replace xfs_bmbt_lookup_ge with a special purpose helper that
is a bit more descriptive.

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

Source kernel commit: e16cf9b03cee4d2797695d4ca691e854c7a24864

Now that we've massaged the callers into the right form we can always
pass the actual extent record instead of the individual fields.

As an additional benefit the btree cursor will now be prepoulated with
the correct extent state instead of having to fix it up later.

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

Source kernel commit: a67d00a55507dc324037f182563e10339945721a

Now that we've massaged the callers into the right form we can always
pass the actual extent record instead of the individual fields.

With that xfs_bmbt_disk_set_allf can go away, and xfs_bmbt_disk_set_all
can be merged into the former implementation of xfs_bmbt_disk_set_allf.

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

Source kernel commit: 79fa6143a939a6b50d1d9dc736336e57d06b849d

Use xfs_iext_get_extent to find, and xfs_iext_update_extent to update
entries in the in-core extent list.  This isolates the function from
the detailed layout of the extent list, and generally makes the code
a lot more readable.

Also get rid of the oldext and newext variables as using the extent
records is a lot more descriptive.

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

Source kernel commit: ca1862b0838604aa048120d87ebbf53cf7c8c8bd

Account for all changes to the delalloc reservation in da_new, and use a
single call xfs_mod_fdblocks to reserve/free blocks, including always
checking for an error.

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

Source kernel commit: 4dcb8869871cc102b9431ae78b40bfc39087b90c

Use xfs_iext_get_extent to find, and xfs_iext_update_extent to update
entries in the in-core extent list.  This isolates the function from
the detailed layout of the extent list, and generally makes the code
a lot more readable.

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

Source kernel commit: 1abb9e55326c19bb41a9a2fd1179ed635e8af38c

Use xfs_iext_update_extent to update entries in the in-core extent list.
This isolates the function from the detailed layout of the extent list,
and generally makes the code a lot more readable.

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

Source kernel commit: 3ffc18ecd30ed21dc503fcbfb343c471a9112fb6

Use xfs_iext_get_extent to find, and xfs_iext_update_extent to update
entries in the in-core extent list.  This isolates the function from
the detailed layout of the extent list, and generally makes the code
a lot more readable.

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

Source kernel commit: 48fd52b16d74b937f44f87f942ddaff5e3e3db64

Use xfs_iext_update_extent to update entries in the in-core extent list.
This isolates the function from the detailed layout of the extent list,
and generally makes the code a lot more readable.

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

Source kernel commit: 491f6f8abfa7a91d23b969be67ed476817bcefd7

Use the same defines as the other extent add and delete helpers, which
both improves code readability and trace point output.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: use correct state defines in xfs_bmap_del_extent_{cow,delay}
Christoph Hellwig [Fri, 17 Nov 2017 04:11:30 +0000 (22:11 -0600)] 
xfs: use correct state defines in xfs_bmap_del_extent_{cow,delay}

Source kernel commit: 0173c689ff4c0855e24ceb898274af1339b5db48

Use the _FILLING values to match the usage in the xfs_bmap_add_extent_*
helpers.  No change in behavior, just better naming in the code and
tracepoint output.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reported-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs: move some more code into xfs_bmap_del_extent_real
Christoph Hellwig [Fri, 17 Nov 2017 04:11:30 +0000 (22:11 -0600)] 
xfs: move some more code into xfs_bmap_del_extent_real

Source kernel commit: 1b24b633aafe4729c468f4144246709cdbda0f35

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>