Commit cf8208d0eabd1d5d2625ec02a175a294c3f30d36
1 parent
f0930fffa9
Exists in
master
and in
7 other branches
sendfile: convert nfsd to splice_direct_to_actor()
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Showing 4 changed files with 34 additions and 19 deletions Side-by-side Diff
fs/nfsd/vfs.c
... | ... | @@ -23,7 +23,7 @@ |
23 | 23 | #include <linux/file.h> |
24 | 24 | #include <linux/mount.h> |
25 | 25 | #include <linux/major.h> |
26 | -#include <linux/ext2_fs.h> | |
26 | +#include <linux/pipe_fs_i.h> | |
27 | 27 | #include <linux/proc_fs.h> |
28 | 28 | #include <linux/stat.h> |
29 | 29 | #include <linux/fcntl.h> |
30 | 30 | |
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | 35 | |
... | ... | @@ -801,26 +801,32 @@ |
801 | 801 | } |
802 | 802 | |
803 | 803 | /* |
804 | - * Grab and keep cached pages assosiated with a file in the svc_rqst | |
805 | - * so that they can be passed to the netowork sendmsg/sendpage routines | |
806 | - * directrly. They will be released after the sending has completed. | |
804 | + * Grab and keep cached pages associated with a file in the svc_rqst | |
805 | + * so that they can be passed to the network sendmsg/sendpage routines | |
806 | + * directly. They will be released after the sending has completed. | |
807 | 807 | */ |
808 | 808 | static int |
809 | -nfsd_read_actor(read_descriptor_t *desc, struct page *page, unsigned long offset , unsigned long size) | |
809 | +nfsd_splice_actor(struct pipe_inode_info *pipe, struct pipe_buffer *buf, | |
810 | + struct splice_desc *sd) | |
810 | 811 | { |
811 | - unsigned long count = desc->count; | |
812 | - struct svc_rqst *rqstp = desc->arg.data; | |
812 | + struct svc_rqst *rqstp = sd->u.data; | |
813 | 813 | struct page **pp = rqstp->rq_respages + rqstp->rq_resused; |
814 | + struct page *page = buf->page; | |
815 | + size_t size; | |
816 | + int ret; | |
814 | 817 | |
815 | - if (size > count) | |
816 | - size = count; | |
818 | + ret = buf->ops->pin(pipe, buf); | |
819 | + if (unlikely(ret)) | |
820 | + return ret; | |
817 | 821 | |
822 | + size = sd->len; | |
823 | + | |
818 | 824 | if (rqstp->rq_res.page_len == 0) { |
819 | 825 | get_page(page); |
820 | 826 | put_page(*pp); |
821 | 827 | *pp = page; |
822 | 828 | rqstp->rq_resused++; |
823 | - rqstp->rq_res.page_base = offset; | |
829 | + rqstp->rq_res.page_base = buf->offset; | |
824 | 830 | rqstp->rq_res.page_len = size; |
825 | 831 | } else if (page != pp[-1]) { |
826 | 832 | get_page(page); |
827 | 833 | |
... | ... | @@ -832,11 +838,15 @@ |
832 | 838 | } else |
833 | 839 | rqstp->rq_res.page_len += size; |
834 | 840 | |
835 | - desc->count = count - size; | |
836 | - desc->written += size; | |
837 | 841 | return size; |
838 | 842 | } |
839 | 843 | |
844 | +static int nfsd_direct_splice_actor(struct pipe_inode_info *pipe, | |
845 | + struct splice_desc *sd) | |
846 | +{ | |
847 | + return __splice_from_pipe(pipe, sd, nfsd_splice_actor); | |
848 | +} | |
849 | + | |
840 | 850 | static __be32 |
841 | 851 | nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, |
842 | 852 | loff_t offset, struct kvec *vec, int vlen, unsigned long *count) |
... | ... | @@ -861,10 +871,15 @@ |
861 | 871 | if (ra && ra->p_set) |
862 | 872 | file->f_ra = ra->p_ra; |
863 | 873 | |
864 | - if (file->f_op->sendfile && rqstp->rq_sendfile_ok) { | |
865 | - rqstp->rq_resused = 1; | |
866 | - host_err = file->f_op->sendfile(file, &offset, *count, | |
867 | - nfsd_read_actor, rqstp); | |
874 | + if (file->f_op->splice_read && rqstp->rq_splice_ok) { | |
875 | + struct splice_desc sd = { | |
876 | + .len = 0, | |
877 | + .total_len = *count, | |
878 | + .pos = offset, | |
879 | + .u.data = rqstp, | |
880 | + }; | |
881 | + | |
882 | + host_err = splice_direct_to_actor(file, &sd, nfsd_direct_splice_actor); | |
868 | 883 | } else { |
869 | 884 | oldfs = get_fs(); |
870 | 885 | set_fs(KERNEL_DS); |
include/linux/sunrpc/svc.h
... | ... | @@ -253,7 +253,7 @@ |
253 | 253 | * determine what device number |
254 | 254 | * to report (real or virtual) |
255 | 255 | */ |
256 | - int rq_sendfile_ok; /* turned off in gss privacy | |
256 | + int rq_splice_ok; /* turned off in gss privacy | |
257 | 257 | * to prevent encrypting page |
258 | 258 | * cache pages */ |
259 | 259 | wait_queue_head_t rq_wait; /* synchronization */ |
net/sunrpc/auth_gss/svcauth_gss.c
net/sunrpc/svc.c
... | ... | @@ -814,7 +814,7 @@ |
814 | 814 | rqstp->rq_res.tail[0].iov_base = NULL; |
815 | 815 | rqstp->rq_res.tail[0].iov_len = 0; |
816 | 816 | /* Will be turned off only in gss privacy case: */ |
817 | - rqstp->rq_sendfile_ok = 1; | |
817 | + rqstp->rq_splice_ok = 1; | |
818 | 818 | /* tcp needs a space for the record length... */ |
819 | 819 | if (rqstp->rq_prot == IPPROTO_TCP) |
820 | 820 | svc_putnl(resv, 0); |