]> www.infradead.org Git - users/hch/xfsprogs.git/log
users/hch/xfsprogs.git
5 years agoxfs: remove XFS_BUF_TO_SBP
Christoph Hellwig [Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)]
xfs: remove XFS_BUF_TO_SBP

Source kernel commit: 3e6e8afd3abb745871ee215738a899a495c54a66

Just dereference bp->b_addr directly and make the code a little
simpler and more clear.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-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>
5 years agoxfs: remove XFS_BUF_TO_AGF
Christoph Hellwig [Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)]
xfs: remove XFS_BUF_TO_AGF

Source kernel commit: 9798f615ad2be48466a01c44ad2257ba64ab03bd

Just dereference bp->b_addr directly and make the code a little
simpler and more clear.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Sandeen <sandeen@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>
5 years agoxfs: remove XFS_BUF_TO_AGI
Christoph Hellwig [Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)]
xfs: remove XFS_BUF_TO_AGI

Source kernel commit: 370c782b98436bb3f9d14a7394ab126cdbeac233

Just dereference bp->b_addr directly and make the code a little
simpler and more clear.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Sandeen <sandeen@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>
5 years agoxfs: remove the xfs_agfl_t typedef
Christoph Hellwig [Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)]
xfs: remove the xfs_agfl_t typedef

Source kernel commit: 4b97510859b22e0db5edf104096af1132daeea9a

There is just a single user left, so remove it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Sandeen <sandeen@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>
5 years agoxfs: remove the agfl_bno member from struct xfs_agfl
Christoph Hellwig [Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)]
xfs: remove the agfl_bno member from struct xfs_agfl

Source kernel commit: 183606d82446110e23987d4b693f3d3fc300bd82

struct xfs_agfl is a header in front of the AGFL entries that exists
for CRC enabled file systems.  For not CRC enabled file systems the AGFL
is simply a list of agbno.  Make the CRC case similar to that by just
using the list behind the new header.  This indirectly solves a problem
with modern gcc versions that warn about taking addresses of packed
structures (and we have to pack the AGFL given that gcc rounds up
structure sizes).  Also replace the helper macro to get from a buffer
with an inline function in xfs_alloc.h to make the code easier to
read.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Sandeen <sandeen@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>
5 years agoxfs: embedded the attrlist cursor into struct xfs_attr_list_context
Christoph Hellwig [Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)]
xfs: embedded the attrlist cursor into struct xfs_attr_list_context

Source kernel commit: e3a19cdea84a42d44ef42ff8b5459c903992bbf2

The attrlist cursor only exists as part of an attr list context, so
embedd the structure instead of pointing to it.  Also give it a proper
xfs_ prefix and remove the obsolete typedef.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove XFS_DA_OP_INCOMPLETE
Christoph Hellwig [Fri, 1 May 2020 21:37:08 +0000 (17:37 -0400)]
xfs: remove XFS_DA_OP_INCOMPLETE

Source kernel commit: 254f800f810415cce05872c88e9ef797d81f4375

Now that we use the on-disk flags field also for the interface to the
lower level attr routines we can use the XFS_ATTR_INCOMPLETE definition
from the on-disk format directly instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: clean up the attr flag confusion
Christoph Hellwig [Fri, 1 May 2020 21:37:04 +0000 (17:37 -0400)]
xfs: clean up the attr flag confusion

Source kernel commit: d5f0f49a9bdd4206e941282dfd323c436331659b

The ATTR_* flags have a long IRIX history, where they a userspace
interface, the on-disk format and an internal interface.  We've split
out the on-disk interface to the XFS_ATTR_* values, but despite (or
because?) of that the flag have still been a mess.  Switch the
internal interface to pass the on-disk XFS_ATTR_* flags for the
namespace and the Linux XATTR_* flags for the actual flags instead.
The ATTR_* values that are actually used are move to xfs_fs.h with a
new XFS_IOC_* prefix to not conflict with the userspace version that
has the same name and must have the same value.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: clean up the ATTR_REPLACE checks
Christoph Hellwig [Fri, 1 May 2020 21:01:33 +0000 (17:01 -0400)]
xfs: clean up the ATTR_REPLACE checks

Source kernel commit: f3e93d95feef7655a980be83a3b1830e8e1711a1

Remove superflous braces, elses after return statements and use a goto
label to merge common error handling.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: rename xfs_attr_list_int to xfs_attr_list
Christoph Hellwig [Fri, 1 May 2020 21:01:33 +0000 (17:01 -0400)]
xfs: rename xfs_attr_list_int to xfs_attr_list

Source kernel commit: 17e1dd83ea21dc7aaf44590e5947338351b99bd0

The version taking the context structure is the main interface to list
attributes, so drop the _int postfix.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: move the legacy xfs_attr_list to xfs_ioctl.c
Christoph Hellwig [Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)]
xfs: move the legacy xfs_attr_list to xfs_ioctl.c

Source kernel commit: 3e7a779937a225336922ce48fe7a4a609c7db3e2

The old xfs_attr_list code is only used by the attrlist by handle
ioctl.  Move it to xfs_ioctl.c with its user.  Also move the
attrlist and attrlist_ent structure to xfs_fs.h, as they are exposed
user ABIs.  They are used through libattr headers with the same name
by at least xfsdump.  Also document this relation so that it doesn't
require a research project to figure out.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove the unused ATTR_ENTRY macro
Christoph Hellwig [Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)]
xfs: remove the unused ATTR_ENTRY macro

Source kernel commit: fe960087121a9fccaead3de44c64fcf356f3410d

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: cleanup struct xfs_attr_list_context
Christoph Hellwig [Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)]
xfs: cleanup struct xfs_attr_list_context

Source kernel commit: a9c8c69b496117912162cdc38dcae953a07b87f7

Replace the alist char pointer with a void buffer given that different
callers use it in different ways.  Use the chance to remove the typedef
and reduce the indentation of the struct definition so that it doesn't
overflow 80 char lines all over.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: factor out a xfs_attr_match helper
Christoph Hellwig [Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)]
xfs: factor out a xfs_attr_match helper

Source kernel commit: 377f16ac67237c8cda05daf363bcbea95212b000

Factor out a helper that compares an on-disk attr vs the name, length and
flags specified in struct xfs_da_args.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: replace ATTR_KERNOTIME with XFS_DA_OP_NOTIME
Christoph Hellwig [Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)]
xfs: replace ATTR_KERNOTIME with XFS_DA_OP_NOTIME

