Commit a82c53a0 authored by Tom Zanussi's avatar Tom Zanussi Committed by Jens Axboe

splice: fix sendfile() issue with relay

Splice isn't always incrementing the ppos correctly, which broke
relay splice.
Signed-off-by: 's avatarTom Zanussi <zanussi@comcast.net>
Tested-by: 's avatarDan Williams <dan.j.williams@intel.com>
Signed-off-by: 's avatarJens Axboe <jens.axboe@oracle.com>
parent 1ec7d99c
...@@ -983,7 +983,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd, ...@@ -983,7 +983,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
while (len) { while (len) {
size_t read_len; size_t read_len;
loff_t pos = sd->pos; loff_t pos = sd->pos, prev_pos = pos;
ret = do_splice_to(in, &pos, pipe, len, flags); ret = do_splice_to(in, &pos, pipe, len, flags);
if (unlikely(ret <= 0)) if (unlikely(ret <= 0))
...@@ -998,15 +998,19 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd, ...@@ -998,15 +998,19 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
* could get stuck data in the internal pipe: * could get stuck data in the internal pipe:
*/ */
ret = actor(pipe, sd); ret = actor(pipe, sd);
if (unlikely(ret <= 0)) if (unlikely(ret <= 0)) {
sd->pos = prev_pos;
goto out_release; goto out_release;
}
bytes += ret; bytes += ret;
len -= ret; len -= ret;
sd->pos = pos; sd->pos = pos;
if (ret < read_len) if (ret < read_len) {
sd->pos = prev_pos + ret;
goto out_release; goto out_release;
}
} }
done: done:
...@@ -1072,7 +1076,7 @@ long do_splice_direct(struct file *in, loff_t *ppos, struct file *out, ...@@ -1072,7 +1076,7 @@ long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
ret = splice_direct_to_actor(in, &sd, direct_splice_actor); ret = splice_direct_to_actor(in, &sd, direct_splice_actor);
if (ret > 0) if (ret > 0)
*ppos += ret; *ppos = sd.pos;
return ret; return ret;
} }
......
...@@ -1191,7 +1191,7 @@ static ssize_t relay_file_splice_read(struct file *in, ...@@ -1191,7 +1191,7 @@ static ssize_t relay_file_splice_read(struct file *in,
ret = 0; ret = 0;
spliced = 0; spliced = 0;
while (len) { while (len && !spliced) {
ret = subbuf_splice_actor(in, ppos, pipe, len, flags, &nonpad_ret); ret = subbuf_splice_actor(in, ppos, pipe, len, flags, &nonpad_ret);
if (ret < 0) if (ret < 0)
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment