Re: [PATCH] TCP Zero Copy for mmapped files

Larry McVoy (lm@bitmover.com)
Sun, 29 Dec 2002 17:29:37 -0800


How about putting this into a different function? It's a lot to add
inline for a special case.

> int tcp_sendmsg(struct sock *sk, struct msghdr *msg, int size)
> {
> struct iovec *iov;
> @@ -1015,6 +1051,7 @@
> int mss_now;
> int err, copied;
> long timeo;
> + int has_sendpage = sk->socket->file->f_op->sendpage != NULL;
>
> tp = &(sk->tp_pinfo.af_tcp);
>
> @@ -1049,6 +1086,44 @@
>
> iov++;
>
> + if (seglen >= PAGE_SIZE && has_sendpage) {
> + struct vm_area_struct *vma =
> + find_vma (current->mm, (long) from);
> + struct file *filp;
> +
> + if (vma && (filp = vma->vm_file)) {
> + read_descriptor_t desc;
> + struct inode *in, *out;
> + loff_t pos = (long) from - vma->vm_start;
> +
> + in = filp->f_dentry->d_inode;
> + out = sk->socket->file->f_dentry->d_inode;
> +
> + if (locks_verify_area (FLOCK_VERIFY_READ, in,
> + filp, filp->f_pos, seglen))
> + goto out_no_zero_copy;
> +
> + if (locks_verify_area (FLOCK_VERIFY_WRITE, out,
> + sk->socket->file, 0, seglen))
> + goto out_no_zero_copy;
> +
> + desc.written = 0;
> + desc.count = seglen;
> + desc.buf = (char *) sk;
> + desc.error = 0;
> +
> + do_generic_file_read (filp, &pos, &desc,
> + file_send_actor);
> +
> + if (!desc.written) {
> + err = desc.error;
> + goto do_error;
> + }
> + copied += desc.written;
> + continue;
> + }
> + }
> +out_no_zero_copy:
> while (seglen > 0) {
> int copy;
>

-- 
---
Larry McVoy            	 lm at bitmover.com           http://www.bitmover.com/lm 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/