Skip to contentSkip to conversation

xfs_io: include headers for preadv/pwritev

PATCH In review Eric Sandeen 4 participants 13 messages Oct 9, 2012 – Oct 11, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 xfs_io: include headers for preadv/pwritev

We need to include uio.h to avoid:

[CC] pread.o
pread.c: In function ‘do_pread’:
pread.c:198: warning: implicit declaration of function ‘preadv’
[CC] pwrite.o
pwrite.c: In function ‘do_pwrite’:
pwrite.c:85: warning: implicit declaration of function ‘pwritev’

---

io/pread.c +2 -0
index 0b9454b..9fad373 100644
@@ -16,6 +16,8 @@
  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#define _BSD_SOURCE 	/* for preadv */
+#include <sys/uio.h>
 #include <xfs/xfs.h>
 #include <xfs/command.h>
 #include <xfs/input.h>
io/pwrite.c +2 -0
index 3689960..848b990 100644
@@ -16,6 +16,8 @@
  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#define _BSD_SOURCE 	/* for pwritev */
+#include <sys/uio.h>
 #include <xfs/xfs.h>
 #include <xfs/command.h>
 #include <xfs/input.h>

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw

PATCH 2/2 xfs_io: configure tests for preadv/pwritev & sync_file_range

On older systems we may not have preadv/pwritev and/or sync_file_range.

Add the configure magic, and stub out the code
where needed.

(sync_file_range just needed a better test; preadv/pwritev took a little more rearranging)

And fix a couple typos ("numberic") while we're at it.

---

configure.in +2 -0
index 664c0e9..b927c32 100644
@@ -108,6 +108,8 @@ AC_HAVE_GETMNTENT
 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
include/builddefs.in +2 -0
index 81ebfcd..4a0e910 100644
@@ -101,6 +101,8 @@ HAVE_GETMNTENT = @have_getmntent@
 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
io/Makefile +5 -1
index bf46d56..23cd90b 100644
@@ -58,7 +58,7 @@ CFILES += inject.c resblks.c
 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
@@ -75,6 +75,10 @@ ifeq ($(HAVE_FALLOCATE),yes)
 LCFLAGS += -DHAVE_FALLOCATE
 endif
 
+ifeq ($(HAVE_PREADV),yes)
+LCFLAGS += -DHAVE_PREADV
+endif
+
 default: depend $(LTCOMMAND)
 
 include $(BUILDRULES)
io/pread.c +23 -6
index 9fad373..9d3720e 100644
@@ -48,7 +48,9 @@ pread_help(void)
 " -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"
@@ -169,8 +171,9 @@ dump_buffer(
 	}
 }
 
+#ifdef HAVE_PREADV
 static int
-do_pread(
+do_preadv(
 	int		fd,
 	off64_t		offset,
 	ssize_t		count,
@@ -180,10 +183,6 @@ do_pread(
 	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;
@@ -205,6 +204,22 @@ do_pread(
 
 	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(
@@ -407,14 +422,16 @@ pread_f(
 		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) {
io/pwrite.c +25 -9
index 848b990..22a3827 100644
@@ -52,24 +52,23 @@ pwrite_help(void)
 " -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_PREADV
 " -V N -- use vectored IO with N iovecs of blocksize each (pwritev)\n"
+#endif
 "\n"));
 }
 
+#ifdef HAVE_PREADV
 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) {
@@ -92,6 +91,23 @@ do_pwrite(
 
 	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,
@@ -298,7 +314,7 @@ pwrite_f(
 		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;
 			}
m4/package_libcdev.m4 +35 -0
index 1e2c256..f489f52 100644
@@ -135,3 +135,38 @@ AC_DEFUN([AC_HAVE_FIEMAP],
        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)
+  ])
+

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v1 1/2
#9 lore raw
In reply to Eric Sandeen
Quoted 8 lines · Eric Sandeen

We need to include uio.h to avoid:

[CC] pread.o
pread.c: In function ‘do_pread’:
pread.c:198: warning: implicit declaration of function ‘preadv’
[CC] pwrite.o
pwrite.c: In function ‘do_pwrite’:
pwrite.c:85: warning: implicit declaration of function ‘pwritev’

Funny, I don't recall ever seeing that error when I wrote these patches. But, yeah, I see them now.

Quoted 1 line
Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#2 lore raw

Re: [PATCH 2/2] xfs_io: configure tests for preadv/pwritev & sync_file_range

In reply to Eric Sandeen
Quoted 6 lines · Eric Sandeen

On older systems we may not have preadv/pwritev and/or sync_file_range.

Add the configure magic, and stub out the code
where needed.

Quoted 6 lines

(sync_file_range just needed a better test; preadv/pwritev took a little more rearranging)

And fix a couple typos ("numberic") while we're at it.

Looks fine, though the "HAVE_PREADV" in the pwritev case is a bit wierd. Perhaps doing this:

include/builddefs.in HAVE_GETMNTENT = @have_getmntent@ · line 104

Quoted 9 lines
include/builddefs.in +1 -0
index 81ebfcd..4a0e910 100644
@@ -101,6 +101,8 @@ HAVE_GETMNTENT = @have_getmntent@
 HAVE_GETMNTINFO = @have_getmntinfo@
 HAVE_FALLOCATE = @have_fallocate@
 HAVE_FIEMAP = @have_fiemap@
+HAVE_PREADV = @have_preadv@

HAVE_PWRITEV = @have_preadv@

Would reduce that wierdness a bit when looking at the pwritev code....

Otherwise everything else looks ok.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#3 lore raw

Re: [PATCH 2/2] xfs_io: configure tests for preadv/pwritev & sync_file_range

Quoted 29 lines · Dave Chinner
Quoted 6 lines · Eric Sandeen

On older systems we may not have preadv/pwritev and/or sync_file_range.

Add the configure magic, and stub out the code
where needed.

Quoted 6 lines

(sync_file_range just needed a better test; preadv/pwritev took a little more rearranging)

And fix a couple typos ("numberic") while we're at it.

Looks fine, though the "HAVE_PREADV" in the pwritev case is a bit wierd. Perhaps doing this:

include/builddefs.in HAVE_GETMNTENT = @have_getmntent@ · line 104

Quoted 9 lines
include/builddefs.in +1 -0
index 81ebfcd..4a0e910 100644
@@ -101,6 +101,8 @@ HAVE_GETMNTENT = @have_getmntent@
 HAVE_GETMNTINFO = @have_getmntinfo@
 HAVE_FALLOCATE = @have_fallocate@
 HAVE_FIEMAP = @have_fiemap@
+HAVE_PREADV = @have_preadv@

HAVE_PWRITEV = @have_preadv@

Quoted 2 lines

Would reduce that wierdness a bit when looking at the pwritev code....

Yeah I was a little unhappy w/ that. But I think then we'd also need:

+ifeq ($(HAVE_PWRITEV),yes)
+LCFLAGS += -DHAVE_PWRITEV
+endif

and at some point we might run out of room on the cmdline ;)

Could change it to HAVE_PREADWRITEV or something ...

-Eric

Quoted 6 lines

Otherwise everything else looks ok.

Cheers,

Dave.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#4 lore raw

Re: [PATCH 2/2] xfs_io: configure tests for preadv/pwritev & sync_file_range

Quoted 35 lines · Eric Sandeen
Quoted 29 lines · Dave Chinner
Quoted 6 lines · Eric Sandeen

On older systems we may not have preadv/pwritev and/or sync_file_range.

Add the configure magic, and stub out the code
where needed.

Quoted 6 lines

(sync_file_range just needed a better test; preadv/pwritev took a little more rearranging)

And fix a couple typos ("numberic") while we're at it.

Looks fine, though the "HAVE_PREADV" in the pwritev case is a bit wierd. Perhaps doing this:

include/builddefs.in HAVE_GETMNTENT = @have_getmntent@ · line 104

Quoted 9 lines
include/builddefs.in +1 -0
index 81ebfcd..4a0e910 100644
@@ -101,6 +101,8 @@ HAVE_GETMNTENT = @have_getmntent@
 HAVE_GETMNTINFO = @have_getmntinfo@
 HAVE_FALLOCATE = @have_fallocate@
 HAVE_FIEMAP = @have_fiemap@
+HAVE_PREADV = @have_preadv@

HAVE_PWRITEV = @have_preadv@

Quoted 2 lines

Would reduce that wierdness a bit when looking at the pwritev code....

Yeah I was a little unhappy w/ that. But I think then we'd also need:

Review

Quoted 3 lines
(quoted diff) +3 -0
+ifeq ($(HAVE_PWRITEV),yes)
+LCFLAGS += -DHAVE_PWRITEV
+endif

True.

Quoted 1 line

and at some point we might run out of room on the cmdline ;)

