All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Yi Yang <yang.y.yi@gmail.com>
Cc: torvalds@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: vmsplice can't work well
Date: Tue, 29 Aug 2006 16:05:43 +0200	[thread overview]
Message-ID: <20060829140542.GN12257@kernel.dk> (raw)
In-Reply-To: <44F4440F.1090300@gmail.com>

On Tue, Aug 29 2006, Yi Yang wrote:
> Hi, Jens
> 
> I try to trace vmsplice and find it can't work in both ppc64 and i386,
> it always return -EFAULT because of the address of iovec.iov_base no
> matter it is page alignment or not, I don't know if I should file a
> bug for it, do you test it on i386 or ppc64?

Please provide an strace of the problem, it works fine for me (on x86-64
and x86, I've previously also tested ppc64 and ia64). Also please see
the splice tools here for more examples:

http://brick.kernel.dk/snaps/splice-git-20060711102502.tar.gz

I patched your program to fix the x86-64 syscall number and one/two
bugs, diff attached. Output for me:

axboe@nelson:/home/axboe $ ./f | cat > /dev/null
getpagesize = 4096
page size: 4096 bytes
written len = 4096

--- f.c~	2006-08-29 16:02:21.000000000 +0200
+++ f.c	2006-08-29 16:04:41.000000000 +0200
@@ -22,7 +22,7 @@
 #elif defined(__x86_64__)
 #define __NR_splice 275
 #define __NR_tee 276
-#define __NR_vmsplice 277
+#define __NR_vmsplice 278
 #elif defined(__powerpc__) || defined(__powerpc64__)
 #define __NR_splice 283
 #define __NR_tee 284
@@ -71,23 +71,26 @@
 	v.iov_base = buffer;
 	v.iov_len = len;
 
-	while (len) {
+	while (v.iov_len) {
 		/*
 		 * in a real app you'd be more clever with poll of course,
 		 * here we are basically just blocking on output room and
 		 * not using the free time for anything interesting.
 		 */
 		if (poll(&pfd, 1, -1) < 0)
-		return xerror("poll");
+			return xerror("poll");
 
 		written = vmsplice(fd, &v, 1, 0);
 		printf("here: len = %d, written = %d\n", len, written);
 
-		if (written <= 0)
+		if (!written)
+			break;
+		else if (written < 0)
 			return xerror("vmsplice");
 		fprintf(stderr, "written len = %d\n", written);
 
-		len -= written;
+		v.iov_len -= written;
+		v.iov_base += written;
 	}
 
 	return 0;
@@ -98,7 +101,7 @@
 	unsigned char *buffer;
 	struct stat sb;
 	long page_size;
-	int i, ret;
+	int i;
 
 	if (fstat(STDOUT_FILENO, &sb) < 0)
 		return xerror("stat");
@@ -112,7 +115,7 @@
 		return xerror("_SC_PAGESIZE");
 
 	fprintf(stderr, "getpagesize = %d\n", getpagesize());
-	fprintf(stderr, "page size: %d bytes\n", page_size);
+	fprintf(stderr, "page size: %d bytes\n", (int) page_size);
 
 	buffer = malloc(2 * 65536);
 	buffer[0]='A';

-- 
Jens Axboe


  reply	other threads:[~2006-08-29 14:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-29 13:41 vmsplice can't work well Yi Yang
2006-08-29 14:05 ` Jens Axboe [this message]
     [not found]   ` <44F5CC08.8010205@mnsu.edu>
     [not found]     ` <20060830174815.GF7331@kernel.dk>
     [not found]       ` <44F5D3C6.1010108@mnsu.edu>
2006-08-31  9:24         ` Jens Axboe
2006-08-31 23:17           ` David Chinner
2006-08-31 23:18             ` Nathan Scott
2006-09-01 13:19           ` David Chinner
2006-09-01 13:45             ` Jens Axboe
2006-09-02  2:31             ` Jeffrey E. Hundstad

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060829140542.GN12257@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=yang.y.yi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.