Example #1
0
/**
 * iscsi_send - generic send routine
 * @sk: kernel's socket
 * @buf: buffer to write from
 * @size: actual size to write
 * @flags: socket's flags
 */
static inline int
iscsi_send(struct iscsi_conn *conn, struct iscsi_buf *buf, int size, int flags)
{
	struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
	struct socket *sk = tcp_conn->sock;
	int offset = buf->sg.offset + buf->sent, res;

	/*
	 * if we got use_sg=0 or are sending something we kmallocd
	 * then we did not have to do kmap (kmap returns page_address)
	 *
	 * if we got use_sg > 0, but had to drop down, we do not
	 * set clustering so this should only happen for that
	 * slab case.
	 */
	if (buf->use_sendmsg)
		res = sock_no_sendpage(sk, buf->sg.page, offset, size, flags);
	else
		res = tcp_conn->sendpage(sk, buf->sg.page, offset, size, flags);

	if (res >= 0) {
		conn->txdata_octets += res;
		buf->sent += res;
		return res;
	}

	tcp_conn->sendpage_failures_cnt++;
	if (res == -EAGAIN)
		res = -ENOBUFS;
	else
		iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
	return res;
}
Example #2
0
static ssize_t scribe_sendpage(struct socket *sock, struct page *page,
			       int offset, size_t size, int flags)
{
	/*
	 * Disabling sendpage: a accept() socket will have a different real_ops,
	 * the unix socket to be specific. So we want to force the same
	 * behavior
	 */
	return sock_no_sendpage(sock, page, offset, size, flags);
}
Example #3
0
ssize_t mhost_sendpage(struct socket *sock, struct page *page, int offset, size_t size, int flags)
{
    struct sock *sk = sock->sk;
    printk(KERN_INFO "mhost_sendpage called\n");
            
    if (sk->sk_prot->sendpage) {
        return sk->sk_prot->sendpage(sk, page, offset, size, flags);
    }
    return sock_no_sendpage(sock, page, offset, size, flags);
};