Description: port to mainline v3.19 kernels
 Port to mainline v3.19 kernels
Author: Andy Whitcroft <apw@ubuntu.com>
Last-Update: 2015-02-26

Index: iscsitarget-1.4.20.3+svn502/kernel/iscsi.c
===================================================================
--- iscsitarget-1.4.20.3+svn502.orig/kernel/iscsi.c	2015-02-23 10:55:39.589332622 +0100
+++ iscsitarget-1.4.20.3+svn502/kernel/iscsi.c	2015-02-23 10:55:39.581332582 +0100
@@ -489,8 +489,7 @@ static void cmnd_skip_pdu(struct iscsi_c
 	}
 	conn->read_iov[i].iov_base = addr;
 	conn->read_iov[i].iov_len = size;
-	conn->read_msg.msg_iov = conn->read_iov;
-	conn->read_msg.msg_iovlen = ++i;
+	iov_iter_init(&conn->read_msg.msg_iter, READ, conn->read_iov, ++i, conn->read_size);
 }
 
 static void iscsi_cmnd_reject(struct iscsi_cmnd *req, int reason)
@@ -718,7 +717,6 @@ static int cmnd_recv_pdu(struct iscsi_co
 	idx = offset >> PAGE_CACHE_SHIFT;
 	offset &= ~PAGE_CACHE_MASK;
 
-	conn->read_msg.msg_iov = conn->read_iov;
 	conn->read_size = size = (size + 3) & -4;
 	conn->read_overflow = 0;
 
@@ -730,16 +728,16 @@ static int cmnd_recv_pdu(struct iscsi_co
 		conn->read_iov[i].iov_base =  addr + offset;
 		if (offset + size <= PAGE_CACHE_SIZE) {
 			conn->read_iov[i].iov_len = size;
-			conn->read_msg.msg_iovlen = ++i;
+			iov_iter_init(&conn->read_msg.msg_iter, READ, conn->read_iov, ++i, conn->read_size);
 			break;
 		}
 		conn->read_iov[i].iov_len = PAGE_CACHE_SIZE - offset;
 		size -= conn->read_iov[i].iov_len;
 		offset = 0;
 		if (++i >= ISCSI_CONN_IOV_MAX) {
-			conn->read_msg.msg_iovlen = i;
 			conn->read_overflow = size;
 			conn->read_size -= size;
+			iov_iter_init(&conn->read_msg.msg_iter, READ, conn->read_iov, i, conn->read_size);
 			break;
 		}
 
@@ -918,7 +916,6 @@ static int nop_out_start(struct iscsi_co
 
 	if ((size = cmnd->pdu.datasize)) {
 		size = (size + 3) & -4;
-		conn->read_msg.msg_iov = conn->read_iov;
 		if (cmnd->pdu.bhs.itt != cpu_to_be32(ISCSI_RESERVED_TAG)) {
 			struct tio *tio;
 			int pg_cnt = get_pgcnt(size);
@@ -946,7 +943,7 @@ static int nop_out_start(struct iscsi_co
 		}
 		assert(!size);
 		conn->read_overflow = size;
-		conn->read_msg.msg_iovlen = i;
+		iov_iter_init(&conn->read_msg.msg_iter, READ, conn->read_iov, i, conn->read_size);
 	}
 
 out:
@@ -986,7 +983,7 @@ static void scsi_cmnd_start(struct iscsi
 		set_cmnd_lunit(req);
 
 	switch (req_hdr->scb[0]) {
-	case SERVICE_ACTION_IN:
+	case SERVICE_ACTION_IN_16:
 		if ((req_hdr->scb[1] & 0x1f) != 0x10)
 			goto error;
 	case INQUIRY:
Index: iscsitarget-1.4.20.3+svn502/kernel/nthread.c
===================================================================
--- iscsitarget-1.4.20.3+svn502.orig/kernel/nthread.c	2015-02-23 10:55:39.589332622 +0100
+++ iscsitarget-1.4.20.3+svn502/kernel/nthread.c	2015-02-24 11:06:42.057236808 +0100
@@ -42,9 +42,8 @@ static inline void iscsi_conn_init_read(
 	len = (len + 3) & -4; // XXX ???
 	conn->read_iov[0].iov_base = data;
 	conn->read_iov[0].iov_len = len;
-	conn->read_msg.msg_iov = conn->read_iov;
-	conn->read_msg.msg_iovlen = 1;
 	conn->read_size = (len + 3) & -4;
+	iov_iter_init(&conn->read_msg.msg_iter, READ, conn->read_iov, 1, conn->read_size);
 }
 
 static void iscsi_conn_read_ahs(struct iscsi_conn *conn, struct iscsi_cmnd *cmnd)
@@ -83,14 +82,18 @@ static int is_data_available(struct iscs
 
 static void forward_iov(struct msghdr *msg, int len)
 {
-	while (msg->msg_iov->iov_len <= len) {
-		len -= msg->msg_iov->iov_len;
-		msg->msg_iov++;
-		msg->msg_iovlen--;
+	struct iovec *iov;
+
+	while (msg->msg_iter.iov->iov_len <= len) {
+		len -= msg->msg_iter.iov->iov_len;
+		msg->msg_iter.iov++;
+		msg->msg_iter.nr_segs--;
 	}
 
-	msg->msg_iov->iov_base = (char *) msg->msg_iov->iov_base + len;
-	msg->msg_iov->iov_len -= len;
+	/* XXX: discards const ... */
+	iov = msg->msg_iter.iov;
+	iov->iov_base = (char *) msg->msg_iter.iov->iov_base + len;
+	iov->iov_len -= len;
 }
 
 static int do_recv(struct iscsi_conn *conn, int state)
@@ -98,6 +101,7 @@ static int do_recv(struct iscsi_conn *co
 	mm_segment_t oldfs;
 	struct msghdr msg;
 	struct iovec iov[ISCSI_CONN_IOV_MAX];
+	size_t iovlen = ISCSI_CONN_IOV_MAX;
 	int i, len, res;
 
 	if (!test_bit(CONN_ACTIVE, &conn->state)) {
@@ -110,12 +114,15 @@ static int do_recv(struct iscsi_conn *co
 		goto out;
 	}
 
-	msg.msg_iov = iov;
-	msg.msg_iovlen = min_t(size_t, conn->read_msg.msg_iovlen, ISCSI_CONN_IOV_MAX);
-	for (i = 0, len = 0; i < msg.msg_iovlen; i++) {
-		iov[i] = conn->read_msg.msg_iov[i];
+	if (conn->read_msg.msg_iter.nr_segs < iovlen)
+		iovlen = conn->read_msg.msg_iter.nr_segs;
+
+	for (i = 0, len = 0; i < iovlen; i++) {
+		iov[i] = conn->read_msg.msg_iter.iov[i];
 		len += iov[i].iov_len;
 	}
+	iov_iter_init(&msg.msg_iter, READ, iov, iovlen, len);
+
 
 	oldfs = get_fs();
 	set_fs(get_ds());
Index: iscsitarget-1.4.20.3+svn502/kernel/conn.c
===================================================================
--- iscsitarget-1.4.20.3+svn502.orig/kernel/conn.c	2015-02-23 10:55:39.589332622 +0100
+++ iscsitarget-1.4.20.3+svn502/kernel/conn.c	2015-02-23 10:55:39.581332582 +0100
@@ -127,7 +127,7 @@ static void iet_socket_bind(struct iscsi
 
 	dprintk(D_GENERIC, "%llu\n", (unsigned long long) session->sid);
 
-	conn->sock = SOCKET_I(conn->file->f_dentry->d_inode);
+	conn->sock = SOCKET_I(file_inode(conn->file));
 	conn->sock->sk->sk_user_data = conn;
 
 	write_lock_bh(&conn->sock->sk->sk_callback_lock);
Index: iscsitarget-1.4.20.3+svn502/kernel/volume.c
===================================================================
--- iscsitarget-1.4.20.3+svn502.orig/kernel/volume.c	2015-02-23 10:55:39.589332622 +0100
+++ iscsitarget-1.4.20.3+svn502/kernel/volume.c	2015-02-23 10:55:39.585332602 +0100
@@ -398,7 +398,7 @@ int is_volume_reserved(struct iet_volume
 		case READ_CAPACITY:
 			/* allowed commands when reserved */
 			break;
-		case SERVICE_ACTION_IN:
+		case SERVICE_ACTION_IN_16:
 			if ((scb[1] & 0x1F) == 0x10)
 				break;
 			/* fall through */
@@ -465,7 +465,7 @@ int is_volume_reserved(struct iet_volume
 		if (excl_access_ro && !registered)
 			err = -EBUSY;
 		break;
-	case SERVICE_ACTION_IN:
+	case SERVICE_ACTION_IN_16:
 		if ((scb[1] & 0x1F) == 0x10)
 			break;
 		/* fall through */
Index: iscsitarget-1.4.20.3+svn502/kernel/file-io.c
===================================================================
--- iscsitarget-1.4.20.3+svn502.orig/kernel/file-io.c	2015-02-23 10:55:39.589332622 +0100
+++ iscsitarget-1.4.20.3+svn502/kernel/file-io.c	2015-02-23 10:55:39.585332602 +0100
@@ -69,7 +69,7 @@ static int fileio_make_request(struct ie
 static int fileio_sync(struct iet_volume *lu, struct tio *tio)
 {
 	struct fileio_data *p = lu->private;
-	struct inode *inode = p->filp->f_dentry->d_inode;
+	struct inode *inode = file_inode(p->filp);
 	struct address_space *mapping = inode->i_mapping;
 	loff_t ppos, count;
 	int res;
@@ -213,7 +213,7 @@ static int fileio_attach(struct iet_volu
 		eprintk("%d\n", err);
 		goto out;
 	}
-	inode = p->filp->f_dentry->d_inode;
+	inode = file_inode(p->filp);
 
 	if (S_ISREG(inode->i_mode))
 		;
Index: iscsitarget-1.4.20.3+svn502/kernel/target_disk.c
===================================================================
--- iscsitarget-1.4.20.3+svn502.orig/kernel/target_disk.c	2015-02-23 10:55:39.589332622 +0100
+++ iscsitarget-1.4.20.3+svn502/kernel/target_disk.c	2015-02-23 10:55:39.585332602 +0100
@@ -606,7 +606,7 @@ static int disk_execute_cmnd(struct iscs
 	case REQUEST_SENSE:
 		send_data_rsp(cmnd, build_request_sense_response);
 		break;
-	case SERVICE_ACTION_IN:
+	case SERVICE_ACTION_IN_16:
 		send_data_rsp(cmnd, build_service_action_in_response);
 		break;
 	case READ_6:
