Skip to content

Commit

Permalink
LU-4423 lnet: don't use iovec instead of kvec
Browse files Browse the repository at this point in the history
Replace struct iovec with struct kvec.

Linux commit: f351bad2b4b4bb74810ad4f127f6602e2d2ae403

Change-Id: Ib7bb49069e42ca82d66a149617361c73ee4d710d
Signed-off-by: Al Viro <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Reviewed-on: http://review.whamcloud.com/17205
Tested-by: Jenkins
Tested-by: Maloo <[email protected]>
Reviewed-by: Andreas Dilger <[email protected]>
Reviewed-by: Bob Glossman <[email protected]>
Reviewed-by: Frank Zago <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
  • Loading branch information
Al Viro authored and Oleg Drokin committed Dec 2, 2015
1 parent 10763bd commit 88f761b
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 118 deletions.
58 changes: 29 additions & 29 deletions lnet/include/lnet/lib-lnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -636,39 +636,39 @@ bool lnet_delay_rule_match_locked(lnet_hdr_t *hdr, struct lnet_msg *msg);
void lnet_counters_get(lnet_counters_t *counters);
void lnet_counters_reset(void);

unsigned int lnet_iov_nob (unsigned int niov, struct iovec *iov);
int lnet_extract_iov (int dst_niov, struct iovec *dst,
int src_niov, struct iovec *src,
unsigned int lnet_iov_nob(unsigned int niov, struct kvec *iov);
int lnet_extract_iov(int dst_niov, struct kvec *dst,
int src_niov, struct kvec *src,
unsigned int offset, unsigned int len);

unsigned int lnet_kiov_nob (unsigned int niov, lnet_kiov_t *iov);
int lnet_extract_kiov (int dst_niov, lnet_kiov_t *dst,
int src_niov, lnet_kiov_t *src,
unsigned int offset, unsigned int len);

void lnet_copy_iov2iov (unsigned int ndiov, struct iovec *diov,
unsigned int doffset,
unsigned int nsiov, struct iovec *siov,
unsigned int soffset, unsigned int nob);
void lnet_copy_kiov2iov (unsigned int niov, struct iovec *iov,
unsigned int iovoffset,
unsigned int nkiov, lnet_kiov_t *kiov,
unsigned int kiovoffset, unsigned int nob);
void lnet_copy_iov2kiov (unsigned int nkiov, lnet_kiov_t *kiov,
unsigned int kiovoffset,
unsigned int niov, struct iovec *iov,
unsigned int iovoffset, unsigned int nob);
void lnet_copy_kiov2kiov (unsigned int ndkiov, lnet_kiov_t *dkiov,
unsigned int doffset,
unsigned int nskiov, lnet_kiov_t *skiov,
unsigned int soffset, unsigned int nob);
int lnet_extract_kiov(int dst_niov, lnet_kiov_t *dst,
int src_niov, lnet_kiov_t *src,
unsigned int offset, unsigned int len);

void lnet_copy_iov2iov(unsigned int ndiov, struct kvec *diov,
unsigned int doffset,
unsigned int nsiov, struct kvec *siov,
unsigned int soffset, unsigned int nob);
void lnet_copy_kiov2iov(unsigned int niov, struct kvec *iov,
unsigned int iovoffset,
unsigned int nkiov, lnet_kiov_t *kiov,
unsigned int kiovoffset, unsigned int nob);
void lnet_copy_iov2kiov(unsigned int nkiov, lnet_kiov_t *kiov,
unsigned int kiovoffset,
unsigned int niov, struct kvec *iov,
unsigned int iovoffset, unsigned int nob);
void lnet_copy_kiov2kiov(unsigned int ndkiov, lnet_kiov_t *dkiov,
unsigned int doffset,
unsigned int nskiov, lnet_kiov_t *skiov,
unsigned int soffset, unsigned int nob);

static inline void
lnet_copy_iov2flat(int dlen, __user void *dest, unsigned int doffset,
unsigned int nsiov, struct iovec *siov, unsigned int soffset,
unsigned int nsiov, struct kvec *siov, unsigned int soffset,
unsigned int nob)
{
struct iovec diov = {/*.iov_base = */ dest, /*.iov_len = */ dlen};
struct kvec diov = {/*.iov_base = */ dest, /*.iov_len = */ dlen};

lnet_copy_iov2iov(1, &diov, doffset,
nsiov, siov, soffset, nob);
Expand All @@ -679,18 +679,18 @@ lnet_copy_kiov2flat(int dlen, void __user *dest, unsigned int doffset,
unsigned int nsiov, lnet_kiov_t *skiov,
unsigned int soffset, unsigned int nob)
{
struct iovec diov = {/* .iov_base = */ dest, /* .iov_len = */ dlen};
struct kvec diov = {/* .iov_base = */ dest, /* .iov_len = */ dlen};

lnet_copy_kiov2iov(1, &diov, doffset,
nsiov, skiov, soffset, nob);
}

static inline void
lnet_copy_flat2iov(unsigned int ndiov, struct iovec *diov, unsigned int doffset,
lnet_copy_flat2iov(unsigned int ndiov, struct kvec *diov, unsigned int doffset,
int slen, void __user *src, unsigned int soffset,
unsigned int nob)
{
struct iovec siov = {/*.iov_base = */ src, /*.iov_len = */slen};
struct kvec siov = {/*.iov_base = */ src, /*.iov_len = */slen};
lnet_copy_iov2iov(ndiov, diov, doffset,
1, &siov, soffset, nob);
}
Expand All @@ -700,7 +700,7 @@ lnet_copy_flat2kiov(unsigned int ndiov, lnet_kiov_t *dkiov,
unsigned int doffset, int slen, void __user *src,
unsigned int soffset, unsigned int nob)
{
struct iovec siov = {/* .iov_base = */ src, /* .iov_len = */ slen};
struct kvec siov = {/* .iov_base = */ src, /* .iov_len = */ slen};
lnet_copy_iov2kiov(ndiov, dkiov, doffset,
1, &siov, soffset, nob);
}
Expand Down
8 changes: 4 additions & 4 deletions lnet/include/lnet/lib-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ typedef struct lnet_msg {
unsigned int msg_wanted;
unsigned int msg_offset;
unsigned int msg_niov;
struct iovec *msg_iov;
struct kvec *msg_iov;
lnet_kiov_t *msg_kiov;

lnet_event_t msg_ev;
Expand Down Expand Up @@ -169,7 +169,7 @@ typedef struct lnet_libmd {
lnet_eq_t *md_eq;
unsigned int md_niov; /* # frags */
union {
struct iovec iov[LNET_MAX_IOV];
struct kvec iov[LNET_MAX_IOV];
lnet_kiov_t kiov[LNET_MAX_IOV];
} md_iov;
} lnet_libmd_t;
Expand Down Expand Up @@ -210,7 +210,7 @@ typedef struct lnet_lnd
/* In data movement APIs below, payload buffers are described as a set
* of 'niov' fragments which are...
* EITHER
* in virtual memory (struct iovec *iov != NULL)
* in virtual memory (struct kvec *iov != NULL)
* OR
* in pages (kernel only: plt_kiov_t *kiov != NULL).
* The LND may NOT overwrite these fragment descriptors.
Expand All @@ -232,7 +232,7 @@ typedef struct lnet_lnd
* credit if the LND does flow control. */
int (*lnd_recv)(struct lnet_ni *ni, void *private, lnet_msg_t *msg,
int delayed, unsigned int niov,
struct iovec *iov, lnet_kiov_t *kiov,
struct kvec *iov, lnet_kiov_t *kiov,
unsigned int offset, unsigned int mlen, unsigned int rlen);

/* lnet_parse() has had to delay processing of this message
Expand Down
4 changes: 2 additions & 2 deletions lnet/include/lnet/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ typedef struct {
* than LNET_MAX_IOV. The lnet_kiov_t is used to describe page-based
* fragments that are not necessarily mapped in virtal memory.
* - LNET_MD_IOVEC bit set: The start field points to the starting
* address of an array of struct iovec and the length field specifies
* address of an array of struct kvec and the length field specifies
* the number of entries in the array. The length can't be bigger
* than LNET_MAX_IOV. The struct iovec is used to describe fragments
* than LNET_MAX_IOV. The struct kvec is used to describe fragments
* that have virtual addresses.
* - Otherwise: The memory region is contiguous. The start field
* specifies the starting address for the memory region and the
Expand Down
2 changes: 1 addition & 1 deletion lnet/klnds/gnilnd/gnilnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -1741,7 +1741,7 @@ int kgnilnd_eager_recv(lnet_ni_t *ni, void *private,
lnet_msg_t *lntmsg, void **new_private);
int kgnilnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
int delayed, unsigned int niov,
struct iovec *iov, lnet_kiov_t *kiov,
struct kvec *iov, lnet_kiov_t *kiov,
unsigned int offset, unsigned int mlen, unsigned int rlen);

__u16 kgnilnd_cksum_kiov(unsigned int nkiov, lnet_kiov_t *kiov, unsigned int offset, unsigned int nob, int dump_blob);
Expand Down
16 changes: 8 additions & 8 deletions lnet/klnds/gnilnd/gnilnd_cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,9 @@ kgnilnd_nak_rdma(kgn_conn_t *conn, int rx_type, int error, __u64 cookie, lnet_ni
}

int
kgnilnd_setup_immediate_buffer(kgn_tx_t *tx, unsigned int niov, struct iovec *iov,
lnet_kiov_t *kiov, unsigned int offset, unsigned int nob)

kgnilnd_setup_immediate_buffer(kgn_tx_t *tx, unsigned int niov,
struct kvec *iov, lnet_kiov_t *kiov,
unsigned int offset, unsigned int nob)
{
kgn_msg_t *msg = &tx->tx_msg;
int i;
Expand Down Expand Up @@ -605,7 +605,7 @@ kgnilnd_setup_immediate_buffer(kgn_tx_t *tx, unsigned int niov, struct iovec *io

int
kgnilnd_setup_virt_buffer(kgn_tx_t *tx,
unsigned int niov, struct iovec *iov,
unsigned int niov, struct kvec *iov,
unsigned int offset, unsigned int nob)

{
Expand Down Expand Up @@ -745,7 +745,7 @@ kgnilnd_setup_phys_buffer(kgn_tx_t *tx, int nkiov, lnet_kiov_t *kiov,

static inline int
kgnilnd_setup_rdma_buffer(kgn_tx_t *tx, unsigned int niov,
struct iovec *iov, lnet_kiov_t *kiov,
struct kvec *iov, lnet_kiov_t *kiov,
unsigned int offset, unsigned int nob)
{
int rc;
Expand Down Expand Up @@ -2113,7 +2113,7 @@ kgnilnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
int target_is_router = lntmsg->msg_target_is_router;
int routing = lntmsg->msg_routing;
unsigned int niov = lntmsg->msg_niov;
struct iovec *iov = lntmsg->msg_iov;
struct kvec *iov = lntmsg->msg_iov;
lnet_kiov_t *kiov = lntmsg->msg_kiov;
unsigned int offset = lntmsg->msg_offset;
unsigned int nob = lntmsg->msg_len;
Expand Down Expand Up @@ -2282,7 +2282,7 @@ kgnilnd_setup_rdma(lnet_ni_t *ni, kgn_rx_t *rx, lnet_msg_t *lntmsg, int mlen)
kgn_conn_t *conn = rx->grx_conn;
kgn_msg_t *rxmsg = rx->grx_msg;
unsigned int niov = lntmsg->msg_niov;
struct iovec *iov = lntmsg->msg_iov;
struct kvec *iov = lntmsg->msg_iov;
lnet_kiov_t *kiov = lntmsg->msg_kiov;
unsigned int offset = lntmsg->msg_offset;
unsigned int nob = lntmsg->msg_len;
Expand Down Expand Up @@ -2431,7 +2431,7 @@ kgnilnd_eager_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
int
kgnilnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
int delayed, unsigned int niov,
struct iovec *iov, lnet_kiov_t *kiov,
struct kvec *iov, lnet_kiov_t *kiov,
unsigned int offset, unsigned int mlen, unsigned int rlen)
{
kgn_rx_t *rx = private;
Expand Down
2 changes: 1 addition & 1 deletion lnet/klnds/o2iblnd/o2iblnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,6 @@ int kiblnd_post_rx (kib_rx_t *rx, int credit);

int kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg);
int kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
unsigned int niov, struct iovec *iov, lnet_kiov_t *kiov,
unsigned int niov, struct kvec *iov, lnet_kiov_t *kiov,
unsigned int offset, unsigned int mlen, unsigned int rlen);

12 changes: 6 additions & 6 deletions lnet/klnds/o2iblnd/o2iblnd_cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ kiblnd_map_tx(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, int nfrags)

static int
kiblnd_setup_rd_iov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
unsigned int niov, struct iovec *iov, int offset, int nob)
unsigned int niov, struct kvec *iov, int offset, int nob)
{
kib_net_t *net = ni->ni_data;
struct page *page;
Expand Down Expand Up @@ -1433,7 +1433,7 @@ kiblnd_send (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
int target_is_router = lntmsg->msg_target_is_router;
int routing = lntmsg->msg_routing;
unsigned int payload_niov = lntmsg->msg_niov;
struct iovec *payload_iov = lntmsg->msg_iov;
struct kvec *payload_iov = lntmsg->msg_iov;
lnet_kiov_t *payload_kiov = lntmsg->msg_kiov;
unsigned int payload_offset = lntmsg->msg_offset;
unsigned int payload_nob = lntmsg->msg_len;
Expand Down Expand Up @@ -1599,7 +1599,7 @@ kiblnd_reply (lnet_ni_t *ni, kib_rx_t *rx, lnet_msg_t *lntmsg)
{
lnet_process_id_t target = lntmsg->msg_target;
unsigned int niov = lntmsg->msg_niov;
struct iovec *iov = lntmsg->msg_iov;
struct kvec *iov = lntmsg->msg_iov;
lnet_kiov_t *kiov = lntmsg->msg_kiov;
unsigned int offset = lntmsg->msg_offset;
unsigned int nob = lntmsg->msg_len;
Expand Down Expand Up @@ -1657,9 +1657,9 @@ kiblnd_reply (lnet_ni_t *ni, kib_rx_t *rx, lnet_msg_t *lntmsg)
}

int
kiblnd_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
unsigned int niov, struct iovec *iov, lnet_kiov_t *kiov,
unsigned int offset, unsigned int mlen, unsigned int rlen)
kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
unsigned int niov, struct kvec *iov, lnet_kiov_t *kiov,
unsigned int offset, unsigned int mlen, unsigned int rlen)
{
kib_rx_t *rx = private;
kib_msg_t *rxmsg = rx->rx_msg;
Expand Down
30 changes: 15 additions & 15 deletions lnet/klnds/socklnd/socklnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ typedef struct /* per scheduler state */
struct page *kss_rx_scratch_pgs[LNET_MAX_IOV];
#endif
#if !SOCKNAL_SINGLE_FRAG_TX || !SOCKNAL_SINGLE_FRAG_RX
struct iovec kss_scratch_iov[LNET_MAX_IOV];
struct kvec kss_scratch_iov[LNET_MAX_IOV];
#endif
} ksock_sched_t;

Expand Down Expand Up @@ -259,12 +259,12 @@ typedef struct
#define SOCKNAL_INIT_ALL 2

/* A packet just assembled for transmission is represented by 1 or more
* struct iovec fragments (the first frag contains the portals header),
* struct kvec fragments (the first frag contains the portals header),
* followed by 0 or more lnet_kiov_t fragments.
*
* On the receive side, initially 1 struct iovec fragment is posted for
* On the receive side, initially 1 struct kvec fragment is posted for
* receive (the header). Once the header has been received, the payload is
* received into either struct iovec or lnet_kiov_t fragments, depending on
* received into either struct kvec or lnet_kiov_t fragments, depending on
* what the header matched or whether the message needs forwarding. */

struct ksock_conn; /* forward ref */
Expand All @@ -279,8 +279,8 @@ typedef struct /* transmit packet */
atomic_t tx_refcount; /* tx reference count */
int tx_nob; /* # packet bytes */
int tx_resid; /* residual bytes */
int tx_niov; /* # packet iovec frags */
struct iovec *tx_iov; /* packet iovec frags */
int tx_niov; /* # packet kvec frags */
struct kvec *tx_iov; /* packet kvec frags */
int tx_nkiov; /* # packet page frags */
unsigned short tx_zc_aborted; /* aborted ZC request */
unsigned short tx_zc_capable:1; /* payload is large enough for ZC */
Expand All @@ -294,11 +294,11 @@ typedef struct /* transmit packet */
int tx_desc_size; /* size of this descriptor */
union {
struct {
struct iovec iov; /* virt hdr */
lnet_kiov_t kiov[0]; /* paged payload */
struct kvec iov; /* virt hdr */
lnet_kiov_t kiov[0]; /* paged payload */
} paged;
struct {
struct iovec iov[1]; /* virt hdr + payload */
struct kvec iov[1]; /* virt hdr + payload */
} virt;
} tx_frags;
} ksock_tx_t;
Expand All @@ -310,7 +310,7 @@ typedef struct /* transmit packet */
/* space for the rx frag descriptors; we either read a single contiguous
* header, or up to LNET_MAX_IOV frags of payload of either type. */
typedef union {
struct iovec iov[LNET_MAX_IOV];
struct kvec iov[LNET_MAX_IOV];
lnet_kiov_t kiov[LNET_MAX_IOV];
} ksock_rxiovspace_t;

Expand Down Expand Up @@ -353,8 +353,8 @@ typedef struct ksock_conn
__u8 ksnc_rx_state; /* what is being read */
int ksnc_rx_nob_left; /* # bytes to next hdr/body */
int ksnc_rx_nob_wanted; /* bytes actually wanted */
int ksnc_rx_niov; /* # iovec frags */
struct iovec *ksnc_rx_iov; /* the iovec frags */
int ksnc_rx_niov; /* # kvec frags */
struct kvec *ksnc_rx_iov; /* the kvec frags */
int ksnc_rx_nkiov; /* # page frags */
lnet_kiov_t *ksnc_rx_kiov; /* the page frags */
ksock_rxiovspace_t ksnc_rx_iov_space;/* space for frag descriptors */
Expand Down Expand Up @@ -614,9 +614,9 @@ int ksocknal_startup (lnet_ni_t *ni);
void ksocknal_shutdown (lnet_ni_t *ni);
int ksocknal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg);
int ksocknal_send (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg);
int ksocknal_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
int delayed, unsigned int niov,
struct iovec *iov, lnet_kiov_t *kiov,
int ksocknal_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
int delayed, unsigned int niov,
struct kvec *iov, lnet_kiov_t *kiov,
unsigned int offset, unsigned int mlen, unsigned int rlen);
int ksocknal_accept(lnet_ni_t *ni, struct socket *sock);

Expand Down
Loading

0 comments on commit 88f761b

Please sign in to comment.