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>
int test;
__uint64_t fileoffset;
int test;
__uint64_t fileoffset;
#define READ_XFER 10 /* block to read at a time when checking */
#define READ_XFER 10 /* block to read at a time when checking */
writeblks(char *fname, int fd, size_t alignment)
{
__uint64_t offset;
writeblks(char *fname, int fd, size_t alignment)
{
__uint64_t offset;
int block;
struct flock64 fl;
int block;
struct flock64 fl;
- if (test)
- buffer = NULL;
- else {
if (posix_memalign((void **) &buffer, alignment, blocksize)) {
perror("malloc");
exit(1);
if (posix_memalign((void **) &buffer, alignment, blocksize)) {
perror("malloc");
exit(1);
return (size_t) dioattr.d_mem;
}
return (size_t) dioattr.d_mem;
}
+static int
+realtime_setup(char *filename, int fd)
+{
+ struct fsxattr rtattr;
+
+ (void) memset(&rtattr, 0, sizeof rtattr);
+ if (xfscntl(filename, fd, FSGETXATTR, &rtattr) < 0) {
+ perror("FSGETXATTR)");
+ return 1;
+ }
+ if ((rtattr.fsx_xflags & XFS_XFLAG_REALTIME) == 0 ||
+ (extsize && rtattr.fsx_extsize != extsize * blocksize)) {
+ rtattr.fsx_xflags |= XFS_XFLAG_REALTIME;
+ if (extsize)
+ rtattr.fsx_extsize = extsize * blocksize;
+ if (xfscntl(filename, fd, FSSETXATTR, &rtattr) < 0) {
+ perror("FSSETXATTR)");
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
int
main(int argc, char *argv[])
{
int
main(int argc, char *argv[])
{
case 'v': verbose++; break;
case 'w': wsync++; break;
case 'd': direct++; break;
case 'v': verbose++; break;
case 'w': wsync++; break;
case 'd': direct++; break;
+ case 'r': rt++; direct++; break;
case 'a': alloconly++; break;
case 'p': preserve++; break;
case 't': test++; preserve++; break;
case 'a': alloconly++; break;
case 'p': preserve++; break;
case 't': test++; preserve++; break;
blocksize, (unsigned long long)filesize, seed,
count, (unsigned long long)fileoffset, extsize);
printf("randholes: verbose=%d, wsync=%d, direct=%d, rt=%d, alloconly=%d, preserve=%d, test=%d\n",
blocksize, (unsigned long long)filesize, seed,
count, (unsigned long long)fileoffset, extsize);
printf("randholes: verbose=%d, wsync=%d, direct=%d, rt=%d, alloconly=%d, preserve=%d, test=%d\n",
- verbose, wsync, direct, rt, alloconly, preserve, test);
+ verbose, wsync, direct ? 1 : 0, rt, alloconly, preserve, test);
/*
* Open the file, write rand block in random places, read them all
/*
* Open the file, write rand block in random places, read them all
perror("malloc");
return 1;
}
perror("malloc");
return 1;
}
oflags=test?(O_RDONLY):(O_RDWR | O_CREAT);
oflags |= (preserve ? 0 : O_TRUNC) |
oflags=test?(O_RDONLY):(O_RDWR | O_CREAT);
oflags |= (preserve ? 0 : O_TRUNC) |
- if (rt) {
- if (xfscntl(filename, fd, FSGETXATTR, &rtattr) < 0) {
- perror("xfsnctl(FSGETXATTR)");
- return 1;
- }
- if ((rtattr.fsx_xflags & XFS_XFLAG_REALTIME) == 0 ||
- (extsize && rtattr.fsx_extsize != extsize * blocksize)) {
- rtattr.fsx_xflags |= XFS_XFLAG_REALTIME;
- if (extsize)
- rtattr.fsx_extsize = extsize * blocksize;
- if (xfscntl(filename, fd, FSSETXATTR, &rtattr) < 0) {
- perror("xfscntl(FSSETXATTR)");
- return 1;
- }
- }
- }
+ if (rt && realtime_setup(filename, fd))
+ return 1;
alignment = get_alignment(filename, fd);
if (! alignment)
alignment = get_alignment(filename, fd);
if (! alignment)