Commit a8adbe378b56acd5945df70753c7e8f6fe223304

Authored by Michał Mirosław
Committed by Jens Axboe
1 parent e4ea0c16a8

fs/splice: Pull buf->ops->confirm() from splice_from_pipe actors

This patch pulls calls to buf->ops->confirm() from all actors passed
(also indirectly) to splice_from_pipe_feed().

Is avoiding the call to buf->ops->confirm() while splice()ing to
/dev/null is an intentional optimization? No other user does that
and this will remove this special case.

Against current linux.git 6313e3c21743cc88bb5bd8aa72948ee1e83937b6.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>

Showing 3 changed files with 14 additions and 37 deletions Side-by-side Diff

drivers/block/loop.c
... ... @@ -397,10 +397,6 @@
397 397 sector_t IV;
398 398 int size, ret;
399 399  
400   - ret = buf->ops->confirm(pipe, buf);
401   - if (unlikely(ret))
402   - return ret;
403   -
404 400 IV = ((sector_t) page->index << (PAGE_CACHE_SHIFT - 9)) +
405 401 (buf->offset >> 9);
406 402 size = sd->len;
... ... @@ -847,10 +847,6 @@
847 847 size_t size;
848 848 int ret;
849 849  
850   - ret = buf->ops->confirm(pipe, buf);
851   - if (unlikely(ret))
852   - return ret;
853   -
854 850 size = sd->len;
855 851  
856 852 if (rqstp->rq_res.page_len == 0) {
... ... @@ -682,19 +682,14 @@
682 682 {
683 683 struct file *file = sd->u.file;
684 684 loff_t pos = sd->pos;
685   - int ret, more;
  685 + int more;
686 686  
687   - ret = buf->ops->confirm(pipe, buf);
688   - if (!ret) {
689   - more = (sd->flags & SPLICE_F_MORE) || sd->len < sd->total_len;
690   - if (file->f_op && file->f_op->sendpage)
691   - ret = file->f_op->sendpage(file, buf->page, buf->offset,
692   - sd->len, &pos, more);
693   - else
694   - ret = -EINVAL;
695   - }
  687 + if (!likely(file->f_op && file->f_op->sendpage))
  688 + return -EINVAL;
696 689  
697   - return ret;
  690 + more = (sd->flags & SPLICE_F_MORE) || sd->len < sd->total_len;
  691 + return file->f_op->sendpage(file, buf->page, buf->offset,
  692 + sd->len, &pos, more);
698 693 }
699 694  
700 695 /*
... ... @@ -727,13 +722,6 @@
727 722 void *fsdata;
728 723 int ret;
729 724  
730   - /*
731   - * make sure the data in this buffer is uptodate
732   - */
733   - ret = buf->ops->confirm(pipe, buf);
734   - if (unlikely(ret))
735   - return ret;
736   -
737 725 offset = sd->pos & ~PAGE_CACHE_MASK;
738 726  
739 727 this_len = sd->len;
740 728  
... ... @@ -805,12 +793,17 @@
805 793 if (sd->len > sd->total_len)
806 794 sd->len = sd->total_len;
807 795  
808   - ret = actor(pipe, buf, sd);
809   - if (ret <= 0) {
  796 + ret = buf->ops->confirm(pipe, buf);
  797 + if (unlikely(ret)) {
810 798 if (ret == -ENODATA)
811 799 ret = 0;
812 800 return ret;
813 801 }
  802 +
  803 + ret = actor(pipe, buf, sd);
  804 + if (ret <= 0)
  805 + return ret;
  806 +
814 807 buf->offset += ret;
815 808 buf->len -= ret;
816 809  
... ... @@ -1044,10 +1037,6 @@
1044 1037 int ret;
1045 1038 void *data;
1046 1039  
1047   - ret = buf->ops->confirm(pipe, buf);
1048   - if (ret)
1049   - return ret;
1050   -
1051 1040 data = buf->ops->map(pipe, buf, 0);
1052 1041 ret = kernel_write(sd->u.file, data + buf->offset, sd->len, sd->pos);
1053 1042 buf->ops->unmap(pipe, buf, data);
... ... @@ -1506,10 +1495,6 @@
1506 1495 {
1507 1496 char *src;
1508 1497 int ret;
1509   -
1510   - ret = buf->ops->confirm(pipe, buf);
1511   - if (unlikely(ret))
1512   - return ret;
1513 1498  
1514 1499 /*
1515 1500 * See if we can use the atomic maps, by prefaulting in the