AC_HAVE_GETMNTINFO
AC_HAVE_FALLOCATE
AC_HAVE_FIEMAP
+AC_HAVE_PREADV
+AC_HAVE_SYNC_FILE_RANGE
AC_HAVE_BLKID_TOPO($enable_blkid)
AC_TYPE_PSINT
HAVE_GETMNTINFO = @have_getmntinfo@
HAVE_FALLOCATE = @have_fallocate@
HAVE_FIEMAP = @have_fiemap@
+HAVE_PREADV = @have_preadv@
+HAVE_SYNC_FILE_RANGE = @have_sync_file_range@
GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
# -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
LCFLAGS += -DHAVE_INJECT -DHAVE_RESBLKS
endif
-ifeq ($(PKG_PLATFORM),linux)
+ifeq ($(HAVE_SYNC_FILE_RANGE),yes)
CFILES += sync_file_range.c
LCFLAGS += -DHAVE_SYNC_FILE_RANGE
endif
LCFLAGS += -DHAVE_FALLOCATE
endif
+# Also implies PWRITEV
+ifeq ($(HAVE_PREADV),yes)
+LCFLAGS += -DHAVE_PREADV -DHAVE_PWRITEV
+endif
+
default: depend $(LTCOMMAND)
include $(BUILDRULES)
" -R -- read at random offsets in the range of bytes\n"
" -Z N -- zeed the random number generator (used when reading randomly)\n"
" (heh, zorry, the -s/-S arguments were already in use in pwrite)\n"
+#ifdef HAVE_PREADV
" -V N -- use vectored IO with N iovecs of blocksize each (preadv)\n"
+#endif
"\n"
" When in \"random\" mode, the number of read operations will equal the\n"
" number required to do a complete forward/backward scan of the range.\n"
}
}
+#ifdef HAVE_PREADV
static int
-do_pread(
+do_preadv(
int fd,
off64_t offset,
ssize_t count,
ssize_t oldlen = 0;
ssize_t bytes = 0;
-
- if (!vectors)
- return pread64(fd, buffer, min(count, buffer_size), offset);
-
/* trim the iovec if necessary */
if (count < buffersize) {
size_t len = 0;
return bytes;
}
+#else
+#define do_preadv(fd, offset, count, buffer_size) (0)
+#endif
+
+static int
+do_pread(
+ int fd,
+ off64_t offset,
+ ssize_t count,
+ ssize_t buffer_size)
+{
+ if (!vectors)
+ return pread64(fd, buffer, min(count, buffer_size), offset);
+
+ return do_preadv(fd, offset, count, buffer_size);
+}
static int
read_random(
case 'v':
vflag = 1;
break;
+#ifdef HAVE_PREADV
case 'V':
vectors = strtoul(optarg, &sp, 0);
if (!sp || sp == optarg) {
- printf(_("non-numberic vector count == %s\n"),
+ printf(_("non-numeric vector count == %s\n"),
optarg);
return 0;
}
break;
+#endif
case 'Z':
zeed = strtoul(optarg, &sp, 0);
if (!sp || sp == optarg) {
" -R -- write at random offsets in the specified range of bytes\n"
" -Z N -- zeed the random number generator (used when writing randomly)\n"
" (heh, zorry, the -s/-S arguments were already in use in pwrite)\n"
+#ifdef HAVE_PWRITEV
" -V N -- use vectored IO with N iovecs of blocksize each (pwritev)\n"
+#endif
"\n"));
}
+#ifdef HAVE_PWRITEV
static int
-do_pwrite(
+do_pwritev(
int fd,
off64_t offset,
ssize_t count,
ssize_t buffer_size)
{
- int vecs = 0;
- ssize_t oldlen = 0;
- ssize_t bytes = 0;
-
-
- if (!vectors)
- return pwrite64(fd, buffer, min(count, buffer_size), offset);
+ int vecs = 0;
+ ssize_t oldlen = 0;
+ ssize_t bytes = 0;
/* trim the iovec if necessary */
if (count < buffersize) {
return bytes;
}
+#else
+#define do_pwritev(fd, offset, count, buffer_size) (0)
+#endif
+
+static int
+do_pwrite(
+ int fd,
+ off64_t offset,
+ ssize_t count,
+ ssize_t buffer_size)
+{
+ if (!vectors)
+ return pwrite64(fd, buffer, min(count, buffer_size), offset);
+
+ return do_pwritev(fd, offset, count, buffer_size);
+}
+
static int
write_random(
off64_t offset,
case 'V':
vectors = strtoul(optarg, &sp, 0);
if (!sp || sp == optarg) {
- printf(_("non-numberic vector count == %s\n"),
+ printf(_("non-numeric vector count == %s\n"),
optarg);
return 0;
}
AC_MSG_RESULT(no))
AC_SUBST(have_fiemap)
])
+
+#
+# Check if we have a preadv libc call (Linux)
+#
+AC_DEFUN([AC_HAVE_PREADV],
+ [ AC_MSG_CHECKING([for preadv])
+ AC_TRY_LINK([
+#define _FILE_OFFSET_BITS 64
+#define _BSD_SOURCE
+#include <sys/uio.h>
+ ], [
+ preadv(0, 0, 0, 0);
+ ], have_preadv=yes
+ AC_MSG_RESULT(yes),
+ AC_MSG_RESULT(no))
+ AC_SUBST(have_preadv)
+ ])
+
+#
+# Check if we have a sync_file_range libc call (Linux)
+#
+AC_DEFUN([AC_HAVE_SYNC_FILE_RANGE],
+ [ AC_MSG_CHECKING([for sync_file_range])
+ AC_TRY_LINK([
+#define _GNU_SOURCE
+#define _FILE_OFFSET_BITS 64
+#include <fcntl.h>
+ ], [
+ sync_file_range(0, 0, 0, 0);
+ ], have_sync_file_range=yes
+ AC_MSG_RESULT(yes),
+ AC_MSG_RESULT(no))
+ AC_SUBST(have_sync_file_range)
+ ])
+