]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/log
thirdparty/xfsprogs-dev.git
7 years agoxfs_logprint: remove the printing of transaction type
Hou Tao [Mon, 19 Sep 2016 06:00:04 +0000 (16:00 +1000)] 
xfs_logprint: remove the printing of transaction type

THe kernel stopped using meaningful types in transaction headers
when delayed logging was introduced. Since then the only transaction
type that reaches the journal is a "Checkpoint" type. Since then,
we've effectivey broken the transaction type printing for newer
kernels, and the current kernels don't even have transaction types
internally. Hence this logprint function is stale, broken, and
causing us problems.

This patch removes the transaction type parsing. If a user needs
this information from logprint, we can still build a binary from a
prior version that correctly decoded the transaction type (e.g.
3.2.1) for that purpose.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agolibxfs: move iswritable "fatal" decision to caller
Eric Sandeen [Mon, 19 Sep 2016 05:53:52 +0000 (15:53 +1000)] 
libxfs: move iswritable "fatal" decision to caller

Simplify platform_check_iswritable by moving the
"fatal" decision up to the (one) caller.  In other words,
simply return whether mounted+writable is true, and
return 1 if so.  Caller decides what to do with that info
based on /its/ "fatal" argument.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfsprogs: Release 4.8.0-rc1 v4.8.0-rc1
Dave Chinner [Thu, 8 Sep 2016 22:16:29 +0000 (08:16 +1000)] 
xfsprogs: Release 4.8.0-rc1

Update all the necessary files for a 4.8.0-rc1 release. Also,
replace all the mailing list contact details with the new list
address, and the project website with xfs.org.

Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_db: pass the inode cluster offset when copying inodes
Darrick J. Wong [Thu, 8 Sep 2016 00:22:28 +0000 (10:22 +1000)] 
xfs_db: pass the inode cluster offset when copying inodes

In copy_inode_chunk, we try to determine whether or not an inode is
free as part of copying the inode records.  The macros involved in
testing ir_free require both the inode record and the offset of an
inode within that chunk.  Prior to sparse inode support, the loop
index "i" was also the inode chunk offset; however, when sparse
support was added, "i" became the inode offset within a cluster and
"ioff" became the inode cluster offset within an inode chunk.
Therefore, it is necessary to pass "ioff + i" to do the free-ness
calculation correctly.

This was discovered while trying to take metadumps of fs images for
scrub testing.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_repair: don't crash on ENOSPC rebuilding a btree
Darrick J. Wong [Thu, 8 Sep 2016 00:22:28 +0000 (10:22 +1000)] 
xfs_repair: don't crash on ENOSPC rebuilding a btree

During btree rebuilding, the cursor setup function checks ext_ptr to
report ENOSPC problems when it grabs the first extent for the btree.
However, subsequent grabs for free space don't check ext_ptr and so we
segfault if there's no space.  Therefore, move the ENOSPC check into
the loop so that we always complain about insufficient space instead
of just crashing.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agolibxfs/linux.c: Replace use of ustat by stat
Felix Janda [Thu, 8 Sep 2016 00:22:28 +0000 (10:22 +1000)] 
libxfs/linux.c: Replace use of ustat by stat

ustat has been used to check whether a device file is mounted.
The function is deprecated and not supported by uclibc and musl.
Now do the check using the *mntent functions.

Based on patch by Natanael Copa <ncopa@alpinelinux.org>.

Signed-off-by: Felix Janda <felix.janda@posteo.de>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agodb: write via array indexing doesn't work
Dave Chinner [Thu, 8 Sep 2016 00:22:19 +0000 (10:22 +1000)] 
db: write via array indexing doesn't work

This command to write a specific AGFL index:

# xfs_db -x -c "agfl 0" -c "write -d bno[32] 78" /dev/ram0

doesn't write to array index 32 - it incorrectly writes to
/somewhere/ in the entire array range.

The issue here is that the write_struct() code assumes that the
object it is printing always a structure member and any array
indexes will be exposed as children of the parent type. This works
just fine for structures with internal arrays, but when the type
being decoded is an array, we get a direct reference to the offset
to be written in the parent object.

Hence we need to take into account the array index returned by the
parent object parsing when calculating the size of the region to be
modified rather than using fcount() as that results in the size
always being set to the size of the entire array and the
modification being written to the wrong place.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_db: properly set dquot_buf when operating on dquot
Eric Sandeen [Thu, 8 Sep 2016 00:22:18 +0000 (10:22 +1000)] 
xfs_db: properly set dquot_buf when operating on dquot

The earlier commit:

66a40d02 db: verify and calculate dquot CRCs

added a "dquot_buf" to the iocur to specify when we were operating
on a dquot and thus handle dquot CRC updates - but nothing ever
actually set dquot_buf to a non-zero value.

Without doing so, we don't recalculate the dquot crc when
changing contents of a dquot:

# xfs_db -x -c "dquot -u 500" -c "p crc" -c "write diskdq.bcount 2" \
    -c "p crc" crctestfile
crc = 0xfd293c68 (correct)
diskdq.bcount = 2
crc = 0xfd293c68 (correct)

[ the "(correct)" tag is another, different issue ]

# xfs_db -x -c "dquot -u 500" -c "p crc" crctestfile
Metadata CRC error detected at xfs_dquot block 0xd8/0x1000
crc = 0xfd293c68 (bad)

With this change, dquot CRCs are properly recalculated in write_cur.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_quota: fix missing break after foreign_allowed option
Zorro Lang [Thu, 8 Sep 2016 00:21:35 +0000 (10:21 +1000)] 
xfs_quota: fix missing break after foreign_allowed option

New quota "-f" has been brought in by:

  29647c8 xfs_quota: add capabilities for use on non-XFS filesystems

But Coverity Scan find a missing break in quota/init.c: init()
function.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_db: add crc manipulation commands
Eric Sandeen [Fri, 26 Aug 2016 01:20:39 +0000 (11:20 +1000)] 
xfs_db: add crc manipulation commands

This adds a new "crc" command to xfs_db for CRC-enabled filesystems.

If a structure has a CRC field, we can validate it, invalidate/corrupt
it, or revalidate/rewrite it:

xfs_db> sb 0
xfs_db> crc -v
crc = 0x796c814f (correct)
xfs_db> crc -i
Metadata CRC error detected at block 0x0/0x200
crc = 0x796c8150 (bad)
xfs_db> crc -r
crc = 0x796c814f (correct)

(-i and -r require "expert" write-capable mode)

This requires temporarily replacing the write verifier with
a dummy which won't recalculate the CRC on the way to disk.

It also required me to write a new flist function, which is
totally foreign to me, so hopefully done right - but it seems
to work here.

[ dchinner: rewrite write_cur() to also skip CRC updates on dquots,
  fix set-but-unused warnings, use iotop_cur safely. ]

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_quota: certain commands must always be available
Bill O'Donnell [Fri, 26 Aug 2016 01:20:37 +0000 (11:20 +1000)] 
xfs_quota: certain commands must always be available

Add CMD_ALL_FSTYPES to enable basic xfs_quota commands (e.g. help,
quit) to be run regardless of the filesystem type we are operating
on.

Use CMD_FLAG_FOREIGN_OK on commands suitable for foreign filesystems.
Refactor init_check_command in quota/init.c for clarity.

[ dchinner: CMD_SKIP_CHECK -> CMD_ALL_FSTYPES ]

Signed-off-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_quota: add capabilities for use on non-XFS filesystems
Bill O'Donnell [Fri, 26 Aug 2016 01:20:32 +0000 (11:20 +1000)] 
xfs_quota: add capabilities for use on non-XFS filesystems

This patch allows xfs_quota to be used on ext4 for project quota
testing in xfstests.  It was based on work originally from Dave
Chinner. As a part of its support for foreign filesystems xfs_quota
is modified with a "-f" command line flag to enable select commands
on those filesystems.

This requires us to discriminate different filesystem types when
walking the fileystem table during argument processing as the table
is now populated with mounted non-XFS filesystems. We should only
select a foreign filesystem mount point if the "-f" flag is present
on the command line.

This patch also updates the usage and man page information
for the new CLI flag appropriately.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_quota: wire up XFS_GETQSTATV
Eric Sandeen [Fri, 26 Aug 2016 01:20:28 +0000 (11:20 +1000)] 
xfs_quota: wire up XFS_GETQSTATV

The new XFS_GETQSTATV quotactl, available since kernel v3.12,
was never implemented in xfs_quota, and the "state" command
continues to use XFS_GETQSTAT, which cannot report both
group & project quota on newer formats.

The new call has room for all 3 quota types (user, group, and
quota), vs just two, where previously project and quota
overlapped.

So:

First, try XFS_GETQSTATV.
If it passes, we have all the information we need, and we print
it. state_qfilestat() is modified to take the newer structure.

If it fails, try XFS_GETQSTAT.  If that passes, we are on an
older kernel with neither XFS_GETQSTATV nor the on-disk project
quota inode.  We copy the available information into the newer
statv structure, carefully determining wither group or project
(or neither) is actually active, and print it with the same
state_qfilestat routine.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_metadump: don't warn about unobfuscated log with -o
Eric Sandeen [Fri, 26 Aug 2016 01:20:17 +0000 (11:20 +1000)] 
xfs_metadump: don't warn about unobfuscated log with -o

It makes no sense to warn about un-obfuscated logs
when we asked xfs_metadump to not obfuscate metadata:

# xfs_metadump -o /dev/loop2 bad.metadump
xfs_metadump: Filesystem log is dirty; image will contain unobfuscated metadata in log.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_repair: fix naming problems in repair/rmap.c
Darrick J. Wong [Fri, 26 Aug 2016 01:20:17 +0000 (11:20 +1000)] 
xfs_repair: fix naming problems in repair/rmap.c

The utility functions in repair/rmap.c should all have a prefix
of 'rmap_' so that they are easily identifiable.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agomisc: fix libxfs api violations
Darrick J. Wong [Fri, 26 Aug 2016 01:19:55 +0000 (11:19 +1000)] 
misc: fix libxfs api violations

Fix all the client programs to use 'libxfs_' prefixes for non-inline
function calls and to negate integer return codes.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agomisc: fix Coverity errors
Darrick J. Wong [Fri, 26 Aug 2016 01:18:12 +0000 (11:18 +1000)] 
misc: fix Coverity errors

Fix various code sloppinesses pointed out by Coverity,
and fix an incorrect comment/debug message.

Coverity-id: 1371628 - 1371638
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agolibxcmd: fix mount option parsing to find rt/log devices
Darrick J. Wong [Fri, 26 Aug 2016 01:17:46 +0000 (11:17 +1000)] 
libxcmd: fix mount option parsing to find rt/log devices

It turns out that glibc's hasmntopt implementation returns NULL
if the opt parameter ends with an equals ('=').  Therefore, we
cannot directly search for the option 'rtdev='; we must instead
have hasmntopt look for 'rtdev' and look for the trailing equals
sign ourselves.  This fixes xfs_info's reporting of external
log and realtime device paths, and xfs_scrub will need it for
data block scrubbing of realtime extents.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: simple btree query range should look right if LE lookup fails
Darrick J. Wong [Fri, 26 Aug 2016 01:17:21 +0000 (11:17 +1000)] 
xfs: simple btree query range should look right if LE lookup fails

If the initial LOOKUP_LE in the simple query range fails to find
anything, we should attempt to increment the btree cursor to see
if there actually /are/ records for what we're trying to find.
Without this patch, a bnobt range query of (0, $agsize) returns
no results because the leftmost record never has a startblock
of zero.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: fix some key handling problems in _btree_simple_query_range
Darrick J. Wong [Fri, 26 Aug 2016 01:16:52 +0000 (11:16 +1000)] 
xfs: fix some key handling problems in _btree_simple_query_range

We only need the record's high key for the first record that we look
at; for all records, we /definitely/ need the regular record key.
Therefore, fix how the simple range query function gets its keys.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: don't perform lookups on zero-height btrees
Darrick J. Wong [Fri, 26 Aug 2016 01:16:41 +0000 (11:16 +1000)] 
xfs: don't perform lookups on zero-height btrees

If the caller passes in a cursor to a zero-height btree (which is
impossible), we never set block to anything but NULL, which causes the
later dereference of it to crash.  Instead, just return -EFSCORRUPTED.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agomkfs.xfs: create filesystems with reverse-mappings rmap-for-4.8
Darrick J. Wong [Fri, 19 Aug 2016 00:54:53 +0000 (10:54 +1000)] 
mkfs.xfs: create filesystems with reverse-mappings

Originally-From: Dave Chinner <dchinner@redhat.com>

Create v5 filesystems with rmapbt turned on.  Document the rmapbt
options to mkfs, and initialize the extra field we added for reflink
support.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
[darrick.wong@oracle.com: split patch, add commit message and extra fields]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agomkfs: set agsize prior to calculating minimum log size
Darrick J. Wong [Fri, 19 Aug 2016 00:53:14 +0000 (10:53 +1000)] 
mkfs: set agsize prior to calculating minimum log size

Each btree has its own maxlevels variable.  Since the level count of
certain btrees depend on agblocks, it's necessary to know the AG size
prior to calculating the log reservations.  These reservations are
needed to calculate the log size and the kernel will refuse to mount
if we guess too low, so stuff in the real agsize when we're formatting
the log.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_repair: check for impossible rmap record field combinations
Darrick J. Wong [Fri, 19 Aug 2016 00:52:41 +0000 (10:52 +1000)] 
xfs_repair: check for impossible rmap record field combinations

Make sure there are no records or keys with impossible field
combinations, such as non-inode records with offsets or flags.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_repair: look for mergeable rmaps
Darrick J. Wong [Fri, 19 Aug 2016 00:52:26 +0000 (10:52 +1000)] 
xfs_repair: look for mergeable rmaps

