hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/scsi/libiscsi_tcp.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * iSCSI over TCP/IP Data-Path lib
34 *
....@@ -6,18 +7,6 @@
67 * Copyright (C) 2005 - 2006 Mike Christie
78 * Copyright (C) 2006 Red Hat, Inc. All rights reserved.
89 * maintained by open-iscsi@googlegroups.com
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published
12
- * by the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version.
14
- *
15
- * This program is distributed in the hope that it will be useful, but
16
- * WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
- * General Public License for more details.
19
- *
20
- * See the file COPYING included with this distribution for more details.
2110 *
2211 * Credits:
2312 * Christoph Hellwig
....@@ -43,6 +32,7 @@
4332 #include <scsi/scsi_host.h>
4433 #include <scsi/scsi.h>
4534 #include <scsi/scsi_transport_iscsi.h>
35
+#include <trace/events/iscsi.h>
4636
4737 #include "iscsi_tcp.h"
4838
....@@ -65,6 +55,9 @@
6555 iscsi_conn_printk(KERN_INFO, _conn, \
6656 "%s " dbg_fmt, \
6757 __func__, ##arg); \
58
+ iscsi_dbg_trace(trace_iscsi_dbg_tcp, \
59
+ &(_conn)->cls_conn->dev, \
60
+ "%s " dbg_fmt, __func__, ##arg);\
6861 } while (0);
6962
7063 static int iscsi_tcp_hdr_recv_done(struct iscsi_tcp_conn *tcp_conn,
....@@ -125,12 +118,17 @@
125118 BUG_ON(sg->length == 0);
126119
127120 /*
121
+ * We always map for the recv path.
122
+ *
128123 * If the page count is greater than one it is ok to send
129124 * to the network layer's zero copy send path. If not we
130
- * have to go the slow sendmsg path. We always map for the
131
- * recv path.
125
+ * have to go the slow sendmsg path.
126
+ *
127
+ * Same goes for slab pages: skb_can_coalesce() allows
128
+ * coalescing neighboring slab objects into a single frag which
129
+ * triggers one of hardened usercopy checks.
132130 */
133
- if (page_count(sg_page(sg)) >= 1 && !recv)
131
+ if (!recv && sendpage_ok(sg_page(sg)))
134132 return;
135133
136134 if (recv) {
....@@ -491,7 +489,7 @@
491489 struct iscsi_tcp_task *tcp_task = task->dd_data;
492490 struct iscsi_data_rsp *rhdr = (struct iscsi_data_rsp *)tcp_conn->in.hdr;
493491 int datasn = be32_to_cpu(rhdr->datasn);
494
- unsigned total_in_length = scsi_in(task->sc)->length;
492
+ unsigned total_in_length = task->sc->sdb.length;
495493
496494 /*
497495 * lib iscsi will update this in the completion handling if there
....@@ -576,11 +574,11 @@
576574 data_length, session->max_burst);
577575
578576 data_offset = be32_to_cpu(rhdr->data_offset);
579
- if (data_offset + data_length > scsi_out(task->sc)->length) {
577
+ if (data_offset + data_length > task->sc->sdb.length) {
580578 iscsi_conn_printk(KERN_ERR, conn,
581579 "invalid R2T with data len %u at offset %u "
582580 "and total length %d\n", data_length,
583
- data_offset, scsi_out(task->sc)->length);
581
+ data_offset, task->sc->sdb.length);
584582 return ISCSI_ERR_DATALEN;
585583 }
586584
....@@ -692,7 +690,7 @@
692690 if (tcp_conn->in.datalen) {
693691 struct iscsi_tcp_task *tcp_task = task->dd_data;
694692 struct ahash_request *rx_hash = NULL;
695
- struct scsi_data_buffer *sdb = scsi_in(task->sc);
693
+ struct scsi_data_buffer *sdb = &task->sc->sdb;
696694
697695 /*
698696 * Setup copy of Data-In into the struct scsi_cmnd
....@@ -774,7 +772,7 @@
774772 iscsi_tcp_data_recv_prep(tcp_conn);
775773 return 0;
776774 }
777
- /* fall through */
775
+ fallthrough;
778776 case ISCSI_OP_LOGOUT_RSP:
779777 case ISCSI_OP_NOOP_IN:
780778 case ISCSI_OP_SCSI_TMFUNC_RSP: