Skip to content

Commit d2fe210

Browse files
dhowellskuba-moo
authored andcommitted
scsi: target: iscsi: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage
Use sendmsg() with MSG_SPLICE_PAGES rather than sendpage. This allows multiple pages and multipage folios to be passed through. TODO: iscsit_fe_sendpage_sg() should perhaps set up a bio_vec array for the entire set of pages it's going to transfer plus two for the header and trailer and page fragments to hold the header and trailer - and then call sendmsg once for the entire message. Signed-off-by: David Howells <dhowells@redhat.com> cc: Mike Christie <michael.christie@oracle.com> cc: Maurizio Lombardi <mlombard@redhat.com> cc: "James E.J. Bottomley" <jejb@linux.ibm.com> cc: "Martin K. Petersen" <martin.petersen@oracle.com> cc: Jens Axboe <axboe@kernel.dk> cc: Matthew Wilcox <willy@infradead.org> cc: Al Viro <viro@zeniv.linux.org.uk> cc: open-iscsi@googlegroups.com Link: https://lore.kernel.org/r/20230623225513.2732256-13-dhowells@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent fa8df34 commit d2fe210

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

drivers/target/iscsi/iscsi_target_util.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,8 @@ int iscsit_fe_sendpage_sg(
11291129
struct iscsit_conn *conn)
11301130
{
11311131
struct scatterlist *sg = cmd->first_data_sg;
1132+
struct bio_vec bvec;
1133+
struct msghdr msghdr = { .msg_flags = MSG_SPLICE_PAGES, };
11321134
struct kvec iov;
11331135
u32 tx_hdr_size, data_len;
11341136
u32 offset = cmd->first_data_sg_off;
@@ -1172,17 +1174,18 @@ int iscsit_fe_sendpage_sg(
11721174
u32 space = (sg->length - offset);
11731175
u32 sub_len = min_t(u32, data_len, space);
11741176
send_pg:
1175-
tx_sent = conn->sock->ops->sendpage(conn->sock,
1176-
sg_page(sg), sg->offset + offset, sub_len, 0);
1177+
bvec_set_page(&bvec, sg_page(sg), sub_len, sg->offset + offset);
1178+
iov_iter_bvec(&msghdr.msg_iter, ITER_SOURCE, &bvec, 1, sub_len);
1179+
1180+
tx_sent = conn->sock->ops->sendmsg(conn->sock, &msghdr,
1181+
sub_len);
11771182
if (tx_sent != sub_len) {
11781183
if (tx_sent == -EAGAIN) {
1179-
pr_err("tcp_sendpage() returned"
1180-
" -EAGAIN\n");
1184+
pr_err("sendmsg/splice returned -EAGAIN\n");
11811185
goto send_pg;
11821186
}
11831187

1184-
pr_err("tcp_sendpage() failure: %d\n",
1185-
tx_sent);
1188+
pr_err("sendmsg/splice failure: %d\n", tx_sent);
11861189
return -1;
11871190
}
11881191

0 commit comments

Comments
 (0)