Blob Blame History Raw
From 6aa25c737705466020e74ad44679d3758b8961f6 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Fri, 2 Oct 2020 16:27:33 +0800
Subject: [PATCH] scsi: libiscsi: use sendpage_ok() in iscsi_tcp_segment_map()
Git-commit: 6aa25c737705466020e74ad44679d3758b8961f6
Patch-mainline: v5.9
References: bsc#1172873

In iscsci driver, iscsi_tcp_segment_map() uses the following code to
check whether the page should or not be handled by sendpage:
    if (!recv && page_count(sg_page(sg)) >= 1 && !PageSlab(sg_page(sg)))

The "page_count(sg_page(sg)) >= 1 && !PageSlab(sg_page(sg)" part is to
make sure the page can be sent to network layer's zero copy path. This
part is exactly what sendpage_ok() does.

This patch uses  use sendpage_ok() in iscsi_tcp_segment_map() to replace
the original open coded checks.

(Coly Li: rebase for 4.12 based SUSE kernel)

Signed-off-by: Coly Li <colyli@suse.de>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Vasily Averin <vvs@virtuozzo.com>
Cc: Cong Wang <amwang@redhat.com>
Cc: Mike Christie <michaelc@cs.wisc.edu>
Cc: Chris Leech <cleech@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: David S. Miller <davem@davemloft.net>

---
 drivers/scsi/libiscsi_tcp.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/scsi/libiscsi_tcp.c
+++ b/drivers/scsi/libiscsi_tcp.c
@@ -130,7 +130,7 @@ static void iscsi_tcp_segment_map(struct
 	 * have to go the slow sendmsg path. We always map for the
 	 * recv path.
 	 */
-	if (page_count(sg_page(sg)) >= 1 && !recv)
+	if (!recv && sendpage_ok(sg_page(sg)))
 		return;
 
 	if (recv) {