Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 65ffc679 authored by Al Viro's avatar Al Viro Committed by Greg Kroah-Hartman
Browse files

lustre: don't reinvent struct bio_vec

parent 28ac4ad0
Loading
Loading
Loading
Loading
+1 −15
Original line number Diff line number Diff line
@@ -503,21 +503,7 @@ typedef struct {
/* NB lustre portals uses struct iovec internally! */
typedef struct iovec lnet_md_iovec_t;

/**
 * A page-based fragment of a MD.
 */
typedef struct {
	/** Pointer to the page where the fragment resides */
	struct page	*kiov_page;
	/** Length in bytes of the fragment */
	unsigned int	 kiov_len;
	/**
	 * Starting offset of the fragment within the page. Note that the
	 * end of the fragment must not pass the end of the page; i.e.,
	 * kiov_len + kiov_offset <= PAGE_SIZE.
	 */
	unsigned int	 kiov_offset;
} lnet_kiov_t;
typedef struct bio_vec lnet_kiov_t;
/** @} lnet_md */

/** \addtogroup lnet_eq
+5 −5
Original line number Diff line number Diff line
@@ -717,8 +717,8 @@ kiblnd_setup_rd_kiov(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc *rd,
	LASSERT(nkiov > 0);
	LASSERT(net);

	while (offset >= kiov->kiov_len) {
		offset -= kiov->kiov_len;
	while (offset >= kiov->bv_len) {
		offset -= kiov->bv_len;
		nkiov--;
		kiov++;
		LASSERT(nkiov > 0);
@@ -728,10 +728,10 @@ kiblnd_setup_rd_kiov(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc *rd,
	do {
		LASSERT(nkiov > 0);

		fragnob = min((int)(kiov->kiov_len - offset), nob);
		fragnob = min((int)(kiov->bv_len - offset), nob);

		sg_set_page(sg, kiov->kiov_page, fragnob,
			    kiov->kiov_offset + offset);
		sg_set_page(sg, kiov->bv_page, fragnob,
			    kiov->bv_offset + offset);
		sg = sg_next(sg);
		if (!sg) {
			CERROR("lacking enough sg entries to map tx\n");
+8 −8
Original line number Diff line number Diff line
@@ -164,13 +164,13 @@ ksocknal_send_kiov(struct ksock_conn *conn, struct ksock_tx *tx)
	do {
		LASSERT(tx->tx_nkiov > 0);

		if (nob < (int)kiov->kiov_len) {
			kiov->kiov_offset += nob;
			kiov->kiov_len -= nob;
		if (nob < (int)kiov->bv_len) {
			kiov->bv_offset += nob;
			kiov->bv_len -= nob;
			return rc;
		}

		nob -= (int)kiov->kiov_len;
		nob -= (int)kiov->bv_len;
		tx->tx_kiov = ++kiov;
		tx->tx_nkiov--;
	} while (nob);
@@ -326,13 +326,13 @@ ksocknal_recv_kiov(struct ksock_conn *conn)
	do {
		LASSERT(conn->ksnc_rx_nkiov > 0);

		if (nob < (int)kiov->kiov_len) {
			kiov->kiov_offset += nob;
			kiov->kiov_len -= nob;
		if (nob < (int)kiov->bv_len) {
			kiov->bv_offset += nob;
			kiov->bv_len -= nob;
			return -EAGAIN;
		}

		nob -= kiov->kiov_len;
		nob -= kiov->bv_len;
		conn->ksnc_rx_kiov = ++kiov;
		conn->ksnc_rx_nkiov--;
	} while (nob);
+18 −24
Original line number Diff line number Diff line
@@ -131,13 +131,13 @@ ksocknal_lib_send_kiov(struct ksock_conn *conn, struct ksock_tx *tx)
	if (tx->tx_msg.ksm_zc_cookies[0]) {
		/* Zero copy is enabled */
		struct sock *sk = sock->sk;
		struct page *page = kiov->kiov_page;
		int offset = kiov->kiov_offset;
		int fragsize = kiov->kiov_len;
		struct page *page = kiov->bv_page;
		int offset = kiov->bv_offset;
		int fragsize = kiov->bv_len;
		int msgflg = MSG_DONTWAIT;

		CDEBUG(D_NET, "page %p + offset %x for %d\n",
		       page, offset, kiov->kiov_len);
		       page, offset, kiov->bv_len);

		if (!list_empty(&conn->ksnc_tx_queue) ||
		    fragsize < tx->tx_resid)
