Whamcloud - gitweb
LU-15851 lnet: Adjust niov checks for large MD 19/47319/3
authorChris Horn <chris.horn@hpe.com>
Sat, 16 Apr 2022 16:01:57 +0000 (10:01 -0600)
committerOleg Drokin <green@whamcloud.com>
Wed, 3 Aug 2022 04:06:42 +0000 (04:06 +0000)
An LNet user can allocate a large contiguous MD. That MD can have >
LNET_MAX_IOV pages which causes some LNDs to assert on either niov
argument passed to lnd_recv() or the value stored in
lnet_msg::msg_niov. This is true even in cases where the actual
transfer size is <= LNET_MTU and will not exceed limits in the LNDs.

Adjust ksocklnd_send()/ksocklnd_recv() to assert on the return value
of lnet_extract_kiov().

Remove the assert on msg_niov (payload_niov) from kiblnd_send().
kiblnd_setup_rd_kiov() will already fail if we exceed ko2iblnd's
available scatter gather entries.

HPE-bug-id: LUS-10878
Test-Parameters: trivial
Fixes: 857f11169f ("LU-13004 lnet: always put a page list into struct lnet_libmd")
Signed-off-by: Chris Horn <chris.horn@hpe.com>
Change-Id: Iaa851d90f735d04e5167bb9c07235625759245b2
Reviewed-on: https://review.whamcloud.com/47319
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Alexey Lyashkov <alexey.lyashkov@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/klnds/o2iblnd/o2iblnd_cb.c
lnet/klnds/socklnd/socklnd_cb.c

index d3b3eec..1030bba 100644 (file)
@@ -1671,7 +1671,6 @@ kiblnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
               payload_nob, payload_niov, libcfs_idstr(target));
 
        LASSERT(payload_nob == 0 || payload_niov > 0);
-       LASSERT(payload_niov <= LNET_MAX_IOV);
 
        /* Thread context */
        LASSERT(!in_interrupt());
index 418b7b4..6b2ba50 100644 (file)
@@ -1003,7 +1003,6 @@ ksocknal_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
               payload_nob, payload_niov, libcfs_idstr(target));
 
        LASSERT (payload_nob == 0 || payload_niov > 0);
-       LASSERT (payload_niov <= LNET_MAX_IOV);
        LASSERT (!in_interrupt ());
 
        desc_size = offsetof(struct ksock_tx,
@@ -1030,6 +1029,8 @@ ksocknal_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
                                         payload_niov, payload_kiov,
                                         payload_offset, payload_nob);
 
+       LASSERT(tx->tx_nkiov <= LNET_MAX_IOV);
+
        if (payload_nob >= *ksocknal_tunables.ksnd_zc_min_payload)
                tx->tx_zc_capable = 1;
 
@@ -1373,7 +1374,6 @@ ksocknal_recv(struct lnet_ni *ni, void *private, struct lnet_msg *msg,
        struct ksock_sched *sched = conn->ksnc_scheduler;
 
         LASSERT (mlen <= rlen);
-        LASSERT (niov <= LNET_MAX_IOV);
 
        conn->ksnc_lnet_msg = msg;
        conn->ksnc_rx_nob_wanted = mlen;
@@ -1393,6 +1393,7 @@ ksocknal_recv(struct lnet_ni *ni, void *private, struct lnet_msg *msg,
                                          niov, kiov, offset, mlen);
        }
 
+       LASSERT(conn->ksnc_rx_nkiov <= LNET_MAX_IOV);
         LASSERT (mlen ==
                  lnet_iov_nob (conn->ksnc_rx_niov, conn->ksnc_rx_iov) +
                  lnet_kiov_nob (conn->ksnc_rx_nkiov, conn->ksnc_rx_kiov));