Unlikely ;)

Quoted 1 line

Could change it to HAVE_PREADWRITEV or something ...

HAVE_VECTORED_IO?

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#5 lore raw

Re: [PATCH 2/2] xfs_io: configure tests for preadv/pwritev & sync_file_range

Quoted 42 lines · Dave Chinner
Quoted 35 lines · Eric Sandeen
Quoted 29 lines · Dave Chinner
Quoted 6 lines · Eric Sandeen

On older systems we may not have preadv/pwritev and/or sync_file_range.

Add the configure magic, and stub out the code
where needed.

Quoted 6 lines

(sync_file_range just needed a better test; preadv/pwritev took a little more rearranging)

And fix a couple typos ("numberic") while we're at it.

Looks fine, though the "HAVE_PREADV" in the pwritev case is a bit wierd. Perhaps doing this:

include/builddefs.in HAVE_GETMNTENT = @have_getmntent@ · line 104

Quoted 9 lines
include/builddefs.in +1 -0
index 81ebfcd..4a0e910 100644
@@ -101,6 +101,8 @@ HAVE_GETMNTENT = @have_getmntent@
 HAVE_GETMNTINFO = @have_getmntinfo@
 HAVE_FALLOCATE = @have_fallocate@
 HAVE_FIEMAP = @have_fiemap@
+HAVE_PREADV = @have_preadv@

HAVE_PWRITEV = @have_preadv@

Quoted 2 lines

Would reduce that wierdness a bit when looking at the pwritev code....

Yeah I was a little unhappy w/ that. But I think then we'd also need:

Review

Quoted 3 lines
(quoted diff) +3 -0
+ifeq ($(HAVE_PWRITEV),yes)
+LCFLAGS += -DHAVE_PWRITEV
+endif

True.

Quoted 7 lines
Quoted 1 line

and at some point we might run out of room on the cmdline ;)

Unlikely ;)

Quoted 1 line

Could change it to HAVE_PREADWRITEV or something ...

HAVE_VECTORED_IO?

Thought about that but we already have readv/writev, just not *P*readv/writev.

I can just add MOAR FLAGS if that looks better to you. ;)

(or HAVE_PVECTORED_IO?) ;)

-Eric

Quoted 4 lines

Cheers,

Dave.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#6 lore raw

Re: [PATCH 2/2] xfs_io: configure tests for preadv/pwritev & sync_file_range

Quoted 45 lines · Eric Sandeen
Quoted 44 lines · Dave Chinner
Quoted 35 lines · Eric Sandeen
Quoted 29 lines · Dave Chinner
Quoted 6 lines · Eric Sandeen

On older systems we may not have preadv/pwritev and/or sync_file_range.

Add the configure magic, and stub out the code
where needed.

Quoted 6 lines

(sync_file_range just needed a better test; preadv/pwritev took a little more rearranging)

And fix a couple typos ("numberic") while we're at it.

