OSDN Git Service

android-x86/kernel.git
5 years agoxfs: bump INUMBERS cursor correctly in xfs_inumbers_walk
Darrick J. Wong [Tue, 9 Jul 2019 02:36:17 +0000 (19:36 -0700)]
xfs: bump INUMBERS cursor correctly in xfs_inumbers_walk

There's a subtle unit conversion error when we increment the INUMBERS
cursor at the end of xfs_inumbers_walk.  If there's an inode chunk at
the very end of the AG /and/ the AG size is a perfect power of two, the
startino of that last chunk (which is in units of AG inodes) will be 63
less than (1 << agino_log).  If we add XFS_INODES_PER_CHUNK to the
startino, we end up with a startino that's larger than (1 << agino_log)
and when we convert that back to fs inode units we'll rip off that upper
bit and wind up back at the start of the AG.

Fix this by converting to units of fs inodes before adding
XFS_INODES_PER_CHUNK so that we'll harmlessly end up pointing to the
next AG.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: don't update lastino for FSBULKSTAT_SINGLE
Darrick J. Wong [Sat, 6 Jul 2019 16:29:01 +0000 (09:29 -0700)]
xfs: don't update lastino for FSBULKSTAT_SINGLE

The kernel test robot found a regression of xfs/054 in the conversion of
bulkstat to use the new iwalk infrastructure -- if a caller set *lastip
= 128 and invoked FSBULKSTAT_SINGLE, the bstat info would be for inode
128, but *lastip would be increased by the kernel to 129.

FSBULKSTAT_SINGLE never incremented lastip before, so it's incorrect to
make such an update to the internal lastino value now.

Fixes: 2810bd6840e463 ("xfs: convert bulkstat to new iwalk infrastructure")
Reported-by: kernel test robot <rong.a.chen@intel.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: online scrub needn't bother zeroing its temporary buffer
Darrick J. Wong [Fri, 5 Jul 2019 17:29:56 +0000 (10:29 -0700)]
xfs: online scrub needn't bother zeroing its temporary buffer

The xattr scrubber functions use the temporary memory buffer either for
storing bitmaps or for testing if attribute value extraction works.  The
bitmap code always zeroes what it needs and the value extraction sets
the buffer contents, so it's not necessary to waste CPU time zeroing on
allocation.

Note that while we never read the contents that the attr value
extraction function sets, we do need to call it to check the remote
attribute header and CRCs to check for corruption.

A flame graph analysis showed that we were spending 7% of a xfs_scrub
run (the whole program, not just the attr scrubber itself) allocating
and zeroing 64k segments needlessly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: only allocate memory for scrubbing attributes when we need it
Darrick J. Wong [Fri, 5 Jul 2019 17:29:56 +0000 (10:29 -0700)]
xfs: only allocate memory for scrubbing attributes when we need it

In examining a flame graph of time spent running xfs_scrub on various
filesystems, I noticed that we spent nearly 7% of the total runtime on
allocating a zeroed 65k buffer for every SCRUB_TYPE_XATTR invocation.
We do this even if none of the attribute values were anywhere near 64k
in size, even if there were no attribute blocks to check space on, and
even if it just turns out there are no attributes at all.

Therefore, rearrange the xattr buffer setup code to support reallocating
with a bigger buffer and redistribute the callers of that function so
that we only allocate memory just prior to needing it, and only allocate
as much as we need.  If we can't get memory with the ILOCK held we'll
bail out with EDEADLOCK which will allocate the maximum memory.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: refactor attr scrub memory allocation function
Darrick J. Wong [Fri, 5 Jul 2019 17:29:55 +0000 (10:29 -0700)]
xfs: refactor attr scrub memory allocation function

Move the code that allocates memory buffers for the extended attribute
scrub code into a separate function so we can reduce memory allocations
in the next patch.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: refactor extended attribute buffer pointer functions
Darrick J. Wong [Fri, 5 Jul 2019 17:29:55 +0000 (10:29 -0700)]
xfs: refactor extended attribute buffer pointer functions

Replace the open-coded attribute buffer pointer calculations with helper
functions to make it more obvious what we're doing with our freeform
memory allocation w.r.t. either storing xattr values or computing btree
block free space.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: attribute scrub should use seen_enough to pass error values
Darrick J. Wong [Fri, 5 Jul 2019 17:29:54 +0000 (10:29 -0700)]
xfs: attribute scrub should use seen_enough to pass error values

When we're iterating all the attributes using the built-in xattr
iterator, we can use the seen_enough variable to pass error codes back
to the main scrub function instead of flattening them into 0/1.  This
will be used in a more exciting fashion in upcoming patches.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: allow single bulkstat of special inodes
Darrick J. Wong [Thu, 4 Jul 2019 03:36:29 +0000 (20:36 -0700)]
xfs: allow single bulkstat of special inodes

Create a new bulk ireq flag that enables userspace to ask us for a
special inode number instead of interpreting @ino as a literal inode
number.  This enables us to query the root inode easily.

