]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sdp: ZCopy doesn't support multithreading - warning & kernel panic protection
authorEldad Zinger <eldadz@mellanox.co.il>
Tue, 12 Oct 2010 08:22:05 +0000 (10:22 +0200)
committerMukesh Kacker <mukesh.kacker@oracle.com>
Tue, 6 Oct 2015 12:05:26 +0000 (05:05 -0700)
Correspond to BUG 2147.

Signed-off-by: Eldad Zinger <eldadz@mellanox.co.il>
drivers/infiniband/ulp/sdp/sdp_main.c
drivers/infiniband/ulp/sdp/sdp_zcopy.c

index ac8fc1c90575d5725426e6e33f20c66c1b049bd5..43e18d769f6df22645a30e47f1e2cb2f44174473 100644 (file)
@@ -1927,6 +1927,7 @@ static int sdp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
        sdp_dbg_data(sk, "%s size = 0x%zx\n", __func__, size);
 
        posts_handler_get(ssk);
+       SDP_WARN_ON(ssk->tx_sa);
 
        flags = msg->msg_flags;
        timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);
index 5f975c578f19e0f2d3b7434150b0b89e5b1e8de0..6cdfc9644eb7ac5c2f051961d01772f1d1aee2a9 100644 (file)
@@ -55,7 +55,17 @@ static int sdp_post_srcavail(struct sock *sk, struct tx_srcavail_state *tx_sa)
        int off, len;
        struct ib_umem_chunk *chunk;
 
-       SDP_WARN_ON(ssk->tx_sa);
+       if (ssk->tx_sa) {
+               /* ssk->tx_sa might already be there in a case of
+                * multithreading: user thread initiated Zcopy and went to
+                * sleep, and now another user thread tries to ZCopy.
+                * Fallback to BCopy - data might be mixed.
+                * TODO: Fix it. fallback to BCopy is not enough because recv
+                * side has seq warnings.
+                */
+               sdp_dbg_data(sk, "user already initiated ZCopy transmission\n");
+               return -EAGAIN;
+       }
 
        BUG_ON(!tx_sa);
        BUG_ON(!tx_sa->fmr || !tx_sa->fmr->fmr->lkey);
@@ -644,7 +654,7 @@ static int do_sdp_sendmsg_zcopy(struct sock *sk, struct tx_srcavail_state *tx_sa
 
        rc = sdp_post_srcavail(sk, tx_sa);
        if (unlikely(rc)) {
-               sdp_dbg(sk, "Error posting SrcAvail\n");
+               sdp_dbg(sk, "Error posting SrcAvail: %d\n", rc);
                goto err_abort_send;
        }