@@ -165,9 +165,9 @@ ksocknal_lib_send_kiov(struct ksock_conn *conn, struct ksock_tx *tx)
		int i;

		for (nob = i = 0; i < niov; i++) {
			scratchiov[i].iov_base = kmap(kiov[i].kiov_page) +
						 kiov[i].kiov_offset;
			nob += scratchiov[i].iov_len = kiov[i].kiov_len;
			scratchiov[i].iov_base = kmap(kiov[i].bv_page) +
						 kiov[i].bv_offset;
			nob += scratchiov[i].iov_len = kiov[i].bv_len;
		}

		if (!list_empty(&conn->ksnc_tx_queue) ||
@@ -177,7 +177,7 @@ ksocknal_lib_send_kiov(struct ksock_conn *conn, struct ksock_tx *tx)
		rc = kernel_sendmsg(sock, &msg, (struct kvec *)scratchiov, niov, nob);

		for (i = 0; i < niov; i++)
			kunmap(kiov[i].kiov_page);
			kunmap(kiov[i].bv_page);
	}
	return rc;
}
@@ -262,7 +262,6 @@ ksocknal_lib_recv_iov(struct ksock_conn *conn)
int
ksocknal_lib_recv_kiov(struct ksock_conn *conn)
{
	struct bio_vec *bv = conn->ksnc_scheduler->kss_scratch_bvec;
	unsigned int niov = conn->ksnc_rx_nkiov;
	lnet_kiov_t   *kiov = conn->ksnc_rx_kiov;
	struct msghdr msg = {
@@ -274,33 +273,28 @@ ksocknal_lib_recv_kiov(struct ksock_conn *conn)
	void *base;
	int sum;
	int fragnob;
	int n;

	for (nob = i = 0; i < niov; i++) {
		nob += bv[i].bv_len = kiov[i].kiov_len;
		bv[i].bv_page = kiov[i].kiov_page;
		bv[i].bv_offset = kiov[i].kiov_offset;
	}
	n = niov;
	for (nob = i = 0; i < niov; i++)
		nob += kiov[i].bv_len;

	LASSERT(nob <= conn->ksnc_rx_nob_wanted);

	iov_iter_bvec(&msg.msg_iter, READ | ITER_BVEC, bv, n, nob);
	iov_iter_bvec(&msg.msg_iter, READ | ITER_BVEC, kiov, niov, nob);
	rc = sock_recvmsg(conn->ksnc_sock, &msg, MSG_DONTWAIT);

	if (conn->ksnc_msg.ksm_csum) {
		for (i = 0, sum = rc; sum > 0; i++, sum -= fragnob) {
			LASSERT(i < niov);

			base = kmap(kiov[i].kiov_page) + kiov[i].kiov_offset;
			fragnob = kiov[i].kiov_len;
			base = kmap(kiov[i].bv_page) + kiov[i].bv_offset;
			fragnob = kiov[i].bv_len;
			if (fragnob > sum)
				fragnob = sum;

			conn->ksnc_rx_csum = ksocknal_csum(conn->ksnc_rx_csum,
							   base, fragnob);

			kunmap(kiov[i].kiov_page);
			kunmap(kiov[i].bv_page);
		}
	}
	return rc;
@@ -324,12 +318,12 @@ ksocknal_lib_csum_tx(struct ksock_tx *tx)

	if (tx->tx_kiov) {
		for (i = 0; i < tx->tx_nkiov; i++) {
			base = kmap(tx->tx_kiov[i].kiov_page) +
			       tx->tx_kiov[i].kiov_offset;
			base = kmap(tx->tx_kiov[i].bv_page) +
			       tx->tx_kiov[i].bv_offset;

			csum = ksocknal_csum(csum, base, tx->tx_kiov[i].kiov_len);
			csum = ksocknal_csum(csum, base, tx->tx_kiov[i].bv_len);

			kunmap(tx->tx_kiov[i].kiov_page);
			kunmap(tx->tx_kiov[i].bv_page);
		}
	} else {
		for (i = 1; i < tx->tx_niov; i++)
+3 −3
Original line number Diff line number Diff line
@@ -134,11 +134,11 @@ lnet_md_build(lnet_libmd_t *lmd, lnet_md_t *umd, int unlink)

		for (i = 0; i < (int)niov; i++) {
			/* We take the page pointer on trust */
			if (lmd->md_iov.kiov[i].kiov_offset +
			    lmd->md_iov.kiov[i].kiov_len > PAGE_SIZE)
			if (lmd->md_iov.kiov[i].bv_offset +
			    lmd->md_iov.kiov[i].bv_len > PAGE_SIZE)
				return -EINVAL; /* invalid length */

			total_length += lmd->md_iov.kiov[i].kiov_len;
			total_length += lmd->md_iov.kiov[i].bv_len;
		}

		lmd->md_length = total_length;
Loading