Check for adjacent mergeable rmaps; this is a sign that we've
screwed up somehow.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_repair: merge data & attr fork reverse mappings
Darrick J. Wong [Fri, 19 Aug 2016 00:52:06 +0000 (10:52 +1000)] 
xfs_repair: merge data & attr fork reverse mappings

Merge data and attribute fork reverse mappings.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_repair: add per-AG btree blocks to rmap data and add to rmapbt
Darrick J. Wong [Fri, 19 Aug 2016 00:51:24 +0000 (10:51 +1000)] 
xfs_repair: add per-AG btree blocks to rmap data and add to rmapbt

Since we can't know the location of the new per-AG btree blocks prior
to constructing the rmapbt, we must record raw reverse-mapping data for
btree blocks while the new btrees are under construction.  After the
rmapbt has been rebuilt, merge the btree rmap entries into the rmapbt
with the libxfs code.

Also refactor the freelist fixing code since we need it to tidy up
the AGFL after each rmapbt allocation.

Use libxfs_rmap_alloc to add rmap records for AG metadata blocks
because it knows how to merge adjacent rmaps.  This particular bug was
discovered while running xfs_repair twice on generic/175 wherein block
X was originally allocated to the rmapbt, then X+1 got allocated to
the rmapbt when we expanded it to hold all the entries for the rmapbt
blocks.