Source kernel commit: 1d7330199400404512b44734d3c792aa4ad82322

op_flags with the XFS_DA_OP_* flags is the usual place for in-kernel
only flags, so move the notime flag there.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove ATTR_ALLOC and XFS_DA_OP_ALLOCVAL
Christoph Hellwig [Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)]
xfs: remove ATTR_ALLOC and XFS_DA_OP_ALLOCVAL

Source kernel commit: d49db18b247d8e7e16f2178cd713f4621d1d7ade

Use a NULL args->value as the indicator to lazily allocate a buffer
instead, and let the caller always free args->value instead of
duplicating the cleanup.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove ATTR_KERNOVAL
Christoph Hellwig [Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)]
xfs: remove ATTR_KERNOVAL

Source kernel commit: e513e25c380ab98d401714077c8b8ff4dae9f98b

We can just pass down the Linux convention of a zero valuelen to just
query for the existance of an attribute to the low-level code instead.
The use in the legacy xfs_attr_list code only used by the ioctl
interface was already dead code, as the callers check that the flag
is not present.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove the xfs_inode argument to xfs_attr_get_ilocked
Christoph Hellwig [Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)]
xfs: remove the xfs_inode argument to xfs_attr_get_ilocked

Source kernel commit: c36f533f14075fee35f8beeb1729d0975fb2e137

The inode can easily be derived from the args structure.  Also
don't bother with else statements after early returns.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: pass an initialized xfs_da_args to xfs_attr_get
Christoph Hellwig [Fri, 1 May 2020 21:01:32 +0000 (17:01 -0400)]
xfs: pass an initialized xfs_da_args to xfs_attr_get

Source kernel commit: e5171d7e989479fe6298f8aedbd94e0aec23f5fc

Instead of converting from one style of arguments to another in
xfs_attr_set, pass the structure from higher up in the call chain.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: pass an initialized xfs_da_args structure to xfs_attr_set
Christoph Hellwig [Fri, 1 May 2020 21:01:30 +0000 (17:01 -0400)]
xfs: pass an initialized xfs_da_args structure to xfs_attr_set

Source kernel commit: a25446224353a773c7f4ba9ee5ae137515204efe

Instead of converting from one style of arguments to another in
xfs_attr_set, pass the structure from higher up in the call chain.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: turn xfs_da_args.value into a void pointer
Christoph Hellwig [Wed, 29 Apr 2020 20:08:34 +0000 (16:08 -0400)]
xfs: turn xfs_da_args.value into a void pointer

Source kernel commit: ead189adb8abebc1555bf2776954131ba00c7619

The xattr values are blobs and should not be typed.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove the MAXNAMELEN check from xfs_attr_args_init
Christoph Hellwig [Wed, 29 Apr 2020 20:08:34 +0000 (16:08 -0400)]
xfs: remove the MAXNAMELEN check from xfs_attr_args_init

Source kernel commit: 4df28c64e4388ac5fa59cd58f9fd6592aae533a2

All the callers already check the length when allocating the
in-kernel xattrs buffers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove the name == NULL check from xfs_attr_args_init
Christoph Hellwig [Wed, 29 Apr 2020 20:08:34 +0000 (16:08 -0400)]
xfs: remove the name == NULL check from xfs_attr_args_init

Source kernel commit: 79f2280b9bfd54aa37b3fa4a80b0037bd29b4f0e

All callers provide a valid name pointer, remove the redundant check.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: merge xfs_attr_remove into xfs_attr_set
Christoph Hellwig [Wed, 29 Apr 2020 20:08:34 +0000 (16:08 -0400)]
xfs: merge xfs_attr_remove into xfs_attr_set

Source kernel commit: 0eb81a5f5c34429f0d86329260b3b07e2d4c5e22

The Linux xattr and acl APIs use a single call for set and remove.
Modify the high-level XFS API to match that and let xfs_attr_set handle
removing attributes as well.  With a little bit of reordering this
removes a lot of code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove the ATTR_INCOMPLETE flag
Christoph Hellwig [Wed, 29 Apr 2020 20:08:34 +0000 (16:08 -0400)]
xfs: remove the ATTR_INCOMPLETE flag

Source kernel commit: 5e81357435cc0ef6b2ba4a9dcfca52be4e471cf5

Replace the ATTR_INCOMPLETE flag with a new boolean field in struct
xfs_attr_list_context.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: open code insert range extent split helper
Brian Foster [Wed, 29 Apr 2020 20:08:34 +0000 (16:08 -0400)]
xfs: open code insert range extent split helper

Source kernel commit: b73df17e4c5ba977205253fb7ef54267717a3cba

The insert range operation currently splits the extent at the target
offset in a separate transaction and lock cycle from the one that
shifts extents. In preparation for reworking insert range into an
atomic operation, lift the code into the caller so it can be easily
condensed to a single rolling transaction and lock cycle and
eliminate the helper. No functional changes.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: fix an undefined behaviour in _da3_path_shift
Qian Cai [Wed, 29 Apr 2020 20:08:34 +0000 (16:08 -0400)]
xfs: fix an undefined behaviour in _da3_path_shift

Source kernel commit: 4982bff1ace1196843f55536fcd4cc119738fe39

In xfs_da3_path_shift() "blk" can be assigned to state->path.blk[-1] if
state->path.active is 1 (which is a valid state) when it tries to add an
entry to a single dir leaf block and then to shift forward to see if
there's a sibling block that would be a better place to put the new
entry. This causes a UBSAN warning given negative array indices are
undefined behavior in C. In practice the warning is entirely harmless
given that "blk" is never dereferenced in this case, but it is still
better to fix up the warning and slightly improve the code.

UBSAN: Undefined behaviour in fs/xfs/libxfs/xfs_da_btree.c:1989:14
index -1 is out of range for type 'xfs_da_state_blk_t [5]'
Call trace:
dump_backtrace+0x0/0x2c8
show_stack+0x20/0x2c
dump_stack+0xe8/0x150
__ubsan_handle_out_of_bounds+0xe4/0xfc
xfs_da3_path_shift+0x860/0x86c [xfs]
xfs_da3_node_lookup_int+0x7c8/0x934 [xfs]
xfs_dir2_node_addname+0x2c8/0xcd0 [xfs]
xfs_dir_createname+0x348/0x38c [xfs]
xfs_create+0x6b0/0x8b4 [xfs]
xfs_generic_create+0x12c/0x1f8 [xfs]
xfs_vn_mknod+0x3c/0x4c [xfs]
xfs_vn_create+0x34/0x44 [xfs]
do_last+0xd4c/0x10c8
path_openat+0xbc/0x2f4
do_filp_open+0x74/0xf4
do_sys_openat2+0x98/0x180
__arm64_sys_openat+0xf8/0x170
do_el0_svc+0x170/0x240
el0_sync_handler+0x150/0x250
el0_sync+0x164/0x180

Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Qian Cai <cai@lca.pw>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove the kuid/kgid conversion wrappers
Christoph Hellwig [Wed, 29 Apr 2020 20:08:34 +0000 (16:08 -0400)]
xfs: remove the kuid/kgid conversion wrappers

