aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJens Axboe <axboe@suse.de>2006-04-19 09:56:12 -0400
committerJens Axboe <axboe@suse.de>2006-04-19 09:56:12 -0400
commitc4f895cbe1e95aab633207fb19c650b7c984c01a (patch)
tree3f8fa236d737da19bd9d7c38ab01079caf7d5f56 /fs
parent91ad66ef4469cb631ec0ccd131b07f16770773f7 (diff)
[PATCH] splice: cleanup the SPLICE_F_NONBLOCK handling
- generic_file_splice_read() more readable and correct - Don't bail on page allocation with NONBLOCK set, just don't allow direct blocking on IO (eg lock_page). Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/splice.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/fs/splice.c b/fs/splice.c
index 7e858557472..78cd264340f 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)