Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] iscsi_tcp: support PF_MEMALLOC/__GFP_MEMALLOC

This patch has software iscsi use PF_MEMALLOC/__GFP_MEMALLOC
to be able to better support swap over iscsi disks similar to
what was added for nbd.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>

authored by

Mike Christie and committed by
James Bottomley
9e45dd73 1fc2b00f

+13 -5
+13 -5
drivers/scsi/iscsi_tcp.c
··· 370 370 static int iscsi_sw_tcp_pdu_xmit(struct iscsi_task *task) 371 371 { 372 372 struct iscsi_conn *conn = task->conn; 373 - int rc; 373 + unsigned long pflags = current->flags; 374 + int rc = 0; 375 + 376 + current->flags |= PF_MEMALLOC; 374 377 375 378 while (iscsi_sw_tcp_xmit_qlen(conn)) { 376 379 rc = iscsi_sw_tcp_xmit(conn); 377 - if (rc == 0) 378 - return -EAGAIN; 380 + if (rc == 0) { 381 + rc = -EAGAIN; 382 + break; 383 + } 379 384 if (rc < 0) 380 - return rc; 385 + break; 386 + rc = 0; 381 387 } 382 388 383 - return 0; 389 + tsk_restore_flags(current, pflags, PF_MEMALLOC); 390 + return rc; 384 391 } 385 392 386 393 /* ··· 672 665 sk->sk_reuse = SK_CAN_REUSE; 673 666 sk->sk_sndtimeo = 15 * HZ; /* FIXME: make it configurable */ 674 667 sk->sk_allocation = GFP_ATOMIC; 668 + sk_set_memalloc(sk); 675 669 676 670 iscsi_sw_tcp_conn_set_callbacks(conn); 677 671 tcp_sw_conn->sendpage = tcp_sw_conn->sock->ops->sendpage;