Looks fine, though the "HAVE_PREADV" in the pwritev case is a bit wierd. Perhaps doing this:

include/builddefs.in HAVE_GETMNTENT = @have_getmntent@ · line 104

Quoted 9 lines
include/builddefs.in +1 -0
index 81ebfcd..4a0e910 100644
@@ -101,6 +101,8 @@ HAVE_GETMNTENT = @have_getmntent@
 HAVE_GETMNTINFO = @have_getmntinfo@
 HAVE_FALLOCATE = @have_fallocate@
 HAVE_FIEMAP = @have_fiemap@
+HAVE_PREADV = @have_preadv@

HAVE_PWRITEV = @have_preadv@

Quoted 2 lines

Would reduce that wierdness a bit when looking at the pwritev code....

Yeah I was a little unhappy w/ that. But I think then we'd also need:

Review

Quoted 3 lines
(quoted diff) +3 -0
+ifeq ($(HAVE_PWRITEV),yes)
+LCFLAGS += -DHAVE_PWRITEV
+endif

True.

Quoted 1 line

and at some point we might run out of room on the cmdline ;)

Quoted 7 lines
Quoted 5 lines

Unlikely ;)

Quoted 1 line

Could change it to HAVE_PREADWRITEV or something ...

HAVE_VECTORED_IO?

Thought about that but we already have readv/writev, just not *P*readv/writev.

xfs_io doesn't use readv/writev, so I don't think it' a major concern.

Red, green, blue, the colour of the bike shed really doesn't matter that much....

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#10 lore raw

PATCH v2 1/2 xfs_io: include headers for preadv/pwritev

In reply to Eric Sandeen

We need to include uio.h to avoid:

[CC] pread.o
pread.c: In function ‘do_pread’:
pread.c:198: warning: implicit declaration of function ‘preadv’
[CC] pwrite.o
pwrite.c: In function ‘do_pwrite’:
pwrite.c:85: warning: implicit declaration of function ‘pwritev’

---

V2: Move _BSD_SOURCE to PCFLAGS intead of in source files per Dave's suggestion.

include/builddefs.in +1 -1
index 81ebfcd..04590d2 100644
@@ -106,7 +106,7 @@ GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
 #	   -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
 
 ifeq ($(PKG_PLATFORM),linux)
-PCFLAGS = -D_GNU_SOURCE -D_XOPEN_SOURCE=500 -D_FILE_OFFSET_BITS=64 $(GCCFLAGS)
+PCFLAGS = -D_GNU_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=500 -D_FILE_OFFSET_BITS=64 $(GCCFLAGS)
 DEPENDFLAGS = -D__linux__
 endif
 ifeq ($(PKG_PLATFORM),gnukfreebsd)
io/pread.c +1 -0
index 0b9454b..7e2ed7d 100644
@@ -16,6 +16,7 @@
  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <sys/uio.h>
 #include <xfs/xfs.h>
 #include <xfs/command.h>
 #include <xfs/input.h>
io/pwrite.c +1 -0
index 3689960..73acbac 100644
@@ -16,6 +16,7 @@
  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <sys/uio.h>
 #include <xfs/xfs.h>
 #include <xfs/command.h>
 #include <xfs/input.h>

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#7 lore raw

PATCH v2 2/2 xfs_io: configure tests for preadv/pwritev & sync_file_range

In reply to Eric Sandeen

On older systems we may not have preadv/pwritev and/or sync_file_range.

Add the configure magic, and stub out the code
where needed.

(sync_file_range just needed a better test; preadv/pwritev took a little more rearranging)

And fix a couple typos ("numberic") while we're at it.

---

V2: add -DHAVE_PWRITEV and use that test in io/pwrite.c rather than HAVE_PREADV

configure.in +2 -0
index 664c0e9..b927c32 100644
@@ -108,6 +108,8 @@ AC_HAVE_GETMNTENT
 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
