Whamcloud - gitweb
LU-13004 gnilnd: remove support for GNILND_BUF_VIRT_*
[fs/lustre-release.git] / lnet / klnds / gnilnd / gnilnd_cb.c
index d6358ff..42b1cd3 100644 (file)
@@ -27,6 +27,9 @@
 #include <asm/page.h>
 #include <linux/nmi.h>
 #include <linux/pagemap.h>
+
+#include <libcfs/linux/linux-mem.h>
+
 #include "gnilnd.h"
 
 /* this is useful when needed to debug wire corruption. */
@@ -274,7 +277,7 @@ kgnilnd_alloc_tx (void)
        if (CFS_FAIL_CHECK(CFS_FAIL_GNI_ALLOC_TX))
                return tx;
 
-       tx = kmem_cache_alloc(kgnilnd_data.kgn_tx_cache, GFP_ATOMIC);
+       tx = kmem_cache_zalloc(kgnilnd_data.kgn_tx_cache, GFP_ATOMIC);
        if (tx == NULL) {
                CERROR("failed to allocate tx\n");
                return NULL;
@@ -282,9 +285,6 @@ kgnilnd_alloc_tx (void)
        CDEBUG(D_MALLOC, "slab-alloced 'tx': %lu at %p.\n",
               sizeof(*tx), tx);
 
-       /* need this memset, cache alloc'd memory is not cleared */
-       memset(tx, 0, sizeof(*tx));
-
        /* setup everything here to minimize time under the lock */
        tx->tx_buftype = GNILND_BUF_NONE;
        tx->tx_msg.gnm_type = GNILND_MSG_NONE;
@@ -301,8 +301,8 @@ kgnilnd_alloc_tx (void)
 #define _kgnilnd_cksum(seed, ptr, nob)  csum_partial(ptr, nob, seed)
 
 /* we don't use offset as every one is passing a buffer reference that already
- * includes the offset into the base address -
- *  see kgnilnd_setup_virt_buffer and kgnilnd_setup_immediate_buffer */
+ * includes the offset into the base address.
+ */
 static inline __u16
 kgnilnd_cksum(void *ptr, size_t nob)
 {
@@ -321,8 +321,8 @@ kgnilnd_cksum(void *ptr, size_t nob)
 }
 
 __u16
-kgnilnd_cksum_kiov(unsigned int nkiov, lnet_kiov_t *kiov,
-                   unsigned int offset, unsigned int nob, int dump_blob)
+kgnilnd_cksum_kiov(unsigned int nkiov, struct bio_vec *kiov,
+                  unsigned int offset, unsigned int nob, int dump_blob)
 {
        __wsum             cksum = 0;
        __wsum             tmpck;
@@ -339,15 +339,15 @@ kgnilnd_cksum_kiov(unsigned int nkiov, lnet_kiov_t *kiov,
 
        /* if loops changes, please change kgnilnd_setup_phys_buffer */
 
-       while (offset >= kiov->kiov_len) {
-               offset -= kiov->kiov_len;
+       while (offset >= kiov->bv_len) {
+               offset -= kiov->bv_len;
                nkiov--;
                kiov++;
                LASSERT(nkiov > 0);
        }
 
-       /* ignore nob here, if nob < (kiov_len - offset), kiov == 1 */
-       odd = (unsigned long) (kiov[0].kiov_len - offset) & 1;
+       /* ignore nob here, if nob < (bv_len - offset), kiov == 1 */
+       odd = (unsigned long) (kiov[0].bv_len - offset) & 1;
 
        if ((odd || *kgnilnd_tunables.kgn_vmap_cksum) && nkiov > 1) {
                struct page **pages = kgnilnd_data.kgn_cksum_map_pages[get_cpu()];
@@ -356,10 +356,10 @@ kgnilnd_cksum_kiov(unsigned int nkiov, lnet_kiov_t *kiov,
                         get_cpu(), kgnilnd_data.kgn_cksum_map_pages);
 
                CDEBUG(D_BUFFS, "odd %d len %u offset %u nob %u\n",
-                      odd, kiov[0].kiov_len, offset, nob);
+                      odd, kiov[0].bv_len, offset, nob);
 
                for (i = 0; i < nkiov; i++) {
-                       pages[i] = kiov[i].kiov_page;
+                       pages[i] = kiov[i].bv_page;
                }
 
                addr = vmap(pages, nkiov, VM_MAP, PAGE_KERNEL);
@@ -372,42 +372,46 @@ kgnilnd_cksum_kiov(unsigned int nkiov, lnet_kiov_t *kiov,
                }
                atomic_inc(&kgnilnd_data.kgn_nvmap_cksum);
 
-               tmpck = _kgnilnd_cksum(0, (void *) addr + kiov[0].kiov_offset + offset, nob);
+               tmpck = _kgnilnd_cksum(0, ((void *) addr + kiov[0].bv_offset +
+                                          offset), nob);
                cksum = tmpck;
 
                if (dump_blob) {
                        kgnilnd_dump_blob(D_BUFFS, "flat kiov RDMA payload",
-                                         (void *)addr + kiov[0].kiov_offset + offset, nob);
+                                         (void *)addr + kiov[0].bv_offset +
+                                         offset, nob);
                }
                CDEBUG(D_BUFFS, "cksum 0x%x (+0x%x) for addr 0x%p+%u len %u offset %u\n",
-                      cksum, tmpck, addr, kiov[0].kiov_offset, nob, offset);
+                      cksum, tmpck, addr, kiov[0].bv_offset, nob, offset);
                vunmap(addr);
        } else {
                do {
-                       fraglen = min(kiov->kiov_len - offset, nob);
+                       fraglen = min(kiov->bv_len - offset, nob);
 
                        /* make dang sure we don't send a bogus checksum if somehow we get
                         * an odd length fragment on anything but the last entry in a kiov  -
                         * we know from kgnilnd_setup_rdma_buffer that we can't have non
                         * PAGE_SIZE pages in the middle, so if nob < PAGE_SIZE, it is the last one */
                        LASSERTF(!(fraglen&1) || (nob < PAGE_SIZE),
-                                "odd fraglen %u on nkiov %d, nob %u kiov_len %u offset %u kiov 0x%p\n",
-                                fraglen, nkiov, nob, kiov->kiov_len, offset, kiov);
+                                "odd fraglen %u on nkiov %d, nob %u bv_len %u offset %u kiov 0x%p\n",
+                                fraglen, nkiov, nob, kiov->bv_len,
+                                offset, kiov);
 
-                       addr = (void *)kmap(kiov->kiov_page) + kiov->kiov_offset + offset;
+                       addr = (void *)kmap(kiov->bv_page) + kiov->bv_offset +
+                               offset;
                        tmpck = _kgnilnd_cksum(cksum, addr, fraglen);
 
                        CDEBUG(D_BUFFS,
                               "cksum 0x%x (+0x%x) for page 0x%p+%u (0x%p) len %u offset %u\n",
-                              cksum, tmpck, kiov->kiov_page, kiov->kiov_offset, addr,
-                              fraglen, offset);
+                              cksum, tmpck, kiov->bv_page, kiov->bv_offset,
+                              addr, fraglen, offset);
 
                        cksum = tmpck;
 
                        if (dump_blob)
                                kgnilnd_dump_blob(D_BUFFS, "kiov cksum", addr, fraglen);
 
-                       kunmap(kiov->kiov_page);
+                       kunmap(kiov->bv_page);
 
                        kiov++;
                        nkiov--;
@@ -507,9 +511,9 @@ kgnilnd_nak_rdma(kgn_conn_t *conn, int rx_type, int error, __u64 cookie, lnet_ni
        kgnilnd_queue_tx(conn, tx);
 }
 
-int
+static int
 kgnilnd_setup_immediate_buffer(kgn_tx_t *tx, unsigned int niov,
-                              struct kvec *iov, lnet_kiov_t *kiov,
+                              struct bio_vec *kiov,
                               unsigned int offset, unsigned int nob)
 {
        kgn_msg_t       *msg = &tx->tx_msg;
@@ -522,44 +526,48 @@ kgnilnd_setup_immediate_buffer(kgn_tx_t *tx, unsigned int niov,
 
        if (nob == 0) {
                tx->tx_buffer = NULL;
-       } else if (kiov != NULL) {
+       } else {
 
                if ((niov > 0) && unlikely(niov > (nob/PAGE_SIZE))) {
-                       niov = ((nob + offset + kiov->kiov_offset + PAGE_SIZE - 1) /
-                               PAGE_SIZE);
+                       niov = round_up(nob + offset + kiov->bv_offset,
+                                       PAGE_SIZE);
                }
 
                LASSERTF(niov > 0 && niov < GNILND_MAX_IMMEDIATE/PAGE_SIZE,
-                       "bad niov %d msg %p kiov %p iov %p offset %d nob%d\n",
-                       niov, msg, kiov, iov, offset, nob);
+                       "bad niov %d msg %p kiov %p offset %d nob%d\n",
+                       niov, msg, kiov, offset, nob);
 
-               while (offset >= kiov->kiov_len) {
-                       offset -= kiov->kiov_len;
+               while (offset >= kiov->bv_len) {
+                       offset -= kiov->bv_len;
                        niov--;
                        kiov++;
                        LASSERT(niov > 0);
                }
                for (i = 0; i < niov; i++) {
-                       /* We can't have a kiov_offset on anything but the first entry,
-                        * otherwise we'll have a hole at the end of the mapping as we only map
-                        * whole pages.
-                        * Also, if we have a kiov_len < PAGE_SIZE but we need to map more
-                        * than kiov_len, we will also have a whole at the end of that page
-                        * which isn't allowed */
-                       if ((kiov[i].kiov_offset != 0 && i > 0) ||
-                           (kiov[i].kiov_offset + kiov[i].kiov_len != PAGE_SIZE && i < niov - 1)) {
-                               CNETERR("Can't make payload contiguous in I/O VM: page %d, offset %u, nob %u, kiov_offset %u, kiov_len %u\n",
-                                      i, offset, nob, kiov->kiov_offset, kiov->kiov_len);
+                       /* We can't have a bv_offset on anything but the first
+                        * entry, otherwise we'll have a hole at the end of the
+                        * mapping as we only map whole pages.
+                        * Also, if we have a bv_len < PAGE_SIZE but we need to
+                        * map more than bv_len, we will also have a whole at
+                        * the end of that page which isn't allowed
+                        */
+                       if ((kiov[i].bv_offset != 0 && i > 0) ||
+                           (kiov[i].bv_offset + kiov[i].bv_len != PAGE_SIZE &&
+                            i < niov - 1)) {
+                               CNETERR("Can't make payload contiguous in I/O VM:page %d, offset %u, nob %u, bv_offset %u bv_len %u\n",
+                                      i, offset, nob, kiov->bv_offset,
+                                       kiov->bv_len);
                                RETURN(-EINVAL);
                        }
-                       tx->tx_imm_pages[i] = kiov[i].kiov_page;
+                       tx->tx_imm_pages[i] = kiov[i].bv_page;
                }
 
                /* hijack tx_phys for the later unmap */
                if (niov == 1) {
                        /* tx->phyx being equal to NULL is the signal for unmap to discern between kmap and vmap */
                        tx->tx_phys = NULL;
-                       tx->tx_buffer = (void *)kmap(tx->tx_imm_pages[0]) + kiov[0].kiov_offset + offset;
+                       tx->tx_buffer = (void *)kmap(tx->tx_imm_pages[0]) +
+                               kiov[0].bv_offset + offset;
                        atomic_inc(&kgnilnd_data.kgn_nkmap_short);
                        GNIDBG_TX(D_NET, tx, "kmapped page for %d bytes for kiov 0x%p, buffer 0x%p",
                                nob, kiov, tx->tx_buffer);
@@ -571,37 +579,18 @@ kgnilnd_setup_immediate_buffer(kgn_tx_t *tx, unsigned int niov,
 
                        }
                        atomic_inc(&kgnilnd_data.kgn_nvmap_short);
-                       /* make sure we take into account the kiov offset as the start of the buffer */
-                       tx->tx_buffer = (void *)tx->tx_phys + kiov[0].kiov_offset + offset;
-                       GNIDBG_TX(D_NET, tx, "mapped %d pages for %d bytes from kiov 0x%p to 0x%p, buffer 0x%p",
-                               niov, nob, kiov, tx->tx_phys, tx->tx_buffer);
+                       /* make sure we take into account the kiov offset as the
+                        * start of the buffer
+                        */
+                       tx->tx_buffer = (void *)tx->tx_phys + kiov[0].bv_offset
+                               + offset;
+                       GNIDBG_TX(D_NET, tx,
+                                 "mapped %d pages for %d bytes from kiov 0x%p to 0x%p, buffer 0x%p",
+                                 niov, nob, kiov, tx->tx_phys, tx->tx_buffer);
                }
                tx->tx_buftype = GNILND_BUF_IMMEDIATE_KIOV;
                tx->tx_nob = nob;
 
-       } else {
-               /* For now this is almost identical to kgnilnd_setup_virt_buffer, but we
-                * could "flatten" the payload into a single contiguous buffer ready
-                * for sending direct over an FMA if we ever needed to. */
-
-               LASSERT(niov > 0);
-
-               while (offset >= iov->iov_len) {
-                       offset -= iov->iov_len;
-                       niov--;
-                       iov++;
-                       LASSERT(niov > 0);
-               }
-
-               if (nob > iov->iov_len - offset) {
-                       CERROR("Can't handle multiple vaddr fragments\n");
-                       return -EMSGSIZE;
-               }
-
-               tx->tx_buffer = (void *)(((unsigned long)iov->iov_base) + offset);
-
-               tx->tx_buftype = GNILND_BUF_IMMEDIATE;
-               tx->tx_nob = nob;
        }
 
        /* checksum payload early - it shouldn't be changing after lnd_send */
@@ -622,35 +611,7 @@ kgnilnd_setup_immediate_buffer(kgn_tx_t *tx, unsigned int niov,
 }
 
 int
-kgnilnd_setup_virt_buffer(kgn_tx_t *tx,
-                         unsigned int niov, struct kvec *iov,
-                         unsigned int offset, unsigned int nob)
-
-{
-       LASSERT(nob > 0);
-       LASSERT(niov > 0);
-       LASSERT(tx->tx_buftype == GNILND_BUF_NONE);
-
-       while (offset >= iov->iov_len) {
-               offset -= iov->iov_len;
-               niov--;
-               iov++;
-               LASSERT(niov > 0);
-       }
-
-       if (nob > iov->iov_len - offset) {
-               CERROR("Can't handle multiple vaddr fragments\n");
-               return -EMSGSIZE;
-       }
-
-       tx->tx_buftype = GNILND_BUF_VIRT_UNMAPPED;
-       tx->tx_nob = nob;
-       tx->tx_buffer = (void *)(((unsigned long)iov->iov_base) + offset);
-       return 0;
-}
-
-int
-kgnilnd_setup_phys_buffer(kgn_tx_t *tx, int nkiov, lnet_kiov_t *kiov,
+kgnilnd_setup_phys_buffer(kgn_tx_t *tx, int nkiov, struct bio_vec *kiov,
                          unsigned int offset, unsigned int nob)
 {
        gni_mem_segment_t *phys;
@@ -678,8 +639,8 @@ kgnilnd_setup_phys_buffer(kgn_tx_t *tx, int nkiov, lnet_kiov_t *kiov,
        /* if loops changes, please change kgnilnd_cksum_kiov
         *   and kgnilnd_setup_immediate_buffer */
 
-       while (offset >= kiov->kiov_len) {
-               offset -= kiov->kiov_len;
+       while (offset >= kiov->bv_len) {
+               offset -= kiov->bv_len;
                nkiov--;
                kiov++;
                LASSERT(nkiov > 0);
@@ -691,30 +652,31 @@ kgnilnd_setup_phys_buffer(kgn_tx_t *tx, int nkiov, lnet_kiov_t *kiov,
        tx->tx_buftype = GNILND_BUF_PHYS_UNMAPPED;
        tx->tx_nob = nob;
 
-       /* kiov_offset is start of 'valid' buffer, so index offset past that */
-       tx->tx_buffer = (void *)((unsigned long)(kiov->kiov_offset + offset));
+       /* bv_offset is start of 'valid' buffer, so index offset past that */
+       tx->tx_buffer = (void *)((unsigned long)(kiov->bv_offset + offset));
        phys = tx->tx_phys;
 
        CDEBUG(D_NET, "tx 0x%p buffer 0x%p map start kiov 0x%p+%u niov %d offset %u\n",
-              tx, tx->tx_buffer, kiov, kiov->kiov_offset, nkiov, offset);
+              tx, tx->tx_buffer, kiov, kiov->bv_offset, nkiov, offset);
 
        do {
-               fraglen = min(kiov->kiov_len - offset, nob);
-
-               /* We can't have a kiov_offset on anything but the first entry,
-                * otherwise we'll have a hole at the end of the mapping as we only map
-                * whole pages. Only the first page is allowed to have an offset -
-                * we'll add that into tx->tx_buffer and that will get used when we
-                * map in the segments (see kgnilnd_map_buffer).
-                * Also, if we have a kiov_len < PAGE_SIZE but we need to map more
-                * than kiov_len, we will also have a whole at the end of that page
-                * which isn't allowed */
+               fraglen = min(kiov->bv_len - offset, nob);
+
+               /* We can't have a bv_offset on anything but the first entry,
+                * otherwise we'll have a hole at the end of the mapping as we
+                * only map whole pages.  Only the first page is allowed to
+                * have an offset - we'll add that into tx->tx_buffer and that
+                * will get used when we map in the segments (see
+                * kgnilnd_map_buffer).  Also, if we have a bv_len < PAGE_SIZE
+                * but we need to map more than bv_len, we will also have a
+                * whole at the end of that page which isn't allowed
+                */
                if ((phys != tx->tx_phys) &&
-                   ((kiov->kiov_offset != 0) ||
-                    ((kiov->kiov_len < PAGE_SIZE) && (nob > kiov->kiov_len)))) {
-                       CERROR("Can't make payload contiguous in I/O VM: page %d, offset %u, nob %u, kiov_offset %u, kiov_len %u\n",
+                   ((kiov->bv_offset != 0) ||
+                    ((kiov->bv_len < PAGE_SIZE) && (nob > kiov->bv_len)))) {
+                       CERROR("Can't make payload contiguous in I/O VM:page %d, offset %u, nob %u, bv_offset %u bv_len %u\n",
                               (int)(phys - tx->tx_phys),
-                              offset, nob, kiov->kiov_offset, kiov->kiov_len);
+                              offset, nob, kiov->bv_offset, kiov->bv_len);
                        rc = -EINVAL;
                        GOTO(error, rc);
                }
@@ -730,11 +692,12 @@ kgnilnd_setup_phys_buffer(kgn_tx_t *tx, int nkiov, lnet_kiov_t *kiov,
                        GOTO(error, rc);
                }
 
-               CDEBUG(D_BUFFS, "page 0x%p kiov_offset %u kiov_len %u nob %u "
-                              "nkiov %u offset %u\n",
-                     kiov->kiov_page, kiov->kiov_offset, kiov->kiov_len, nob, nkiov, offset);
+               CDEBUG(D_BUFFS,
+                      "page 0x%p bv_offset %u bv_len %u nob %u nkiov %u offset %u\n",
+                      kiov->bv_page, kiov->bv_offset, kiov->bv_len, nob, nkiov,
+                      offset);
 
-               phys->address = page_to_phys(kiov->kiov_page);
+               phys->address = page_to_phys(kiov->bv_page);
                phys++;
                kiov++;
                nkiov--;
@@ -762,21 +725,10 @@ error:
 
 static inline int
 kgnilnd_setup_rdma_buffer(kgn_tx_t *tx, unsigned int niov,
-                         struct kvec *iov, lnet_kiov_t *kiov,
+                         struct bio_vec *kiov,
                          unsigned int offset, unsigned int nob)
 {
-       int     rc;
-
-       LASSERTF((iov == NULL) != (kiov == NULL), "iov 0x%p, kiov 0x%p, tx 0x%p,"
-                                               " offset %d, nob %d, niov %d\n"
-                                               , iov, kiov, tx, offset, nob, niov);
-
-       if (kiov != NULL) {
-               rc = kgnilnd_setup_phys_buffer(tx, niov, kiov, offset, nob);
-       } else {
-               rc = kgnilnd_setup_virt_buffer(tx, niov, iov, offset, nob);
-       }
-       return rc;
+       return kgnilnd_setup_phys_buffer(tx, niov, kiov, offset, nob);
 }
 
 /* kgnilnd_parse_lnet_rdma()
@@ -792,14 +744,14 @@ kgnilnd_setup_rdma_buffer(kgn_tx_t *tx, unsigned int niov,
 static void
 kgnilnd_parse_lnet_rdma(struct lnet_msg *lntmsg, unsigned int *niov,
                        unsigned int *offset, unsigned int *nob,
-                       lnet_kiov_t **kiov, int put_len)
+                       struct bio_vec **kiov, int put_len)
 {
        /* GETs are weird, see kgnilnd_send */
        if (lntmsg->msg_type == LNET_MSG_GET) {
                if ((lntmsg->msg_md->md_options & LNET_MD_KIOV) == 0) {
                        *kiov = NULL;
                } else {
-                       *kiov = lntmsg->msg_md->md_iov.kiov;
+                       *kiov = lntmsg->msg_md->md_kiov;
                }
                *niov = lntmsg->msg_md->md_niov;
                *nob = lntmsg->msg_md->md_length;
@@ -815,10 +767,10 @@ kgnilnd_parse_lnet_rdma(struct lnet_msg *lntmsg, unsigned int *niov,
 static inline void
 kgnilnd_compute_rdma_cksum(kgn_tx_t *tx, int put_len)
 {
-       unsigned int     niov, offset, nob;
-       lnet_kiov_t     *kiov;
-       struct lnet_msg      *lntmsg = tx->tx_lntmsg[0];
-       int              dump_cksum = (*kgnilnd_tunables.kgn_checksum_dump > 1);
+       unsigned int niov, offset, nob;
+       struct bio_vec *kiov;
+       struct lnet_msg *lntmsg = tx->tx_lntmsg[0];
+       int dump_cksum = (*kgnilnd_tunables.kgn_checksum_dump > 1);
 
        GNITX_ASSERTF(tx, ((tx->tx_msg.gnm_type == GNILND_MSG_PUT_DONE) ||
                           (tx->tx_msg.gnm_type == GNILND_MSG_GET_DONE) ||
@@ -868,8 +820,8 @@ kgnilnd_verify_rdma_cksum(kgn_tx_t *tx, __u16 rx_cksum, int put_len)
        int              rc = 0;
        __u16            cksum;
        unsigned int     niov, offset, nob;
-       lnet_kiov_t     *kiov;
-       struct lnet_msg      *lntmsg = tx->tx_lntmsg[0];
+       struct bio_vec  *kiov;
+       struct lnet_msg *lntmsg = tx->tx_lntmsg[0];
        int dump_on_err = *kgnilnd_tunables.kgn_checksum_dump;
 
        /* we can only match certain requests */
@@ -952,12 +904,6 @@ kgnilnd_mem_add_map_list(kgn_device_t *dev, kgn_tx_t *tx)
                dev->gnd_map_nphys++;
                dev->gnd_map_physnop += tx->tx_phys_npages;
                break;
-
-       case GNILND_BUF_VIRT_MAPPED:
-               bytes = tx->tx_nob;
-               dev->gnd_map_nvirt++;
-               dev->gnd_map_virtnob += tx->tx_nob;
-               break;
        }
 
        if (tx->tx_msg.gnm_type == GNILND_MSG_PUT_ACK ||
@@ -1001,12 +947,6 @@ kgnilnd_mem_del_map_list(kgn_device_t *dev, kgn_tx_t *tx)
                dev->gnd_map_nphys--;
                dev->gnd_map_physnop -= tx->tx_phys_npages;
                break;
-
-       case GNILND_BUF_VIRT_UNMAPPED:
-               bytes = tx->tx_nob;
-               dev->gnd_map_nvirt--;
-               dev->gnd_map_virtnob -= tx->tx_nob;
-               break;
        }
 
        if (tx->tx_msg.gnm_type == GNILND_MSG_PUT_ACK ||
@@ -1059,7 +999,6 @@ kgnilnd_map_buffer(kgn_tx_t *tx)
        case GNILND_BUF_IMMEDIATE:
        case GNILND_BUF_IMMEDIATE_KIOV:
        case GNILND_BUF_PHYS_MAPPED:
-       case GNILND_BUF_VIRT_MAPPED:
                return 0;
 
        case GNILND_BUF_PHYS_UNMAPPED:
@@ -1072,41 +1011,16 @@ kgnilnd_map_buffer(kgn_tx_t *tx)
                 * - this needs to turn into a non-fatal error soon to allow
                 *  GART resource, etc starvation handling */
                if (rrc != GNI_RC_SUCCESS) {
-                       GNIDBG_TX(D_NET, tx, "Can't map %d pages: dev %d "
-                               "phys %u pp %u, virt %u nob %llu",
+                       GNIDBG_TX(D_NET, tx,
+                                 "Can't map %d pages: dev %d phys %u pp %u",
                                tx->tx_phys_npages, dev->gnd_id,
-                               dev->gnd_map_nphys, dev->gnd_map_physnop,
-                               dev->gnd_map_nvirt, dev->gnd_map_virtnob);
+                               dev->gnd_map_nphys, dev->gnd_map_physnop);
                        RETURN(rrc == GNI_RC_ERROR_RESOURCE ? -ENOMEM : -EINVAL);
                }
 
                tx->tx_buftype = GNILND_BUF_PHYS_MAPPED;
                kgnilnd_mem_add_map_list(dev, tx);
                return 0;
-
-       case GNILND_BUF_VIRT_UNMAPPED:
-               rrc = kgnilnd_mem_register(dev->gnd_handle,
-                       (__u64)tx->tx_buffer, tx->tx_nob,
-                       NULL, flags, &tx->tx_map_key);
-               if (rrc != GNI_RC_SUCCESS) {
-                       GNIDBG_TX(D_NET, tx, "Can't map %u bytes: dev %d "
-                               "phys %u pp %u, virt %u nob %llu",
-                               tx->tx_nob, dev->gnd_id,
-                               dev->gnd_map_nphys, dev->gnd_map_physnop,
-                               dev->gnd_map_nvirt, dev->gnd_map_virtnob);
-                       RETURN(rrc == GNI_RC_ERROR_RESOURCE ? -ENOMEM : -EINVAL);
-               }
-
-               tx->tx_buftype = GNILND_BUF_VIRT_MAPPED;
-               kgnilnd_mem_add_map_list(dev, tx);
-               if (tx->tx_msg.gnm_type == GNILND_MSG_PUT_ACK ||
-                   tx->tx_msg.gnm_type == GNILND_MSG_GET_REQ) {
-                       atomic64_add(tx->tx_nob, &dev->gnd_rdmaq_bytes_out);
-                       GNIDBG_TX(D_NETTRACE, tx, "rdma ++ %d to %ld\n",
-                              tx->tx_nob, atomic64_read(&dev->gnd_rdmaq_bytes_out));
-               }
-
-               return 0;
        }
 }
 
@@ -1150,8 +1064,6 @@ kgnilnd_unmap_buffer(kgn_tx_t *tx, int error)
        /* code below relies on +1 relationship ... */
        BUILD_BUG_ON(GNILND_BUF_PHYS_MAPPED !=
                     (GNILND_BUF_PHYS_UNMAPPED + 1));
-       BUILD_BUG_ON(GNILND_BUF_VIRT_MAPPED !=
-                    (GNILND_BUF_VIRT_UNMAPPED + 1));
 
        switch (tx->tx_buftype) {
        default:
@@ -1160,7 +1072,6 @@ kgnilnd_unmap_buffer(kgn_tx_t *tx, int error)
        case GNILND_BUF_NONE:
        case GNILND_BUF_IMMEDIATE:
        case GNILND_BUF_PHYS_UNMAPPED:
-       case GNILND_BUF_VIRT_UNMAPPED:
                break;
        case GNILND_BUF_IMMEDIATE_KIOV:
                if (tx->tx_phys != NULL) {
@@ -1174,7 +1085,6 @@ kgnilnd_unmap_buffer(kgn_tx_t *tx, int error)
                break;
 
        case GNILND_BUF_PHYS_MAPPED:
-       case GNILND_BUF_VIRT_MAPPED:
                LASSERT(tx->tx_conn != NULL);
 
                dev = tx->tx_conn->gnc_device;
@@ -2104,15 +2014,15 @@ kgnilnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
        int               target_is_router = lntmsg->msg_target_is_router;
        int               routing = lntmsg->msg_routing;
        unsigned int      niov = lntmsg->msg_niov;
-       struct kvec      *iov = lntmsg->msg_iov;
-       lnet_kiov_t      *kiov = lntmsg->msg_kiov;
+       struct bio_vec   *kiov = lntmsg->msg_kiov;
        unsigned int      offset = lntmsg->msg_offset;
        unsigned int      nob = lntmsg->msg_len;
        unsigned int      msg_vmflush = lntmsg->msg_vmflush;
        kgn_net_t        *net = ni->ni_data;
        kgn_tx_t         *tx;
        int               rc = 0;
-       int               mpflag = 0;
+       /* '1' for consistency with code that checks !mpflag to restore */
+       unsigned int mpflag = 1;
        int               reverse_rdma_flag = *kgnilnd_tunables.kgn_reverse_rdma;
 
        /* NB 'private' is different depending on what we're sending.... */
@@ -2126,12 +2036,8 @@ kgnilnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
        LASSERTF(niov <= LNET_MAX_IOV,
                "lntmsg %p niov %d\n", lntmsg, niov);
 
-       /* payload is either all vaddrs or all pages */
-       LASSERTF(!(kiov != NULL && iov != NULL),
-               "lntmsg %p kiov %p iov %p\n", lntmsg, kiov, iov);
-
        if (msg_vmflush)
-               mpflag = cfs_memory_pressure_get_and_set();
+               mpflag = memalloc_noreclaim_save();
 
        switch (type) {
        default:
@@ -2169,16 +2075,9 @@ kgnilnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
                        rc = -ENOMEM;
                        goto out;
                }
-               /* slightly different options as we might actually have a GET with a
-                * MD_KIOV set but a non-NULL md_iov.iov */
-               if ((lntmsg->msg_md->md_options & LNET_MD_KIOV) == 0)
-                       rc = kgnilnd_setup_rdma_buffer(tx, lntmsg->msg_md->md_niov,
-                                                     lntmsg->msg_md->md_iov.iov, NULL,
-                                                     0, lntmsg->msg_md->md_length);
-               else
-                       rc = kgnilnd_setup_rdma_buffer(tx, lntmsg->msg_md->md_niov,
-                                                     NULL, lntmsg->msg_md->md_iov.kiov,
-                                                     0, lntmsg->msg_md->md_length);
+               rc = kgnilnd_setup_rdma_buffer(tx, lntmsg->msg_md->md_niov,
+                                              lntmsg->msg_md->md_kiov,
+                                              0, lntmsg->msg_md->md_length);
                if (rc != 0) {
                        CERROR("unable to setup buffer: %d\n", rc);
                        kgnilnd_tx_done(tx, rc);
@@ -2221,7 +2120,8 @@ kgnilnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
                        goto out;
                }
 
-               rc = kgnilnd_setup_rdma_buffer(tx, niov, iov, kiov, offset, nob);
+               rc = kgnilnd_setup_rdma_buffer(tx, niov,
+                                              kiov, offset, nob);
                if (rc != 0) {
                        kgnilnd_tx_done(tx, rc);
                        rc = -EIO;
@@ -2250,7 +2150,7 @@ kgnilnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
                goto out;
        }
 
-       rc = kgnilnd_setup_immediate_buffer(tx, niov, iov, kiov, offset, nob);
+       rc = kgnilnd_setup_immediate_buffer(tx, niov, NULL, kiov, offset, nob);
        if (rc != 0) {
                kgnilnd_tx_done(tx, rc);
                goto out;
@@ -2263,7 +2163,7 @@ kgnilnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
 out:
        /* use stored value as we could have already finalized lntmsg here from a failed launch */
        if (msg_vmflush)
-               cfs_memory_pressure_restore(mpflag);
+               memalloc_noreclaim_restore(mpflag);
        return rc;
 }
 
@@ -2273,8 +2173,7 @@ kgnilnd_setup_rdma(struct lnet_ni *ni, kgn_rx_t *rx, struct lnet_msg *lntmsg, in
        kgn_conn_t    *conn = rx->grx_conn;
        kgn_msg_t     *rxmsg = rx->grx_msg;
        unsigned int   niov = lntmsg->msg_niov;
-       struct kvec   *iov = lntmsg->msg_iov;
-       lnet_kiov_t   *kiov = lntmsg->msg_kiov;
+       struct bio_vec *kiov = lntmsg->msg_kiov;
        unsigned int   offset = lntmsg->msg_offset;
        unsigned int   nob = lntmsg->msg_len;
        int            done_type;
@@ -2304,7 +2203,7 @@ kgnilnd_setup_rdma(struct lnet_ni *ni, kgn_rx_t *rx, struct lnet_msg *lntmsg, in
        if (rc != 0)
                goto failed_1;
 
-       rc = kgnilnd_setup_rdma_buffer(tx, niov, iov, kiov, offset, nob);
+       rc = kgnilnd_setup_rdma_buffer(tx, niov, kiov, offset, nob);
        if (rc != 0)
                goto failed_1;
 
@@ -2422,7 +2321,7 @@ kgnilnd_eager_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg,
 int
 kgnilnd_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg,
             int delayed, unsigned int niov,
-            struct kvec *iov, lnet_kiov_t *kiov,
+            struct bio_vec *kiov,
             unsigned int offset, unsigned int mlen, unsigned int rlen)
 {
        kgn_rx_t    *rx = private;
@@ -2435,14 +2334,11 @@ kgnilnd_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg,
 
        LASSERT(!in_interrupt());
        LASSERTF(mlen <= rlen, "%d <= %d\n", mlen, rlen);
-       /* Either all pages or all vaddrs */
-       LASSERTF(!(kiov != NULL && iov != NULL), "kiov %p iov %p\n",
-               kiov, iov);
 
        GNIDBG_MSG(D_NET, rxmsg, "conn %p, rxmsg %p, lntmsg %p"
-               " niov=%d kiov=%p iov=%p offset=%d mlen=%d rlen=%d",
+               " niov=%d kiov=%p offset=%d mlen=%d rlen=%d",
                conn, rxmsg, lntmsg,
-               niov, kiov, iov, offset, mlen, rlen);
+               niov, kiov, offset, mlen, rlen);
 
        /* we need to lock here as recv can be called from any context */
        read_lock(&kgnilnd_data.kgn_peer_conn_lock);
@@ -2459,8 +2355,8 @@ kgnilnd_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg,
        switch (rxmsg->gnm_type) {
        default:
                GNIDBG_MSG(D_NETERROR, rxmsg, "conn %p, rx %p, rxmsg %p, lntmsg %p"
-               " niov=%d kiov=%p iov=%p offset=%d mlen=%d rlen=%d",
-               conn, rx, rxmsg, lntmsg, niov, kiov, iov, offset, mlen, rlen);
+               " niov=%d kiov=%p offset=%d mlen=%d rlen=%d",
+               conn, rx, rxmsg, lntmsg, niov, kiov, offset, mlen, rlen);
                LBUG();
 
        case GNILND_MSG_IMMEDIATE:
@@ -2513,16 +2409,10 @@ kgnilnd_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg,
                        }
                }
 
-               if (kiov != NULL)
-                       lnet_copy_flat2kiov(
-                               niov, kiov, offset,
-                               *kgnilnd_tunables.kgn_max_immediate,
-                               &rxmsg[1], 0, mlen);
-               else
-                       lnet_copy_flat2iov(
-                               niov, iov, offset,
-                               *kgnilnd_tunables.kgn_max_immediate,
-                               &rxmsg[1], 0, mlen);
+               lnet_copy_flat2kiov(
+                       niov, kiov, offset,
+                       *kgnilnd_tunables.kgn_max_immediate,
+                       &rxmsg[1], 0, mlen);
 
                kgnilnd_consume_rx(rx);
                lnet_finalize(lntmsg, 0);
@@ -2554,7 +2444,8 @@ kgnilnd_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg,
                        GOTO(nak_put_req, rc);
                }
 
-               rc = kgnilnd_setup_rdma_buffer(tx, niov, iov, kiov, offset, mlen);
+               rc = kgnilnd_setup_rdma_buffer(tx, niov,
+                                              kiov, offset, mlen);
                if (rc != 0) {
                        GOTO(nak_put_req, rc);
                }
@@ -2614,12 +2505,11 @@ nak_put_req:
                        if (rc != 0)
                                GOTO(nak_get_req_rev, rc);
 
-
-                       rc = kgnilnd_setup_rdma_buffer(tx, niov, iov, kiov, offset, mlen);
+                       rc = kgnilnd_setup_rdma_buffer(tx, niov,
+                                                      kiov, offset, mlen);
                        if (rc != 0)
                                GOTO(nak_get_req_rev, rc);
 
-
                        tx->tx_msg.gnm_u.putack.gnpam_src_cookie =
                                rxmsg->gnm_u.putreq.gnprm_cookie;
                        tx->tx_msg.gnm_u.putack.gnpam_dst_cookie = tx->tx_id.txe_cookie;
@@ -3120,7 +3010,7 @@ kgnilnd_reaper(void *arg)
 int
 kgnilnd_recv_bte_get(kgn_tx_t *tx) {
        unsigned niov, offset, nob;
-       lnet_kiov_t     *kiov;
+       struct bio_vec *kiov;
        struct lnet_msg *lntmsg = tx->tx_lntmsg[0];
        kgnilnd_parse_lnet_rdma(lntmsg, &niov, &offset, &nob, &kiov, tx->tx_nob_rdma);
 
@@ -4474,8 +4364,7 @@ kgnilnd_check_fma_rx(kgn_conn_t *conn)
                if (tx == NULL)
                        break;
 
-               GNITX_ASSERTF(tx, tx->tx_buftype == GNILND_BUF_PHYS_MAPPED ||
-                              tx->tx_buftype == GNILND_BUF_VIRT_MAPPED,
+               GNITX_ASSERTF(tx, tx->tx_buftype == GNILND_BUF_PHYS_MAPPED,
                               "bad tx buftype %d", tx->tx_buftype);
 
                kgnilnd_finalize_rx_done(tx, msg);
@@ -4493,8 +4382,7 @@ kgnilnd_check_fma_rx(kgn_conn_t *conn)
                if (tx == NULL)
                        break;
 
-               GNITX_ASSERTF(tx, tx->tx_buftype == GNILND_BUF_PHYS_MAPPED ||
-                              tx->tx_buftype == GNILND_BUF_VIRT_MAPPED,
+               GNITX_ASSERTF(tx, tx->tx_buftype == GNILND_BUF_PHYS_MAPPED,
                               "bad tx buftype %d", tx->tx_buftype);
 
                kgnilnd_complete_tx(tx, msg->gnm_u.completion.gncm_retval);
@@ -4506,8 +4394,7 @@ kgnilnd_check_fma_rx(kgn_conn_t *conn)
                if (tx == NULL)
                        break;
 
-               GNITX_ASSERTF(tx, tx->tx_buftype == GNILND_BUF_PHYS_MAPPED ||
-                              tx->tx_buftype == GNILND_BUF_VIRT_MAPPED,
+               GNITX_ASSERTF(tx, tx->tx_buftype == GNILND_BUF_PHYS_MAPPED,
                               "bad tx buftype %d", tx->tx_buftype);
 
                lnet_set_reply_msg_len(net->gnn_ni, tx->tx_lntmsg[1],
@@ -4521,8 +4408,7 @@ kgnilnd_check_fma_rx(kgn_conn_t *conn)
                if (tx == NULL)
                        break;
 
-               GNITX_ASSERTF(tx, tx->tx_buftype == GNILND_BUF_PHYS_MAPPED ||
-                               tx->tx_buftype == GNILND_BUF_VIRT_MAPPED,
+               GNITX_ASSERTF(tx, tx->tx_buftype == GNILND_BUF_PHYS_MAPPED,
                                "bad tx buftype %d", tx->tx_buftype);
 
                kgnilnd_finalize_rx_done(tx, msg);
@@ -4535,8 +4421,7 @@ kgnilnd_check_fma_rx(kgn_conn_t *conn)
                if (tx == NULL)
                        break;
 
-               GNITX_ASSERTF(tx, tx->tx_buftype == GNILND_BUF_PHYS_MAPPED ||
-                              tx->tx_buftype == GNILND_BUF_VIRT_MAPPED,
+               GNITX_ASSERTF(tx, tx->tx_buftype == GNILND_BUF_PHYS_MAPPED,
                               "bad tx buftype %d", tx->tx_buftype);
 
                kgnilnd_finalize_rx_done(tx, msg);
@@ -4548,8 +4433,7 @@ kgnilnd_check_fma_rx(kgn_conn_t *conn)
                if (tx == NULL)
                        break;
 
-               GNITX_ASSERTF(tx, tx->tx_buftype == GNILND_BUF_PHYS_MAPPED ||
-                              tx->tx_buftype == GNILND_BUF_VIRT_MAPPED,
+               GNITX_ASSERTF(tx, tx->tx_buftype == GNILND_BUF_PHYS_MAPPED,
                                "bad tx buftype %d", tx->tx_buftype);
 
                kgnilnd_complete_tx(tx, msg->gnm_u.completion.gncm_retval);
@@ -4852,11 +4736,9 @@ kgnilnd_process_mapped_tx(kgn_device_t *dev)
                } else {
                       GNIDBG_TX(log_retrans_level, tx,
                                "transient map failure #%d %d pages/%d bytes phys %u@%u "
-                               "virt %u@%llu "
                                "nq_map %d mdd# %d/%d GART %ld",
                                dev->gnd_map_attempt, tx->tx_phys_npages, tx->tx_nob,
                                dev->gnd_map_nphys, dev->gnd_map_physnop * PAGE_SIZE,
-                               dev->gnd_map_nvirt, dev->gnd_map_virtnob,
                                atomic_read(&dev->gnd_nq_map),
                                atomic_read(&dev->gnd_n_mdd), atomic_read(&dev->gnd_n_mdd_held),
                                atomic64_read(&dev->gnd_nbytes_map));