Some hex numbers are prefixed with "0x" and right-aligned with spaces,
leading to output like "0x beef". Make that "0x0beef" instead.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Move the run_fsx shell function into common/rc. Fix it to avoid
duplicate output on errors. Write the actual fsx parameters used into
$seqres.full instead of the BSIZE and PSIZE placeholders.
Include the symbolic fallocate mode in fsx error messages instead of the
numeric value. Use fprintf(stderr, ...) instead of warn() when
including strerror(errno) doesn't make sense.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
The NFS implementation of fallocate() does not support passing the
KEEP_SIZE flag by itself, causing tests to randomly fail.
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
1000 operations is not nearly enough to debug complex data integrity
issues, so increase the log buffer by an order of magnitude.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Move the inclusion of falloc.h with all it's possible defines for the
fallocate mode into global.h header file so we do not have to include
and define it manually in every tool using fallocate.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
This explicitly sends MS_SYNC as the flag to msync() in
fsx.c, in domapwrite(). Without this flag, the memory
written to the mmap'ed region will not be flushed to disk;
in fact, on Linux, calling msync() with a '0' or MS_ASYNC
flag is a no-op.
Signed-off-by: Curt Wohlgemuth <curtw@google.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Before punching a hole in a file, TRIM_OFF_LEN() calls
TRIM_OFF_LEN() in order to make sure the offset and size
used are in a reasonable range. But currently the range
it's limited to is maxfilelen, which allows the offset
(and therefore offset + len) to be beyond EOF.
Later, do_punch_hole() ignores any request that starts beyond
EOF, so we might as well limit requests to the file size.
It appears that a hole punch request that starts within a
file but whose length extends beyond it is treated simply
as a hole punch up to EOF. So there's no harm in limiting
the end of a hole punch request to the file size either.
Therefore, use TRIM_OFF_LEN() to put both the the offset
and length of a request within the file size for hole
punch requests.
Signed-off-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
A recent commit added a TRIM_OFF_LEN() macro in "ltp/fsx.c":
5843147e xfstests: fsx fallocate support is b0rked
A later commit fixed a problem with that macro:
c47d7a51 xfstests: fix modulo-by-zero error in fsx
There is an extra flag parameter in that macro that I didn't like
in either version. When looking at it the second time around I
concluded that there was no need for the flag after all.
Going back to the first commit, the code that TRIM_OFF_LEN()
replaced had one of two forms:
- For OP_READ and OP_MAP_READ:
if (file_size)
offset %= file_size;
else
offset = 0;
if (offset + size > file_size)
size = file_size - offset;
- For all other cases (except OP_TRUNCATE):
offset %= maxfilelen;
if (offset + size > maxfilelen)
size = maxfilelen - offset;
There's no harm in ensuring maxfilelen is non-zero (and doing so
is safer than what's done above). So both of the above can be
generalized this way:
if (SIZE_LIMIT)
offset %= SIZE_LIMIT;
else
offset = 0;
if (offset + size > SIZE_LIMIT)
size = SIZE_LIMIT - offset;
In other words, there is no need for the extra flag in the macro.
The following patch just does away with it. It uses the value of
the "size" parameter directly in avoiding a divide-by-zero, and in
the process avoids referencing the global "file_size" within the
macro expansion.
Signed-off-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
The libxfs resync brought in a new round_up macro that conflicts with the
round_up function in fsx. Rename the latter to allow building against the
new headers.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
The recent fsx fixes has a logic error in the offset trimming code.
If a read is done when the file size is zero, then the logic error
causes a offset % 0 opertaion to occur. This causes fsx to get a
SIGFPE and die.
This was not discovered during my testing because I was using a
random seed that didn't trip this condition. Changing the seed to
that which test 091 uses (the default of 1) causes such an operation
to occur....
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fsx segvs when dumping fallocate log entries. Fix magic string
array index parameters to be zero based rather than one based.
While touching log string related stuff, make the format consistent
with read and write operations so the log dump is easier to look at
with the human eye.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Alex Elder <aelder@sgi.com>
The recent fallocate/fpunch additions to fsx have not actually be
executing fallocate/fpunch operations. The logic to select what
operation to run is broken in such a way that fsx has been executing
mapped writes and truncates instead of fallocate and fpunch
operations.
Remove all the (b0rken) smarty-pants selection logic from the test()
function. Replace it with a clearly defined set of operations for
each mode and use understandable fallback logic when various
operation types have been disabled. Then use a simple switch
statement to execute each of the different operations, removing the
tortured nesting of if/else statements that only serve to obfuscate
the code.
As a result, fsx uses fallocate/fpunch appropriately during
operations and uses/disableѕ the operations as defined on the
command line correctly.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Alex Elder <aelder@sgi.com>
The operation flags parameter to fallocate is the second parameter,
not the last. Hence the fpunch test is actually testing for falloc
support, not fpunch. Somebody needs a brown paper bag.
Also, add a ftruncate call whenthe fpunch succeeds just in case the
file was not already zero sized. Failing to ensure we start with a
zero length file can cause read ops to fail size checks if they
occur before the file is written to be the main test loop.
While there, observe the quiet flag the same as the falloc test
does and have them both emit the warning at the same error level.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Alex Elder <aelder@sgi.com>
This patch adds punch hole tests to the fsx stress test.
Signed-off-by: Allison Henderson <achender@us.ibm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
ltp/fsx.c tests whether the filesystem it is run on supports fallocate.
If it is not supported the fsx will print warning to stderr. This leads
to fails of tests 075, 112, 127 for the filesystems that do not support
fallocate. The tests use ltp/fsx but do not filter out stderr. Since
ltp/fsx.c can work without fallocate support I propose to move this
message to stdout unless quiet output is not requested. Previous patch
printed the message even if -q flag was used. This patch honours the flag.
This simple patch fixes the issue for me, tested on all the mentioned tests:
Signed-off-by: Boris Ranto <branto@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Add random runtime fallocate calls to fsx (vs. the existing
preallocate file at start of run).
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Alex Elder <aelder@sgi.com>
Check to make sure the VM system provided 0's beyond the true end of
the file mapping (as required by mmap def in 1996 posix 1003.1)
This check was taken from the FreeBSD version of fsx.c.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
The bcmp() function comes from BSD 4.3, and was deprecated in
POSIX.1-2001. It was removed entirely in POSIX.1-2008.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
The bzero() function comes from BSD 4.3, and was deprecated in
POSIX.1-2001. It was removed entirely in POSIX.1-2008.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>