include/builddefs.in +2 -0
index 04590d2..0a3fa1a 100644
@@ -101,6 +101,8 @@ HAVE_GETMNTENT = @have_getmntent@
 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
io/Makefile +6 -1
index bf46d56..50edf91 100644
@@ -58,7 +58,7 @@ CFILES += inject.c resblks.c
 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
@@ -75,6 +75,11 @@ ifeq ($(HAVE_FALLOCATE),yes)
 LCFLAGS += -DHAVE_FALLOCATE
 endif
 
+# Also implies PWRITEV
+ifeq ($(HAVE_PREADV),yes)
+LCFLAGS += -DHAVE_PREADV -DHAVE_PWRITEV
+endif
+
 default: depend $(LTCOMMAND)
 
 include $(BUILDRULES)
io/pread.c +23 -6
index 7e2ed7d..a42baed 100644
@@ -47,7 +47,9 @@ pread_help(void)
 " -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"
@@ -168,8 +170,9 @@ dump_buffer(
 	}
 }
 
+#ifdef HAVE_PREADV
 static int
-do_pread(
+do_preadv(
 	int		fd,
 	off64_t		offset,
 	ssize_t		count,
@@ -179,10 +182,6 @@ do_pread(
 	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;
@@ -204,6 +203,22 @@ do_pread(
 
 	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(
@@ -406,14 +421,16 @@ pread_f(
 		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) {
io/pwrite.c +25 -9
index 73acbac..a2f0a81 100644
@@ -51,24 +51,23 @@ pwrite_help(void)
 " -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) {
@@ -91,6 +90,23 @@ do_pwrite(
 
 	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,
@@ -297,7 +313,7 @@ pwrite_f(
 		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;
 			}
m4/package_libcdev.m4 +35 -0
index 1e2c256..f489f52 100644
@@ -135,3 +135,38 @@ AC_DEFUN([AC_HAVE_FIEMAP],
        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)
+  ])
+

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v2 1/2
#11 lore raw
In reply to Eric Sandeen
Quoted 10 lines · Eric Sandeen

We need to include uio.h to avoid:

[CC] pread.o
pread.c: In function ‘do_pread’:
pread.c:198: warning: implicit declaration of function ‘preadv’
[CC] pwrite.o
pwrite.c: In function ‘do_pwrite’:
pwrite.c:85: warning: implicit declaration of function ‘pwritev’

Looks good.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v2 2/2
#8 lore raw

Re: [PATCH 2/2 V2] xfs_io: configure tests for preadv/pwritev & sync_file_range

In reply to Eric Sandeen
Quoted 16 lines · Eric Sandeen

On older systems we may not have preadv/pwritev and/or sync_file_range.

Add the configure magic, and stub out the code
where needed.

(sync_file_range just needed a better test; preadv/pwritev took a little more rearranging)

And fix a couple typos ("numberic") while we're at it.

---

V2: add -DHAVE_PWRITEV and use that test in io/pwrite.c rather than HAVE_PREADV

.....

io/Makefile ifeq ($(HAVE_FALLOCATE),yes) · line 81

Quoted 4 lines
io/Makefile +4 -0
+# Also implies PWRITEV
+ifeq ($(HAVE_PREADV),yes)
+LCFLAGS += -DHAVE_PREADV -DHAVE_PWRITEV
+endif

Nice solution ;)

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#12 lore raw
In reply to Eric Sandeen
Quoted 11 lines · Eric Sandeen

We need to include uio.h to avoid:

[CC] pread.o
pread.c: In function ‘do_pread’:
pread.c:198: warning: implicit declaration of function ‘preadv’
[CC] pwrite.o
pwrite.c: In function ‘do_pwrite’:
pwrite.c:85: warning: implicit declaration of function ‘pwritev’

---

I had a problem downloading this patch. It was small, so I recreated. I hope it was correct.

Committed to git://oss.sgi.com/xfs/cmds/xfsprogs.git, master branch.

--Mark.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs