]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/log
thirdparty/xfsprogs-dev.git
6 years agoxfs_io: add a new 'log_writes' command
Ross Zwisler [Thu, 4 Jan 2018 19:58:29 +0000 (13:58 -0600)] 
xfs_io: add a new 'log_writes' command

Add a new 'log_writes' command to xfs_io so that we can add dm-log-writes
log marks.  It's helpful to allow users of xfs_io to adds these marks from
within xfs_io instead of waiting until after xfs_io exits because then they
are able to replay the dm-log-writes log up to immediately after another
xfs_io operation such as mwrite.  This isolates the log replay from other
operations that happen as part of xfs_io exiting (file handles being
closed, mmaps being torn down, etc.).  This also allows users to insert
multiple marks between different xfs_io commands.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Suggested-by: Dave Chinner <david@fromorbit.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoxfs_io: add MAP_SYNC support to mmap()
Ross Zwisler [Thu, 4 Jan 2018 19:58:29 +0000 (13:58 -0600)] 
xfs_io: add MAP_SYNC support to mmap()

Add support for a new -S flag to xfs_io's mmap command.  This opens the
mapping with the (MAP_SYNC | MAP_SHARED_VALIDATE) flags instead of the
standard MAP_SHARED flag.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Suggested-by: Dave Chinner <david@fromorbit.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: do not allow both "dev" and "name" subopts for log or realtime
Eric Sandeen [Thu, 4 Jan 2018 19:58:10 +0000 (13:58 -0600)] 
mkfs: do not allow both "dev" and "name" subopts for log or realtime

Todauy this works, with last-parsed-wins semantics:

mkfs.xfs -f -l logdev=/dev/sda1,name=/dev/sda2 /dev/sda3

Disallow it to avoid ambiguity.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: pass switch case value directly into getnum/getstr
Eric Sandeen [Thu, 4 Jan 2018 19:56:50 +0000 (13:56 -0600)] 
mkfs: pass switch case value directly into getnum/getstr

Parsing did this sort of thing:

case D_AGCOUNT:
cli->agcount = getnum(value, opts, D_AGCOUNT);

which was just begging for a cut and paste error between the
case value and the enum passed into getnum/getstr.  Pass
"subopt" instead so that it is always consistent with the case.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: un-document removed logarithm based CLI options
Eric Sandeen [Thu, 4 Jan 2018 19:56:29 +0000 (13:56 -0600)] 
mkfs: un-document removed logarithm based CLI options

Remove logarithm-based options from usage() and manpage.

Fixes: 70f72d5 "mkfs: remove logarithm based CLI options"
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: remove logarithm based CLI options
Dave Chinner [Wed, 3 Jan 2018 20:10:10 +0000 (14:10 -0600)] 
mkfs: remove logarithm based CLI options

Very few people use the log2 based size options for various mkfs
parameters and they just clutter up the code. Get rid of them.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: resolve sector size CLI conflicts
Dave Chinner [Wed, 3 Jan 2018 20:10:10 +0000 (14:10 -0600)] 
mkfs: resolve sector size CLI conflicts

Now we have a two dimensional conflict array, convert the sector
size CLI option conflict determination to use it. To get the error
specification just right, we also need to tweak how we store
and validate the sector size CLI parameter state in the options
table.

Old:

$ mkfs.xfs -N -s size=4k -d sectsize=512 /dev/pmem0
Cannot specify both -d sectsize and -d sectlog
.....

New:

$ mkfs.xfs -N -s size=4k -d sectsize=512 /dev/pmem0
Cannot specify both -s size and -d sectsize
.....

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@sandeen.net>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: convert subopt name, val pairs to enums and declared arrays
Dave Chinner [Wed, 3 Jan 2018 20:10:10 +0000 (14:10 -0600)] 
mkfs: convert subopt name, val pairs to enums and declared arrays

Replace the nasty #define + implicit array index definitions with
pre-declared enums and index specific name array declarations.

This cleans up the code quite a bit and the pre-declaration of the
enums allows tables to use indexes from other tables in things like
conflict specifications.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: support arbitrary conflict specification
Dave Chinner [Wed, 3 Jan 2018 20:10:10 +0000 (14:10 -0600)] 
mkfs: support arbitrary conflict specification

Currently the conflict table is a single dimension, allowing
conflicts to be specified in the same option table. however, we
have conflicts that span option tables (e.g. sector size) and
so we need to encode both the table and the option that conflicts.

Add support for a two dimensional conflict definition and convert
all the code over to use it.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@sandeen.net>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: protofile only needs to be set up once
Dave Chinner [Wed, 3 Jan 2018 20:10:10 +0000 (14:10 -0600)] 
mkfs: protofile only needs to be set up once

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: simplify minimum log size calculation
Dave Chinner [Wed, 3 Jan 2018 20:10:10 +0000 (14:10 -0600)] 
mkfs: simplify minimum log size calculation

mkfs jumps through hoops to call libxfs_log_calc_minimum_size() to
set the minimum log size. We already have a xfs_mount at this point,
we just need to set the superblock up slightly earlier and then mkfs
can call libxfs_log_calc_minimum_size() directly. This means we can
remove mkfs/maxtrres.c completely.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: use opts parameter during option parsing
Dave Chinner [Wed, 3 Jan 2018 20:10:10 +0000 (14:10 -0600)] 
mkfs: use opts parameter during option parsing

Rather than hard coding the global table variable into the
parsing functions.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: remove use-once default macros
Eric Sandeen [Wed, 3 Jan 2018 20:10:10 +0000 (14:10 -0600)] 
mkfs: remove use-once default macros

sb_feat was a weird mishmash of hardcoded defaults and macros
(which were used in only this place).

