Commit b146166e authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: iovec cleanups - the rest

the rest of iovec cleanups: nbd, dvb-net, sock.c::sock_no_sendpage(),
econet over udp and ip_vs switched to use of kvec and kernel_...msg().
parent b145333f
......@@ -158,15 +158,12 @@ static void nbd_end_request(struct request *req)
static int sock_xmit(struct socket *sock, int send, void *buf, int size,
int msg_flags)
{
mm_segment_t oldfs;
int result;
struct msghdr msg;
struct iovec iov;
struct kvec iov;
unsigned long flags;
sigset_t oldset;
oldfs = get_fs();
set_fs(get_ds());
/* Allow interception of SIGKILL only
* Don't allow other signals to interrupt the transmission */
spin_lock_irqsave(&current->sighand->siglock, flags);
......@@ -182,17 +179,15 @@ static int sock_xmit(struct socket *sock, int send, void *buf, int size,
iov.iov_len = size;
msg.msg_name = NULL;
msg.msg_namelen = 0;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_namelen = 0;
msg.msg_flags = msg_flags | MSG_NOSIGNAL;
if (send)
result = sock_sendmsg(sock, &msg, size);
result = kernel_sendmsg(sock, &msg, &iov, 1, size);
else
result = sock_recvmsg(sock, &msg, size, 0);
result = kernel_recvmsg(sock, &msg, &iov, 1, size, 0);
if (signal_pending(current)) {
siginfo_t info;
......@@ -219,7 +214,6 @@ static int sock_xmit(struct socket *sock, int send, void *buf, int size,
recalc_sigpending();
spin_unlock_irqrestore(&current->sighand->siglock, flags);
set_fs(oldfs);
return result;
}
......
......@@ -43,7 +43,7 @@
#include "dvb_functions.h"
static inline __u32 iov_crc32( __u32 c, struct iovec *iov, unsigned int cnt )
static inline __u32 iov_crc32( __u32 c, struct kvec *iov, unsigned int cnt )
{
unsigned int j;
for (j = 0; j < cnt; j++)
......@@ -481,7 +481,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
/* Check CRC32, we've got it in our skb already. */
unsigned short ulen = htons(priv->ule_sndu_len);
unsigned short utype = htons(priv->ule_sndu_type);
struct iovec iov[4] = {
struct kvec iov[4] = {
{ &ulen, sizeof ulen },
{ &utype, sizeof utype },
{ NULL, 0 },
......
......@@ -128,7 +128,7 @@ static inline void ip_tr_mc_map(u32 addr, char *buf)
}
struct ip_reply_arg {
struct iovec iov[1];
struct kvec iov[1];
u32 csum;
int csumoffset; /* u16 offset of csum in iov[0].iov_base */
/* -1 if not needed */
......
......@@ -1065,30 +1065,12 @@ int sock_no_mmap(struct file *file, struct socket *sock, struct vm_area_struct *
ssize_t sock_no_sendpage(struct socket *sock, struct page *page, int offset, size_t size, int flags)
{
ssize_t res;
struct msghdr msg;
struct iovec iov;
mm_segment_t old_fs;
char *kaddr;
kaddr = kmap(page);
msg.msg_name = NULL;
msg.msg_namelen = 0;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_flags = flags;
/* This cast is ok because of the "set_fs(KERNEL_DS)" */
iov.iov_base = (void __user *) (kaddr + offset);
struct msghdr msg = {.msg_flags = flags};
struct kvec iov;
char *kaddr = kmap(page);
iov.iov_base = kaddr + offset;
iov.iov_len = size;
old_fs = get_fs();
set_fs(KERNEL_DS);
res = sock_sendmsg(sock, &msg, size);
set_fs(old_fs);
res = kernel_sendmsg(sock, &msg, &iov, 1, size);
kunmap(page);
return res;
}
......
......@@ -774,38 +774,22 @@ static int ec_queue_packet(struct sock *sk, struct sk_buff *skb,
static void aun_send_response(__u32 addr, unsigned long seq, int code, int cb)
{
struct sockaddr_in sin;
struct iovec iov;
struct aunhdr ah;
struct sockaddr_in sin = {
.sin_family = AF_INET,
.sin_port = htons(AUN_PORT),
.sin_addr = {.s_addr = addr}
};
struct aunhdr ah = {.code = code, .cb = cb, .handle = seq};
struct kvec iov = {.iov_base = (void *)&ah, .iov_len = sizeof(ah)};
struct msghdr udpmsg;
int err;
mm_segment_t oldfs;
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_port = htons(AUN_PORT);
sin.sin_addr.s_addr = addr;
ah.code = code;
ah.pad = 0;
ah.port = 0;
ah.cb = cb;
ah.handle = seq;
iov.iov_base = (void *)&ah;
iov.iov_len = sizeof(ah);
udpmsg.msg_name = (void *)&sin;
udpmsg.msg_namelen = sizeof(sin);
udpmsg.msg_iov = &iov;
udpmsg.msg_iovlen = 1;
udpmsg.msg_control = NULL;
udpmsg.msg_controllen = 0;
udpmsg.msg_flags=0;
oldfs = get_fs(); set_fs(KERNEL_DS);
err = sock_sendmsg(udpsock, &udpmsg, sizeof(ah));
set_fs(oldfs);
kernel_sendmsg(udpsock, &udpmsg, &iov, 1, sizeof(ah));
}
......
......@@ -555,25 +555,15 @@ static struct socket * make_receive_sock(void)
static int
ip_vs_send_async(struct socket *sock, const char *buffer, const size_t length)
{
struct msghdr msg;
mm_segment_t oldfs;
struct iovec iov;
struct msghdr msg = {.msg_flags = MSG_DONTWAIT|MSG_NOSIGNAL};
struct kvec iov;
int len;
EnterFunction(7);
iov.iov_base = (void *)buffer;
iov.iov_len = length;
msg.msg_name = 0;
msg.msg_namelen = 0;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_flags = MSG_DONTWAIT|MSG_NOSIGNAL;
oldfs = get_fs(); set_fs(KERNEL_DS);
len = sock_sendmsg(sock, &msg, (size_t)(length));
set_fs(oldfs);
len = kernel_sendmsg(sock, &msg, &iov, 1, (size_t)(length));
LeaveFunction(7);
return len;
......@@ -583,27 +573,17 @@ ip_vs_send_async(struct socket *sock, const char *buffer, const size_t length)
static int
ip_vs_receive(struct socket *sock, char *buffer, const size_t buflen)
{
struct msghdr msg;
struct iovec iov;
struct msghdr msg = {NULL,};
struct kvec iov;
int len;
mm_segment_t oldfs;
EnterFunction(7);
/* Receive a packet */
iov.iov_base = buffer;
iov.iov_len = (size_t)buflen;
msg.msg_name = NULL;
msg.msg_namelen = 0;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_flags = 0;
oldfs = get_fs(); set_fs(KERNEL_DS);
len = sock_recvmsg(sock, &msg, buflen, 0);
set_fs(oldfs);
len = kernel_recvmsg(sock, &msg, &iov, 1, buflen, 0);
if (len < 0)
return -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment