Commit Graph

203 Commits

Author SHA1 Message Date
Darrick J. Wong 614e33f1b5 xfs: test xfs_db source command
Make sure that the 'source' command works correctly whether supplied
via command line or interactive prompt.

You probably want "xfs_db: fix the 'source' command when passed as a
-c option" in xfsprogs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2017-01-27 16:06:12 +08:00
Darrick J. Wong f5f0c11a67 xfs: fuzz every field of every structure
Previously, our XFS fuzzing efforts were limited to using the xfs_db
blocktrash command to scribble garbage all over a block.  This is
pretty easy to discover; it would be far more interesting if we could
fuzz individual fields looking for unhandled corner cases.  Since we
now have an online scrub tool, use it to check for our targeted
corruptions prior to the usual steps of writing to the FS, taking it
offline, repairing, and re-checking.

These tests use the new xfs_db 'fuzz' command to test corner case
handling of every field.  The 'print' command tells us which fields
are available, and the fuzz command can write zeroes or ones to the
field; set the high, middle, or low bit; add or subtract numbers; or
randomize the field.  We loop through all fields and all fuzz verbs to
see if we can trip up the kernel.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2017-01-27 16:06:12 +08:00
Amir Goldstein 726f8c357f xfs: test handling of invalid inode modes
Set all possible file type values for different types of files
and verify that xfs_repair detects the correct errors.

When setting invalid file type values (e.g. core.mode = 0170644),
all files are expected to have been junked by xfs_repair.

When setting valid file type values to non matching file types,
xfs_repair would either detect wrong format and junk the file, e.g.:
  would have junked entry "DATA" in directory PARENT_INO
or detect a ftype mismatch error, e.g.:
  would fix ftype mismatch (5/3) in directory/child PARENT_INO/FIFO_INO

If ftype feature is enabled, when setting file type to one of the
special types (i.e. FIFO(1), CHRDEV(2),BLKDEV(6),SOCKET(14)),
xfs_repair is expected to detect ftype mismatch error. Otherwise,
xfs_repair is not expected to detect ftype mismatch error.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2017-01-15 13:56:45 +08:00
Darrick J. Wong 466369dc92 xfs/ext4: check negative inode size
Craft a malicious filesystem image with a negative inode size,
then try to trigger a kernel DoS by appending data to the file.
Ideally this should trigger verifier errors instead of hanging.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2017-01-15 13:56:45 +08:00
Eric Sandeen 54c0f9cd4f xfs/118: add to dangerous group
Failure results in an oops, so add it to dangerous.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2017-01-10 11:43:19 +08:00
Eric Sandeen 052b0777d7 xfs: testcase for kernelspace xfs_fsr extent handling flaw
This is a testcase for a bug which goes way back; googling
"xfs_trans_log_inode NULL pointer dereference" yields sporadic
reports over several years.

The test sets up several two-extent files with speculative
preallocation on them, and then runs xfs_fsr.  The kernelside
code ignores the preallocation, and therefore sets up the
temporary inode incorrectly after the inode fork swap.

It is a "dangerous" test because the extent mishandling on
the temporary inode causes a null pointer dereference and
oops when the inode's i_itemp pointer gets overwritten
and we blow up in logging code that tries to use it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-11-13 14:01:07 +08:00
Eryu Guan c61fa13e94 xfs: renumber tests after merge
Tests were merged with high seq numbers to avoid conflicts with
other tests. Now renumber them to contiguous numbers, as all other
tests have been merged correctly. This is easier to do than
assigning the final seq numbers at commit time.

Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-10-08 14:02:04 +08:00
Darrick J. Wong c6aa8a7666 xfs: check copy-on-write fragmentation
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-10-08 13:50:06 +08:00
Darrick J. Wong 8144ddc459 xfs: test realtime rmapbt code
Test the realtime rmap btree code by exercising various IO patterns
on realtime files.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-10-07 17:49:38 +08:00
Darrick J. Wong f9da3861fc xfs: more rmapbt tests
More tests for the reverse mapping functionality.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-10-07 17:26:37 +08:00
Eric Sandeen f57e3c3b49 xfs: exercise and validate the xfs_io inode command
Run various modes of the xfs_io "inode" command.

This fails today, I have some patches to fix it up.
The "grep -q" for failures strings are fairly loose
because I'm changing them, and don't want to depend
on the exact error or usage message ...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-10-07 17:18:53 +08:00
Eryu Guan c27a67f0e7 fstests: move now-generic xfs project quota tests generic
Now that these tests have been made generic, move them into the
generic/ dir and update group files.

xfs/133 -> generic/383
xfs/134 -> generic/384
xfs/196 -> generic/385
xfs/262 -> generic/386

Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-09-23 12:30:04 +08:00
Eric Sandeen fe901ccaa7 fstests: move now-generic quota tests to generic
Now that these tests have been made generic, move them into
the generic/ dir and update group files.

xfs/054 -> generic/379
xfs/118 -> generic/380
xfs/138 -> generic/381
xfs/260 -> generic/382

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-09-23 11:35:42 +08:00
Zorro Lang 81dc4bc728 xfs: various operations on mounted fs
xfsprogs takes use of ustat(2) to check if a given device is
mounted, but ustat(2) is deprecated and may not be available on
newer architectures, e.g. aarch64. In such cases, xfsprogs failed to
detect mounted device, which would result in something like
xfs_mdrestore overwriting a mounted XFS.

So adding a case to do xfs_mdrestore, xfs_copy, xfs_db, mkfs and
xfs_repair against mounted XFS to make sure they refuse to do so.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-09-15 12:26:58 +08:00
Darrick J. Wong 06d400134e xfs: test getbmapx shared extent reporting
Test that getbmapx returns exact shared extents.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-09-08 19:36:13 +08:00
Darrick J. Wong c49136ef66 xfs: test getfsmap ioctl
Add some simple tests for the new getfsmap ioctl.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-09-08 19:33:14 +08:00
Darrick J. Wong bb5bd55108 xfs: test swapext with reflink
Add a few tests to stress the new swapext code for reflink and rmap.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-09-02 16:40:34 +08:00
Zorro Lang 1083413cd4 xfs: rw remount with unknown ro-compat features
Although ro-compat features cannot be mounted rw, a bug allows an
ro->rw remount transition, and this will corrupt the filesystem if
it contains ro-compat features unknown to the running kernel.

This bug has been fixed on linux kernel (d0a58e8 xfs: disallow rw
remount on fs with unknown ro-compat features), this case is the
regression testcase of that bug.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-08-30 11:36:13 +08:00
Theodore Ts'o 21eb9d303c fstests: add punch, collapse, insert, zero test groups
Define test groups for those tests which have _require_xfs_io_command
for punch, collapse, insert, and zero.  This makes it easier to
exclude tests that use one of these fallocate commands.  Or if you
want to specifically test for those fallocate commands you can do
this.

This obviates an out-of-tree xfstests patch I maintain which used an
XFS_IO_AVOID environment variable to suppress running tests that use
punch, collapse, insert, etc.  This was rejected because of the
claim that it could be done using groups.  So this commit is in
response to those upstream comments.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-08-26 15:45:03 +08:00
Zorro Lang d6a6cf579f xfs: EIO error handling test
Besides fail_at_unmount, all EIO error handling can stop umount
hanging on IO error too.

This case test EIO/max_retries and EIO/retry_timeout_seconds as
below:

1) fail_at_unmount=0 && \
   EIO/max_retries=1 && \
   EIO/retry_timeout_seconds=0

2) fail_at_unmount=0 && \
   EIO/max_retries=-1 && \
   EIO/retry_timeout_seconds=1

Make sure when fail_at_unmount=0, umount won't hang there.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-08-26 15:29:49 +08:00
Eric Sandeen 397c6eb2b6 xfs: test xfs_quota "state" command
This exercises the xfs_quota "state" command for every
combination of user, group, and project quota enablement
on both crc (with project quota inode on disk) and non-crc
(where project quota overlaps group quota on disk) filesystems.

It currently requires patches to the upstream kernel
("quota: fill in Q_XGETQSTAT inode information for inactive quotas")
and to xfsprogs ("xfs_quota: wire up XFS_GETQSTATV") to pass.

Rather than trying to make it run on older kernels without
crc capability, I restrict the test to crc-capable environments,
but test with and without crcs enabled (and hence with and without
project quota inode on disk).

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-08-26 15:29:49 +08:00
Darrick J. Wong 73f8e854f6 xfs: test attr_list_by_handle cursor iteration
Apparently the XFS attr_list_by_handle ioctl has never actually
copied the cursor contents back to user space, which means that
iteration has never worked.  Add a test case for this and see

"xfs: in _attrlist_by_handle, copy the cursor back to userspace".

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-08-05 10:44:50 +08:00
Darrick J. Wong f9261d3646 xfs/128: cycle_mount the scratch device
This test uses the scratch device, so cycle that, not the test dev.
This is also a xfs_fsr test, so put it in the fsr group.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-08-05 10:32:10 +08:00
Darrick J. Wong 7c61e4c39e xfs/26[34]: remove duplicate tests
These two tests were accidentally double-added as xfs/30[78], but
the newer versions have fixed up helper usage and fewer whitespace
problems, so nuke the old tests.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-08-05 10:32:10 +08:00
Zorro Lang b18191a1d0 xfs/106: rewrite to make it a reliable regression test
xfs/106 is testing basic functions of xfs_quota command, but
there're three problems prevent people from running it as a reliable
regression test (i.e. it's not in 'auto' group):

- It tests unavailable commands in current xfs_quota, e.g. "warn"
- Lack of test coverage of important commands, e.g. "disable,
  enable, off and remove" commands
- Test output doesn't match golden image

So rewrite this case to test as many xfs_quota sub-commands and
options as possible and add it to 'auto' group, except:

- some "-v" options
- all "-a" options, because it's hard to get deterministic output
- default quota, this should be already covered by other tests
- project command options, I will write another case to test it
- report command -l option, which is a new option and will cause
  failure when testing with xfsprogs prior to 3.1 version.
- quot command -c option, which may output different histogram in
  different systems or hosts.
- warn command, which is not currently implemented.
- print, df, free, help, quit and path commands.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-07-31 10:36:53 +08:00