The reason for adding the ability to query specifically the root
directory inode is that certain programs (xfsdump and xfsrestore) want
to confirm when they've been pointed to the root directory.  The
userspace code assumes the root directory is always the first result
from calling bulkstat with lastino == 0, but this isn't true if the
(initial btree roots + initial AGFL + inode alignment padding) is itself
long enough to be allocated to new inodes if all of those blocks should
happen to be free at the same time.  Rather than make userspace guess
at internal filesystem state, we provide a direct query.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: specify AG in bulk req
Darrick J. Wong [Thu, 4 Jul 2019 03:36:28 +0000 (20:36 -0700)]
xfs: specify AG in bulk req

Add a new xfs_bulk_ireq flag to constrain the iteration to a single AG.
If the passed-in startino value is zero then we start with the first
inode in the AG that the user passes in; otherwise, we iterate only
within the same AG as the passed-in inode.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: wire up the v5 inumbers ioctl
Darrick J. Wong [Thu, 4 Jul 2019 03:36:28 +0000 (20:36 -0700)]
xfs: wire up the v5 inumbers ioctl

Wire up the v5 INUMBERS ioctl.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: wire up new v5 bulkstat ioctls
Darrick J. Wong [Thu, 4 Jul 2019 03:36:27 +0000 (20:36 -0700)]
xfs: wire up new v5 bulkstat ioctls

Wire up the new v5 BULKSTAT ioctl.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: introduce v5 inode group structure
Darrick J. Wong [Thu, 4 Jul 2019 03:36:27 +0000 (20:36 -0700)]
xfs: introduce v5 inode group structure

Introduce a new "v5" inode group structure that fixes the alignment
and padding problems of the existing structure.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: introduce new v5 bulkstat structure
Darrick J. Wong [Thu, 4 Jul 2019 03:36:26 +0000 (20:36 -0700)]
xfs: introduce new v5 bulkstat structure

Introduce a new version of the in-core bulkstat structure that supports
our new v5 format features.  This structure also fills the gaps in the
previous structure.  We leave wiring up the ioctls for the next patch.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: rename bulkstat functions
Darrick J. Wong [Thu, 4 Jul 2019 03:36:26 +0000 (20:36 -0700)]
xfs: rename bulkstat functions

Rename the bulkstat functions to 'fsbulkstat' so that they match the
ioctl names.  We will be introducing a new set of bulkstat/inumbers
ioctls soon, and it will be important to keep the names straight.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: remove various bulk request typedef usage
Darrick J. Wong [Thu, 4 Jul 2019 03:36:25 +0000 (20:36 -0700)]
xfs: remove various bulk request typedef usage

Remove xfs_bstat_t, xfs_fsop_bulkreq_t, xfs_inogrp_t, and similarly
named compat typedefs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agofs: xfs: xfs_log: Change return type from int to void
Hariprasad Kelam [Wed, 3 Jul 2019 14:34:18 +0000 (07:34 -0700)]
fs: xfs: xfs_log: Change return type from int to void

Change return types of below functions as they never fails
xfs_log_mount_cancel
xlog_recover_cancel
xlog_recover_cancel_intents

fix below issue reported by coccicheck
fs/xfs/xfs_log_recover.c:4886:7-12: Unneeded variable: "error". Return
"0" on line 4926

Signed-off-by: Hariprasad Kelam <hariprasad.kelam@gmail.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: poll waiting for quotacheck
Darrick J. Wong [Wed, 3 Jul 2019 14:33:27 +0000 (07:33 -0700)]
xfs: poll waiting for quotacheck

Create a pwork destroy function that uses polling instead of
uninterruptible sleep to wait for work items to finish so that we can
touch the softlockup watchdog.  IOWs, gross hack.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: multithreaded iwalk implementation
Darrick J. Wong [Wed, 3 Jul 2019 14:33:26 +0000 (07:33 -0700)]
xfs: multithreaded iwalk implementation

Create a parallel iwalk implementation and switch quotacheck to use it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: refactor INUMBERS to use iwalk functions
Darrick J. Wong [Tue, 2 Jul 2019 16:39:43 +0000 (09:39 -0700)]
xfs: refactor INUMBERS to use iwalk functions

Now that we have generic functions to walk inode records, refactor the
INUMBERS implementation to use it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: refactor iwalk code to handle walking inobt records
Darrick J. Wong [Tue, 2 Jul 2019 16:39:43 +0000 (09:39 -0700)]
xfs: refactor iwalk code to handle walking inobt records

Refactor xfs_iwalk_ag_start and xfs_iwalk_ag so that the bits that are
particular to bulkstat (trimming the start irec, starting inode
readahead, and skipping empty groups) can be controlled via flags in the
iwag structure.

This enables us to add a new function to walk all inobt records which
will be used for the new INUMBERS implementation in the next patch.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: refactor xfs_iwalk_grab_ichunk
Darrick J. Wong [Tue, 2 Jul 2019 16:39:42 +0000 (09:39 -0700)]
xfs: refactor xfs_iwalk_grab_ichunk

In preparation for reusing the iwalk code for the inogrp walking code
(aka INUMBERS), move the initial inobt lookup and retrieval code out of
xfs_iwalk_grab_ichunk so that we call the masking code only when we need
to trim out the inodes that came before the cursor in the inobt record
(aka BULKSTAT).

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: clean up long conditionals in xfs_iwalk_ichunk_ra
Darrick J. Wong [Tue, 2 Jul 2019 16:39:42 +0000 (09:39 -0700)]
xfs: clean up long conditionals in xfs_iwalk_ichunk_ra

Refactor xfs_iwalk_ichunk_ra to avoid long conditionals.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: change xfs_iwalk_grab_ichunk to use startino, not lastino
Darrick J. Wong [Tue, 2 Jul 2019 16:39:41 +0000 (09:39 -0700)]
xfs: change xfs_iwalk_grab_ichunk to use startino, not lastino

Now that the inode chunk grabbing function is a static function in the
iwalk code, change its behavior so that @agino is the inode where we
want to /start/ the iteration.  This reduces cognitive friction with the
callers and simplifes the code.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: move bulkstat ichunk helpers to iwalk code
Darrick J. Wong [Tue, 2 Jul 2019 16:39:41 +0000 (09:39 -0700)]
xfs: move bulkstat ichunk helpers to iwalk code

Now that we've reworked the bulkstat code to use iwalk, we can move the
old bulkstat ichunk helpers to xfs_iwalk.c.  No functional changes here.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: calculate inode walk prefetch more carefully
Darrick J. Wong [Tue, 2 Jul 2019 16:39:40 +0000 (09:39 -0700)]
xfs: calculate inode walk prefetch more carefully

The existing inode walk prefetch is based on the old bulkstat code,
which simply allocated 4 pages worth of memory and prefetched that many
inobt records, regardless of however many inodes the caller requested.
65536 inodes is a lot to prefetch (~32M on x64, ~512M on arm64) so let's
scale things down a little more intelligently based on the number of
inodes requested, etc.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: convert bulkstat to new iwalk infrastructure
Darrick J. Wong [Tue, 2 Jul 2019 16:39:40 +0000 (09:39 -0700)]
xfs: convert bulkstat to new iwalk infrastructure

Create a new ibulk structure incore to help us deal with bulk inode stat
state tracking and then convert the bulkstat code to use the new iwalk
iterator.  This disentangles inode walking from bulk stat control for
simpler code and enables us to isolate the formatter functions to the
ioctl handling code.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: bulkstat should copy lastip whenever userspace supplies one
Darrick J. Wong [Tue, 2 Jul 2019 16:39:39 +0000 (09:39 -0700)]
xfs: bulkstat should copy lastip whenever userspace supplies one

When userspace passes in a @lastip pointer we should copy the results
back, even if the @ocount pointer is NULL.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: convert quotacheck to use the new iwalk functions
Darrick J. Wong [Tue, 2 Jul 2019 16:39:39 +0000 (09:39 -0700)]
xfs: convert quotacheck to use the new iwalk functions

Convert quotacheck to use the new iwalk iterator to dig through the
inodes.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: create simplified inode walk function
Darrick J. Wong [Tue, 2 Jul 2019 16:39:38 +0000 (09:39 -0700)]
xfs: create simplified inode walk function

Create a new iterator function to simplify walking inodes in an XFS
filesystem.  This new iterator will replace the existing open-coded
walking that goes on in various places.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: create iterator error codes
Darrick J. Wong [Tue, 2 Jul 2019 16:39:38 +0000 (09:39 -0700)]
xfs: create iterator error codes

Currently, xfs doesn't have generic error codes defined for "stop
iterating"; we just reuse the XFS_BTREE_QUERY_* return values.  This
looks a little weird if we're not actually iterating a btree index.
Before we start adding more iterators, we should create general
XFS_ITER_{CONTINUE,ABORT} return values and define the XFS_BTREE_QUERY_*
ones from that.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
5 years agoxfs: remove XFS_TRANS_NOFS
Christoph Hellwig [Sat, 29 Jun 2019 02:31:38 +0000 (19:31 -0700)]
xfs: remove XFS_TRANS_NOFS

Instead of a magic flag for xfs_trans_alloc, just ensure all callers
that can't relclaim through the file system use memalloc_nofs_save to
set the per-task nofs flag.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: simplify xfs_ioend_can_merge
Christoph Hellwig [Sat, 29 Jun 2019 02:31:37 +0000 (19:31 -0700)]
xfs: simplify xfs_ioend_can_merge

Compare the block layer status directly instead of converting it to
an errno first.

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>
5 years agoxfs: allow merging ioends over append boundaries
Christoph Hellwig [Sat, 29 Jun 2019 02:31:37 +0000 (19:31 -0700)]
xfs: allow merging ioends over append boundaries

There is no real problem merging ioends that go beyond i_size into an
ioend that doesn't.  We just need to move the append transaction to the
base ioend.  Also use the opportunity to use a real error code instead
of the magic 1 to cancel the transactions, and write a comment
explaining the scheme.

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>
5 years agoxfs: fix a comment typo in xfs_submit_ioend
Christoph Hellwig [Sat, 29 Jun 2019 02:31:36 +0000 (19:31 -0700)]
xfs: fix a comment typo in xfs_submit_ioend

The fail argument is long gone, update the comment.

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>
5 years agoxfs: remove the unused xfs_count_page_state declaration
Christoph Hellwig [Sat, 29 Jun 2019 02:31:36 +0000 (19:31 -0700)]
xfs: remove the unused xfs_count_page_state declaration

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>
5 years agoxfs: fix iclog allocation size
Christoph Hellwig [Sat, 29 Jun 2019 02:31:36 +0000 (19:31 -0700)]
xfs: fix iclog allocation size

Properly allocate the space for the bio_vecs instead of just one byte
per bio_vec.

Fixes: 79b54d9bfcdcd0a ("xfs: use bios directly to write log buffers")
Reported-by: syzbot+b75afdbe271a0d7ac4f6@syzkaller.appspotmail.com
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>
5 years agoxfs: remove unused header files
Eric Sandeen [Sat, 29 Jun 2019 02:30:43 +0000 (19:30 -0700)]
xfs: remove unused header files

There are many, many xfs header files which are included but
unneeded (or included twice) in the xfs code, so remove them.

nb: xfs_linux.h includes about 9 headers for everyone, so those
explicit includes get removed by this.  I'm not sure what the
preference is, but if we wanted explicit includes everywhere,
a followup patch could remove those xfs_*.h includes from
xfs_linux.h and move them into the files that need them.
Or it could be left as-is.

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>
5 years agoxfs: implement cgroup aware writeback
Christoph Hellwig [Sat, 29 Jun 2019 02:30:22 +0000 (19:30 -0700)]
xfs: implement cgroup aware writeback

Link every newly allocated writeback bio to cgroup pointed to by the
writeback control structure, and charge every byte written back to it.

Tested-by: Stefan Priebe - Profihost AG <s.priebe@profihost.ag>
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>
5 years agoxfs: simplify xfs_chain_bio
Christoph Hellwig [Sat, 29 Jun 2019 02:30:22 +0000 (19:30 -0700)]
xfs: simplify xfs_chain_bio

Move setting up operation and write hint to xfs_alloc_ioend, and
then just copy over all needed information from the previous bio
in xfs_chain_bio and stop passing various parameters to it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: account for log space when formatting new AGs
Darrick J. Wong [Sat, 29 Jun 2019 02:30:21 +0000 (19:30 -0700)]
xfs: account for log space when formatting new AGs

When we're writing out a fresh new AG, make sure that we don't list an
internal log as free and that we create the rmap for the region.  growfs
never does this, but we will need it when we hook up mkfs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
5 years agoxfs: refactor free space btree record initialization
Darrick J. Wong [Sat, 29 Jun 2019 02:30:21 +0000 (19:30 -0700)]
xfs: refactor free space btree record initialization

Refactor the code that populates the free space btrees of a new AG so
that we can avoid code duplication once things start getting
complicated.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
5 years agoxfs: always update params on small allocation
Brian Foster [Sat, 29 Jun 2019 02:30:20 +0000 (19:30 -0700)]
xfs: always update params on small allocation

xfs_alloc_ag_vextent_small() doesn't update the output parameters in
the event of an AGFL allocation. Instead, it updates the
xfs_alloc_arg structure directly to complete the allocation.

Update both args and the output params to provide consistent
behavior for future callers.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: skip small alloc cntbt logic on NULL cursor
Brian Foster [Sat, 29 Jun 2019 02:30:20 +0000 (19:30 -0700)]
xfs: skip small alloc cntbt logic on NULL cursor

The small allocation helper is implemented in a way that is fairly
tightly integrated to the existing allocation algorithms. It expects
a cntbt cursor beyond the end of the tree, attempts to locate the
last record in the tree and only attempts an AGFL allocation if the
cntbt is empty.

The upcoming generic algorithm doesn't rely on the cntbt processing
of this function. It will only call this function when the cntbt
doesn't have a big enough extent or is empty and thus AGFL
allocation is the only remaining option. Tweak
xfs_alloc_ag_vextent_small() to handle a NULL cntbt cursor and skip
the cntbt logic. This facilitates use by the existing allocation
code and new code that only requires an AGFL allocation attempt.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: move small allocation helper
Brian Foster [Sat, 29 Jun 2019 02:30:19 +0000 (19:30 -0700)]
xfs: move small allocation helper

Move the small allocation helper further up in the file to avoid the
need for a function declaration. The remaining declarations will be
removed by followup patches. No functional changes.

Signed-off-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>
5 years agoxfs: clean up small allocation helper
Brian Foster [Sat, 29 Jun 2019 02:30:19 +0000 (19:30 -0700)]
xfs: clean up small allocation helper