Make it consistent by removing the use-once macros, and remove
the unused XFS_DFL_LOG_SIZE while we're in here.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: document sb_feat_args members
Eric Sandeen [Wed, 3 Jan 2018 20:10:10 +0000 (14:10 -0600)] 
mkfs: document sb_feat_args members

Some of these are more self-explanatory than others ("nci?").
Just mention the bit each one controls, and put them in order
while we're at it.  There are more comments about each bit
near its definition.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: invert project id width boolean name
Eric Sandeen [Wed, 3 Jan 2018 20:10:10 +0000 (14:10 -0600)] 
mkfs: invert project id width boolean name

It's a bit nuts that we have a projid32bit mkfs option, but
we carry around the inverse of its value in "projid16bit" -
just flip it around for sanity.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: remove unused m_uuid in sb_feat_args
Eric Sandeen [Wed, 3 Jan 2018 20:10:09 +0000 (14:10 -0600)] 
mkfs: remove unused m_uuid in sb_feat_args

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: Don't emit default config message yet
Eric Sandeen [Wed, 3 Jan 2018 20:10:09 +0000 (14:10 -0600)] 
mkfs: Don't emit default config message yet

Until we have more than one possible source of configuration,
there is no need to emit the only possibility and clutter
the output.  We can decide how it should all look when we
get more than one source.

Apply some i18n to the config description, though.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agoMerge branch 'libxfs-4.15-sync' into for-next
Eric Sandeen [Wed, 3 Jan 2018 20:09:36 +0000 (14:09 -0600)] 
Merge branch 'libxfs-4.15-sync' into for-next

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 agolibxfs: libxfs_nproc should never return negative numbers
Darrick J. Wong [Thu, 7 Dec 2017 03:24:49 +0000 (21:24 -0600)] 
libxfs: libxfs_nproc should never return negative numbers

Prevent libxfs_nproc from returning a negative/zero CPU count if
platform_nproc happens to error out.

Fixes-coverity-id: 1425909
Fixes-coverity-id: 1425910
Fixes-coverity-id: 1425913
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 agomkfs: tidy up definitions
Dave Chinner [Wed, 6 Dec 2017 23:28:03 +0000 (17:28 -0600)] 
mkfs: tidy up definitions

Put all the internal macro definitions at the top of the file so
they can be easily found and remove teh ones that aren't used
anymore.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: move error functions
Dave Chinner [Wed, 6 Dec 2017 23:28:02 +0000 (17:28 -0600)] 
mkfs: move error functions

Move all the error and helper functions like conflict() to the top
of the file so we can get rid of the forward declarations.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: cleanup redundant temporary code
Dave Chinner [Wed, 6 Dec 2017 23:28:02 +0000 (17:28 -0600)] 
mkfs: cleanup redundant temporary code

Now the factoring is complete, we can remove the remaining temporary
code that was used to isolate the factoring from the rest of the
code.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: factor log size calculations
Dave Chinner [Wed, 6 Dec 2017 23:28:02 +0000 (17:28 -0600)] 
mkfs: factor log size calculations

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
6 years agomkfs: factor initial mount setup
Dave Chinner [Wed, 6 Dec 2017 23:27:50 +0000 (17:27 -0600)] 
mkfs: factor initial mount setup

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

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

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

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

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

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

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

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

The data and log stripe calculations a spaghettied all over the mkfs
code. This patch pulls all of the different chunks of code together
into calc_stripe_factors() and removes all the redundant/repeated
checks and calculations that are made.

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

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

Hiding references to variables inside macros instead of passing them
as parameters is just plain nasty. Fix it before going any further.

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

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

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

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

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

This also adds a check that disallows changing the sector size on
internal logs.

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

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

Start factoring all the sector size validation code into a
function that takes cli, dft and cfg structures. This starts
removing option flags and some of the temporary code in the input
parsing structures.

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

Names like "qflag" and "Nflag" don't tell us what the flag is
supposed to do, so rename them to be obvious in function.

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

mkfs has lots of options that require default values. Some of these
are centralised, but others aren't. Introduce a new structure
designed to hold default values for all the parameters that need
defaults in one place.

This structure also provides a mechanism for providing mkfs defaults
from a config file. This is not implemented in this series, but a
comment is left where it is expected this functionality will hook
in.

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

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

There are some slight changes to the way log alignment is calculated
in the change. Instead of using a flag, it checks the log start
block to see if it's different to the first free block in the log
AG, and if it is different then does the aligned setup. This means
we no longer have to care if the log is aligned or not, the code
will do the right thing in all cases.

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

Prior to formating the device(s), we have to take several steps to
prepare them and check that they are appropriate for the formatting
that is about to take place. Pull all this into a single function
that is run before mounting the libxfs infrastructure.

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

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

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

Formatting the on disk XFS structures requires a certain set of
validated and calculated parameters. By the time we start writing
information to disk this has all been done. Abstract this information
out into a separate structures and initialise it with all the
calculated parameters so we can factor the mkfs formatting code
to use it.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Move the filesystem topology code out of libxcmd.

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

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

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

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

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

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

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

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

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

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

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

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

Ribbit!  Ribbit!

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

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

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

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

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

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

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

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

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

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

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

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

New compiler, new checks, new warnings.

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

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

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

Source kernel commit: 274e0a1f4777b9362fc03a34e86358cc36003e48

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

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

Source kernel commit: 6818caa4cdc95d9ec5642a4439f8271a80189b48

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

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

Source kernel commit: 2015a63dce8d73a439232a0d5162c88d8513101e

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

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

Update all the necessary files for a 4.14.0 release.

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

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

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

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

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

The field name is f_flags.

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

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

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

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>