Source kernel commit: ba8adad5d036733d240fa8a8f4d055f3d4490562

Remove the XFS wrappers for converting from and to the kuid/kgid types.
Mostly this means switching to VFS i_{u,g}id_{read,write} helpers, but
in a few spots the calls to the conversion functions is open coded.
To match the use of sb->s_user_ns in the helpers and other file systems,
sb->s_user_ns is also used in the quota code.  The ACL code already does
the conversion in a grotty layering violation in the VFS xattr code,
so it keeps using init_user_ns for the identity mapping.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove the icdinode di_uid/di_gid members
Christoph Hellwig [Wed, 29 Apr 2020 20:08:30 +0000 (16:08 -0400)]
xfs: remove the icdinode di_uid/di_gid members

Source kernel commit: 542951592c99ff7b15c050954c051dd6dd6c0f97

Use the Linux inode i_uid/i_gid members everywhere and just convert
from/to the scalar value when reading or writing the on-disk inode.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: ensure that the inode uid/gid match values match the icdinode ones
Christoph Hellwig [Wed, 29 Apr 2020 18:10:49 +0000 (14:10 -0400)]
xfs: ensure that the inode uid/gid match values match the icdinode ones

Source kernel commit: 3d8f2821502d0b60bac2789d0bea951fda61de0c

Instead of only synchronizing the uid/gid values in xfs_setup_inode,
ensure that they always match to prepare for removing the icdinode
fields.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: add agf freeblocks verify in xfs_agf_verify
Zheng Bin [Wed, 29 Apr 2020 18:10:49 +0000 (14:10 -0400)]
xfs: add agf freeblocks verify in xfs_agf_verify

Source kernel commit: d0c7feaf87678371c2c09b3709400be416b2dc62

We recently used fuzz(hydra) to test XFS and automatically generate
tmp.img(XFS v5 format, but some metadata is wrong)

xfs_repair information(just one AG):
agf_freeblks 0, counted 3224 in ag 0
agf_longest 536874136, counted 3224 in ag 0
sb_fdblocks 613, counted 3228

Test as follows:
mount tmp.img tmpdir
cp file1M tmpdir
sync

In 4.19-stable, sync will stuck, the reason is:
xfs_mountfs
xfs_check_summary_counts
if ((!xfs_sb_version_haslazysbcount(&mp->m_sb) ||
XFS_LAST_UNMOUNT_WAS_CLEAN(mp)) &&
!xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS))
return 0;  -->just return, incore sb_fdblocks still be 613
xfs_initialize_perag_data

cp file1M tmpdir -->ok(write file to pagecache)
sync -->stuck(write pagecache to disk)
xfs_map_blocks
xfs_iomap_write_allocate
while (count_fsb != 0) {
nimaps = 0;
while (nimaps == 0) { --> endless loop
nimaps = 1;
xfs_bmapi_write(..., &nimaps) --> nimaps becomes 0 again
xfs_bmapi_write
xfs_bmap_alloc
xfs_bmap_btalloc
xfs_alloc_vextent
xfs_alloc_fix_freelist
xfs_alloc_space_available -->fail(agf_freeblks is 0)

In linux-next, sync not stuck, cause commit c2b3164320b5 ("xfs:
use the latest extent at writeback delalloc conversion time") remove
the above while, dmesg is as follows:
[   55.250114] XFS (loop0): page discard on page ffffea0008bc7380, inode 0x1b0c, offset 0.

Users do not know why this page is discard, the better soultion is:
1. Like xfs_repair, make sure sb_fdblocks is equal to counted
(xfs_initialize_perag_data did this, who is not called at this mount)
2. Add agf verify, if fail, will tell users to repair

This patch use the second soultion.

Signed-off-by: Zheng Bin <zhengbin13@huawei.com>
Signed-off-by: Ren Xudong <renxudong1@huawei.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: Release v5.6.0 master v5.6.0
Eric Sandeen [Tue, 14 Apr 2020 19:29:59 +0000 (15:29 -0400)]
xfsprogs: Release v5.6.0

Update all the necessary files for a 5.6.0 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_scrub: don't set WorkingDirectory= in systemd job
Darrick J. Wong [Tue, 14 Apr 2020 16:56:20 +0000 (12:56 -0400)]
xfs_scrub: don't set WorkingDirectory= in systemd job

Somewhere between systemd 237 and 245, they changed the order in which a
job has its uid/gid set; capabilities applied; and working directory
set.  Whereas before they did it in an order such that you could set the
working directory to a path inaccessible to 'nobody' (either because
they did it before changing the uid or after adding capabilities), now
they don't and users instead get a service failure:

xfs_scrub@-boot.service: Changing to the requested working directory failed: Permission denied
xfs_scrub@-boot.service: Failed at step CHDIR spawning /usr/sbin/xfs_scrub: Permission denied
xfs_scrub@-boot.service: Main process exited, code=exited, status=200/CHDIR

Regardless, xfs_scrub works just fine with PWD set to /, so remove that
directive.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: Release v5.6.0-rc1 v5.6.0-rc1
Eric Sandeen [Wed, 8 Apr 2020 13:48:54 +0000 (09:48 -0400)]
xfsprogs: Release v5.6.0-rc1

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

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: remove libxfs_iomove
Christoph Hellwig [Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)]
libxfs: remove libxfs_iomove

This function has been removed in the kernel already.  Replace the only
user that want to zero buffers with a straight call to memset.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove XFS_BUF_SET_BDSTRAT_FUNC
Christoph Hellwig [Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)]
xfs: remove XFS_BUF_SET_BDSTRAT_FUNC

This function doesn't exist in the kernel and is purely a stub in
xfsprogs, so remove it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: turn the xfs_buf_incore stub into an inline function
Christoph Hellwig [Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)]
libxfs: turn the xfs_buf_incore stub into an inline function

