When running xfstests on a 4k logical sector device, I ran into a test
failure in test 198. The errors were all due to trying to do 512 byte
aligned I/O on a 4k logical sector device. The attached patch tries to
auto-detect the proper block size if no alignment is specified. If it
fails for one reason or another, it defaults to 4k alignment. This
seems to work fine in my test rig.
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Many of the "count-the-holes" tests (008, 012, etc) do writes that extend the
file and hence allocation patterns are dependent on speculative allocation
beyond EOF behaviour. Hence if we change that behaviour, these tests all fail
because there is a different pattern of holes.
Make the tests independent of EOF preallocation behaviour by first truncating
the file to the size the test is defined to use. This prevents speculative
prealocation from occurring, and hence changes in such behaviour will not cause
the tests to fail.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
When compiling "fiemap-tester.c" in my environment, I am
getting complaints at the first reference to "uint64_t"
in <linux/fs.h>. This simple patch resolves that.
Signed-off-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Minor bits to wrap up this series.
- Bumped up the number of blocks read at once from 10 to 256
- Shorten remaining long lines
- Re-factor findblock()
- Get rid of global variable "nvalid"
- Add a few more comments
- Give all global symbols static scope
- Update the copyright message
- Various other minor formatting changes.
Signed-off-by: Alex Elder <aelder@sgi.com>
Acked-by: Dave Chinner <david@fromorbit.com>
Move the argument parsing code out of main() and into a separate
parseargs() routine. The name of the target file for the test
is returned by parseargs() if no error occurs.
Signed-off-by: Alex Elder <aelder@sgi.com>
Acked-by: Dave Chinner <david@fromorbit.com>
Make readblks() a bit more readable by computing a few things
into local variables, and pulling out a few of the comma-separated
expressions that were previously in the for loop headers.
Signed-off-by: Alex Elder <aelder@sgi.com>
Acked-by: Dave Chinner <david@fromorbit.com>
Encapsulate the code that sets up the use of files on the realtime
volume. Using realtime implies direct I/O; move the code that makes
that so into the argument parsing code.
Signed-off-by: Alex Elder <aelder@sgi.com>
Acked-by: Dave Chinner <david@fromorbit.com>
Use posix_memalign() rather than memalign() regardless of whether
direct I/O is to be used. Don't store the dioattr data in a global
variable.
Signed-off-by: Alex Elder <aelder@sgi.com>
Acked-by: Dave Chinner <david@fromorbit.com>
Pull the code used to get alignment information for direct I/O into
a separate function.
Signed-off-by: Alex Elder <aelder@sgi.com>
Acked-by: Dave Chinner <david@fromorbit.com>
Define a macro "xfscntl()" that effectively hides the differences
between the Linux xfsctl() and Irix fcntl() kernel interfaces.
Signed-off-by: Alex Elder <aelder@sgi.com>
Acked-by: Dave Chinner <david@fromorbit.com>
Rearrange the functions in the file so they no longer need to be
declared at the top. (This change involves only wholesale moves
of these blocks of code.)
Signed-off-by: Alex Elder <aelder@sgi.com>
Acked-by: Dave Chinner <david@fromorbit.com>
Reformat the usage message and provide a little more
information about default values and units for options
for the "randholes" command.
Signed-off-by: Alex Elder <aelder@sgi.com>
Acked-by: Dave Chinner <david@fromorbit.com>
If nothing is being written (i.e., in "test" mode), there's no need
for "randholes" to allocate a write buffer. But to do this we make
this series of changes:
- When "very" verbose (> 1), there's no point in printing the values
that have just been written to the file. They are just the file
offset, and the buffer will not have changed between initializing
those values and writing it out.
- If we don't print the values at those offsets, then there's no
need to fill them in at all when we're in test mode.
- Now we only use the write buffer if we're not in test mode,
so we can skip the allocation.
Signed-off-by: Alex Elder <aelder@sgi.com>
Acked-by: Dave Chinner <david@fromorbit.com>
This patch fixes two bugs in the "randholes" test program.
First, it is possible for findblock() to return -1 if the random
block number it picks is at or above the highest in-range block
that's already been selected. But this case isn't checked and
the value is blindly used thereafter as if it were valid. Just
exit if this ever occurs.
Second, when the "alloconly" option is is set, blocks are
preallocated in the target file rather than actually writing them.
But unlike when the blocks are written and subsequently read, the
preallocated blocks are *not* offset by the fileoffset parameter.
I'm pretty sure nobody every noticed this because the program itself
doesn't do any verification when blocks are only preallocated. But
it's an inconsistency and I think it ought to be fixed.
Signed-off-by: Alex Elder <aelder@sgi.com>
Acked-by: Dave Chinner <david@fromorbit.com>
This replicates file corruption we've seen with qemu-kvm when
we use if=virtio,cache=none,aio=native for IO to a sparse
ext4- or xfs-hosted file, and the partitions/filesystems
within that file image are not block-aligned. (think sector
63 here...) This results in AIO IOs not aligned to the
filesystem blocks.
This test modifies aiodio_sparse2.c to add an option to start
the file IO at an offset.
When we do 4k writes to a 16k file in 2 threads, starting
at offset 512, we get 0s interspersed in the file where they
should not be:
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000200 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 |................|
*
00001000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00001200 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 |................|
....
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
When Christoph and I were discussing bulkstat coherency on IRC, we
realised that inode lookup from bulkstat was not actually looking up
the inode allocation btree in xfs_imap() before reading the inode
buffer from disk in xfs_iread(). Bulkstat uses the same lookup
mechanism as handle validation to avoid shutting down the filesystem
if inode numbers that point to non-inode buffers (i.e. invalid) are
passed in the handle.
The problem with this is that when we delete inodes from disk and we
remove the inode chunk (i.e. deallocate inodes) we mark both the
inodes in memory and the cluster buffer as stale, thereby preventing
it from being written back to disk. The result of this is that some
number of inodes remain on disk looking like allocated, in use
inodes (i.e. di_mode is not zero).
Hence if we get a cold cache lookup from a stale handle that
references such an inode, we can read the inode off disk even though
it has been deleted because we don't check if the inode is allocated
or not. If the inode chunk has not been overwritten, then the inode
read will succeed and the handle-to-dentry conversion will not error
out like it is supposed to. The result is that stale NFS filehandles
and open_by_handle() will succeed incorrectly on unlinked files for
cold cache lookups.
This is a bug that has been present ever since the inode chunk
deletion code was implemented. This test exercises the problem and
documents the hoops you have to jump through to reproduce it.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
This is an adapted version of the reproduced in OSS BZ #874, which
shows file corruption when using the extent size hint.
Signed-off-by: Geoffrey Wehrman <gwehrman@sgi.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
According to Documentation/filesystems/fiemap.txt, If fm_extent_count
is zero, then the fm_extents[] array is ignored (no extents will be
returned), and the fm_mapped_extents count will hold the number of
extents needed.
This is broken by commit 97db39a1f6f69e906e98118392400de5217aa33a.
So add this test case in fiemap tester to avoid future regression.
Signed-off-by: Tao Ma <tao.ma@oracle.com>
Reviewed-by: Dave Chinner <david@fromorbit.com>
Set up autoconf to find the correct headers and compat libraries for
debian squeeze, and massage the includes to ensure the right headers get
included. Also fix a compile warning that was emitted now that it is being
compiled.
Signed-off-by: Dave Chinner <david@fromorbit.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Make sure at least the tests passing -p0 like xfstests 225 can work when
built without fallocate support.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Sandeen <sandeen@sandeen.net>
Preliminary fiemap testing support based on a test util written by
Josef Bacik.
For now it's only run with preallocation disabled, because xfs has a
tendency to fill in holes with data blocks (EOF prealloc stuff I
think) and similar for explicit preallocation, so this is breaking
the preallocation tests for now, when it finds a "data" block where
it expects a preallocated block.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>