Christoph reports slab corruption when a deferred refcount update
aborts during _defer_finish(). The cause of this was broken log item
state tracking in xfs_defer_pending -- upon an abort,
_defer_trans_abort() will call abort_intent on all intent items,
including the ones that have already had a done item attached.
This is incorrect because each intent item has 2 refcount: the first
is released when the intent item is committed to the log; and the
second is released when the _done_ item is committed to the log, or
by the intent creator if there is no done item. In other words, once
we log the done item, responsibility for releasing the intent item's
second refcount is transferred to the done item and /must not/ be
performed by anything else.
The dfp_committed flag should have been tracking whether or not we had
a done item so that _defer_trans_abort could decide if it needs to
abort the intent item, but due to a thinko this was not the case. Rip
it out and track the done item directly so that we do the right thing
w.r.t. intent item freeing.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reported-by: Christoph Hellwig <hch@infradead.org> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
From inspection, the superblock sb_inprogress check is done in the
verifier and triggered only for the primary superblock via a
"bp->b_bn == XFS_SB_DADDR" check.
Unfortunately, the primary superblock is an uncached buffer, and
hence it is configured by xfs_buf_read_uncached() with:
bp->b_bn = XFS_BUF_DADDR_NULL; /* always null for uncached buffers */
And so this check never triggers. Fix it.
cc: <stable@vger.kernel.org> Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dave Chinner <david@fromorbit.com>
Because we are mangling the diff source/destination locations, we
have to add prefixes to them to get them to apply cleanly as -p1
patches. This is all fine until we create or remove a file and
the the src/dest is /dev/null. Applying a prefix here causes
the diff to be malformed and it won't apply.
Add another hack to work around this limitation of filterdiff when
reformatting the diff into readable format.
Dave Chinner [Mon, 24 Oct 2016 22:04:33 +0000 (09:04 +1100)]
libxfs_apply: filter commits from libxfs only
When pulling commits from the kernel, it's easy to specify a commit
range such as "v4.8..for-next" to indicate we want to pull all
commits for libxfs since the 4.8 kernel release. Unfortunately,
this pull commits from all over the kernel tree, not just
fs/xfs/libxfs.
Filter the commit list retrieval to limit the commits to those touch
fs/xfs/libxfs so that we only attempt to apply the realtively small
number of relevant commits.
Eric Sandeen [Sun, 2 Oct 2016 23:56:00 +0000 (10:56 +1100)]
xfs_io: fix inode command with "-n" for bogus inode
If we ask for the next allocated inode after a number for which
no other inode exists, the bulkstat returns success, but with
count == 0. If we ignore this fact, we print a garbage result
from bstat.bs_ino in this case, so fix it.
Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Eric Sandeen [Sun, 2 Oct 2016 23:50:21 +0000 (10:50 +1100)]
xfs_io: refactor inode command
The inode_f function is a bit convoluted; the default
find-last-inode case appears at the end, there are several return
points, we print the same basic information using 2 different
variables in 2 different locations depending on the mode we're in,
the "inode not found" was a printf & exit in the middle of the
function, etc.
Move the default case up to the top so it's more obvious, not
buried.
Make a new var, result_ino, which holds whatever we want to print
regardless of the mode, and then handle all the output at the end.
Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Eric Sandeen [Sun, 2 Oct 2016 23:47:47 +0000 (10:47 +1100)]
xfs_io: move inode command arg handling to top
As it stands, collecting the inode number and testing args validity
is all tangled up; for example the test for "-n" having no inode is
buried in an else after a large code block which handles something
else.
Get inode number argument collection and testing out of the way
before doing anything else.
Clean up the error message if a non-numeric inode arg is given.
Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Eric Sandeen [Sun, 2 Oct 2016 23:46:03 +0000 (10:46 +1100)]
xfs_io: factor out new get_last_inode() helper
The inode command by default finds the last allocated inode in the
filesystem via bulkstat, and this specific function is open-coded
after other cases are handled, leading to a fairly long inode_f
function and confusing code flow.
Clean it up by factoring it into a new function, more refactoring
will follow.
Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Darrick J. Wong [Sun, 2 Oct 2016 23:42:22 +0000 (10:42 +1100)]
xfs_repair: add freesp btree block overflow to the free space
If we overestimate the number of blocks needed to rebuild the free
space btrees to the point that we have more blocks than fit in the
AGFL, save those blocks and reinsert them into the free space at
the end of phase 5. Previously, the overflow blocks would simply
be lost.
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>
Darrick J. Wong [Sun, 2 Oct 2016 23:40:32 +0000 (10:40 +1100)]
xfs_repair: fix bogosity when rmapping new AGFL blocks
When repair rebuilds the AGFL, the blocks can come either from the
in-core free space tree or they can come as a result of overestimating
the number of blocks needed to rebuild the on-disk free space btree.
The code in here was trying to only create rmap records for AGFL blocks
that did /not/ come from free space btree rebuild overestimation, but
was totally broken. The initial and check conditions were totally wrong
if there was any overflow. Remove a stray debug printf too.
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>
Eryu Guan [Sun, 2 Oct 2016 23:36:14 +0000 (10:36 +1100)]
libxcmd: fix counting of xfs entries in fs_table_insert
Commit bb80e3d6cd04 ("libxcmd: populate fs table with xfs entries
first, foreign entries last") adds a new counter "xfs_fs_count" and
increases the counter when inserting an XFS entry.
But it missed a counter when fs_count is zero (inserting the first
path) and the entry has no FS_FOREIGN bit set, i.e. the first XFS
entry doesn't increase xfs_fs_count.
This results in args_command() mess and infinite loop in xfs/244
when testing v4 XFS (xfs/244 notrun on v5 XFS, but this bug still
reproduces on v5 XFS). e.g.
Eric Sandeen [Thu, 22 Sep 2016 23:16:52 +0000 (09:16 +1000)]
xfs_copy: Fix meta UUID handling on multiple copies
Zorro reported that when making multiple copies of a V5
filesystem with xfs_copy while generating new UUIDs, all
but the first copy were corrupt.
Upon inspection, the corruption was related to incorrect UUIDs;
the original UUID, as stamped into every metadata structure,
was not preserved in the sb_meta_uuid field of the superblock
on any but the first copy.
This happened because sb_update_uuid was using the UUID present in
the ag_hdr structure as the unchanging meta-uuid which is to match
existing structures, but it also /updates/ that UUID with the
new identifying UUID present in tcarg. So the newly-generated
UUIDs moved transitively from tcarg->uuid to ag_hdr->xfs_sb->sb_uuid
to ag_hdr->xfs_sb->sb_meta_uuid each time the function got called.
Fix this by looking instead to the unchanging, original UUID
present in the xfs_sb_t we are given, which reflects the original
filesystem's metadata UUID, and copy /that/ UUID into each target
filesystem's meta_uuid field.
Most of this patch is changing comments and re-ordering tests
to match; the functional change is to simply use the *sb rather
than the *ag_hdr to identify the proper metadata UUID.
Reported-and-tested-by: Zorro Lang <zlang@redhat.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Eric Sandeen [Thu, 22 Sep 2016 23:16:47 +0000 (09:16 +1000)]
xfs_repair: fix segfault from uninitialized tp in mv_orphanage
After 9074815 xfs: better xfs_trans_alloc interface, mv_orphanage
was passing an uninitialized *tp into libxfs_dir_lookup, because
the trans_alloc() call which was present prior to the call got
removed in that commit.
This ultimately led to testing an uninit tp var:
Conditional jump or move depends on uninitialised value(s)
at 0x434D01: libxfs_trans_read_buf_map (trans.c:554)
by 0x45152E: libxfs_da_read_buf (xfs_da_btree.c:2610)
by 0x456ACB: xfs_dir3_block_read (xfs_dir2_block.c:136)
by 0x4570A8: xfs_dir2_block_lookup_int (xfs_dir2_block.c:675)
by 0x457DB7: xfs_dir2_block_lookup (xfs_dir2_block.c:623)
by 0x455F54: libxfs_dir_lookup (xfs_dir2.c:399)
by 0x421C46: mv_orphanage (phase6.c:1095)
by 0x4222C2: check_for_orphaned_inodes (phase6.c:3108)
by 0x423ABD: phase6 (phase6.c:3287)
by 0x42E4B2: main (xfs_repair.c:933)
and ended with a segfault as we tried to use that tp when
searching for the buffer in xfs_trans_buf_item_match():
I think simply passing in NULL for this tp is sufficient to fix
this; we'll just go read the buffer from disk in
libxfs_trans_read_buf_map rather than trying to find it in an
existing transaction.
Reported-by: Consigliere <admin@russenmafia.at> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Eric Sandeen [Mon, 19 Sep 2016 22:49:41 +0000 (08:49 +1000)]
libxfs: factor mount checks into helper function
platform_check_ismounted switched to a getmntent() loop after
ustat disappeared on some new platforms.
We also use a similar mechanism for determining the
ro/rw-mounted status of a device in platform_check_iswritable.
Because the loops are essentially the same, factor them into a
single helper which accepts a VERBOSE flag to print info if the
device is found in the checked-for state, and a WRITABLE flag
which only checks specifically for a mounted and /writable/ device.
Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Eric Sandeen [Mon, 19 Sep 2016 22:48:54 +0000 (08:48 +1000)]
mkfs.xfs: clarify ftype defaults in manpage
When CRCs were made default, a few leftovers related to its
prior non-default status remained in the manpage, in the ftype
section. Clean those up, stating the correct default for this
feature.
Reported-by: Chris Murphy <chris@cmurf.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Eric Sandeen [Mon, 19 Sep 2016 06:07:55 +0000 (16:07 +1000)]
xfs_io: allow chattr & chproj on foreign filesystems
Now that FS_IOC_FSSETXATTR is a generic vfs call, these
functions can be used on non-xfs filesystems, and this is
needed for generic project quota testing.
Eric Sandeen [Mon, 19 Sep 2016 06:06:57 +0000 (16:06 +1000)]
xfs_quota: un-flag non-foreign-capable commands
The off command calls XFS_QUOTAOFF / Q_XQUOTAOFF, which calls
quota_disable in the kernel, which returns ENOSYS if the
->quota_enable quota op doesn't exist - and it does not exist
on any non-xfs filesystems.
We could get clever if we wanted it, and send Q_QUOTAOFF
instead for foreign filesystems, but for now it's broken
so just remove the flag.
The free command relies on XFS_IOC_FSGEOMETRY_V1, so unflag it
as well.
Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Bill O'Donnell <billodo@redhat.com Signed-off-by: Dave Chinner <david@fromorbit.com>
Eric Sandeen [Mon, 19 Sep 2016 06:06:36 +0000 (16:06 +1000)]
xfs_quota: Enable 3 more foreign commands
Enable restore, limit, and timer.
Unsupported commands remain, for lack of kernel support, generally:
warn, quot,, enable, disable, and remove.
xfs_quota> report
User quota on /mnt/test2/git/xfsprogs/mnt (/dev/loop0)
Blocks
User ID Used Soft Hard Warn/Grace
---------- --------------------------------------------------
root 13 0 0 00 [--------]
xfs_quota> restore -f quotadump
xfs_quota> report
User quota on /mnt/test2/git/xfsprogs/mnt (/dev/loop0)
Blocks
User ID Used Soft Hard Warn/Grace
---------- --------------------------------------------------
root 13 0 0 00 [--------]
testuser 0 16384 32768 00 [--------]
fsgqa 0 102400 112640 00 [--------]
xfs_quota> limit bsoft=200m fsgqa
xfs_quota> report
User quota on /mnt/test2/git/xfsprogs/mnt (/dev/loop0)
Blocks
User ID Used Soft Hard Warn/Grace
---------- --------------------------------------------------
root 13 0 0 00 [--------]
testuser 0 16384 32768 00 [--------]
fsgqa 0 204800 112640 00 [--------]
xfs_quota> state -u
User quota state on /mnt/test2/git/xfsprogs/mnt (/dev/loop0)
Accounting: ON
Enforcement: ON
Inode: #12 (16 blocks, 1 extents)
Blocks grace time: [7 days]
Inodes grace time: [7 days]
xfs_quota> timer -b 3days
xfs_quota> state -u
User quota state on /mnt/test2/git/xfsprogs/mnt (/dev/loop0)
Accounting: ON
Enforcement: ON
Inode: #12 (16 blocks, 1 extents)
Blocks grace time: [3 days]
Inodes grace time: [7 days]
Realtime Blocks grace time: [--------]
Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Bill O'Donnell <billodo@redhat.com Signed-off-by: Dave Chinner <david@fromorbit.com>
Bill O'Donnell [Mon, 19 Sep 2016 06:05:45 +0000 (16:05 +1000)]
xfs_quota: add case for foreign fs, disabled regardless of foreign_allowed
Some commands are disallowed for foreign filesystems,
regardless of whether or not the -f flag is thrown.
Add a case for this condition and improve commenting
and output messaging accordingly in init_check_command.
Signed-off-by: Bill O'Donnell <billodo@redhat.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Bill O'Donnell [Mon, 19 Sep 2016 06:02:41 +0000 (16:02 +1000)]
xfs_quota: print and path output formatting: maintain reverse compatibility
This patch adjusts the formatting of the xfs_quota print and
path outputs, in order to maintain reverse compatability:
when -f flag isn't used, need to keep the output same as in
previous version.
Signed-off-by: Bill O'Donnell <billodo@redhat.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Bill O'Donnell [Mon, 19 Sep 2016 06:02:22 +0000 (16:02 +1000)]
libxcmd: populate fs table with xfs entries first, foreign entries last
Commits b20b6c2 and 29647c8 modified xfs_quota for use on
non-XFS filesystems. Modifications to fs_initialise_mounts
(paths.c) resulted in an xfstest fail (xfs/261), due to foreign
fs paths being picked up first from the fs table. The xfs_quota
print command then complained about not being able to print the
foreign paths, instead of previous behavior (quiet).
This patch restores correct behavior, sorting the table so that
xfs entries are first, followed by foreign fs entries. The patch
maintains the order of xfs entries and foreign entries in the
same order as mtab entries. Then, in functions which print all
paths we can simply break at the first foreign path if the -f
switch is not specified.
Signed-off-by: Bill O'Donnell <billodo@redhat.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Eric Sandeen [Mon, 19 Sep 2016 06:01:14 +0000 (16:01 +1000)]
xfs_repair: exit with status 2 if log dirtiness is unknown
This new case is mostly like the known dirty log case; the log
is corrupt, dirtiness cannot be determined, and a mount/umount
cycle or an xfs_repair -L is required.
So exit with status 2 here as well.
Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Zorro Lang <zlang@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
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>
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>
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.
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>
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>
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>
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>
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:
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>