Replace the macro with an inline function to avoid compiler warnings with new
backports of kernel code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_scrub: fix type error in render_ino_from_handle
Darrick J. Wong [Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)]
xfs_scrub: fix type error in render_ino_from_handle

render_ino_from_handle is passed a struct xfs_bulkstat, not xfs_bstat.
Fix this.

Fixes: 4cca629d6ae3807 ("misc: convert xfrog_bulkstat functions to have v5 semantics")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_repair: fix dir_read_buf use of libxfs_da_read_buf
Darrick J. Wong [Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)]
xfs_repair: fix dir_read_buf use of libxfs_da_read_buf

xfs_da_read_buf dropped the 'mappedbno' argument in favor of a flags
argument.  Foolishly, we're passing that parameter (which is -1 in all
callers) to xfs_da_read_buf, which gets us the wrong behavior.

Since mappedbno == -1 meant "complain if we fall into a hole" (which is
the default behavior of xfs_da_read_buf) we can fix this by passing a
zero flags argument and getting rid of mappedbno entirely.

Coverity-id: 1457898
Fixes: 5f356ae6d ("xfs: remove the mappedbno argument to xfs_da_read_buf")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_db: clean up the salvage read callsites in set_cur()
Darrick J. Wong [Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)]
xfs_db: clean up the salvage read callsites in set_cur()

Clean up the LIBXFS_READBUF_SALVAGE call sites in set_cur so that we
use the return value directly instead of scraping it out later.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: check return value of device flush when closing device
Darrick J. Wong [Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)]
libxfs: check return value of device flush when closing device

Although the libxfs_umount function flushes all devices when unmounting
the incore filesystem, the libxfs io code will flush the device again
when the application close them.  Check and report any errors that might
happen, though this is unlikely.

Coverity-id: 1460464
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: don't barf in libxfs_bwrite on a null buffer ops name
Darrick J. Wong [Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)]
libxfs: don't barf in libxfs_bwrite on a null buffer ops name

Don't crash if we failed to write a buffer that had no buffer verifier.
This should be rare in practice, but coverity found a valid bug.

Coverity-id: 1460462
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_io: set exitcode on failure appropriately
Dave Chinner [Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)]
xfs_io: set exitcode on failure appropriately

Many operations don't set the exitcode when they fail, resulting
in xfs_io exiting with a zero (no failure) exit code despite the
command failing and returning an error. The command return code is
really a boolean to tell the libxcmd command loop whether to
continue processing or not, while exitcode is the actual xfs_io exit
code returned to the parent on exit.

This patchset just makes the code do the right thing. It's not the
nicest code, but it's a start at producing correct behaviour.

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>
5 years agoxfsprogs: fix silently broken option parsing
Dave Chinner [Wed, 8 Apr 2020 13:48:04 +0000 (09:48 -0400)]
xfsprogs: fix silently broken option parsing

When getopt() is passed an option string like "-m -n" and the
parameter m is defined as "m:", getopt returns a special error
to indication that the optstring started with a "-". Any getopt()
caller that is just catching the "?" error character will not
not catch this special error, so it silently eats the parameter
following -m.

Lots of getopt loops in xfsprogs have this issue. Convert them all
to just use a "default:" to catch anything unexpected.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: LDFLAGS comes from configure, not environment
Dave Chinner [Tue, 7 Apr 2020 18:29:39 +0000 (14:29 -0400)]
xfsprogs: LDFLAGS comes from configure, not environment

When doing:

$ LDFLAGS=foo make

bad things happen because we don't initialise LDFLAGS to an empty
string in include/builddefs.in and hence make takes wahtever is in
the environment and runs with it. This causes problems with linker
options specified correctly through configure.

We don't support overriding build flags (like CFLAGS) though the
make environment, so it was an oversight 13 years ago to allow
LDFLAGS to be overridden when adding support to custom LDFLAGS being
passed from the the configure script. This ensures we only ever use
linker flags from configure, not the make environment.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: Fix --disable-static option build
Dave Chinner [Tue, 7 Apr 2020 18:29:39 +0000 (14:29 -0400)]
xfsprogs: Fix --disable-static option build

Internal xfsprogs libraries are linked statically to binaries as
they are not shipped libraries. Using --disable-static prevents the
internal static libraries from being built and this breaks dead code
elimination and results in linker failures from link dependencies
introduced by dead code.

We can't remove the --disable-static option that causes this as it
is part of the libtool/autoconf generated infrastructure. We can,
however, override --disable-static on a per-library basis inside the
build by passing -static to the libtool link command. Therefore, add
-static to all the internal libraries we build and link statically
to the shipping binaries.

This build command now succeeds:

$ make realclean; make configure; ./configure --disable-static ; make

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agomkfs: use cvtnum from libfrog
Dave Chinner [Tue, 7 Apr 2020 18:29:39 +0000 (14:29 -0400)]
mkfs: use cvtnum from libfrog

Move the checks for zero block/sector size to the libfrog code
and return -1LL as an invalid value instead. Catch the invalid
value in mkfs and error out there instead of inside cvtnum.

Also rename the libfrog block/sector size variables so they don't
shadow the mkfs global variables of the same name and mark the
string being passed in as a const.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: Release v5.6.0-rc0 libxfs-5.6-sync v5.6.0-rc0
Eric Sandeen [Wed, 18 Mar 2020 16:37:30 +0000 (12:37 -0400)]
xfsprogs: Release v5.6.0-rc0

Update all the necessary files for a 5.6.0-rc0 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove unnecessary null pointer checks from _read_agf callers
Darrick J. Wong [Sat, 14 Mar 2020 03:04:09 +0000 (23:04 -0400)]
xfs: remove unnecessary null pointer checks from _read_agf callers

Source kernel commit: 706b8c5bc70391be510a5454f307db90b622b279

Drop the null buffer pointer checks in all code that calls
xfs_alloc_read_agf and doesn't pass XFS_ALLOC_FLAG_TRYLOCK because
they're no longer necessary.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: make xfs_*read_agf return EAGAIN to ALLOC_FLAG_TRYLOCK callers
Darrick J. Wong [Sat, 14 Mar 2020 03:01:00 +0000 (23:01 -0400)]
xfs: make xfs_*read_agf return EAGAIN to ALLOC_FLAG_TRYLOCK callers

Source kernel commit: f48e2df8a877ca1c19d92cfd7e74cc5956fa84cb

Refactor xfs_read_agf and xfs_alloc_read_agf to return EAGAIN if the
caller passed TRYLOCK and we weren't able to get the lock; and change
the callers to recognize this.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove the xfs_btree_get_buf[ls] functions
Darrick J. Wong [Sat, 14 Mar 2020 03:01:00 +0000 (23:01 -0400)]
xfs: remove the xfs_btree_get_buf[ls] functions

Source kernel commit: ee647f85cb81b09bbfa2886954828ed03fa3ec38

Remove the xfs_btree_get_bufs and xfs_btree_get_bufl functions, since
they're pretty trivial oneliners.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: make xfs_trans_get_buf return an error code
Darrick J. Wong [Sat, 14 Mar 2020 03:01:00 +0000 (23:01 -0400)]
xfs: make xfs_trans_get_buf return an error code

Source kernel commit: ce92464c180b60e79022bdf1175b7737a11f59b7

Convert xfs_trans_get_buf() to return numeric error codes like most
everywhere else in xfs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: make xfs_trans_get_buf_map return an error code
Darrick J. Wong [Sat, 14 Mar 2020 03:01:00 +0000 (23:01 -0400)]
xfs: make xfs_trans_get_buf_map return an error code

Source kernel commit: 9676b54e6e28689af1b4247569f14466bdfc5390

Convert xfs_trans_get_buf_map() to return numeric error codes like most
everywhere else in xfs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: make xfs_buf_read return an error code
Darrick J. Wong [Sat, 14 Mar 2020 03:01:00 +0000 (23:01 -0400)]
xfs: make xfs_buf_read return an error code

Source kernel commit: 0e3eccce5e0e438bc1aa3c2913221d3d43a1bef4

Convert xfs_buf_read() to return numeric error codes like most
everywhere else in xfs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: make xfs_buf_get_uncached return an error code
Darrick J. Wong [Sat, 14 Mar 2020 03:01:00 +0000 (23:01 -0400)]
xfs: make xfs_buf_get_uncached return an error code

Source kernel commit: 2842b6db3d539bec08d080b22635b6e8acaa30ec

Convert xfs_buf_get_uncached() to return numeric error codes like most
everywhere else in xfs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: make xfs_buf_get return an error code
Darrick J. Wong [Sat, 14 Mar 2020 03:01:00 +0000 (23:01 -0400)]
xfs: make xfs_buf_get return an error code

Source kernel commit: 841263e93310595c30653a9f530b2d7bbeed5aae

Convert xfs_buf_get() to return numeric error codes like most
everywhere else in xfs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: make xfs_buf_read_map return an error code
Darrick J. Wong [Sat, 14 Mar 2020 03:01:00 +0000 (23:01 -0400)]
xfs: make xfs_buf_read_map return an error code

Source kernel commit: 4ed8e27b4f755f50d78dc3d9f9760b60e891f97b

Convert xfs_buf_read_map() to return numeric error codes like most
everywhere else in xfs.  This involves moving the open-coded logic that
reports metadata IO read / corruption errors and stales the buffer into
xfs_buf_read_map so that the logic is all in one place.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: make libxfs_buf_read_map return an error code
Darrick J. Wong [Sat, 14 Mar 2020 03:01:00 +0000 (23:01 -0400)]
libxfs: make libxfs_buf_read_map return an error code

Make libxfs_buf_read_map() and libxfs_readbuf() return an error code
instead of making callers guess what happened based on whether or not
they got a buffer back.

Add a new SALVAGE flag so that certain utilities (xfs_db and xfs_repair)
can attempt salvage operations even if the verifiers failed, which was
the behavior before this change.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: refactor libxfs_readbuf out of existence
Darrick J. Wong [Sat, 14 Mar 2020 03:01:00 +0000 (23:01 -0400)]
libxfs: refactor libxfs_readbuf out of existence

The two libxfs_readbuf* functions are awfully similar, so refactor one
into the other to reduce duplicated code.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: make libxfs_buf_get_map return an error code
Darrick J. Wong [Sat, 14 Mar 2020 03:00:59 +0000 (23:00 -0400)]
libxfs: make libxfs_buf_get_map return an error code

Convert libxfs_buf_get_map() to return numeric error codes like most
everywhere else in xfsprogs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: make libxfs_getbuf_flags return an error code
Darrick J. Wong [Sat, 14 Mar 2020 03:00:59 +0000 (23:00 -0400)]
libxfs: make libxfs_getbuf_flags return an error code

Convert libxfs_getbuf_flags() to return numeric error codes like most
everywhere else in xfsprogs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: make __cache_lookup return an error code
Darrick J. Wong [Sat, 14 Mar 2020 03:00:57 +0000 (23:00 -0400)]
libxfs: make __cache_lookup return an error code

Convert __cache_lookup() to return numeric error codes like most
everywhere else in xfsprogs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: make struct xfs_buf_log_format have a consistent size
Darrick J. Wong [Sat, 14 Mar 2020 03:00:52 +0000 (23:00 -0400)]
xfs: make struct xfs_buf_log_format have a consistent size

Source kernel commit: b7df5e92055c69666e3c82f31f193120d98f04e3

Increase XFS_BLF_DATAMAP_SIZE by 1 to fill in the implied padding at the
end of struct xfs_buf_log_format.  This makes the size consistent so
that we can check it in xfs_ondisk.h, and will be needed once we start
logging attribute values.

On amd64 we get the following pahole:

struct xfs_buf_log_format {
short unsigned int         blf_type;       /*     0     2 */
short unsigned int         blf_size;       /*     2     2 */
short unsigned int         blf_flags;      /*     4     2 */
short unsigned int         blf_len;        /*     6     2 */
long long int              blf_blkno;      /*     8     8 */
unsigned int               blf_map_size;   /*    16     4 */
unsigned int               blf_data_map[16]; /*    20    64 */
/* --- cacheline 1 boundary (64 bytes) was 20 bytes ago --- */

/* size: 88, cachelines: 2, members: 7 */
/* padding: 4 */
/* last cacheline: 24 bytes */
};

But on i386 we get the following:

struct xfs_buf_log_format {
short unsigned int         blf_type;       /*     0     2 */
short unsigned int         blf_size;       /*     2     2 */
short unsigned int         blf_flags;      /*     4     2 */
short unsigned int         blf_len;        /*     6     2 */
long long int              blf_blkno;      /*     8     8 */
unsigned int               blf_map_size;   /*    16     4 */
unsigned int               blf_data_map[16]; /*    20    64 */
/* --- cacheline 1 boundary (64 bytes) was 20 bytes ago --- */

/* size: 84, cachelines: 2, members: 7 */
/* last cacheline: 20 bytes */
};

Notice how the amd64 compiler inserts 4 bytes of padding to the end of
the structure to ensure 8-byte alignment.  Prior to "xfs: fix memory
corruption during remote attr value buffer invalidation" we would try to
write to blf_data_map[17], which is harmless on amd64 but really bad on
i386.

This shouldn't cause any changes in the ondisk logging formats because
the log code writes out the log vectors with the appropriate size for
the log item's map_size, and log recovery treats the data_map array as a
VLA.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: streamline xfs_attr3_leaf_inactive
Darrick J. Wong [Sat, 14 Mar 2020 03:00:39 +0000 (23:00 -0400)]
xfs: streamline xfs_attr3_leaf_inactive

Source kernel commit: 0bb9d159bd018b271e783d3b2d3bc82fa0727321

Now that we know we don't have to take a transaction to stale the incore
buffers for a remote value, get rid of the unnecessary memory allocation
in the leaf walker and call the rmt_stale function directly.  Flatten
the loop while we're at it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: fix memory corruption during remote attr value buffer invalidation
Darrick J. Wong [Sat, 14 Mar 2020 03:00:30 +0000 (23:00 -0400)]
xfs: fix memory corruption during remote attr value buffer invalidation

Source kernel commit: e8db2aafcedb7d88320ab83f1000f1606b26d4d7

While running generic/103, I observed what looks like memory corruption
and (with slub debugging turned on) a slub redzone warning on i386 when
inactivating an inode with a 64k remote attr value.

On a v5 filesystem, maximally sized remote attr values require one block
more than 64k worth of space to hold both the remote attribute value
header (64 bytes).  On a 4k block filesystem this results in a 68k
buffer; on a 64k block filesystem, this would be a 128k buffer.  Note
that even though we'll never use more than 65,600 bytes of this buffer,
XFS_MAX_BLOCKSIZE is 64k.

This is a problem because the definition of struct xfs_buf_log_format
allows for XFS_MAX_BLOCKSIZE worth of dirty bitmap (64k).  On i386 when we
invalidate a remote attribute, xfs_trans_binval zeroes all 68k worth of
the dirty map, writing right off the end of the log item and corrupting
memory.  We've gotten away with this on x86_64 for years because the
compiler inserts a u32 padding on the end of struct xfs_buf_log_format.

Fortunately for us, remote attribute values are written to disk with
xfs_bwrite(), which is to say that they are not logged.  Fix the problem
by removing all places where we could end up creating a buffer log item
for a remote attribute value and leave a note explaining why.  Next,
replace the open-coded buffer invalidation with a call to the helper we
created in the previous patch that does better checking for bad metadata
before marking the buffer stale.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: refactor remote attr value buffer invalidation
Darrick J. Wong [Sat, 14 Mar 2020 03:00:22 +0000 (23:00 -0400)]
xfs: refactor remote attr value buffer invalidation

Source kernel commit: 8edbb26b06023de31ad7d4c9b984d99f66577929

Hoist the code that invalidates remote extended attribute value buffers
into a separate helper function.  This prepares us for a memory
corruption fix in the next patch.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: Add __packed to xfs_dir2_sf_entry_t definition
Vincenzo Frascino [Sat, 14 Mar 2020 03:00:12 +0000 (23:00 -0400)]
xfs: Add __packed to xfs_dir2_sf_entry_t definition

Source kernel commit: ca78eee7b4ac13b63f5e872f7c3a5ca66b2df8da

xfs_check_ondisk_structs() verifies that the sizes of the data types
used by xfs are correct via the XFS_CHECK_STRUCT_SIZE() macro.

Since the structures padding can vary depending on the ABI (e.g. on
ARM OABI structures are padded to multiple of 32 bits), it may happen
that xfs_dir2_sf_entry_t size check breaks the compilation with the
assertion below:

In file included from linux/include/linux/string.h:6,
from linux/include/linux/uuid.h:12,
from linux/fs/xfs/xfs_linux.h:10,
from linux/fs/xfs/xfs.h:22,
from linux/fs/xfs/xfs_super.c:7:
In function ‘xfs_check_ondisk_structs’,
inlined from ‘init_xfs_fs’ at linux/fs/xfs/xfs_super.c:2025:2:
linux/include/linux/compiler.h:350:38:
error: call to ‘__compiletime_assert_107’ declared with attribute
error: XFS: sizeof(xfs_dir2_sf_entry_t) is wrong, expected 3
_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)

Restore the correct behavior adding __packed to the structure definition.

Cc: Darrick J. Wong <darrick.wong@oracle.com>
Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: introduce XFS_MAX_FILEOFF
Darrick J. Wong [Sat, 14 Mar 2020 02:59:57 +0000 (22:59 -0400)]
xfs: introduce XFS_MAX_FILEOFF

Source kernel commit: a5084865524dee1fe8ea1fee17c60b4369ad4f5e

Introduce a new #define for the maximum supported file block offset.
We'll use this in the next patch to make it more obvious that we're
doing some operation for all possible inode fork mappings after a given
offset.  We can't use ULLONG_MAX here because bunmapi uses that to
detect when it's done.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: Remove all strlen in all xfs_attr_* functions for attr names.
Allison Henderson [Sat, 14 Mar 2020 02:59:48 +0000 (22:59 -0400)]
xfs: Remove all strlen in all xfs_attr_* functions for attr names.

Source kernel commit: d29f781c32b1d1366c8ac10be31dad1e1f39c336

This helps to pre-simplify the extra handling of the null terminator in
delayed operations which use memcpy rather than strlen.  Later
when we introduce parent pointers, attribute names will become binary,
so strlen will not work at all.  Removing uses of strlen now will
help reduce complexities later

Signed-off-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: fix misuse of the XFS_ATTR_INCOMPLETE flag
Christoph Hellwig [Sat, 14 Mar 2020 02:59:39 +0000 (22:59 -0400)]
xfs: fix misuse of the XFS_ATTR_INCOMPLETE flag

Source kernel commit: 780d29057781d986cd87dbbe232cd02876ad430f

XFS_ATTR_INCOMPLETE is a flag in the on-disk attribute format, and thus
in a different namespace as the ATTR_* flags in xfs_da_args.flags.
Switch to using a XFS_DA_OP_INCOMPLETE flag in op_flags instead.  Without
this users might be able to inject this flag into operations using the
attr by handle ioctl.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: clear kernel only flags in XFS_IOC_ATTRMULTI_BY_HANDLE
Christoph Hellwig [Sat, 14 Mar 2020 02:59:30 +0000 (22:59 -0400)]
xfs: clear kernel only flags in XFS_IOC_ATTRMULTI_BY_HANDLE

Source kernel commit: 953aa9d136f53e226448dbd801a905c28f8071bf

Don't allow passing arbitrary flags as they change behavior including
memory allocation that the call stack is not prepared for.

Fixes: ddbca70cc45c ("xfs: allocate xattr buffer on demand")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs: remove shadow variable in xfs_btree_lshift
Eric Sandeen [Sat, 14 Mar 2020 02:59:15 +0000 (22:59 -0400)]
xfs: remove shadow variable in xfs_btree_lshift

Source kernel commit: 5a57c05b56b6eb2b4e3eb2a9f205e39e849325a1

Sparse warns about a shadow variable in this function after the
Fixed: commit added another int i; with larger scope.  It's safe
to remove the one with the smaller scope to fix this shadow,
although the shadow itself is harmless.

Fixes: 2c813ad66a72 ("xfs: support btrees with overlapping intervals for keys")
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>
5 years agoxfsprogs: Release v5.5.0 v5.5.0
Eric Sandeen [Fri, 13 Mar 2020 14:53:45 +0000 (10:53 -0400)]
xfsprogs: Release v5.5.0

Update all the necessary files for a 5.5.0 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: don't warn about packed members
Dave Chinner [Fri, 13 Mar 2020 14:22:07 +0000 (10:22 -0400)]
xfsprogs: don't warn about packed members

gcc 9.2.1 throws lots of new warnings during the build like this:

xfs_format.h:790:3: warning: taking address of packed member of ‘struct xfs_agfl’ may result in an unaligned pointer value [-Waddress-of-packed-member]
  790 |   &(XFS_BUF_TO_AGFL(bp)->agfl_bno[0]) : \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xfs_alloc.c:3149:13: note: in expansion of macro ‘XFS_BUF_TO_AGFL_BNO’
 3149 |  agfl_bno = XFS_BUF_TO_AGFL_BNO(mp, agflbp);
      |             ^~~~~~~~~~~~~~~~~~~

We know this packed structure aligned correctly, so turn off this
warning to shut gcc up.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
[sandeen: kernel has done this globally as well in 6f303d60534]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfsprogs: Release v5.5.0-rc1 v5.5.0-rc1
Eric Sandeen [Tue, 3 Mar 2020 01:38:14 +0000 (20:38 -0500)]
xfsprogs: Release v5.5.0-rc1

Update all the necessary files for a 5.5.0-rc1 prerelease.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_admin: revert online label setting ability
Eric Sandeen [Tue, 3 Mar 2020 01:38:12 +0000 (20:38 -0500)]
xfs_admin: revert online label setting ability

"xfs_admin can't print both label and UUID for mounted filesystems"
https://bugzilla.kernel.org/show_bug.cgi?id=206429

alerted us to the problem that if /any/ options that use xfs_io get
specified to xfs_admin, they are the /only/ ones that get run:

                # Try making the changes online, if supported
                if [ -n "$IO_OPTS" ] && mntpt="$(find_mntpt_for_arg "$1")"
                then
                        eval xfs_io -x -p xfs_admin $IO_OPTS "$mntpt"
                        test "$?" -eq 0 && exit 0
                fi

and thanks to the exit, the xfs_db operations don't get run at all.

We could move on to the xfs_db commands after executing the xfs_io
commands, but we build them all up in parallel at this time:

        l)      DB_OPTS=$DB_OPTS" -r -c label"
                IO_OPTS=$IO_OPTS" -r -c label"
                ;;

so we'd need to keep track of these, and not re-run them in xfs_db.

Another issue is that prior to this commit, we'd run commands in
command line order.

So I experimented with building up an array of commands, invoking xfs_db
or xfs_io one command at a time as needed for each, and ... it got overly
complicated.

It's broken now, and so far a clean solution isn't evident, and I hate to
leave it broken across another release.  So revert it for now.

Reverts: 3f153e051a ("xfs_admin: enable online label getting and setting")
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: convert buffer priority get/set macros to functions
Darrick J. Wong [Sun, 1 Mar 2020 17:34:11 +0000 (12:34 -0500)]
libxfs: convert buffer priority get/set macros to functions

Convert these shouty macros to proper functions.  We can't make them
static inline functions unless I f the 'libxfs_bcache' reference.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[sandeen: fix a couple long lines]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: rename libxfs_getbuf_map to libxfs_buf_get_map
Darrick J. Wong [Sun, 1 Mar 2020 17:34:11 +0000 (12:34 -0500)]
libxfs: rename libxfs_getbuf_map to libxfs_buf_get_map

Rename this function to match the kernel function.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: rename libxfs_readbuf_map to libxfs_buf_read_map
Darrick J. Wong [Sun, 1 Mar 2020 17:34:11 +0000 (12:34 -0500)]
libxfs: rename libxfs_readbuf_map to libxfs_buf_read_map

Rename this function to match the kernel function.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: hide libxfs_getbuf_flags
Darrick J. Wong [Sun, 1 Mar 2020 17:34:11 +0000 (12:34 -0500)]
libxfs: hide libxfs_getbuf_flags

Hide this function since it's internal to rdwr.c.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: remove the libxfs_{get,put}bufr APIs
Darrick J. Wong [Sun, 1 Mar 2020 17:34:11 +0000 (12:34 -0500)]
libxfs: remove the libxfs_{get,put}bufr APIs

Hide libxfs_getbufr since nobody should be using the internal function,
and fold libxfs_putbufr into its only caller.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: remove dangerous casting between cache_node and xfs_buf
Darrick J. Wong [Sun, 1 Mar 2020 17:34:11 +0000 (12:34 -0500)]
libxfs: remove dangerous casting between cache_node and xfs_buf

Get rid of all the dangerous casting between cache_node and xfs_buf
since we can use container_of now.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: remove dangerous casting between xfs_buf and cache_node
Darrick J. Wong [Sun, 1 Mar 2020 17:34:11 +0000 (12:34 -0500)]
libxfs: remove dangerous casting between xfs_buf and cache_node

Get rid of all the dangerous casting between xfs_buf and cache_node
since we can dereference directly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: remove libxfs_writebuf_int
Darrick J. Wong [Sun, 1 Mar 2020 17:34:11 +0000 (12:34 -0500)]
libxfs: remove libxfs_writebuf_int

This function is the same as libxfs_buf_dirty so use that instead.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: remove unused flags parameter to libxfs_buf_mark_dirty
Darrick J. Wong [Sun, 1 Mar 2020 17:34:11 +0000 (12:34 -0500)]
libxfs: remove unused flags parameter to libxfs_buf_mark_dirty

Nobody uses the flags parameter, so get rid of it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: straighten out libxfs_writebuf naming confusion
Darrick J. Wong [Sun, 1 Mar 2020 17:34:11 +0000 (12:34 -0500)]
libxfs: straighten out libxfs_writebuf naming confusion

libxfs_writebuf is not a well named function -- it marks the buffer
dirty and then releases the caller's reference.  The actual write comes
when the cache is flushed, either because someone explicitly told the
cache to flush or because we started buffer reclaim.

Make the buffer release explicit in the callers and rename the function
to say what it actually does -- it marks the buffer dirty outside of
transaction context.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: use uncached buffers for initial mkfs writes
Darrick J. Wong [Sun, 1 Mar 2020 17:34:11 +0000 (12:34 -0500)]
libxfs: use uncached buffers for initial mkfs writes

Teach mkfs to use uncached buffers to write the start and end of the
data device, the initial superblock, and the end of the realtime device
instead of open-coding uncached buffers.  This means we can get rid of
libxfs_purgebuf since we handle the state from the start now.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxlog: use uncached buffers instead of open-coding them
Darrick J. Wong [Sun, 1 Mar 2020 17:34:10 +0000 (12:34 -0500)]
libxlog: use uncached buffers instead of open-coding them

Use the new uncached buffer functions to manage buffers instead of
open-coding the logic.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: convert libxfs_log_clear to use uncached buffers
Darrick J. Wong [Sun, 1 Mar 2020 17:34:10 +0000 (12:34 -0500)]
libxfs: convert libxfs_log_clear to use uncached buffers

Convert the log clearing function to use uncached buffers like
everything else, instead of using the raw buffer get/put functions.
This will eventually enable us to hide them more effectively.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: move log functions for convenience
Darrick J. Wong [Sun, 1 Mar 2020 17:34:10 +0000 (12:34 -0500)]
libxfs: move log functions for convenience

Move libxfs_log_clear and libxfs_log_header to the bottom of the file so
that we avoid having to create advance declarations of static functions
in the next patch.  No functional changes.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_copy: use uncached buffer reads to get the superblock
Darrick J. Wong [Sun, 1 Mar 2020 17:34:10 +0000 (12:34 -0500)]
xfs_copy: use uncached buffer reads to get the superblock

Upon startup, xfs_copy needs to read the filesystem superblock to mount
the filesystem.  We cannot know the filesystem sector size until we read
the superblock, but we also do not want to introduce aliasing in the
buffer cache.  Convert this code to the new uncached buffer read API so
that we can stop open-coding it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agoxfs_db: use uncached buffer reads to get the superblock
Darrick J. Wong [Sun, 1 Mar 2020 17:34:10 +0000 (12:34 -0500)]
xfs_db: use uncached buffer reads to get the superblock

Upon startup, xfs_db needs to check if it is even looking at an XFS
filesystem, and it needs the AG 0 superblock contents to initialize the
incore mount.  We cannot know the filesystem sector size until we read
the superblock, but we also do not want to introduce aliasing in the
buffer cache.  Convert this code to the new uncached buffer read API so
that we can stop open-coding it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: introduce libxfs_buf_read_uncached
Darrick J. Wong [Sun, 1 Mar 2020 17:34:10 +0000 (12:34 -0500)]
libxfs: introduce libxfs_buf_read_uncached

Introduce an uncached read function so that userspace can handle them in
the same way as the kernel.  This also eliminates the need for some of
the libxfs_purgebuf calls (and two trips into the cache code).

Refactor the get/read uncached buffer functions to hide the details of
uncached buffer-ism in rdwr.c.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: make libxfs_readbufr stash the error value in b_error
Darrick J. Wong [Sun, 1 Mar 2020 17:34:10 +0000 (12:34 -0500)]
libxfs: make libxfs_readbufr stash the error value in b_error

Make libxfs_readbufr stash the error value in b_error, which will make
the behavior consistent between regular and multi-mapping buffers.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: make libxfs_readbuf_verify return an error code
Darrick J. Wong [Sun, 1 Mar 2020 17:34:10 +0000 (12:34 -0500)]
libxfs: make libxfs_readbuf_verify return an error code

Return the bp->b_error from libxfs_readbuf_verify instead of making
callers check it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: rename libxfs_writebufr to libxfs_bwrite
Darrick J. Wong [Sun, 1 Mar 2020 17:34:10 +0000 (12:34 -0500)]
libxfs: rename libxfs_writebufr to libxfs_bwrite

Rename this function so that we have an API that matches the kernel
without a #define.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: replace libxfs_readbuf with libxfs_buf_read
Darrick J. Wong [Sun, 1 Mar 2020 17:34:10 +0000 (12:34 -0500)]
libxfs: replace libxfs_readbuf with libxfs_buf_read

Change all the libxfs_readbuf calls to libxfs_buf_read to match the
kernel interface.  This enables us to hide libxfs_readbuf and simplify
the userspace buffer interface further.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: replace libxfs_getbuf with libxfs_buf_get
Darrick J. Wong [Sun, 1 Mar 2020 17:34:10 +0000 (12:34 -0500)]
libxfs: replace libxfs_getbuf with libxfs_buf_get

Change all the libxfs_getbuf calls to libxfs_buf_get to match the
kernel interface, since one is a #define of the other.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: replace libxfs_putbuf with libxfs_buf_relse
Darrick J. Wong [Sun, 1 Mar 2020 17:33:38 +0000 (12:33 -0500)]
libxfs: replace libxfs_putbuf with libxfs_buf_relse

Change all the libxfs_putbuf calls to libxfs_buf_relse to match the
kernel interface, since one is a #define of the other.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
5 years agolibxfs: remove LIBXFS_B_EXIT
Darrick J. Wong [Sun, 1 Mar 2020 17:33:38 +0000 (12:33 -0500)]
libxfs: remove LIBXFS_B_EXIT

Now that we've removed all users of LIBXFS_B_EXIT, remove it as well.

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>