linux内核tcp_sendmsg函数的struct kiocb *iocb的作用和,相关打印信息的问题(分值有点少,就这么点了,等赚了再加分)
各位linux内核高手们:晚辈想请教个问题,(分值有点少,给不出来了,等赚了再加分)用tcp发送数据最终是要到
int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,size_t size)函数里面,但是我在函数代码里面没有看到参数struct kiocb *iocb的用处,这是何解?我准备在这种加一个压缩算法,对tcp的数据部分进行压缩。但是有些问题,我用ftp发送了3M的文件文件,copied是计算发送了多少数据,copy表示每一次从用户空间复制的数据
int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
size_t size)
{
。。。。。
clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
mss_now = tcp_send_mss(sk, &size_goal, flags);
/* Ok commence sending. */
iovlen = msg->msg_iovlen;
iov = msg->msg_iov;
copied = 0;
err = -EPIPE;
if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))
goto out_err;
sg = sk->sk_route_caps & NETIF_F_SG;
printk(KERN_INFO " tcp_sendmsg mss_now=%d\n",mss_now);
printk(KERN_INFO " tcp_sendmsg msg->msg_iovlen=%d\n",iovlen);
while (--iovlen >= 0) {
size_t seglen = iov->iov_len;
unsigned char __user *from = iov->iov_base;
printk(KERN_INFO " tcp_sendmsg iov->iov_len=%d\n",iov->iov_len);
printk(KERN_INFO " tcp_sendmsg max = size_goal==%d\n",size_goal);
iov++;
while (seglen > 0) {
int copy = 0;
int max = size_goal;
结果显示::
Sep 7 14:57:42 ubuntu kernel: [ 2908.250091] tcp_sendmsg mss_now=1448
Sep 7 14:57:42 ubuntu kernel: [ 2908.250094] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:42 ubuntu kernel: [ 2908.250097] tcp_sendmsg iov->iov_len=51056
Sep 7 14:57:42 ubuntu kernel: [ 2908.250099] tcp_sendmsg max = size_goal==2896
Sep 7 14:57:42 ubuntu kernel: [ 2908.250135] tcp_sendmsg mss_now=1448
Sep 7 14:57:42 ubuntu kernel: [ 2908.250137] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:42 ubuntu kernel: [ 2908.250140] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:42 ubuntu kernel: [ 2908.250142] tcp_sendmsg max = size_goal==2896
Sep 7 14:57:42 ubuntu kernel: [ 2908.250152] tcp_sendmsg mss_now=1448
Sep 7 14:57:42 ubuntu kernel: [ 2908.250154] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:42 ubuntu kernel: [ 2908.250156] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:42 ubuntu kernel: [ 2908.250158] tcp_sendmsg max = size_goal==2896
Sep 7 14:57:43 ubuntu kernel: [ 2908.301186] tcp_sendmsg mss_now=1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.301191] tcp_sendmsg msg->msg_iovlen=1
Sep 7 14:57:43 ubuntu kernel: [ 2908.301194] tcp_sendmsg iov->iov_len=65536
Sep 7 14:57:43 ubuntu kernel: [ 2908.301197] tcp_sendmsg max = size_goal==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301201] tcp_sendmsg copy==1448
Sep 7 14:57:43 ubuntu kernel: [ 2908.301207] tcp_sendmsg copy==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301211] tcp_sendmsg copy==3888
Sep 7 14:57:43 ubuntu kernel: [ 2908.301218] tcp_sendmsg copy==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301222] tcp_sendmsg copy==4136
Sep 7 14:57:43 ubuntu kernel: [ 2908.301228] tcp_sendmsg copy==40
Sep 7 14:57:43 ubuntu kernel: [ 2908.301233] tcp_sendmsg copy==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301238] tcp_sendmsg copy==288
Sep 7 14:57:43 ubuntu kernel: [ 2908.301243] tcp_sendmsg copy==4344
Sep 7 14:57:43 ubuntu kernel: [ 2908.301248] tcp_sendmsg copy==536
Sep 7 14:57:43 ubuntu kernel: [ 2908.301253] tcp_sendmsg