aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/splice.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/fs/splice.c b/fs/splice.c
index ef808227bc11..6c9828651e6f 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -492,7 +492,7 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
492 492
493 ret = 0; 493 ret = 0;
494 spliced = 0; 494 spliced = 0;
495 while (len) { 495 while (len && !spliced) {
496 ret = __generic_file_splice_read(in, ppos, pipe, len, flags); 496 ret = __generic_file_splice_read(in, ppos, pipe, len, flags);
497 497
498 if (ret < 0) 498 if (ret < 0)
@@ -1060,15 +1060,10 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
1060 sd->flags &= ~SPLICE_F_NONBLOCK; 1060 sd->flags &= ~SPLICE_F_NONBLOCK;
1061 1061
1062 while (len) { 1062 while (len) {
1063 size_t read_len, max_read_len; 1063 size_t read_len;
1064
1065 /*
1066 * Do at most PIPE_BUFFERS pages worth of transfer:
1067 */
1068 max_read_len = min(len, (size_t)(PIPE_BUFFERS*PAGE_SIZE));
1069 1064
1070 ret = do_splice_to(in, &sd->pos, pipe, max_read_len, flags); 1065 ret = do_splice_to(in, &sd->pos, pipe, len, flags);
1071 if (unlikely(ret < 0)) 1066 if (unlikely(ret <= 0))
1072 goto out_release; 1067 goto out_release;
1073 1068
1074 read_len = ret; 1069 read_len = ret;
@@ -1080,26 +1075,17 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
1080 * could get stuck data in the internal pipe: 1075 * could get stuck data in the internal pipe:
1081 */ 1076 */
1082 ret = actor(pipe, sd); 1077 ret = actor(pipe, sd);
1083 if (unlikely(ret < 0)) 1078 if (unlikely(ret <= 0))
1084 goto out_release; 1079 goto out_release;
1085 1080
1086 bytes += ret; 1081 bytes += ret;
1087 len -= ret; 1082 len -= ret;
1088 1083
1089 /* 1084 if (ret < read_len)
1090 * In nonblocking mode, if we got back a short read then 1085 goto out_release;
1091 * that was due to either an IO error or due to the
1092 * pagecache entry not being there. In the IO error case
1093 * the _next_ splice attempt will produce a clean IO error
1094 * return value (not a short read), so in both cases it's
1095 * correct to break out of the loop here:
1096 */
1097 if ((flags & SPLICE_F_NONBLOCK) && (read_len < max_read_len))
1098 break;
1099 } 1086 }
1100 1087
1101 pipe->nrbufs = pipe->curbuf = 0; 1088 pipe->nrbufs = pipe->curbuf = 0;
1102
1103 return bytes; 1089 return bytes;
1104 1090
1105out_release: 1091out_release:
@@ -1161,10 +1147,12 @@ long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
1161 .pos = *ppos, 1147 .pos = *ppos,
1162 .u.file = out, 1148 .u.file = out,
1163 }; 1149 };
1164 size_t ret; 1150 long ret;
1165 1151
1166 ret = splice_direct_to_actor(in, &sd, direct_splice_actor); 1152 ret = splice_direct_to_actor(in, &sd, direct_splice_actor);
1167 *ppos = sd.pos; 1153 if (ret > 0)
1154 *ppos += ret;
1155
1168 return ret; 1156 return ret;
1169} 1157}
1170 1158