Whamcloud - gitweb
LU-18749 socklnd: check page for zerocopy 05/58205/2
authorYang Sheng <ys@whamcloud.com>
Mon, 10 Feb 2025 19:35:20 +0000 (03:35 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 6 Mar 2025 08:09:50 +0000 (08:09 +0000)
We should check the page state to ensure kernel
can handle it in zerocopy case.

Signed-off-by: Yang Sheng <ys@whamcloud.com>
Change-Id: Ib82989bcca9898ecc176ddc0c9a6cd4eafbad89f
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58205
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Frank Sehr <fsehr@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/klnds/socklnd/socklnd_lib.c

index d2ff979..7700fa8 100644 (file)
@@ -90,12 +90,20 @@ ksocknal_lib_send_hdr(struct ksock_conn *conn, struct ksock_tx *tx,
 }
 
 static int
-ksocknal_lib_sendpage(struct socket *sock, struct bio_vec *kiov, int msgflg)
+ksocknal_lib_sendpage(struct socket *sock, struct bio_vec *kiov,
+                     int nkiov, int msgflg)
 {
 #ifdef MSG_SPLICE_PAGES
        struct msghdr msg = {.msg_flags = msgflg | MSG_SPLICE_PAGES};
+       int i;
 
        iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, kiov, 1, kiov->bv_len);
+       for (i = 0; i < nkiov; i++) {
+               if (!sendpage_ok(kiov[i].bv_page)) {
+                       msg.msg_flags &= ~MSG_SPLICE_PAGES;
+                       break;
+               }
+       }
 
        return sock_sendmsg(sock, &msg);
 #else
@@ -132,7 +140,7 @@ ksocknal_lib_send_kiov(struct ksock_conn *conn, struct ksock_tx *tx,
                    kiov->bv_len < tx->tx_resid)
                        msgflg |= MSG_MORE;
 
-               rc = ksocknal_lib_sendpage(sock, kiov, msgflg);
+               rc = ksocknal_lib_sendpage(sock, kiov, tx->tx_nkiov, msgflg);
        } else {
 #if SOCKNAL_SINGLE_FRAG_TX || !SOCKNAL_RISK_KMAP_DEADLOCK
                struct kvec scratch;