[dchinner: libxfs'ify the libxfs calls.]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_repair: rebuild reverse-mapping btree
Darrick J. Wong [Fri, 19 Aug 2016 00:43:24 +0000 (10:43 +1000)] 
xfs_repair: rebuild reverse-mapping btree

Rebuild the reverse-mapping btree with the rmap observations
corresponding to file extents, bmbt blocks, and fixed per-AG metadata.

Leave a few empty slots in each rmapbt leaf when we're rebuilding
the rmapbt so that we can insert records for the AG metadata blocks
without causing too many btree splits.  This (hopefully) prevents the
situation where running xfs_repair greatly increases the size of the
btree.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_repair: check existing rmapbt entries against observed rmaps
Darrick J. Wong [Fri, 19 Aug 2016 00:33:49 +0000 (10:33 +1000)] 
xfs_repair: check existing rmapbt entries against observed rmaps

Once we've finished collecting reverse mapping observations from the
metadata scan, check those observations against the rmap btree
(particularly if we're in -n mode) to detect rmapbt problems.

[dchinner: libxfs'ify the various libxfs calls. ]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_repair: add fixed-location per-AG rmaps
Darrick J. Wong [Fri, 19 Aug 2016 00:20:03 +0000 (10:20 +1000)] 
xfs_repair: add fixed-location per-AG rmaps

Add reverse-mappings for fixed-location per-AG metadata such as inode
chunks, superblocks, and the log to the raw rmap list, then merge the
raw rmap data (which also has the BMBT data) into the main rmap list.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_repair: add inode bmbt block rmaps
Darrick J. Wong [Fri, 19 Aug 2016 00:10:15 +0000 (10:10 +1000)] 
xfs_repair: add inode bmbt block rmaps

Record BMBT blocks in the raw rmap list.

[dchinner: remove unused lastowner/lastoffset variables from scan.c]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_repair: record and merge raw rmap data
Darrick J. Wong [Fri, 19 Aug 2016 00:09:23 +0000 (10:09 +1000)] 
xfs_repair: record and merge raw rmap data

Since we still allow merging of BMBT block, AG metadata, and AG btree
block rmaps, provide a facility to collect these raw observations and
merge them (with maximal length) into the main rmap list.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_repair: collect reverse-mapping data for refcount/rmap tree rebuilding
Darrick J. Wong [Fri, 19 Aug 2016 00:05:56 +0000 (10:05 +1000)] 
xfs_repair: collect reverse-mapping data for refcount/rmap tree rebuilding

Collect reverse-mapping data for the entire filesystem so that we can
later check and rebuild the reference count tree and the reverse mapping
tree.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_repair: create a slab API for allocating arrays in large chunks
Darrick J. Wong [Fri, 19 Aug 2016 00:03:21 +0000 (10:03 +1000)] 
xfs_repair: create a slab API for allocating arrays in large chunks

Create a slab-based array and a bag-of-pointers data structure to
facilitate rapid linear scans of reverse-mapping data for later
reconstruction of the refcount and rmap btrees.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_repair: fix fino_bno calculation when rmapbt is enabled
Darrick J. Wong [Thu, 18 Aug 2016 23:57:04 +0000 (09:57 +1000)] 
xfs_repair: fix fino_bno calculation when rmapbt is enabled

In xfs_repair, we calculate where we think mkfs put the root inode
block.  However, the rmapbt component doesn't account for the fact
that mkfs reserved 2 AGFL blocks for the rmapbt, so its calculation
is off by a bit.  This leads to it complaining (incorrectly) about the
root inode block being in the wrong place and blowing up.

[dchinner: small comment update to indicate AGFL block accounting]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_repair: use rmap btree data to check block types
Darrick J. Wong [Thu, 18 Aug 2016 23:53:30 +0000 (09:53 +1000)] 
xfs_repair: use rmap btree data to check block types

Originally-From: Dave Chinner <dchinner@redhat.com>

Use the rmap btree to pre-populate the block type information so that
when repair iterates the primary metadata, we can confirm the block
type.

Ensure that we remove the flag bits from blockcount before using the
length field.

When we're processing rmap records, we set the bmap state of
the entire extent, not just the first block of the extent.  This
enables us to catch improperly overlapping rmap records and later to
ensure that the entire primary metadata extent matches (owner-wise)
the reverse mapping.  It also enables us to catch the case where the
rmapbt maps something that isn't pointed to by primary metadata.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
[darrick.wong@oracle.com: split patch, strip flag bits from blockcount]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_logprint: support rmap redo items
Darrick J. Wong [Thu, 18 Aug 2016 23:50:22 +0000 (09:50 +1000)] 
xfs_logprint: support rmap redo items

Print reverse mapping update redo items.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_io: add rmap-finish error injection type
Darrick J. Wong [Thu, 18 Aug 2016 23:48:44 +0000 (09:48 +1000)] 
xfs_io: add rmap-finish error injection type

Add XFS_ERRTAG_RMAP_FINISH_ONE to the types of errors we can inject.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_growfs: report rmapbt presence
Darrick J. Wong [Thu, 18 Aug 2016 23:48:32 +0000 (09:48 +1000)] 
xfs_growfs: report rmapbt presence

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_db: introduce the 'fsmap' command to find what owns a set of fsblocks
Darrick J. Wong [Thu, 18 Aug 2016 23:47:57 +0000 (09:47 +1000)] 
xfs_db: introduce the 'fsmap' command to find what owns a set of fsblocks

Introduce a new 'fsmap' command to the fs debugger that will query the
rmap btree to report the file/metadata extents mapped to a range of
physical blocks.

[dchinner: xfs_rmap_query_range -> libxfs_rmap_query_range]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_db: copy the rmap btree
Darrick J. Wong [Thu, 18 Aug 2016 23:39:03 +0000 (09:39 +1000)] 
xfs_db: copy the rmap btree

Copy the rmapbt when we're metadumping the filesystem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_db: spot check rmapbt
Darrick J. Wong [Thu, 18 Aug 2016 23:36:46 +0000 (09:36 +1000)] 
xfs_db: spot check rmapbt

Check the rmapbt for obvious errors.  We're leaving thorough checks
such as comparing the primary metadata against the rmapbt contents
for newer things like xfs_repair.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_db: display rmap btree contents
Darrick J. Wong [Thu, 18 Aug 2016 23:33:41 +0000 (09:33 +1000)] 
xfs_db: display rmap btree contents

Originally-From: Dave Chinner <dchinner@redhat.com>

Teach the debugger how to dump the reverse-mapping btree contents.
Decode the extra fields in the rmapbt records and keys now that we
support reflink.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
[darrick: split patch, add commit message, decode extra fields]
[darrick: support overlapped interval btree fields]
[darrick: move unwritten bit to rm_offset]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agolibxfs: add deferred ops item handlers for userspace
Darrick J. Wong [Thu, 18 Aug 2016 23:32:31 +0000 (09:32 +1000)] 
libxfs: add deferred ops item handlers for userspace

Add deferred ops handlers for userspace, which simply call back
into the libxfs functions.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agolibxfs: fix various oddities in the kernel import
Darrick J. Wong [Thu, 18 Aug 2016 23:31:29 +0000 (09:31 +1000)] 
libxfs: fix various oddities in the kernel import

Fix some minor anomalies in the kernel -> xfsprogs import of the
4.8 libxfs code.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: remove OWN_AG rmap when allocating a block from the AGFL
Darrick J. Wong [Thu, 18 Aug 2016 23:30:57 +0000 (09:30 +1000)] 
xfs: remove OWN_AG rmap when allocating a block from the AGFL

When we're really tight on space, xfs_alloc_ag_vextent_small() can
allocate a block from the AGFL and give it to the caller.  Since the
caller is never the AGFL-fixing method, we must remove the OWN_AG
reverse mapping because it will clash with whatever rmap the caller
wants to set up.  This bug was discovered by running generic/299
repeatedly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: store rmapbt block count in the AGF
Darrick J. Wong [Thu, 18 Aug 2016 23:30:47 +0000 (09:30 +1000)] 
xfs: store rmapbt block count in the AGF

Track the number of blocks used for the rmapbt in the AGF.  When we
get to the AG reservation code we need this counter to quickly
make our reservation during mount.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_io: add free-extent error injection type
Darrick J. Wong [Thu, 18 Aug 2016 23:29:55 +0000 (09:29 +1000)] 
xfs_io: add free-extent error injection type

Add XFS_ERRTAG_FREE_EXTENT to the types of errors we can inject.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoman: document the DAX fsxattr inode flag
Darrick J. Wong [Thu, 18 Aug 2016 23:29:41 +0000 (09:29 +1000)] 
man: document the DAX fsxattr inode flag

Document the new inode flag in struct fsxattr for DAX.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_logprint: fix formatting issues with the EFI printing code
Darrick J. Wong [Thu, 18 Aug 2016 23:29:28 +0000 (09:29 +1000)] 
xfs_logprint: fix formatting issues with the EFI printing code

Fix some formatting issues with the EFI handling functions.
This is a purely mechanical whitespace fix, no code changes
aside from adding 'static'.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_logprint: move the EFI copying/printing functions to a redo items file
Darrick J. Wong [Thu, 18 Aug 2016 23:28:41 +0000 (09:28 +1000)] 
xfs_logprint: move the EFI copying/printing functions to a redo items file

Move the functions that handle EFI items into a separate file to
avoid cluttering up log_misc.c even more when we start adding the
other redo item types.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agomkfs: fix library ordering
Darrick J. Wong [Thu, 18 Aug 2016 23:28:06 +0000 (09:28 +1000)] 
mkfs: fix library ordering

libblkid depends on libuuid, so we must specify -lblkid before -luuid.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_repair: preserve in-core meta_uuid while zeroing unused sb portions
Darrick J. Wong [Thu, 18 Aug 2016 23:27:30 +0000 (09:27 +1000)] 
xfs_repair: preserve in-core meta_uuid while zeroing unused sb portions

If we zero unused parts of the superblock, we must preserve meta_uuid
across the zeroing because meta_uuid is used to verify the v5 format
checksums even on non-metauuid filesystems.  If we don't, the next
thing that happens is that all metadata fails in the verifier and the
whole filesystem is "toast".

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_io: bmap should print 'delalloc', not '-2'
Darrick J. Wong [Thu, 18 Aug 2016 23:26:52 +0000 (09:26 +1000)] 
xfs_io: bmap should print 'delalloc', not '-2'

The bmap command (without -v) should print 'delalloc' and not -2
for the physical block number of an extent.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs_buflock: add a tool that can be used to find buffer deadlocks
Darrick J. Wong [Thu, 18 Aug 2016 23:26:19 +0000 (09:26 +1000)] 
xfs_buflock: add a tool that can be used to find buffer deadlocks

Add a (rough) python script that can parse the output of:
# trace-cmd -e xfs_buf_*lock*' <other tracepoints>
to identify xfs_buf deadlocks between XFS threads.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agolibxfs: fix xfs_isset pointer calculation
Darrick J. Wong [Thu, 18 Aug 2016 23:20:46 +0000 (09:20 +1000)] 
libxfs: fix xfs_isset pointer calculation

In the macro xfs_isset, the variable 'a' is a pointer to an array
type.  However, the bit offset calculation uses sizeof(a), which
returns the size of the pointer, not the size of an array element.
Fix this, which also fixes the problem where xfs_check spits out
bogus "rtblock X expected type unknown, got rtfree" messages.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: move (and rename) the deferred bmap-free tracepoints libxfs-4.8-sync
Darrick J. Wong [Wed, 10 Aug 2016 05:04:43 +0000 (15:04 +1000)] 
xfs: move (and rename) the deferred bmap-free tracepoints

Source kernel commit: 3481b68285238054be519ad0c8cad5cc2425e26c

Rename the deferred bmap-free to extent_free and make them only
trigger when we're really running deferred ops.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: remove the extents array from the rmap update done log item
Darrick J. Wong [Wed, 10 Aug 2016 04:54:46 +0000 (14:54 +1000)] 
xfs: remove the extents array from the rmap update done log item

Source kernel commit: 722e251770306ee325151b28e40b5d7e5497d687

Nothing ever uses the extent array in the rmap update done redo
item, so remove it before it is fixed in the on-disk log format.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: in btree_lshift, only allocate temporary cursor when needed
Darrick J. Wong [Wed, 10 Aug 2016 04:53:46 +0000 (14:53 +1000)] 
xfs: in btree_lshift, only allocate temporary cursor when needed

Source kernel commit: c1d22ae89cf6086d6a457b3b9241fcb36ebddd14

We only need the temporary cursor in _btree_lshift if we're shifting
in an overlapped btree.  Therefore, factor that into a single block
of code so we avoid unnecessary cursor duplication.

Also fix use of the wrong cursor when checking for corruption in
xfs_btree_rshift().

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: remove unnecesary lshift/rshift key initialization
Darrick J. Wong [Wed, 10 Aug 2016 04:52:46 +0000 (14:52 +1000)] 
xfs: remove unnecesary lshift/rshift key initialization

Source kernel commit: 1f704b2b47822435765aee16f120ae06cc40e78c

In the lshift/rshift functions we don't use the key variable for
anything now, so remove the variable and its initializer.  The
update_keys functions figure out the key for a block on their own.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: remove the get*keys and update_keys btree ops pointers
Darrick J. Wong [Wed, 10 Aug 2016 04:52:41 +0000 (14:52 +1000)] 
xfs: remove the get*keys and update_keys btree ops pointers

Source kernel commit: 973b83194bf12f7e315aace57ae2096ff7b82360

These are internal btree functions; we don't need them to be
dispatched via function pointers.  Make them static again and
just check the overlapped flag to figure out what we need to
do.  The strategy behind this patch was suggested by Christoph.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Suggested-by: Christoph Hellwig <hch@infradead.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: enable the rmap btree functionality
Darrick J. Wong [Wed, 10 Aug 2016 04:52:38 +0000 (14:52 +1000)] 
xfs: enable the rmap btree functionality

Source kernel commit: 1c0607ace9bd639d22ad1bd453ffeb7d55913f88

Originally-From: Dave Chinner <dchinner@redhat.com>

Add the feature flag to the supported matrix so that the kernel can
mount and use rmap btree enabled filesystems

Signed-off-by: Dave Chinner <dchinner@redhat.com>
[darrick.wong@oracle.com: move the experimental tag]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: don't update rmapbt when fixing agfl
Darrick J. Wong [Wed, 10 Aug 2016 04:52:20 +0000 (14:52 +1000)] 
xfs: don't update rmapbt when fixing agfl

Source kernel commit: 04f130605ff6fb01a93a0885607921df9c463eed

Allow a caller of xfs_alloc_fix_freelist to disable rmapbt updates
when fixing the AG freelist.  xfs_repair needs this during phase 5
to be able to adjust the freelist while it's reconstructing the rmap
btree; the missing entries will be added back at the very end of
phase 5 once the AGFL contents settle down.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: add rmap btree geometry feature flag
Darrick J. Wong [Wed, 10 Aug 2016 04:52:16 +0000 (14:52 +1000)] 
xfs: add rmap btree geometry feature flag

Source kernel commit: 5d650e90a101557a7a652989c6d5eb657ae2476b

Originally-From: Dave Chinner <dchinner@redhat.com>

So xfs_info and other userspace utilities know the filesystem is
using this feature.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: propagate bmap updates to rmapbt
Darrick J. Wong [Wed, 10 Aug 2016 04:52:14 +0000 (14:52 +1000)] 
xfs: propagate bmap updates to rmapbt

Source kernel commit: 9c19464469556a0cd342fc40a24926ab46d7d243

When we map, unmap, or convert an extent in a file's data or attr
fork, schedule a respective update in the rmapbt.  Previous versions
of this patch required a 1:1 correspondence between bmap and rmap,
but this is no longer true as we now have ability to make interval
queries against the rmapbt.

We use the deferred operations code to handle redo operations
atomically and deadlock free.  This plumbs in all five rmap actions
(map, unmap, convert extent, alloc, free); we'll use the first three
now for file data, and reflink will want the last two.  We also add
an error injection site to test log recovery.

Finally, we need to fix the bmap shift extent code to adjust the
rmaps correctly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: enable the xfs_defer mechanism to process rmaps to update
Darrick J. Wong [Wed, 10 Aug 2016 04:49:44 +0000 (14:49 +1000)] 
xfs: enable the xfs_defer mechanism to process rmaps to update

Source kernel commit: f8dbebef98f0b960a0e91d6b8d45c288c377797b

Connect the xfs_defer mechanism with the pieces that we'll need to
handle deferred rmap updates.  We'll wire up the existing code to
our new deferred mechanism later.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: create rmap update intent log items
Darrick J. Wong [Wed, 10 Aug 2016 04:49:16 +0000 (14:49 +1000)] 
xfs: create rmap update intent log items

Source kernel commit: 5880f2d78ff17c6ee7c7f6d4071bfd13090c264c

Create rmap update intent/done log items to record redo information in
the log.  Because we need to roll transactions between updating the
bmbt mapping and updating the reverse mapping, we also have to track
the status of the metadata updates that will be recorded in the
post-roll transactions, just in case we crash before committing the
final transaction.  This mechanism enables log recovery to finish what
was already started.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: add rmap btree insert and delete helpers
Darrick J. Wong [Wed, 10 Aug 2016 04:49:13 +0000 (14:49 +1000)] 
xfs: add rmap btree insert and delete helpers

Source kernel commit: abf09233817b5ea1241db0c187136d3b4738d218

Add a couple of helper functions to encapsulate rmap btree insert and
delete operations.  Add tracepoints to the update function.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: convert unwritten status of reverse mappings
Darrick J. Wong [Wed, 10 Aug 2016 04:47:47 +0000 (14:47 +1000)] 
xfs: convert unwritten status of reverse mappings

Source kernel commit: fb7d9267692a5cdc01648bf4c8fdca51054bc0f2

Provide a function to convert an unwritten rmap extent to a real one
and vice versa.

[ dchinner: Note that this algorithm and code was derived from the
existing bmapbt unwritten extent conversion code in
xfs_bmap_add_extent_unwritten_real(). ]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: remove an extent from the rmap btree
Darrick J. Wong [Wed, 10 Aug 2016 04:45:20 +0000 (14:45 +1000)] 
xfs: remove an extent from the rmap btree

Source kernel commit: f922cd90b82c5e78a860f194728d4dadc8575106

Originally-From: Dave Chinner <dchinner@redhat.com>

Now that we have records in the rmap btree, we need to remove them
when extents are freed. This needs to find the relevant record in
the btree and remove/trim/split it accordingly.

[darrick.wong@oracle.com: make rmap routines handle the enlarged keyspace]
[dchinner: remove remaining unused debug printks]
[darrick: fix a bug when growfs in an AG with an rmap ending at EOFS]

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: add an extent to the rmap btree
Darrick J. Wong [Wed, 10 Aug 2016 04:45:17 +0000 (14:45 +1000)] 
xfs: add an extent to the rmap btree

Source kernel commit: 0a1b0b3855cf74bb11243076b00178a0f1a0320e

Originally-From: Dave Chinner <dchinner@redhat.com>

Now all the btree, free space and transaction infrastructure is in
place, we can finally add the code to insert reverse mappings to the
rmap btree. Freeing will be done in a separate patch, so just the
addition operation can be focussed on here.

[darrick: handle owner offsets when adding rmaps]
[dchinner: remove remaining debug printk statements]
[darrick: move unwritten bit to rm_offset]

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: teach rmapbt to support interval queries
Darrick J. Wong [Wed, 10 Aug 2016 04:38:58 +0000 (14:38 +1000)] 
xfs: teach rmapbt to support interval queries

Source kernel commit: c543838a1e00a5f8791e59ae570b1030d70906f2

Now that the generic btree code supports querying all records within a
range of keys, use that functionality to allow us to ask for all the
extents mapped to a range of physical blocks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: support overlapping intervals in the rmap btree
Darrick J. Wong [Wed, 10 Aug 2016 04:38:58 +0000 (14:38 +1000)] 
xfs: support overlapping intervals in the rmap btree

Source kernel commit: cfed56ae5f410cd6c1601712a9ed4645b71b170c

Now that the generic btree code supports overlapping intervals, plug
in the rmap btree to this functionality.  We will need it to find
potential left neighbors in xfs_rmap_{alloc,free} later in the patch
set.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: add rmap btree operations
Darrick J. Wong [Wed, 10 Aug 2016 04:38:56 +0000 (14:38 +1000)] 
xfs: add rmap btree operations

Source kernel commit: 4b8ed67794fe57b23801c65f4ea5b0f0b1f0dbab

Originally-From: Dave Chinner <dchinner@redhat.com>

Implement the generic btree operations needed to manipulate rmap
btree blocks. This is very similar to the per-ag freespace btree
implementation, and uses the AGFL for allocation and freeing of
blocks.

Adapt the rmap btree to store owner offsets within each rmap record,
and to handle the primary key being redefined as the tuple
[agblk, owner, offset].  The expansion of the primary key is crucial
to allowing multiple owners per extent.

[darrick: adapt the btree ops to deal with offsets]
[darrick: remove init_rec_from_key]
[darrick: move unwritten bit to rm_offset]

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: rmap btree requires more reserved free space
Darrick J. Wong [Wed, 10 Aug 2016 04:35:53 +0000 (14:35 +1000)] 
xfs: rmap btree requires more reserved free space

Source kernel commit: 525488520ac69a3612dbceefa573b255a83005e9

Originally-From: Dave Chinner <dchinner@redhat.com>

The rmap btree is allocated from the AGFL, which means we have to
ensure ENOSPC is reported to userspace before we run out of free
space in each AG. The last allocation in an AG can cause a full
height rmap btree split, and that means we have to reserve at least
this many blocks *in each AG* to be placed on the AGFL at ENOSPC.
Update the various space calculation functions to handle this.

Also, because the macros are now executing conditional code and are
called quite frequently, convert them to functions that initialise
variables in the struct xfs_mount, use the new variables everywhere
and document the calculations better.

[darrick.wong@oracle.com: don't reserve blocks if !rmap]
[dchinner@redhat.com: update m_ag_max_usable after growfs]

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: rmap btree transaction reservations
Darrick J. Wong [Wed, 10 Aug 2016 04:33:22 +0000 (14:33 +1000)] 
xfs: rmap btree transaction reservations

Source kernel commit: fa30f03cda26783b1294af6e7da9f1142da0f52e

The rmap btrees will use the AGFL as the block allocation source, so
we need to ensure that the transaction reservations reflect the fact
this tree is modified by allocation and freeing. Hence we need to
extend all the extent allocation/free reservations used in
transactions to handle this.

Note that this also gets rid of the unused XFS_ALLOCFREE_LOG_RES
macro, as we now do buffer reservations based on the number of
buffers logged via xfs_calc_buf_res(). Hence we only need the buffer
count calculation now.

[darrick: use rmap_maxlevels when calculating log block resv]

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: define the on-disk rmap btree format
Darrick J. Wong [Wed, 10 Aug 2016 04:33:20 +0000 (14:33 +1000)] 
xfs: define the on-disk rmap btree format

Source kernel commit: 035e00acb5c719bd003639b90716a7e94e023b73

Originally-From: Dave Chinner <dchinner@redhat.com>

Now we have all the surrounding call infrastructure in place, we can
start filling out the rmap btree implementation. Start with the
on-disk btree format; add everything needed to read, write and
manipulate rmap btree blocks. This prepares the way for adding the
btree operations implementation.

[darrick: record owner and offset info in rmap btree]
[darrick: fork, bmbt and unwritten state in rmap btree]
[darrick: flags are a separate field in xfs_rmap_irec]
[darrick: calculate maxlevels separately]
[darrick: move the 'unwritten' bit into unused parts of rm_offset]

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: introduce rmap extent operation stubs
Darrick J. Wong [Wed, 10 Aug 2016 01:53:23 +0000 (11:53 +1000)] 
xfs: introduce rmap extent operation stubs

Source kernel commit: 673930c34a4500c616cf9b2bbe1ae131ead2e155

Originally-From: Dave Chinner <dchinner@redhat.com>

Add the stubs into the extent allocation and freeing paths that the
rmap btree implementation will hook into. While doing this, add the
trace points that will be used to track rmap btree extent
manipulations.

[darrick.wong@oracle.com: Extend the stubs to take full owner info.]

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: add owner field to extent allocation and freeing
Darrick J. Wong [Wed, 10 Aug 2016 01:42:22 +0000 (11:42 +1000)] 
xfs: add owner field to extent allocation and freeing

Source kernel commit: 340785cca16246f82ccaf11740d885017a9e9341

For the rmap btree to work, we have to feed the extent owner
information to the the allocation and freeing functions. This
information is what will end up in the rmap btree that tracks
allocated extents. While we technically don't need the owner
information when freeing extents, passing it allows us to validate
that the extent we are removing from the rmap btree actually
belonged to the owner we expected it to belong to.

We also define a special set of owner values for internal metadata
that would otherwise have no owner. This allows us to tell the
difference between metadata owned by different per-ag btrees, as
well as static fs metadata (e.g. AG headers) and internal journal
blocks.

There are also a couple of special cases we need to take care of -
during EFI recovery, we don't actually know who the original owner
was, so we need to pass a wildcard to indicate that we aren't
checking the owner for validity. We also need special handling in
growfs, as we "free" the space in the last AG when extending it, but
because it's new space it has no actual owner...

While touching the xfs_bmap_add_free() function, re-order the
parameters to put the struct xfs_mount first.

Extend the owner field to include both the owner type and some sort
of index within the owner.  The index field will be used to support
reverse mappings when reflink is enabled.

When we're freeing extents from an EFI, we don't have the owner
information available (rmap updates have their own redo items).
xfs_free_extent therefore doesn't need to do an rmap update. Make
sure that the log replay code signals this correctly.

This is based upon a patch originally from Dave Chinner. It has been
extended to add more owner information with the intent of helping
recovery operations when things go wrong (e.g. offset of user data
block in a file).

[dchinner: de-shout the xfs_rmap_*_owner helpers]
[darrick: minor style fixes suggested by Christoph Hellwig]

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: rmap btree add more reserved blocks
Darrick J. Wong [Wed, 10 Aug 2016 01:42:20 +0000 (11:42 +1000)] 
xfs: rmap btree add more reserved blocks

Source kernel commit: 8018026ef29756af6144e2e2e8dffc9c2ed0d6f7

Originally-From: Dave Chinner <dchinner@redhat.com>

XFS reserves a small amount of space in each AG for the minimum
number of free blocks needed for operation. Adding the rmap btree
increases the number of reserved blocks, but it also increases the
complexity of the calculation as the free inode btree is optional
(like the rmbt).

Rather than calculate the prealloc blocks every time we need to
check it, add a function to calculate it at mount time and store it
in the struct xfs_mount, and convert the XFS_PREALLOC_BLOCKS macro
just to use the xfs-mount variable directly.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: add rmap btree stats infrastructure
Darrick J. Wong [Wed, 10 Aug 2016 01:36:28 +0000 (11:36 +1000)] 
xfs: add rmap btree stats infrastructure

Source kernel commit: 00f4e4f9073cb6d455c27dc8e92b421edcdc5011

Originally-From: Dave Chinner <dchinner@redhat.com>

The rmap btree will require the same stats as all the other generic
btrees, so add all the code for that now.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: introduce rmap btree definitions
Darrick J. Wong [Wed, 10 Aug 2016 01:36:21 +0000 (11:36 +1000)] 
xfs: introduce rmap btree definitions

Source kernel commit: b87049444ac4a6515ba0427d16a73438b646435b

Originally-From: Dave Chinner <dchinner@redhat.com>

Add new per-ag rmap btree definitions to the per-ag structures. The
rmap btree will sit in the empty slots on disk after the free space
btrees, and hence form a part of the array of space management
btrees. This requires the definition of the btree to be contiguous
with the free space btrees.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: increase XFS_BTREE_MAXLEVELS to fit the rmapbt
Darrick J. Wong [Wed, 10 Aug 2016 01:36:01 +0000 (11:36 +1000)] 
xfs: increase XFS_BTREE_MAXLEVELS to fit the rmapbt

Source kernel commit: df3954ff72590fd20b68261a0c939e40fa3579ea

By my calculations, a 1,073,741,824 block AG with a 1k block size
can attain a maximum height of 9.  Assuming a record size of 24
bytes, a key/ptr size of 44 bytes, and half-full btree nodes, we'd
need 53,687,092 blocks for the records and ~6 million blocks for the
keys.  That requires a btree of height 9 based on the following
derivation:

Block size = 1024b
sblock CRC header = 56b
== 1024-56 = 968 bytes for tree data

rmapbt record = 24b
== 40 records per leaf block

rmapbt ptr/key = 44b
== 22 ptr/keys per block

Worst case, each block is half full, so 20 records and 11 ptrs per block.

1073741824 rmap records / 20 records per block
== 53687092 leaf blocks

53687092 leaves / 11 ptrs per block
== 4880645 level 1 blocks
== 443695 level 2 blocks
== 40336 level 3 blocks
== 3667 level 4 blocks
== 334 level 5 blocks
== 31 level 6 blocks
== 3 level 7 blocks
== 1 level 8 block

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: add tracepoints and error injection for deferred extent freeing
Darrick J. Wong [Wed, 10 Aug 2016 01:35:59 +0000 (11:35 +1000)] 
xfs: add tracepoints and error injection for deferred extent freeing

Source kernel commit: ba9e780246a15a35f8ebe5b60f4a11bb58e85bda

Add a couple of tracepoints for the deferred extent free operation and
a site for injecting errors while finishing the operation.  This makes
it easier to debug deferred ops and test log redo.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: rename flist/free_list to dfops
Darrick J. Wong [Wed, 10 Aug 2016 01:34:02 +0000 (11:34 +1000)] 
xfs: rename flist/free_list to dfops

Source kernel commit: 2c3234d1ef53030ff6a79d55ba1fb291098467c2

Mechanical change of flist/free_list to dfops, since they're now
deferred ops, not just a freeing list.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: change xfs_bmap_{finish,cancel,init,free} -> xfs_defer_*
Darrick J. Wong [Wed, 10 Aug 2016 01:29:41 +0000 (11:29 +1000)] 
xfs: change xfs_bmap_{finish,cancel,init,free} -> xfs_defer_*

Source kernel commit: 310a75a3c6c747857ad53dd25f2ede3de13612c9

Drop the compatibility shims that we were using to integrate the new
deferred operation mechanism into the existing code.  No new code.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: rework xfs_bmap_free callers to use xfs_defer_ops
Darrick J. Wong [Wed, 10 Aug 2016 01:29:40 +0000 (11:29 +1000)] 
xfs: rework xfs_bmap_free callers to use xfs_defer_ops

Source kernel commit: 3ab78df2a59a485f479d26852a060acfd8c4ecd7

Restructure everything that used xfs_bmap_free to use xfs_defer_ops
instead.  For now we'll just remove the old symbols and play some
cpp magic to make it work; in the next patch we'll actually rename
everything.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: enable the xfs_defer mechanism to process extents to free
Darrick J. Wong [Wed, 10 Aug 2016 01:29:40 +0000 (11:29 +1000)] 
xfs: enable the xfs_defer mechanism to process extents to free

Source kernel commit: 9749fee83f38fca8dbe67161a033db22e3c4a2dd

Connect the xfs_defer mechanism with the pieces that we'll need to
handle deferred extent freeing.  We'll wire up the existing code to
our new deferred mechanism later.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: add tracepoints for the deferred ops mechanism
Darrick J. Wong [Wed, 10 Aug 2016 01:29:37 +0000 (11:29 +1000)] 
xfs: add tracepoints for the deferred ops mechanism

Source kernel commit: 3cd48abcc1f76d6cd5ce61f3540801849a6c82e0

Add tracepoints for the internals of the deferred ops mechanism
and tracepoint classes for clients of the dops, to make debugging
easier.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: move deferred operations into a separate file
Darrick J. Wong [Wed, 10 Aug 2016 01:29:37 +0000 (11:29 +1000)] 
xfs: move deferred operations into a separate file

Source kernel commit: 4e0cc29b91a8056f902f0974b49084b07491905f

All the code around struct xfs_bmap_free basically implements a
deferred operation framework through which we can roll transactions
(to unlock buffers and avoid violating lock order rules) while
managing all the necessary log redo items.  Previously we only used
this code to free extents after some sort of mapping operation, but
with the advent of rmap and reflink, we suddenly need to do more than
that.

With that in mind, xfs_bmap_free really becomes a deferred ops control
structure.  Rename the structure and move the deferred ops into their
own file to avoid further bloating of the bmap code.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: refactor btree owner change into a separate visit-blocks function
Darrick J. Wong [Wed, 10 Aug 2016 01:29:37 +0000 (11:29 +1000)] 
xfs: refactor btree owner change into a separate visit-blocks function

Source kernel commit: 28a89567b8bd95f42c17822d276cccb5b085810d

Refactor the btree_change_owner function into a more generic apparatus
which visits all blocks in a btree.  We'll use this in a subsequent
patch for counting btree blocks for AG reservations.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: introduce interval queries on btrees
Darrick J. Wong [Wed, 10 Aug 2016 01:29:36 +0000 (11:29 +1000)] 
xfs: introduce interval queries on btrees

Source kernel commit: 105f7d83db4f82ce170893eaaca946754e38541f

Create a function to enable querying of btree records mapping to a
range of keys.  This will be used in subsequent patches to allow
querying the reverse mapping btree to find the extents mapped to a
range of physical blocks, though the generic code can be used for
any range query.

The overlapped query range function needs to use the btree get_block
helper because the root block could be an inode, in which case
bc_bufs[nlevels-1] will be NULL.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: support btrees with overlapping intervals for keys
Darrick J. Wong [Wed, 10 Aug 2016 01:29:36 +0000 (11:29 +1000)] 
xfs: support btrees with overlapping intervals for keys

Source kernel commit: 2c813ad66a7218a64db68f0a4bfa8d2d9caef4c0

On a filesystem with both reflink and reverse mapping enabled, it's
possible to have multiple rmap records referring to the same blocks on
disk.  When overlapping intervals are possible, querying a classic
btree to find all records intersecting a given interval is inefficient
because we cannot use the left side of the search interval to filter
out non-matching records the same way that we can use the existing
btree key to filter out records coming after the right side of the
search interval.  This will become important once we want to use the
rmap btree to rebuild BMBTs, or implement the (future) fsmap ioctl.

(For the non-overlapping case, we can perform such queries trivially
by starting at the left side of the interval and walking the tree
until we pass the right side.)

Therefore, extend the btree code to come closer to supporting
intervals as a first-class record attribute.  This involves widening
the btree node's key space to store both the lowest key reachable via
the node pointer (as the btree does now) and the highest key reachable
via the same pointer and teaching the btree modifying functions to
keep the highest-key records up to date.

This behavior can be turned on via a new btree ops flag so that btrees
that cannot store overlapping intervals don't pay the overhead costs
in terms of extra code and disk format changes.

When we're deleting a record in a btree that supports overlapped
interval records and the deletion results in two btree blocks being
joined, we defer updating the high/low keys until after all possible
joining (at higher levels in the tree) have finished.  At this point,
the btree pointers at all levels have been updated to remove the empty
blocks and we can update the low and high keys.

When we're doing this, we must be careful to update the keys of all
node pointers up to the root instead of stopping at the first set of
keys that don't need updating.  This is because it's possible for a
single deletion to cause joining of multiple levels of tree, and so
we need to update everything going back to the root.

The diff_two_keys functions return < 0, 0, or > 0 if key1 is less than,
equal to, or greater than key2, respectively.  This is consistent
with the rest of the kernel and the C library.

In btree_updkeys(), we need to evaluate the force_all parameter before
running the key diff to avoid reading uninitialized memory when we're
forcing a key update.  This happens when we've allocated an empty slot
at level N + 1 to point to a new block at level N and we're in the
process of filling out the new keys.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: add function pointers for get/update keys to the btree
Darrick J. Wong [Wed, 10 Aug 2016 01:29:36 +0000 (11:29 +1000)] 
xfs: add function pointers for get/update keys to the btree

Source kernel commit: 70b2265935544c2ba64619172fd757bd0ca91800

Add some function pointers to bc_ops to get the btree keys for
leaf and node blocks, and to update parent keys of a block.
Convert the _btree_updkey calls to use our new pointer, and
modify the tree shape changing code to call the appropriate
get_*_keys pointer instead of _btree_copy_keys because the
overlapping btree has to calculate high key values.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: during btree split, save new block key & ptr for future insertion
Darrick J. Wong [Wed, 10 Aug 2016 01:29:36 +0000 (11:29 +1000)] 
xfs: during btree split, save new block key & ptr for future insertion

Source kernel commit: e5821e57af54abc36ea299bde6c101a804cfac27

When a btree block has to be split, we pass the new block's ptr from
xfs_btree_split() back to xfs_btree_insert() via a pointer parameter;
however, we pass the block's key through the cursor's record.  It is a
little weird to "initialize" a record from a key since the non-key
attributes will have garbage values.

When we go to add support for interval queries, we have to be able to
pass the lowest and highest keys accessible via a pointer.  There's no
clean way to pass this back through the cursor's record field.
Therefore, pass the key directly back to xfs_btree_insert() the same
way that we pass the btree_ptr.

As a bonus, we no longer need init_rec_from_key and can drop it from the
codebase.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: set *stat=1 after iroot realloc
Darrick J. Wong [Wed, 10 Aug 2016 01:29:36 +0000 (11:29 +1000)] 
xfs: set *stat=1 after iroot realloc

Source kernel commit: 0d309791bdc0a92f1db5dfc171d884a6b8583702

If we make the inode root block of a btree unfull by expanding the
root, we must set *stat to 1 to signal success, rather than leaving
it uninitialized.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: fix locking of the rt bitmap/summary inodes
Darrick J. Wong [Wed, 10 Aug 2016 01:29:36 +0000 (11:29 +1000)] 
xfs: fix locking of the rt bitmap/summary inodes

Source kernel commit: f4a0660de34451e30f0bb8b65946b79c8bd375ca

When we're deleting realtime extents, we need to lock the summary
inode in case we need to update the summary info to prevent an assert
on the rsumip inode lock on a debug kernel.  While we're at it, fix
the locking annotations so that we avoid triggering lockdep warnings.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: fix attr shortform structure alignment on cris
Darrick J. Wong [Wed, 10 Aug 2016 01:29:36 +0000 (11:29 +1000)] 
xfs: fix attr shortform structure alignment on cris

Source kernel commit: 3dadf901ddc0a1275b622b1a170557bd0d136862

Apparently cris doesn't require structure stride to align with the
largest type in the struct, so list[0] isn't at offset 4 like it is
everywhere else.  Fix this... insofar as existing XFSes on cris are
screwed.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: remove __arch_pack
Christoph Hellwig [Wed, 10 Aug 2016 01:29:36 +0000 (11:29 +1000)] 
xfs: remove __arch_pack

Source kernel commit: aa2dd0ad4d6d7dd85bb13ed64b872803be046f96

Instead we always declare struct xfs_dir2_sf_hdr as packed.  That's
the expected layout, and while most major architectures do the packing
by default the new structure size and offset checker showed that not
only the ARM old ABI got this wrong, but various minor embedded
architectures did as well.

[Verified that no code change on x86-64 results from this change]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
7 years agoxfs: kill xfs_dir2_inou_t
Christoph Hellwig [Wed, 10 Aug 2016 01:29:36 +0000 (11:29 +1000)] 
xfs: kill xfs_dir2_inou_t

Source kernel commit: 266b6969c3dfd3c81d8601754c8b0e25bb52615b

And use an array of unsigned char values directly to avoid problems
with architectures that pad the size of structures.  This also gets
rid of the xfs_dir2_ino4_t and xfs_dir2_ino8_t types, and introduces
new constants for the size of 4 and 8 bytes as well as the size
difference between the two.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>