aboutsummaryrefslogtreecommitdiffstats
path: root/fs/splice.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/splice.c')
-rw-r--r--fs/splice.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/fs/splice.c b/fs/splice.c
index 7e8585574726..78cd264340f2 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -279,14 +279,6 @@ find_page:
279 page = find_get_page(mapping, index); 279 page = find_get_page(mapping, index);
280 if (!page) { 280 if (!page) {
281 /* 281 /*
282 * If in nonblock mode then dont block on
283 * readpage (we've kicked readahead so there
284 * will be asynchronous progress):
285 */
286 if (flags & SPLICE_F_NONBLOCK)
287 break;
288
289 /*
290 * page didn't exist, allocate one 282 * page didn't exist, allocate one
291 */ 283 */
292 page = page_cache_alloc_cold(mapping); 284 page = page_cache_alloc_cold(mapping);
@@ -307,6 +299,13 @@ find_page:
307 * If the page isn't uptodate, we may need to start io on it 299 * If the page isn't uptodate, we may need to start io on it
308 */ 300 */
309 if (!PageUptodate(page)) { 301 if (!PageUptodate(page)) {
302 /*
303 * If in nonblock mode then dont block on waiting
304 * for an in-flight io page
305 */
306 if (flags & SPLICE_F_NONBLOCK)
307 break;
308
310 lock_page(page); 309 lock_page(page);
311 310
312 /* 311 /*
@@ -400,17 +399,20 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
400 while (len) { 399 while (len) {
401 ret = __generic_file_splice_read(in, ppos, pipe, len, flags); 400 ret = __generic_file_splice_read(in, ppos, pipe, len, flags);
402 401
403 if (ret <= 0) 402 if (ret < 0)
404 break; 403 break;
404 else if (!ret) {
405 if (spliced)
406 break;
407 if (flags & SPLICE_F_NONBLOCK) {
408 ret = -EAGAIN;
409 break;
410 }
411 }
405 412
406 *ppos += ret; 413 *ppos += ret;
407 len -= ret; 414 len -= ret;
408 spliced += ret; 415 spliced += ret;
409
410 if (!(flags & SPLICE_F_NONBLOCK))
411 continue;
412 ret = -EAGAIN;
413 break;
414 } 416 }
415 417
416 if (spliced) 418 if (spliced)