xfs_alloc_ag_vextent_small() is kind of a mess. Clean it up in
preparation for future changes. No functional changes.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: merge xfs_trans_bmap.c into xfs_bmap_item.c
Christoph Hellwig [Sat, 29 Jun 2019 02:29:42 +0000 (19:29 -0700)]
xfs: merge xfs_trans_bmap.c into xfs_bmap_item.c

Keep all bmap item related code together.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: merge xfs_trans_rmap.c into xfs_rmap_item.c
Christoph Hellwig [Sat, 29 Jun 2019 02:29:41 +0000 (19:29 -0700)]
xfs: merge xfs_trans_rmap.c into xfs_rmap_item.c

Keep all rmap item related code together in one file.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: merge xfs_trans_refcount.c into xfs_refcount_item.c
Christoph Hellwig [Sat, 29 Jun 2019 02:29:41 +0000 (19:29 -0700)]
xfs: merge xfs_trans_refcount.c into xfs_refcount_item.c

Keep all the refcount item related code together in one file.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: merge xfs_trans_extfree.c into xfs_extfree_item.c
Christoph Hellwig [Sat, 29 Jun 2019 02:28:17 +0000 (19:28 -0700)]
xfs: merge xfs_trans_extfree.c into xfs_extfree_item.c

Keep all the extree item related code together in one file.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: merge xfs_bud_init into xfs_trans_get_bud
Christoph Hellwig [Sat, 29 Jun 2019 02:27:36 +0000 (19:27 -0700)]
xfs: merge xfs_bud_init into xfs_trans_get_bud

There is no good reason to keep these two functions separate.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: merge xfs_rud_init into xfs_trans_get_rud
Christoph Hellwig [Sat, 29 Jun 2019 02:27:36 +0000 (19:27 -0700)]
xfs: merge xfs_rud_init into xfs_trans_get_rud

There is no good reason to keep these two functions separate.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: merge xfs_cud_init into xfs_trans_get_cud
Christoph Hellwig [Sat, 29 Jun 2019 02:27:35 +0000 (19:27 -0700)]
xfs: merge xfs_cud_init into xfs_trans_get_cud

There is no good reason to keep these two functions separate.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: merge xfs_efd_init into xfs_trans_get_efd
Christoph Hellwig [Sat, 29 Jun 2019 02:27:35 +0000 (19:27 -0700)]
xfs: merge xfs_efd_init into xfs_trans_get_efd

There is no good reason to keep these two functions separate.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: remove a pointless comment duplicated above all xfs_item_ops instances
Christoph Hellwig [Sat, 29 Jun 2019 02:27:34 +0000 (19:27 -0700)]
xfs: remove a pointless comment duplicated above all xfs_item_ops instances

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: use a list_head for iclog callbacks
Christoph Hellwig [Sat, 29 Jun 2019 02:27:34 +0000 (19:27 -0700)]
xfs: use a list_head for iclog callbacks

Replace the hand grown linked list handling and cil context attachment
with the standard list_head structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: remove the xfs_log_item_t typedef
Christoph Hellwig [Sat, 29 Jun 2019 02:27:33 +0000 (19:27 -0700)]
xfs: remove the xfs_log_item_t typedef

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: don't cast inode_log_items to get the log_item
Christoph Hellwig [Sat, 29 Jun 2019 02:27:33 +0000 (19:27 -0700)]
xfs: don't cast inode_log_items to get the log_item

The cast is not type safe, and we can just dereference the first
member instead to start with.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: add a flag to release log items on commit
Christoph Hellwig [Sat, 29 Jun 2019 02:27:32 +0000 (19:27 -0700)]
xfs: add a flag to release log items on commit

We have various items that are released from ->iop_comitting.  Add a
flag to just call ->iop_release from the commit path to avoid tons
of boilerplate code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: split iop_unlock
Christoph Hellwig [Sat, 29 Jun 2019 02:27:32 +0000 (19:27 -0700)]
xfs: split iop_unlock

The iop_unlock method is called when comitting or cancelling a
transaction.  In the latter case, the transaction may or may not be
aborted.  While there is no known problem with the current code in
practice, this implementation is limited in that any log item
implementation that might want to differentiate between a commit and a
cancellation must rely on the aborted state.  The aborted bit is only
set when the cancelled transaction is dirty, however.  This means that
there is no way to distinguish between a commit and a clean transaction
cancellation.

For example, intent log items currently rely on this distinction.  The
log item is either transferred to the CIL on commit or released on
transaction cancel. There is currently no possibility for a clean intent
log item in a transaction, but if that state is ever introduced a cancel
of such a transaction will immediately result in memory leaks of the
associated log item(s).  This is an interface deficiency and landmine.

To clean this up, replace the iop_unlock method with an iop_release
method that is specific to transaction cancel.  The existing
iop_committing method occurs at the same time as iop_unlock in the
commit path and there is no need for two separate callbacks here.
Overload the iop_committing method with the current commit time
iop_unlock implementations to eliminate the need for the latter and
further simplify the interface.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: don't use xfs_trans_free_items in the commit path
Christoph Hellwig [Sat, 29 Jun 2019 02:27:31 +0000 (19:27 -0700)]
xfs: don't use xfs_trans_free_items in the commit path

While commiting items looks very similar to freeing them on error it is
a different operation, and they will diverge a bit soon.

Split out the commit case from xfs_trans_free_items, inline it into
xfs_log_commit_cil and give it a separate trace point.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: remove the dummy iop_push implementation for inode creation items
Christoph Hellwig [Sat, 29 Jun 2019 02:27:31 +0000 (19:27 -0700)]
xfs: remove the dummy iop_push implementation for inode creation items

This method should never be called, so don't waste code on it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: don't require log items to implement optional methods
Christoph Hellwig [Sat, 29 Jun 2019 02:27:30 +0000 (19:27 -0700)]
xfs: don't require log items to implement optional methods

Just check if they are present first.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: stop using XFS_LI_ABORTED as a parameter flag
Christoph Hellwig [Sat, 29 Jun 2019 02:27:30 +0000 (19:27 -0700)]
xfs: stop using XFS_LI_ABORTED as a parameter flag

Just pass a straight bool aborted instead of abusing XFS_LI_ABORTED as a
flag in function parameters.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: fix a trivial comment typo in xfs_trans_committed_bulk
Christoph Hellwig [Sat, 29 Jun 2019 02:27:29 +0000 (19:27 -0700)]
xfs: fix a trivial comment typo in xfs_trans_committed_bulk

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: add struct xfs_mount pointer to struct xfs_buf
Christoph Hellwig [Sat, 29 Jun 2019 02:27:29 +0000 (19:27 -0700)]
xfs: add struct xfs_mount pointer to struct xfs_buf

We need to derive the mount pointer from a buffer in a lot of place.
Add a direct pointer to short cut the pointer chasing.

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>
5 years agoxfs: remove the b_io_length field in struct xfs_buf
Christoph Hellwig [Sat, 29 Jun 2019 02:27:28 +0000 (19:27 -0700)]
xfs: remove the b_io_length field in struct xfs_buf

This field is now always idential to b_length.

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>
5 years agoxfs: properly type the b_log_item field in struct xfs_buf
Christoph Hellwig [Sat, 29 Jun 2019 02:27:28 +0000 (19:27 -0700)]
xfs: properly type the b_log_item field in struct xfs_buf

Now that the log code doesn't abuse this field any more we can
declare it as a struct xfs_buf_log_item pointer.

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>
5 years agoxfs: remove unused buffer cache APIs
Christoph Hellwig [Sat, 29 Jun 2019 02:27:27 +0000 (19:27 -0700)]
xfs: remove unused buffer cache APIs

Now that the log code uses bios directly we can drop various special
cases in the buffer cache code.

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>
5 years agoxfs: stop using bp naming for log recovery buffers
Christoph Hellwig [Sat, 29 Jun 2019 02:27:27 +0000 (19:27 -0700)]
xfs: stop using bp naming for log recovery buffers

Now that we don't use struct xfs_buf to hold log recovery buffer rename
the related functions and variables to just talk of a buffer instead of
using the bp name that we usually use for xfs_buf related functionality.

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>
5 years agoxfs: use bios directly to read and write the log recovery buffers
Christoph Hellwig [Sat, 29 Jun 2019 02:27:26 +0000 (19:27 -0700)]
xfs: use bios directly to read and write the log recovery buffers

The xfs_buf structure is basically used as a glorified container for
a memory allocation in the log recovery code.  Replace it with a
call to kmem_alloc_large and a simple abstraction to read into or
write from it synchronously using chained bios.

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>
5 years agoxfs: return an offset instead of a pointer from xlog_align
Christoph Hellwig [Sat, 29 Jun 2019 02:27:26 +0000 (19:27 -0700)]
xfs: return an offset instead of a pointer from xlog_align

This simplifies both the helper and the callers.  We lost a bit of
size sanity checking, but that is already covered by KASAN if needed.

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>
5 years agoxfs: move the log ioend workqueue to struct xlog
Christoph Hellwig [Sat, 29 Jun 2019 02:27:25 +0000 (19:27 -0700)]
xfs: move the log ioend workqueue to struct xlog

Move the workqueue used for log I/O completions from struct xfs_mount
to struct xlog to keep it self contained in the log code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[darrick: destroy the log workqueue after ensuring log ios are done]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: use bios directly to write log buffers
Christoph Hellwig [Sat, 29 Jun 2019 02:27:25 +0000 (19:27 -0700)]
xfs: use bios directly to write log buffers

Currently the XFS logging code uses the xfs_buf structure and
associated APIs to write the log buffers to disk.  This requires
various special cases in the log code and is generally not very
optimal.

Instead of using a buffer just allocate a kmem_alloc_larger region for
each log buffer, and use a bio and bio_vec array embedded in the iclog
structure to write the buffer to disk.  This also allows for using
the bio split and chaining case to deal with the case of a log
buffer wrapping around the end of the log.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[darrick: don't split if/else with an #endif]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: make use of the l_targ field in struct xlog
Christoph Hellwig [Sat, 29 Jun 2019 02:27:24 +0000 (19:27 -0700)]
xfs: make use of the l_targ field in struct xlog

Use the slightly shorter way to get at the buftarg for the log device
wherever we can in the log and log recovery code.

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>
5 years agoxfs: remove the syncing argument from xlog_verify_iclog
Christoph Hellwig [Sat, 29 Jun 2019 02:27:24 +0000 (19:27 -0700)]
xfs: remove the syncing argument from xlog_verify_iclog

The only caller unconditionally passes true here.

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>
5 years agoxfs: update both stat counters together in xlog_sync
Christoph Hellwig [Sat, 29 Jun 2019 02:27:23 +0000 (19:27 -0700)]
xfs: update both stat counters together in xlog_sync

Just a small bit of code tidying up.

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>
5 years agoxfs: factor out iclog size calculation from xlog_sync
Christoph Hellwig [Sat, 29 Jun 2019 02:27:23 +0000 (19:27 -0700)]
xfs: factor out iclog size calculation from xlog_sync

Split out another self-contained bit of code from xlog_sync.

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>
5 years agoxfs: factor out splitting of an iclog from xlog_sync
Christoph Hellwig [Sat, 29 Jun 2019 02:27:22 +0000 (19:27 -0700)]
xfs: factor out splitting of an iclog from xlog_sync

Split out a self-contained chunk of code from xlog_sync that calculates
the split offset for an iclog that wraps the log end and bumps the
cycles for the second half.

Use the chance to bring some sanity to the variables used to track the
split in xlog_sync by not changing the count variable, and instead use
split as the offset for the split and use those to calculate the
sizes and offsets for the two write buffers.

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>
5 years agoxfs: factor out log buffer writing from xlog_sync
Christoph Hellwig [Sat, 29 Jun 2019 02:27:22 +0000 (19:27 -0700)]
xfs: factor out log buffer writing from xlog_sync

Replace the not very useful xlog_bdstrat wrapper with a new version that
that takes care of all the common logic for writing log buffers.  Use
the opportunity to avoid overloading the buffer address with the log
relative address, and to shed the unused return value.

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>
5 years agoxfs: don't use REQ_PREFLUSH for split log writes
Christoph Hellwig [Sat, 29 Jun 2019 02:27:21 +0000 (19:27 -0700)]
xfs: don't use REQ_PREFLUSH for split log writes

If we have to split a log write because it wraps the end of the log we
can't just use REQ_PREFLUSH to flush before the first log write,
as the writes might get reordered somewhere in the I/O stack.  Issue
a manual flush in that case so that the ordering of the two log I/Os
doesn't matter.

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>
5 years agoxfs: remove XLOG_STATE_IOABORT
Christoph Hellwig [Sat, 29 Jun 2019 02:27:21 +0000 (19:27 -0700)]
xfs: remove XLOG_STATE_IOABORT

This value is the only flag in ic_state, which we otherwise use as
a state.  Switch it to a new debug-only field and also report and
actual error in the buffer in the I/O completion path.

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>
5 years agoxfs: reformat xlog_get_lowest_lsn
Christoph Hellwig [Sat, 29 Jun 2019 02:27:20 +0000 (19:27 -0700)]
xfs: reformat xlog_get_lowest_lsn

Reformat xlog_get_lowest_lsn to our usual style.

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>
5 years agoxfs: cleanup xlog_get_iclog_buffer_size
Christoph Hellwig [Sat, 29 Jun 2019 02:27:20 +0000 (19:27 -0700)]
xfs: cleanup xlog_get_iclog_buffer_size

We don't really need all the messy branches in the function, as it
really does three things, out of which 2 are common for all branches:

 1) set up mount point log buffer size and count values if not already
    done from mount options
 2) calculate the number of log headers
 3) set up all the values in struct xlog based on the above

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>
5 years agoxfs: remove the l_iclog_size_log field from struct xlog
Christoph Hellwig [Sat, 29 Jun 2019 02:27:19 +0000 (19:27 -0700)]
xfs: remove the l_iclog_size_log field from struct xlog

This field is never used, so we can simply kill it.

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>
5 years agoxfs: make mem_to_page available outside of xfs_buf.c
Christoph Hellwig [Sat, 29 Jun 2019 02:27:19 +0000 (19:27 -0700)]
xfs: make mem_to_page available outside of xfs_buf.c

Rename the function to kmem_to_page and move it to kmem.h together
with our kmem_large allocator that may either return kmalloced or
vmalloc pages.

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>
5 years agoxfs: renumber XBF_WRITE_FAIL
Christoph Hellwig [Sat, 29 Jun 2019 02:27:18 +0000 (19:27 -0700)]
xfs: renumber XBF_WRITE_FAIL

Assining a numerical value that is not close to the flags
defined near by is just asking for conflicts later on.

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>
5 years agoxfs: remove the never used _XBF_COMPOUND flag
Christoph Hellwig [Sat, 29 Jun 2019 02:27:18 +0000 (19:27 -0700)]
xfs: remove the never used _XBF_COMPOUND flag

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>
5 years agoxfs: remove the no-op spinlock_destroy stub
Christoph Hellwig [Sat, 29 Jun 2019 02:27:17 +0000 (19:27 -0700)]
xfs: remove the no-op spinlock_destroy stub

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>
5 years agoxfs: move xfs_ino_geometry to xfs_shared.h
Darrick J. Wong [Sat, 29 Jun 2019 02:25:35 +0000 (19:25 -0700)]
xfs: move xfs_ino_geometry to xfs_shared.h

The inode geometry structure isn't related to ondisk format; it's
support for the mount structure.  Move it to xfs_shared.h.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
5 years agoxfs: claim maintainership of loose files
Darrick J. Wong [Sat, 29 Jun 2019 02:25:35 +0000 (19:25 -0700)]
xfs: claim maintainership of loose files

Claim maintainership over the miscellaneous files outside of fs/xfs/
that came from xfs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
5 years agoxfs: remove unused flag arguments
Eric Sandeen [Wed, 12 Jun 2019 16:00:00 +0000 (09:00 -0700)]
xfs: remove unused flag arguments

There are several functions which take a flag argument that is
only ever passed as "0," so remove these arguments.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: remove the debug-only q_transp field from struct xfs_dquot
Christoph Hellwig [Wed, 12 Jun 2019 15:59:59 +0000 (08:59 -0700)]
xfs: remove the debug-only q_transp field from struct xfs_dquot

The field is only used for a few assertations.  Shrink the dqout
structure instead, similarly to what commit f3ca87389dbf
("xfs: remove i_transp") did for the xfs_inode.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: merge xfs_buf_zero and xfs_buf_iomove
Christoph Hellwig [Wed, 12 Jun 2019 15:59:59 +0000 (08:59 -0700)]
xfs: merge xfs_buf_zero and xfs_buf_iomove

xfs_buf_zero is the only caller of xfs_buf_iomove.  Remove support
for copying from or to the buffer in xfs_buf_iomove and merge the
two functions.

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>
5 years agoxfs: remove unused flags arg from getsb interfaces
Eric Sandeen [Wed, 12 Jun 2019 15:59:58 +0000 (08:59 -0700)]
xfs: remove unused flags arg from getsb interfaces

The flags value is always passed as 0 so remove the argument.

Signed-off-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>
5 years agoxfs: include WARN, REPAIR build options in XFS_BUILD_OPTIONS
Eric Sandeen [Wed, 5 Jun 2019 18:19:48 +0000 (11:19 -0700)]
xfs: include WARN, REPAIR build options in XFS_BUILD_OPTIONS

The XFS_BUILD_OPTIONS string, shown at module init time and
in modinfo output, does not currently include all available
build options.  So, add in CONFIG_XFS_WARN and CONFIG_XFS_REPAIR.

It has been suggested in some quarters
That this is not enough.
Well ...

Anybody who would like to see this in a sysfs file can send
a patch.  :)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: finish converting to inodes_per_cluster
Darrick J. Wong [Wed, 5 Jun 2019 18:19:36 +0000 (11:19 -0700)]
xfs: finish converting to inodes_per_cluster

Finish converting all the old inode_cluster_size >> inopblog users to
inodes_per_cluster.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
5 years agoxfs: fix inode_cluster_size rounding mayhem
Darrick J. Wong [Wed, 5 Jun 2019 18:19:35 +0000 (11:19 -0700)]
xfs: fix inode_cluster_size rounding mayhem

inode_cluster_size is supposed to represent the size (in bytes) of an
inode cluster buffer.  We avoid having to handle multiple clusters per
filesystem block on filesystems with large blocks by openly rounding
this value up to 1 FSB when necessary.  However, we never reset
inode_cluster_size to reflect this new rounded value, which adds to the
potential for mistakes in calculating geometries.

Fix this by setting inode_cluster_size to reflect the rounded-up size if
needed, and special-case the few places in the sparse inodes code where
we actually need the smaller value to validate on-disk metadata.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
5 years agoxfs: refactor inode geometry setup routines
Darrick J. Wong [Wed, 5 Jun 2019 18:19:35 +0000 (11:19 -0700)]
xfs: refactor inode geometry setup routines

Migrate all of the inode geometry setup code from xfs_mount.c into a
single libxfs function that we can share with xfsprogs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
5 years agoxfs: separate inode geometry
Darrick J. Wong [Wed, 5 Jun 2019 18:19:34 +0000 (11:19 -0700)]
xfs: separate inode geometry

Separate the inode geometry information into a distinct structure.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
5 years agofuse: copy_file_range needs to strip setuid bits and update timestamps
Amir Goldstein [Wed, 5 Jun 2019 15:04:51 +0000 (08:04 -0700)]
fuse: copy_file_range needs to strip setuid bits and update timestamps

Like ->write_iter(), we update mtime and strip setuid of dst file before
copy and like ->read_iter(), we update atime of src file after copy.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Acked-by: Miklos Szeredi <miklos@szeredi.hu>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>