Patch: It is not necessary to try to increase the priority of the wq thread from userspace

2016-03-30 Thread Richard Sharpe
Hi folks,

We recently found that iscsid was iterating through /proc//stat
looking for the workqueue iscsi-q-NN and then setting its nice value
to -20.

Then we investigated some more because it seemed like this could be
more easily done from the kernel.

What we discovered is that with modern Linux kernels, at least since
3.10.0 and possibly earlier, the thread called  is not the
actual workqueue thread, it is the rescue thread for the workqueue,
and it already runs at -20!

Indeed, the work items are handled on a pool of threads.

This patch removes that call and code as it is redundant and actually
causes things to take longer and is a problem when you are trying to
start hundreds of iSCSI sessions.

There is another patch for the LLD to use a WQ_HIGHPRI queue to
achieve the original intent.

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at https://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.
From 86d76f1e6c52b8f3af26ec82667c626a63415a96 Mon Sep 17 00:00:00 2001
From: Richard Sharpe 
Date: Wed, 30 Mar 2016 18:49:48 -0700
Subject: [PATCH] It is not necessary to change the priority of the processes
 called [iscsi-q-NN] for a couple of reasons:

1. That process/thread already has a nice value of -20
2. It is the rescue thread associated with the workqueue created
   for the iSCSI session, not the actual workqueue.

There is a separate patch to the iSCSI LLD that will make the
intended priority change.

Signed-off-by: Richard Sharpe 
---
 usr/initiator.c | 84 -
 1 file changed, 84 deletions(-)

diff --git a/usr/initiator.c b/usr/initiator.c
index 8cd1896..3d380a2 100644
--- a/usr/initiator.c
+++ b/usr/initiator.c
@@ -1352,89 +1352,6 @@ static void session_conn_recv_pdu(void *data)
 	}
 }
 
-static void session_increase_wq_priority(struct iscsi_session *session)
-{
-	DIR *proc_dir;
-	struct dirent *proc_dent;
-	struct stat statb;
-	char stat_file[PATH_SIZE];
-	char sbuf[1024];	/* got this from ps */
-	int pid, stat_fd, num_read;
-	char *proc_name, *proc_name_end;
-	uint32_t host_no;
-
-	/* drivers like bnx2i and qla4xxx do not have a write wq */
-	if (session->t->caps & CAP_DATA_PATH_OFFLOAD)
-		return;
-
-	proc_dir = opendir(PROC_DIR);
-	if (!proc_dir)
-		goto fail;
-
-	while ((proc_dent = readdir(proc_dir))) {
-		if (!strcmp(proc_dent->d_name, ".") ||
-		!strcmp(proc_dent->d_name, ".."))
-			continue;
-		if (sscanf(proc_dent->d_name, "%d", &pid) != 1)
-			continue;
-
-		memset(stat_file, 0, sizeof(stat_file));
-		sprintf(stat_file, PROC_DIR"/%d/stat", pid);
-		if (stat(stat_file, &statb))
-			continue;
-
-		if (!S_ISREG( statb.st_mode))
-			continue;
-
-		stat_fd = open(stat_file, O_RDONLY);
-		if (stat_fd == -1)
-			continue;
-
-		memset(sbuf, 0, sizeof(sbuf));
-		num_read = read(stat_fd, sbuf, sizeof(sbuf));
-		close(stat_fd);
-		if (num_read == -1)
-			continue;
-		if (num_read == sizeof(sbuf))
-			sbuf[num_read - 1] = '\0';
-		else
-			sbuf[num_read] = '\0';
-
-		/*
-		 * Finally match proc name to iscsi thread name.
-		 * In newer kernels the name is iscsi_wq_%HOST_NO.
-		 * In older kernels before 2.6.30, it was scsi_wq_%HOST_NO.
-		 *
-		 * We only support newer kernels.
-		 */
-		proc_name = strchr(sbuf, '(') + 1;
-		if (!proc_name)
-			continue;
-
-		proc_name_end = strchr(proc_name, ')');
-		if (!proc_name_end)
-			continue;
-
-		*proc_name_end = '\0';
-
-		if (sscanf(proc_name, "iscsi_q_%u\n", &host_no) == 1) {
-			if (host_no == session->hostno) {
-if (!setpriority(PRIO_PROCESS, pid,
-	session->nrec.session.xmit_thread_priority)) {
-	closedir(proc_dir);
-	return;
-} else
-	break;
-			}
-		}
-	}
-	closedir(proc_dir);
-fail:
-	log_error("Could not set session%d priority. "
-		  "READ/WRITE throughout and latency could be "
-		  "affected.", session->id);
-}
-
 static int session_ipc_create(struct iscsi_session *session)
 {
 	struct iscsi_conn *conn = &session->conn[0];
@@ -1463,7 +1380,6 @@ retry_create:
 
 	if (!err) {
 		session->hostno = host_no;
-		session_increase_wq_priority(session);
 	}
 	return err;
 }
-- 
2.4.3



Corruption of config files causing

2015-11-16 Thread Richard Sharpe
What seems to be happening is that the config files are getting
corrupted in interesting ways such that they have more than 2048 chars
in a line without an NL.

Eg:

---
/var/lib/iscsi/nodes/iqn.2010-06.com.nutanix:volumegroup-
d86fb4c6-0a26-4a99-a4c4-38966b1955c8/10.5.20.138,3260,
1^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
@^@^@^@^@^@^@^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@^@^@^@^@^@^@^@^@^@^@^@^
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@#
BEGIN RECORD 6.2.0-873.13.el6
node.name = iqn.2010-06.com.nutanix:volumegroup-5bd06b21-fb06-
4b8e-b973-e81b86409e39
--

There are other cases. Some where both of the first two lines are two
long or where the second line is missing.

This then causes errors like this:

iscsiadm: Could not stat /var/lib/iscsi/nodes//,3260,-1
/default to delete node err 2\n\niscsiadm: Could not add/update 
[tcp:[hw=,ip=,net_if=,iscsi_if=default] 10.35.65.25,3260,1 scale_sd2]


I hear that there might be a patch to fix this problem.


Can anyone point me at it?

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
T