All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] iscsid / systemd / dracut integration effort
@ 2012-12-10 22:08 Chris Leech
       [not found] ` <1355177316-25803-1-git-send-email-cleech-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 16+ messages in thread
From: Chris Leech @ 2012-12-10 22:08 UTC (permalink / raw)
  To: open-iscsi-/JYPxA39Uh5TLH3MbocFFw,
	systemd-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	initramfs-u79uwXL29TY76Z2rM5mHXA
  Cc: agrover-H+wXaHxf7aLQT0dZR+AlfA, Chris Leech

Sorry about the cross-posting, but I think that in order to get this right I'm
going to need as much feedback as I can get.

I think I've got this working pretty well now (at least for my iBFT configured
iSCSI root test case), although the dracut module still needs work.  This is
based on the iscsid socket activation patch from Tomasz Torcz and the unit
files from Tomasz and Jóhann B. Guðmundsson.

Attempting to start iscsid using systemd unit files (socket activated or not)
was impacting my iscsi-root test setup.  Rather than try to preserve the old
logic that used the _netdev mount flag to determine when iscsid could be safely
shutdown, I've been working on following the guidelines for root storage
daemons http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons.

1) I patched iscsid to set argv[0][0] = '@' if a new --initrd flag is passed on
   the command line.  It's simple, it works, we don't kill iscsid before the
   root filesystem is unmounted.

2) When starting iscsid from the initrd, I then ran into issues of iscsid not
   functioning properly after the switch_root.  It's not mentioned in the
   RootStorageDaemons documentation, but if a process left running from the
   initrd needs further filesystem access at runtime it will need to be able to
   chroot itself before the switch_root.  I patched iscsid and iscsiadm with a
   newroot command (using plymouth as an example), and used a dracut clenaup
   hook to call "iscsiadm --newroot /sysroot".

3) Related to #2, launching iscsid as a Type=simple service from the initrd
   (I'm testing this with Fedora 18 beta, where dracut uses systemd in the
   initrd) results in STDOUT/STDERR access after the switch_root failing with
   EPIPE.  It seems that the connection to the journal process is dead once the
   initrd instantiated systemd-journald is replaced with the runtime process.

   I can at least keep iscsid functioning if I run it as Type=forking, but I'm
   not sure if I'm losing runtime logging or not.  I may be able to do
   something with the StandardOutput and StandardError options in the service
   file.

4) None of this helps if the sessions are shutdown when we still need them.
   Rather than the all-or-nothing _netdev mount option checks that have been
   used in the past, I'm attempting to use the fact that iscsiadm will skip
   over session that match a node with startup=onboot set when doing a
   logoutall.  The iscsi_mark_root_nodes script is borrowed from the SUSE init
   scripts in the open-iscsi repos written by Hannes Reinecke.  I've made minor
   changes to export the list of sessions activated in the initramfs, and then
   mark those as onboot when starting iscsi.service.

Things that still need looking into.

1) Command line configured iSCSI parameters.  If iscsistart is to be fully
   removed something needs to setup the node from the command line.  Or
   iscsistart needs to be able to run alongside iscsid.

2) Proper ordering of the iscsi.service for non-root filesystems.

Any and all feedback and/or help welcome.

- Chris

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [RFC] iscsid: add --initrd option to set run from initrd hint for systemd
       [not found] ` <1355177316-25803-1-git-send-email-cleech-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2012-12-10 22:08   ` Chris Leech
  2012-12-10 22:08   ` [RFC] iscsiadm, iscsid: newroot command to survive switch_root Chris Leech
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: Chris Leech @ 2012-12-10 22:08 UTC (permalink / raw)
  To: open-iscsi-/JYPxA39Uh5TLH3MbocFFw,
	systemd-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	initramfs-u79uwXL29TY76Z2rM5mHXA
  Cc: agrover-H+wXaHxf7aLQT0dZR+AlfA, Chris Leech

See http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons
---
 usr/iscsid.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/usr/iscsid.c b/usr/iscsid.c
index b4bb65b..7d71085 100644
--- a/usr/iscsid.c
+++ b/usr/iscsid.c
@@ -61,6 +61,7 @@ static pid_t log_pid;
 static gid_t gid;
 static int daemonize = 1;
 static int mgmt_ipc_fd;
+static int initrd = 0;
 
 static struct option const long_options[] = {
 	{"config", required_argument, NULL, 'c'},
@@ -73,6 +74,7 @@ static struct option const long_options[] = {
 	{"pid", required_argument, NULL, 'p'},
 	{"help", no_argument, NULL, 'h'},
 	{"version", no_argument, NULL, 'v'},
+	{"initrd", no_argument, &initrd, 1},
 	{NULL, 0, NULL, 0},
 };
 
@@ -95,6 +97,7 @@ Open-iSCSI initiator daemon.\n\
   -p, --pid=pidfile       use pid file (default " PID_FILE ").\n\
   -h, --help              display this help and exit\n\
   -v, --version           display version and exit\n\
+  --initrd                run from initrd\n\
 ");
 	}
 	exit(status);
@@ -383,12 +386,17 @@ int main(int argc, char *argv[])
 		case 'h':
 			usage(0);
 			break;
+		case 0:
+			break;
 		default:
 			usage(1);
 			break;
 		}
 	}
 
+	if (initrd)
+		argv[0][0] = '@';
+
 	/* initialize logger */
 	log_pid = log_init(program_name, DEFAULT_AREA_SIZE,
 		      daemonize ? log_do_log_daemon : log_do_log_std, NULL);
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC] iscsiadm, iscsid: newroot command to survive switch_root
       [not found] ` <1355177316-25803-1-git-send-email-cleech-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2012-12-10 22:08   ` [RFC] iscsid: add --initrd option to set run from initrd hint for systemd Chris Leech
@ 2012-12-10 22:08   ` Chris Leech
  2012-12-10 22:08   ` [RFC] iscsi unit files and helper script Chris Leech
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: Chris Leech @ 2012-12-10 22:08 UTC (permalink / raw)
  To: open-iscsi-/JYPxA39Uh5TLH3MbocFFw,
	systemd-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	initramfs-u79uwXL29TY76Z2rM5mHXA
  Cc: agrover-H+wXaHxf7aLQT0dZR+AlfA, Chris Leech

When started from initramfs, iscsid needs to be able to chroot itself
to the runtime filesystem before the switch_root occurs.  In the
initramfs "iscsiadm --newroot {root fs mount before switch}" should be
called before the switch_root.
---
 usr/iscsiadm.c | 30 +++++++++++++++++++++++++++++-
 usr/mgmt_ipc.c | 11 +++++++++++
 usr/mgmt_ipc.h |  6 +++++-
 3 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 8f9de05..7b601b3 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -111,9 +111,10 @@ static struct option const long_options[] =
 	{"packetsize", required_argument, NULL, 'b'},
 	{"count", required_argument, NULL, 'c'},
 	{"interval", required_argument, NULL, 'i'},
+	{"newroot", required_argument, NULL, 'N'},
 	{NULL, 0, NULL, 0},
 };
-static char *short_options = "RlDVhm:a:b:c:C:p:P:T:H:i:I:U:k:L:d:r:n:v:o:sSt:u";
+static char *short_options = "RlDVhm:a:b:c:C:p:P:T:H:i:I:U:k:L:d:r:n:v:o:sSt:uN:";
 
 static void usage(int status)
 {
@@ -251,6 +252,22 @@ static void kill_iscsid(int priority)
 	}
 }
 
+static void do_newroot(char *newroot)
+{
+	iscsiadm_req_t req;
+	iscsiadm_rsp_t rsp;
+	int rc;
+
+	memset(&req, 0, sizeof(req));
+	req.command = MGMT_IPC_NEWROOT;
+	strncpy(req.u.newroot.path, newroot, PATH_MAX);
+	rc = iscsid_exec_req(&req, &rsp, 0);
+	if (rc) {
+		iscsi_err_print_msg(rc);
+		log_error("Could not send NEWROOT command");
+	}
+}
+
 /*
  * TODO: we can display how the ifaces are related to node records.
  * And we can add a scsi_host mode which would display how
@@ -2411,6 +2428,7 @@ main(int argc, char **argv)
 	uint32_t host_no = -1;
 	struct user_param *param;
 	struct list_head params;
+	char *newroot = NULL;
 
 	INIT_LIST_HEAD(&params);
 	INIT_LIST_HEAD(&ifaces);
@@ -2433,6 +2451,9 @@ main(int argc, char **argv)
 	while ((ch = getopt_long(argc, argv, short_options,
 				 long_options, &longindex)) >= 0) {
 		switch (ch) {
+		case 'N':
+			newroot = strndup(optarg, PATH_MAX);
+			break;
 		case 'k':
 			killiscsid = atoi(optarg);
 			if (killiscsid < 0) {
@@ -2579,6 +2600,13 @@ main(int argc, char **argv)
 		goto free_ifaces;
 	}
 
+	if (newroot) {
+		do_newroot(newroot);
+		free(newroot);
+		newroot = NULL;
+		goto free_ifaces;
+	}
+
 	if (mode < 0)
 		usage(ISCSI_ERR_INVAL);
 
diff --git a/usr/mgmt_ipc.c b/usr/mgmt_ipc.c
index f34f688..b4170ce 100644
--- a/usr/mgmt_ipc.c
+++ b/usr/mgmt_ipc.c
@@ -226,6 +226,16 @@ mgmt_ipc_immediate_stop(queue_task_t *qtask)
 }
 
 static int
+mgmt_ipc_newroot(queue_task_t *qtask)
+{
+	char *newroot = qtask->req.u.newroot.path;
+	if (chdir(newroot) || chroot(".") || chdir("/"))
+		return ISCSI_ERR;
+	mgmt_ipc_write_rsp(qtask, ISCSI_SUCCESS);
+	return ISCSI_SUCCESS;
+}
+
+static int
 mgmt_ipc_conn_remove(queue_task_t *qtask)
 {
 	return ISCSI_ERR;
@@ -534,6 +544,7 @@ static mgmt_ipc_fn_t *	mgmt_ipc_functions[__MGMT_IPC_MAX_COMMAND] = {
 [MGMT_IPC_NOTIFY_DEL_NODE]	= mgmt_ipc_notify_del_node,
 [MGMT_IPC_NOTIFY_ADD_PORTAL]	= mgmt_ipc_notify_add_portal,
 [MGMT_IPC_NOTIFY_DEL_PORTAL]	= mgmt_ipc_notify_del_portal,
+[MGMT_IPC_NEWROOT]		= mgmt_ipc_newroot,
 };
 
 void mgmt_ipc_handle(int accept_fd)
diff --git a/usr/mgmt_ipc.h b/usr/mgmt_ipc.h
index 55972ed..102ffff 100644
--- a/usr/mgmt_ipc.h
+++ b/usr/mgmt_ipc.h
@@ -22,6 +22,7 @@
 #include "types.h"
 #include "iscsi_if.h"
 #include "config.h"
+#include "limits.h"
 
 #define ISCSIADM_NAMESPACE	"ISCSIADM_ABSTRACT_NAMESPACE"
 #define PEERUSER_MAX		64
@@ -46,6 +47,7 @@ typedef enum iscsiadm_cmd {
 	MGMT_IPC_NOTIFY_DEL_NODE	= 17,
 	MGMT_IPC_NOTIFY_ADD_PORTAL	= 18,
 	MGMT_IPC_NOTIFY_DEL_PORTAL	= 19,
+	MGMT_IPC_NEWROOT		= 20,
 
 	__MGMT_IPC_MAX_COMMAND
 } iscsiadm_cmd_e;
@@ -75,8 +77,10 @@ typedef struct iscsiadm_req {
 			int param;
 			/* TODO: make this variable len to support */
 			char value[IFNAMSIZ + 1];
-
 		} set_host_param;
+		struct ipc_msg_newroot {
+			char path[PATH_MAX + 1];
+		} newroot;
 	} u;
 } iscsiadm_req_t;
 
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC] iscsi unit files and helper script
       [not found] ` <1355177316-25803-1-git-send-email-cleech-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2012-12-10 22:08   ` [RFC] iscsid: add --initrd option to set run from initrd hint for systemd Chris Leech
  2012-12-10 22:08   ` [RFC] iscsiadm, iscsid: newroot command to survive switch_root Chris Leech
@ 2012-12-10 22:08   ` Chris Leech
       [not found]     ` <1355177316-25803-4-git-send-email-cleech-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2012-12-10 22:08   ` [RFC] dracut iscsi module: early attempt to launch iscsid from the initramfs Chris Leech
                     ` (2 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Chris Leech @ 2012-12-10 22:08 UTC (permalink / raw)
  To: open-iscsi-/JYPxA39Uh5TLH3MbocFFw,
	systemd-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	initramfs-u79uwXL29TY76Z2rM5mHXA
  Cc: agrover-H+wXaHxf7aLQT0dZR+AlfA, Chris Leech

iSCSI service and socket files, and the iscsi_mark_root_nodes helper script to
preserve sessions started in the initramfs.

diff -Naur a/iscsid.service b/iscsid.service
--- a/iscsid.service	1969-12-31 16:00:00.000000000 -0800
+++ b/iscsid.service	2012-12-10 13:38:38.643307001 -0800
@@ -0,0 +1,9 @@
+[Unit]
+Description=Open-iSCSI
+Documentation=man:iscsid(8) man:iscsiadm(8)
+After=network.target NetworkManager-wait-online.service iscsiuio.service tgtd.service targetcli.service
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/iscsid -f -n
+ExecStop=/sbin/iscsiadm -k 0 2
diff -Naur a/iscsid.socket b/iscsid.socket
--- a/iscsid.socket	1969-12-31 16:00:00.000000000 -0800
+++ b/iscsid.socket	2012-12-10 13:38:38.643307001 -0800
@@ -0,0 +1,9 @@
+[Unit]
+Description=Open-iSCSI iscsid Socket
+Documentation=man:iscsid(8) man:iscsiadm(8)
+
+[Socket]
+ListenStream=@ISCSIADM_ABSTRACT_NAMESPACE
+
+[Install]
+WantedBy=sockets.target
diff -Naur a/iscsi.service b/iscsi.service
--- a/iscsi.service	1969-12-31 16:00:00.000000000 -0800
+++ b/iscsi.service	2012-12-10 13:38:38.643307001 -0800
@@ -0,0 +1,18 @@
+[Unit]
+Description=Login and scanning of iSCSI devices
+Documentation=man:iscsiadm(8) man:iscsid(8)
+#Requires=iscsid.service
+#BindTo=iscsid.service
+After=network.target NetworkManager-wait-online.service iscsid.service
+ConditionPathExists=/etc/iscsi/initiatorname.iscsi
+
+[Service]
+Type=oneshot
+ExecStart=/usr/libexec/iscsi_mark_root_nodes
+ExecStart=/sbin/iscsiadm -m node --loginall=automatic
+ExecStop=/bin/sync
+ExecStop=/sbin/iscsiadm -m node --logoutall=automatic
+RemainAfterExit=true
+
+[Install]
+WantedBy=remote-fs.target
diff -Naur a/iscsiuio.service b/iscsiuio.service
--- a/iscsiuio.service	1969-12-31 16:00:00.000000000 -0800
+++ b/iscsiuio.service	2012-12-10 13:38:38.643307001 -0800
@@ -0,0 +1,11 @@
+[Unit]
+Description=iSCSI UserSpace I/O driver
+Documentation=man:iscsiuio(8)
+Requires=iscsid.service
+BindTo=iscsid.service
+Before=iscsid.service
+After=network.target NetworkManager-wait-online.service
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/iscsiuio -f
diff -Naur a/iscsiuio.socket b/iscsiuio.socket
--- a/iscsiuio.socket	1969-12-31 16:00:00.000000000 -0800
+++ b/iscsiuio.socket	2012-12-10 13:38:38.643307001 -0800
@@ -0,0 +1,9 @@
+[Unit]
+Description=Open-iSCSI iscsiuio
+Documentation=man:iscsiuio(8)
+
+[Socket]
+ListenStream=@ISCSID_UIP_ABSTRACT_NAMESPACE
+
+[Install]
+WantedBy=sockets.target
diff -Naur a/usr/libexec/iscsi_mark_root_nodes b/usr/libexec/iscsi_mark_root_nodes
--- a/usr/libexec/iscsi_mark_root_nodes	1969-12-31 16:00:00.000000000 -0800
+++ b/usr/libexec/iscsi_mark_root_nodes	2012-12-10 13:38:47.322082141 -0800
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+ISCSIADM=/sbin/iscsiadm
+SESSION_FILE=/run/initramfs/iscsi.sessions
+
+if [ ! -f $SESSION_FILE ] ; then
+  exit 0
+fi
+
+while read t num i target; do
+  ip=${i%:*}
+  $ISCSIADM -m node -p $ip -T $target -o update -n node.startup -v onboot
+done < $SESSION_FILE
+

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [RFC] dracut iscsi module: early attempt to launch iscsid from the initramfs
       [not found] ` <1355177316-25803-1-git-send-email-cleech-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
                     ` (2 preceding siblings ...)
  2012-12-10 22:08   ` [RFC] iscsi unit files and helper script Chris Leech
@ 2012-12-10 22:08   ` Chris Leech
  2012-12-10 23:56   ` [systemd-devel] [RFC] iscsid / systemd / dracut integration effort "Jóhann B. Guðmundsson"
  2012-12-14 19:01   ` Mike Christie
  5 siblings, 0 replies; 16+ messages in thread
From: Chris Leech @ 2012-12-10 22:08 UTC (permalink / raw)
  To: open-iscsi-/JYPxA39Uh5TLH3MbocFFw,
	systemd-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	initramfs-u79uwXL29TY76Z2rM5mHXA
  Cc: agrover-H+wXaHxf7aLQT0dZR+AlfA, Chris Leech

Not complete, but working well for iBFT configured iSCSI boot for me.
---
 modules.d/95iscsi/cleanup-iscsi.sh        |  3 ++-
 modules.d/95iscsi/iscsid-initrd.service   | 10 ++++++++++
 modules.d/95iscsi/iscsid-initrd.socket    |  9 +++++++++
 modules.d/95iscsi/iscsiroot.sh            | 26 ++++++++++++++------------
 modules.d/95iscsi/iscsiuio-initrd.service | 11 +++++++++++
 modules.d/95iscsi/iscsiuio-initrd.socket  |  9 +++++++++
 modules.d/95iscsi/module-setup.sh         | 14 ++++++++++++--
 7 files changed, 67 insertions(+), 15 deletions(-)
 create mode 100644 modules.d/95iscsi/iscsid-initrd.service
 create mode 100644 modules.d/95iscsi/iscsid-initrd.socket
 create mode 100644 modules.d/95iscsi/iscsiuio-initrd.service
 create mode 100644 modules.d/95iscsi/iscsiuio-initrd.socket

diff --git a/modules.d/95iscsi/cleanup-iscsi.sh b/modules.d/95iscsi/cleanup-iscsi.sh
index a2d5951..0dc0ceb 100755
--- a/modules.d/95iscsi/cleanup-iscsi.sh
+++ b/modules.d/95iscsi/cleanup-iscsi.sh
@@ -2,5 +2,6 @@
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
-[ -e /sys/module/bnx2i ] && killproc iscsiuio
+NEWROOT=/sysroot
+iscsiadm --newroot $NEWROOT
 
diff --git a/modules.d/95iscsi/iscsid-initrd.service b/modules.d/95iscsi/iscsid-initrd.service
new file mode 100644
index 0000000..16dc4c4
--- /dev/null
+++ b/modules.d/95iscsi/iscsid-initrd.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Open-iSCSI
+Documentation=man:iscsid(8) man:iscsiadm(8)
+After=network.target NetworkManager-wait-online.service
+
+[Service]
+Type=forking
+ExecStart=/usr/sbin/iscsid --initrd
+PIDFile=/var/run/iscsid.pid
+KillMode=none
diff --git a/modules.d/95iscsi/iscsid-initrd.socket b/modules.d/95iscsi/iscsid-initrd.socket
new file mode 100644
index 0000000..58a8d12
--- /dev/null
+++ b/modules.d/95iscsi/iscsid-initrd.socket
@@ -0,0 +1,9 @@
+[Unit]
+Description=Open-iSCSI iscsid Socket
+Documentation=man:iscsid(8) man:iscsiadm(8)
+
+[Socket]
+ListenStream=@ISCSIADM_ABSTRACT_NAMESPACE
+
+[Install]
+WantedBy=sockets.target
diff --git a/modules.d/95iscsi/iscsiroot.sh b/modules.d/95iscsi/iscsiroot.sh
index 1a8cc8d..c2766a1 100755
--- a/modules.d/95iscsi/iscsiroot.sh
+++ b/modules.d/95iscsi/iscsiroot.sh
@@ -49,7 +49,9 @@ if getargbool 0 rd.iscsi.firmware -d -y iscsi_firmware ; then
 	iscsi_param="$iscsi_param --param $p"
     done
 
-    iscsistart -b $iscsi_param
+    # iscsistart -b $iscsi_param
+    iscsiadm -m fw -l
+    iscsiadm -m session > /run/initramfs/iscsi.sessions
     exit 0
 fi
 
@@ -146,17 +148,17 @@ handle_netroot()
     # force udevsettle to break
     > $hookdir/initqueue/work
 
-    iscsistart -i $iscsi_initiator -t $iscsi_target_name        \
-        -g $iscsi_target_group -a $iscsi_target_ip      \
-        -p $iscsi_target_port \
-        ${iscsi_username+-u $iscsi_username} \
-        ${iscsi_password+-w $iscsi_password} \
-        ${iscsi_in_username+-U $iscsi_in_username} \
-        ${iscsi_in_password+-W $iscsi_in_password} \
-	${iscsi_iface_name+--param iface.iscsi_ifacename=$iscsi_iface_name} \
-	${iscsi_netdev_name+--param iface.net_ifacename=$iscsi_netdev_name} \
-        ${iscsi_param} \
-	|| :
+#    iscsistart -i $iscsi_initiator -t $iscsi_target_name        \
+#        -g $iscsi_target_group -a $iscsi_target_ip      \
+#        -p $iscsi_target_port \
+#        ${iscsi_username+-u $iscsi_username} \
+#        ${iscsi_password+-w $iscsi_password} \
+#        ${iscsi_in_username+-U $iscsi_in_username} \
+#        ${iscsi_in_password+-W $iscsi_in_password} \
+#	${iscsi_iface_name+--param iface.iscsi_ifacename=$iscsi_iface_name} \
+#	${iscsi_netdev_name+--param iface.net_ifacename=$iscsi_netdev_name} \
+#        ${iscsi_param} \
+#	|| :
 }
 
 # loop over all netroot parameter
diff --git a/modules.d/95iscsi/iscsiuio-initrd.service b/modules.d/95iscsi/iscsiuio-initrd.service
new file mode 100644
index 0000000..54883df
--- /dev/null
+++ b/modules.d/95iscsi/iscsiuio-initrd.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=iSCSI UserSpace I/O driver
+Documentation=man:iscsiuio(8)
+Before=iscsid.service
+After=network.target NetworkManager-wait-online.service
+
+[Service]
+Type=forking
+ExecStart=/usr/sbin/iscsiuio --initrd
+PIDFile=/var/run/iscsiuio.pid
+KillMode=none
diff --git a/modules.d/95iscsi/iscsiuio-initrd.socket b/modules.d/95iscsi/iscsiuio-initrd.socket
new file mode 100644
index 0000000..9eacc56
--- /dev/null
+++ b/modules.d/95iscsi/iscsiuio-initrd.socket
@@ -0,0 +1,9 @@
+[Unit]
+Description=Open-iSCSI iscsiuio
+Documentation=man:iscsiuio(8)
+
+[Socket]
+ListenStream=@ISCSID_UIP_ABSTRACT_NAMESPACE
+
+[Install]
+WantedBy=sockets.target
diff --git a/modules.d/95iscsi/module-setup.sh b/modules.d/95iscsi/module-setup.sh
index d251a0d..7acabbe 100755
--- a/modules.d/95iscsi/module-setup.sh
+++ b/modules.d/95iscsi/module-setup.sh
@@ -5,7 +5,7 @@
 check() {
     local _rootdev
     # If our prerequisites are not met, fail anyways.
-    type -P iscsistart hostname iscsi-iname >/dev/null || return 1
+    type -P iscsid iscsiadm hostname iscsi-iname >/dev/null || return 1
 
     # If hostonly was requested, fail the check if we are not actually
     # booting from root.
@@ -73,10 +73,20 @@ installkernel() {
 }
 
 install() {
-    dracut_install umount iscsistart hostname iscsi-iname
+    dracut_install iscsid iscsiadm umount hostname iscsi-iname
     dracut_install -o iscsiuio
+    dracut_install -o /etc/iscsi/initiatorname.iscsi
+    dracut_install -o /etc/iscsi/iscsid.conf
     inst_hook cmdline 90 "$moddir/parse-iscsiroot.sh"
     inst_hook cleanup 90 "$moddir/cleanup-iscsi.sh"
     inst "$moddir/iscsiroot.sh" "/sbin/iscsiroot"
     inst "$moddir/mount-lun.sh" "/bin/mount-lun.sh"
+
+    mkdir -p ${initdir}/${systemdsystemunitdir}/sockets.target.wants
+    inst_simple "${moddir}/iscsid-initrd.service" "${systemdsystemunitdir}/iscsid.service"
+    inst_simple "${moddir}/iscsid-initrd.socket" "${systemdsystemunitdir}/iscsid.socket"
+    ln -fs ../iscsid.socket "${initdir}/${systemdsystemunitdir}/sockets.target.wants/iscsid.socket"
+    inst_simple "${moddir}/iscsiuio-initrd.service" "${systemdsystemunitdir}/iscsiuio.service"
+    inst_simple "${moddir}/iscsiuio-initrd.socket" "${systemdsystemunitdir}/iscsiuio.socket"
+    ln -fs ../iscsiuio.socket "${initdir}/${systemdsystemunitdir}/sockets.target.wants/iscsiuio.socket"
 }
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [systemd-devel] [RFC] iscsid / systemd / dracut integration effort
       [not found] ` <1355177316-25803-1-git-send-email-cleech-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
                     ` (3 preceding siblings ...)
  2012-12-10 22:08   ` [RFC] dracut iscsi module: early attempt to launch iscsid from the initramfs Chris Leech
@ 2012-12-10 23:56   ` "Jóhann B. Guðmundsson"
       [not found]     ` <50C67697.7020208-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2012-12-14 19:01   ` Mike Christie
  5 siblings, 1 reply; 16+ messages in thread
From: "Jóhann B. Guðmundsson" @ 2012-12-10 23:56 UTC (permalink / raw)
  To: Chris Leech
  Cc: open-iscsi-/JYPxA39Uh5TLH3MbocFFw,
	systemd-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	initramfs-u79uwXL29TY76Z2rM5mHXA, agrover-H+wXaHxf7aLQT0dZR+AlfA

On 12/10/2012 10:08 PM, Chris Leech wrote:
> Sorry about the cross-posting, but I think that in order to get this right I'm
> going to need as much feedback as I can get.
>
> I think I've got this working pretty well now (at least for my iBFT configured
> iSCSI root test case), although the dracut module still needs work.  This is
> based on the iscsid socket activation patch from Tomasz Torcz and the unit
> files from Tomasz and Jóhann B. Guðmundsson.
>
> Attempting to start iscsid using systemd unit files (socket activated or not)
> was impacting my iscsi-root test setup.  Rather than try to preserve the old
> logic that used the _netdev mount flag to determine when iscsid could be safely
> shutdown, I've been working on following the guidelines for root storage
> daemons http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons.
>
> 1) I patched iscsid to set argv[0][0] = '@' if a new --initrd flag is passed on
>     the command line.  It's simple, it works, we don't kill iscsid before the
>     root filesystem is unmounted.
>
> 2) When starting iscsid from the initrd, I then ran into issues of iscsid not
>     functioning properly after the switch_root.  It's not mentioned in the
>     RootStorageDaemons documentation, but if a process left running from the
>     initrd needs further filesystem access at runtime it will need to be able to
>     chroot itself before the switch_root.  I patched iscsid and iscsiadm with a
>     newroot command (using plymouth as an example), and used a dracut clenaup
>     hook to call "iscsiadm --newroot /sysroot".
>
> 3) Related to #2, launching iscsid as a Type=simple service from the initrd
>     (I'm testing this with Fedora 18 beta, where dracut uses systemd in the
>     initrd) results in STDOUT/STDERR access after the switch_root failing with
>     EPIPE.  It seems that the connection to the journal process is dead once the
>     initrd instantiated systemd-journald is replaced with the runtime process.
>
>     I can at least keep iscsid functioning if I run it as Type=forking, but I'm
>     not sure if I'm losing runtime logging or not.  I may be able to do
>     something with the StandardOutput and StandardError options in the service
>     file.

You should be using Type=forking here

>
> 4) None of this helps if the sessions are shutdown when we still need them.
>     Rather than the all-or-nothing _netdev mount option checks that have been
>     used in the past, I'm attempting to use the fact that iscsiadm will skip
>     over session that match a node with startup=onboot set when doing a
>     logoutall.  The iscsi_mark_root_nodes script is borrowed from the SUSE init
>     scripts in the open-iscsi repos written by Hannes Reinecke.  I've made minor
>     changes to export the list of sessions activated in the initramfs, and then
>     mark those as onboot when starting iscsi.service.
>
> Things that still need looking into.
>
> 1) Command line configured iSCSI parameters.  If iscsistart is to be fully
>     removed something needs to setup the node from the command line.  Or
>     iscsistart needs to be able to run alongside iscsid.
>
> 2) Proper ordering of the iscsi.service for non-root filesystems.
>
> Any and all feedback and/or help welcome.
>

Looking the unit file for iscsid I do believe I missed this ( basically 
the same as multipath unit ) since you know it's early boot special, 
root and all that ;)

[Unit]

# Before or After lvm2-activation-early.service
DefaultDependencies=no
Conflicts=shutdown.target

[Install]
WantedBy=sysinit.target

JBG

-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC] iscsi unit files and helper script
       [not found]     ` <1355177316-25803-4-git-send-email-cleech-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2012-12-11 21:47       ` Mike Christie
       [not found]         ` <50C7A9D7.8080900-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Christie @ 2012-12-11 21:47 UTC (permalink / raw)
  To: open-iscsi-/JYPxA39Uh5TLH3MbocFFw
  Cc: Chris Leech, systemd-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	initramfs-u79uwXL29TY76Z2rM5mHXA, agrover-H+wXaHxf7aLQT0dZR+AlfA

Thanks for working on this. Just one question. Is this patch for some
other package? How does it relate to the unit files in Tomasz's
patchset? He unit files with the same name.


On 12/10/2012 04:08 PM, Chris Leech wrote:
> iSCSI service and socket files, and the iscsi_mark_root_nodes helper script to
> preserve sessions started in the initramfs.
> 
> diff -Naur a/iscsid.service b/iscsid.service
> --- a/iscsid.service	1969-12-31 16:00:00.000000000 -0800
> +++ b/iscsid.service	2012-12-10 13:38:38.643307001 -0800
> @@ -0,0 +1,9 @@
> +[Unit]
> +Description=Open-iSCSI
> +Documentation=man:iscsid(8) man:iscsiadm(8)
> +After=network.target NetworkManager-wait-online.service iscsiuio.service tgtd.service targetcli.service
> +
> +[Service]
> +Type=simple
> +ExecStart=/usr/sbin/iscsid -f -n
> +ExecStop=/sbin/iscsiadm -k 0 2
> diff -Naur a/iscsid.socket b/iscsid.socket
> --- a/iscsid.socket	1969-12-31 16:00:00.000000000 -0800
> +++ b/iscsid.socket	2012-12-10 13:38:38.643307001 -0800
> @@ -0,0 +1,9 @@
> +[Unit]
> +Description=Open-iSCSI iscsid Socket
> +Documentation=man:iscsid(8) man:iscsiadm(8)
> +
> +[Socket]
> +ListenStream=@ISCSIADM_ABSTRACT_NAMESPACE
> +
> +[Install]
> +WantedBy=sockets.target
> diff -Naur a/iscsi.service b/iscsi.service
> --- a/iscsi.service	1969-12-31 16:00:00.000000000 -0800
> +++ b/iscsi.service	2012-12-10 13:38:38.643307001 -0800
> @@ -0,0 +1,18 @@
> +[Unit]
> +Description=Login and scanning of iSCSI devices
> +Documentation=man:iscsiadm(8) man:iscsid(8)
> +#Requires=iscsid.service
> +#BindTo=iscsid.service
> +After=network.target NetworkManager-wait-online.service iscsid.service
> +ConditionPathExists=/etc/iscsi/initiatorname.iscsi
> +
> +[Service]
> +Type=oneshot
> +ExecStart=/usr/libexec/iscsi_mark_root_nodes
> +ExecStart=/sbin/iscsiadm -m node --loginall=automatic
> +ExecStop=/bin/sync
> +ExecStop=/sbin/iscsiadm -m node --logoutall=automatic
> +RemainAfterExit=true
> +
> +[Install]
> +WantedBy=remote-fs.target
> diff -Naur a/iscsiuio.service b/iscsiuio.service
> --- a/iscsiuio.service	1969-12-31 16:00:00.000000000 -0800
> +++ b/iscsiuio.service	2012-12-10 13:38:38.643307001 -0800
> @@ -0,0 +1,11 @@
> +[Unit]
> +Description=iSCSI UserSpace I/O driver
> +Documentation=man:iscsiuio(8)
> +Requires=iscsid.service
> +BindTo=iscsid.service
> +Before=iscsid.service
> +After=network.target NetworkManager-wait-online.service
> +
> +[Service]
> +Type=simple
> +ExecStart=/usr/sbin/iscsiuio -f
> diff -Naur a/iscsiuio.socket b/iscsiuio.socket
> --- a/iscsiuio.socket	1969-12-31 16:00:00.000000000 -0800
> +++ b/iscsiuio.socket	2012-12-10 13:38:38.643307001 -0800
> @@ -0,0 +1,9 @@
> +[Unit]
> +Description=Open-iSCSI iscsiuio
> +Documentation=man:iscsiuio(8)
> +
> +[Socket]
> +ListenStream=@ISCSID_UIP_ABSTRACT_NAMESPACE
> +
> +[Install]
> +WantedBy=sockets.target
> diff -Naur a/usr/libexec/iscsi_mark_root_nodes b/usr/libexec/iscsi_mark_root_nodes
> --- a/usr/libexec/iscsi_mark_root_nodes	1969-12-31 16:00:00.000000000 -0800
> +++ b/usr/libexec/iscsi_mark_root_nodes	2012-12-10 13:38:47.322082141 -0800
> @@ -0,0 +1,14 @@
> +#!/bin/bash
> +
> +ISCSIADM=/sbin/iscsiadm
> +SESSION_FILE=/run/initramfs/iscsi.sessions
> +
> +if [ ! -f $SESSION_FILE ] ; then
> +  exit 0
> +fi
> +
> +while read t num i target; do
> +  ip=${i%:*}
> +  $ISCSIADM -m node -p $ip -T $target -o update -n node.startup -v onboot
> +done < $SESSION_FILE
> +
> 

-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC] iscsi unit files and helper script
       [not found]         ` <50C7A9D7.8080900-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>
@ 2012-12-11 22:43           ` Chris Leech
  0 siblings, 0 replies; 16+ messages in thread
From: Chris Leech @ 2012-12-11 22:43 UTC (permalink / raw)
  To: Mike Christie
  Cc: open-iscsi-/JYPxA39Uh5TLH3MbocFFw,
	systemd-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	initramfs-u79uwXL29TY76Z2rM5mHXA, agrover-H+wXaHxf7aLQT0dZR+AlfA

On Tue, Dec 11, 2012 at 03:47:03PM -0600, Mike Christie wrote:
> Thanks for working on this. Just one question. Is this patch for some
> other package? How does it relate to the unit files in Tomasz's
> patchset? He unit files with the same name.

I just diffed against an empty directory to show what I was testing
with, it might have made more sense for this to not be a patch but I was
on a roll.

There's a difference between running as forking or simple here, but
that's not a big deal.  And I've been making changes to my iscsi.service
for automatic starting and stoping of sessions today, getting the
ordering right to not run into problems with automatic mount points.

I haven't run into any problems with the patches I posted, but I'm not
happy with the unit files just yet.

- Chris

> On 12/10/2012 04:08 PM, Chris Leech wrote:
> > iSCSI service and socket files, and the iscsi_mark_root_nodes helper script to
> > preserve sessions started in the initramfs.
> > 
> > diff -Naur a/iscsid.service b/iscsid.service
> > --- a/iscsid.service	1969-12-31 16:00:00.000000000 -0800
> > +++ b/iscsid.service	2012-12-10 13:38:38.643307001 -0800
> > @@ -0,0 +1,9 @@
> > +[Unit]
> > +Description=Open-iSCSI
> > +Documentation=man:iscsid(8) man:iscsiadm(8)
> > +After=network.target NetworkManager-wait-online.service iscsiuio.service tgtd.service targetcli.service
> > +
> > +[Service]
> > +Type=simple
> > +ExecStart=/usr/sbin/iscsid -f -n
> > +ExecStop=/sbin/iscsiadm -k 0 2
> > diff -Naur a/iscsid.socket b/iscsid.socket
> > --- a/iscsid.socket	1969-12-31 16:00:00.000000000 -0800
> > +++ b/iscsid.socket	2012-12-10 13:38:38.643307001 -0800
> > @@ -0,0 +1,9 @@
> > +[Unit]
> > +Description=Open-iSCSI iscsid Socket
> > +Documentation=man:iscsid(8) man:iscsiadm(8)
> > +
> > +[Socket]
> > +ListenStream=@ISCSIADM_ABSTRACT_NAMESPACE
> > +
> > +[Install]
> > +WantedBy=sockets.target
> > diff -Naur a/iscsi.service b/iscsi.service
> > --- a/iscsi.service	1969-12-31 16:00:00.000000000 -0800
> > +++ b/iscsi.service	2012-12-10 13:38:38.643307001 -0800
> > @@ -0,0 +1,18 @@
> > +[Unit]
> > +Description=Login and scanning of iSCSI devices
> > +Documentation=man:iscsiadm(8) man:iscsid(8)
> > +#Requires=iscsid.service
> > +#BindTo=iscsid.service
> > +After=network.target NetworkManager-wait-online.service iscsid.service
> > +ConditionPathExists=/etc/iscsi/initiatorname.iscsi
> > +
> > +[Service]
> > +Type=oneshot
> > +ExecStart=/usr/libexec/iscsi_mark_root_nodes
> > +ExecStart=/sbin/iscsiadm -m node --loginall=automatic
> > +ExecStop=/bin/sync
> > +ExecStop=/sbin/iscsiadm -m node --logoutall=automatic
> > +RemainAfterExit=true
> > +
> > +[Install]
> > +WantedBy=remote-fs.target
> > diff -Naur a/iscsiuio.service b/iscsiuio.service
> > --- a/iscsiuio.service	1969-12-31 16:00:00.000000000 -0800
> > +++ b/iscsiuio.service	2012-12-10 13:38:38.643307001 -0800
> > @@ -0,0 +1,11 @@
> > +[Unit]
> > +Description=iSCSI UserSpace I/O driver
> > +Documentation=man:iscsiuio(8)
> > +Requires=iscsid.service
> > +BindTo=iscsid.service
> > +Before=iscsid.service
> > +After=network.target NetworkManager-wait-online.service
> > +
> > +[Service]
> > +Type=simple
> > +ExecStart=/usr/sbin/iscsiuio -f
> > diff -Naur a/iscsiuio.socket b/iscsiuio.socket
> > --- a/iscsiuio.socket	1969-12-31 16:00:00.000000000 -0800
> > +++ b/iscsiuio.socket	2012-12-10 13:38:38.643307001 -0800
> > @@ -0,0 +1,9 @@
> > +[Unit]
> > +Description=Open-iSCSI iscsiuio
> > +Documentation=man:iscsiuio(8)
> > +
> > +[Socket]
> > +ListenStream=@ISCSID_UIP_ABSTRACT_NAMESPACE
> > +
> > +[Install]
> > +WantedBy=sockets.target
> > diff -Naur a/usr/libexec/iscsi_mark_root_nodes b/usr/libexec/iscsi_mark_root_nodes
> > --- a/usr/libexec/iscsi_mark_root_nodes	1969-12-31 16:00:00.000000000 -0800
> > +++ b/usr/libexec/iscsi_mark_root_nodes	2012-12-10 13:38:47.322082141 -0800
> > @@ -0,0 +1,14 @@
> > +#!/bin/bash
> > +
> > +ISCSIADM=/sbin/iscsiadm
> > +SESSION_FILE=/run/initramfs/iscsi.sessions
> > +
> > +if [ ! -f $SESSION_FILE ] ; then
> > +  exit 0
> > +fi
> > +
> > +while read t num i target; do
> > +  ip=${i%:*}
> > +  $ISCSIADM -m node -p $ip -T $target -o update -n node.startup -v onboot
> > +done < $SESSION_FILE
> > +
> > 
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [systemd-devel] [RFC] iscsid / systemd / dracut integration effort
       [not found]     ` <50C67697.7020208-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2012-12-11 23:26       ` Chris Leech
       [not found]         ` <20121211232646.GC5307-r8IHplWLGbA5tHQWs+pTeqPFFGjUI2lm2LY78lusg7I@public.gmane.org>
  0 siblings, 1 reply; 16+ messages in thread
From: Chris Leech @ 2012-12-11 23:26 UTC (permalink / raw)
  To: "Jóhann B. Guðmundsson"
  Cc: open-iscsi-/JYPxA39Uh5TLH3MbocFFw,
	systemd-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	initramfs-u79uwXL29TY76Z2rM5mHXA, agrover-H+wXaHxf7aLQT0dZR+AlfA

On Mon, Dec 10, 2012 at 11:56:07PM +0000, "Jóhann B. Guðmundsson" wrote:
> On 12/10/2012 10:08 PM, Chris Leech wrote:
> >
> >2) Proper ordering of the iscsi.service for non-root filesystems.
> >
> >Any and all feedback and/or help welcome.
> >
> 
> Looking the unit file for iscsid I do believe I missed this (
> basically the same as multipath unit ) since you know it's early
> boot special, root and all that ;)
> 
> [Unit]
> 
> # Before or After lvm2-activation-early.service
> DefaultDependencies=no
> Conflicts=shutdown.target
> 
> [Install]
> WantedBy=sysinit.target

Thanks, this got me going in the right direction.  These unit files
seems to be working much better for me, with the startup and shutdown
ordering between iscsi, iscsid, and remote-fs mounts sorted out.  I'm
not sure about the tgtd/targetcli stuff, not sure what the original need
there was.

My non-root test install with /home on iSCSI also has a swap partition
on it, and that's still causing me all sorts of trouble if I don't
comment it out in fstab.  Trying to order all this before swap.target
blew up in my face pretty good.

- Chris

--- iscsi.service ---

[Unit]
Description=Login and scanning of iSCSI devices
Documentation=man:iscsiadm(8) man:iscsid(8)
DefaultDependencies=no
Conflicts=shutdown.target
After=systemd-remount-fs.service network.target iscsid.service iscsiuio.service
Before=remote-fs.target
ConditionPathExists=/etc/iscsi/initiatorname.iscsi

[Service]
Type=oneshot
ExecStart=/usr/libexec/iscsi_mark_root_nodes
ExecStart=/sbin/iscsiadm -m node --loginall=automatic
ExecStop=/bin/sync
ExecStop=/sbin/iscsiadm -m node --logoutall=automatic
RemainAfterExit=true

[Install]
WantedBy=sysinit.target

--- iscsid.service ---

[Unit]
Description=Open-iSCSI
Documentation=man:iscsid(8) man:iscsiadm(8)
DefaultDependencies=no
Conflicts=shutdown.target
After=network.target tgtd.service targetcli.service
Before=remote-fs-pre.target

[Service]
Type=simple
ExecStart=/usr/sbin/iscsid -f -n
ExecStop=/sbin/iscsiadm -k 0 2

--- iscsid.socket ---

[Unit]
Description=Open-iSCSI iscsid Socket
Documentation=man:iscsid(8) man:iscsiadm(8)

[Socket]
ListenStream=@ISCSIADM_ABSTRACT_NAMESPACE

[Install]
WantedBy=sockets.target


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [systemd-devel] [RFC] iscsid / systemd / dracut integration effort
       [not found]         ` <20121211232646.GC5307-r8IHplWLGbA5tHQWs+pTeqPFFGjUI2lm2LY78lusg7I@public.gmane.org>
@ 2012-12-12  0:46           ` "Jóhann B. Guðmundsson"
  2012-12-12 20:45           ` Tomasz Torcz
  2013-09-23 17:33           ` The Lee-Man
  2 siblings, 0 replies; 16+ messages in thread
From: "Jóhann B. Guðmundsson" @ 2012-12-12  0:46 UTC (permalink / raw)
  To: Chris Leech, open-iscsi-/JYPxA39Uh5TLH3MbocFFw,
	systemd-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	initramfs-u79uwXL29TY76Z2rM5mHXA, agrover-H+wXaHxf7aLQT0dZR+AlfA

On 12/11/2012 11:26 PM, Chris Leech wrote:
> On Mon, Dec 10, 2012 at 11:56:07PM +0000, "Jóhann B. Gušmundsson" wrote:
>> On 12/10/2012 10:08 PM, Chris Leech wrote:
>>> 2) Proper ordering of the iscsi.service for non-root filesystems.
>>>
>>> Any and all feedback and/or help welcome.
>>>
>> Looking the unit file for iscsid I do believe I missed this (
>> basically the same as multipath unit ) since you know it's early
>> boot special, root and all that ;)
>>
>> [Unit]
>>
>> # Before or After lvm2-activation-early.service
>> DefaultDependencies=no
>> Conflicts=shutdown.target
>>
>> [Install]
>> WantedBy=sysinit.target
> Thanks, this got me going in the right direction.  These unit files
> seems to be working much better for me, with the startup and shutdown
> ordering between iscsi, iscsid, and remote-fs mounts sorted out.  I'm
> not sure about the tgtd/targetcli stuff, not sure what the original need
> there was.

You should remove if it's not necessary for iscsi to function and the 
ordering for iscsi be put in those units instead

>
> My non-root test install with /home on iSCSI also has a swap partition
> on it, and that's still causing me all sorts of trouble if I don't
> comment it out in fstab.

Hmm even if you add noauto after the relevant swap entry in /etc/fstab 
actually it might be necessary for you to create a .swap unit for it.
( man systemd.swap for details )

>    Trying to order all this before swap.target
> blew up in my face pretty good.

You should not order it after the swap.target however you can order 
.swap unit before the swap.target

>
> - Chris
>
> --- iscsi.service ---
>
> [Unit]
> Description=Login and scanning of iSCSI devices
> Documentation=man:iscsiadm(8) man:iscsid(8)
> DefaultDependencies=no
> Conflicts=shutdown.target
> After=systemd-remount-fs.service network.target iscsid.service iscsiuio.service
> Before=remote-fs.target
> ConditionPathExists=/etc/iscsi/initiatorname.iscsi
>
> [Service]
> Type=oneshot
> ExecStart=/usr/libexec/iscsi_mark_root_nodes
> ExecStart=/sbin/iscsiadm -m node --loginall=automatic
> ExecStop=/bin/sync
> ExecStop=/sbin/iscsiadm -m node --logoutall=automatic
> RemainAfterExit=true
>
> [Install]
> WantedBy=sysinit.target
>
> --- iscsid.service ---
>
> [Unit]
> Description=Open-iSCSI
> Documentation=man:iscsid(8) man:iscsiadm(8)
> DefaultDependencies=no
> Conflicts=shutdown.target
> After=network.target tgtd.service targetcli.service
> Before=remote-fs-pre.target
>
> [Service]
> Type=simple
> ExecStart=/usr/sbin/iscsid -f -n
> ExecStop=/sbin/iscsiadm -k 0 2
>
> --- iscsid.socket ---
>
> [Unit]
> Description=Open-iSCSI iscsid Socket
> Documentation=man:iscsid(8) man:iscsiadm(8)
>
> [Socket]
> ListenStream=@ISCSIADM_ABSTRACT_NAMESPACE
>
> [Install]
> WantedBy=sockets.target
>
>

So it seems to be in ready enough to be pushed to rawhide and the next 
step is to boot with "systemd.log_level=debug systemd.log_target=kmsg 
log_buf_len=1M enforcing=0" in the kernel command line to actually see 
why that's blowing up in your face.

One question the iscsid is calling fork() right so why are you so 
incline to use type simple for it?

There is an ordering gotcha when using type simple units which boils to 
systemd has no way of knowing if what it just fired up is finished 
running/setup etc. ( unless notified ) so you might find yourself in a 
race condition.

JBG

-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [systemd-devel] [RFC] iscsid / systemd / dracut integration effort
       [not found]         ` <20121211232646.GC5307-r8IHplWLGbA5tHQWs+pTeqPFFGjUI2lm2LY78lusg7I@public.gmane.org>
  2012-12-12  0:46           ` "Jóhann B. Guðmundsson"
@ 2012-12-12 20:45           ` Tomasz Torcz
       [not found]             ` <20121212204545.GA23313-bmXekecGUa3k6X4NQihNpw@public.gmane.org>
  2013-09-23 17:33           ` The Lee-Man
  2 siblings, 1 reply; 16+ messages in thread
From: Tomasz Torcz @ 2012-12-12 20:45 UTC (permalink / raw)
  To: systemd-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	open-iscsi-/JYPxA39Uh5TLH3MbocFFw
  Cc: Chris Leech, "Jóhann B. Guðmundsson",
	initramfs-u79uwXL29TY76Z2rM5mHXA, agrover-H+wXaHxf7aLQT0dZR+AlfA

On Tue, Dec 11, 2012 at 03:26:46PM -0800, Chris Leech wrote:
> Thanks, this got me going in the right direction.  These unit files
> seems to be working much better for me, with the startup and shutdown
> ordering between iscsi, iscsid, and remote-fs mounts sorted out.  I'm
> not sure about the tgtd/targetcli stuff, not sure what the original need
> there was.

  "After tgtd" was added in Fedora for cases when system accesses targets
exported by the same system. So targets would be configured first, and
only then accessed by iscsid.  "after tgtd" was added, "after targetcli" is natural
expansion of it.

-- 
Tomasz Torcz                 Morality must always be based on practicality.
xmpp: zdzichubg-veJsmC5npURmR6Xm/wNWPw@public.gmane.org                -- Baron Vladimir Harkonnen

-- 
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [systemd-devel] [RFC] iscsid / systemd / dracut integration effort
       [not found]             ` <20121212204545.GA23313-bmXekecGUa3k6X4NQihNpw@public.gmane.org>
@ 2012-12-13  0:45               ` Andy Grover
  0 siblings, 0 replies; 16+ messages in thread
From: Andy Grover @ 2012-12-13  0:45 UTC (permalink / raw)
  To: systemd-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	open-iscsi-/JYPxA39Uh5TLH3MbocFFw, Chris Leech,
	"Jóhann B. Guðmundsson",
	initramfs-u79uwXL29TY76Z2rM5mHXA

On 12/12/2012 12:45 PM, Tomasz Torcz wrote:
> On Tue, Dec 11, 2012 at 03:26:46PM -0800, Chris Leech wrote:
>> Thanks, this got me going in the right direction.  These unit files
>> seems to be working much better for me, with the startup and shutdown
>> ordering between iscsi, iscsid, and remote-fs mounts sorted out.  I'm
>> not sure about the tgtd/targetcli stuff, not sure what the original need
>> there was.
> 
>   "After tgtd" was added in Fedora for cases when system accesses targets
> exported by the same system. So targets would be configured first, and
> only then accessed by iscsid.  "after tgtd" was added, "after targetcli" is natural
> expansion of it.

See, I figured target should come after initiator, so target could
re-export iscsi-initiator-backed block devices :-)

-- Andy

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC] iscsid / systemd / dracut integration effort
       [not found] ` <1355177316-25803-1-git-send-email-cleech-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
                     ` (4 preceding siblings ...)
  2012-12-10 23:56   ` [systemd-devel] [RFC] iscsid / systemd / dracut integration effort "Jóhann B. Guðmundsson"
@ 2012-12-14 19:01   ` Mike Christie
  5 siblings, 0 replies; 16+ messages in thread
From: Mike Christie @ 2012-12-14 19:01 UTC (permalink / raw)
  To: open-iscsi-/JYPxA39Uh5TLH3MbocFFw
  Cc: Chris Leech, systemd-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	initramfs-u79uwXL29TY76Z2rM5mHXA, agrover-H+wXaHxf7aLQT0dZR+AlfA

On 12/10/2012 04:08 PM, Chris Leech wrote:
> Sorry about the cross-posting, but I think that in order to get this right I'm
> going to need as much feedback as I can get.
> 
> I think I've got this working pretty well now (at least for my iBFT configured
> iSCSI root test case), although the dracut module still needs work.  This is
> based on the iscsid socket activation patch from Tomasz Torcz and the unit
> files from Tomasz and Jóhann B. Guðmundsson.
> 
> Attempting to start iscsid using systemd unit files (socket activated or not)
> was impacting my iscsi-root test setup.  Rather than try to preserve the old
> logic that used the _netdev mount flag to determine when iscsid could be safely
> shutdown, I've been working on following the guidelines for root storage
> daemons http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons.
> 
> 1) I patched iscsid to set argv[0][0] = '@' if a new --initrd flag is passed on
>    the command line.  It's simple, it works, we don't kill iscsid before the
>    root filesystem is unmounted.
> 
> 2) When starting iscsid from the initrd, I then ran into issues of iscsid not
>    functioning properly after the switch_root.  It's not mentioned in the
>    RootStorageDaemons documentation, but if a process left running from the
>    initrd needs further filesystem access at runtime it will need to be able to
>    chroot itself before the switch_root.  I patched iscsid and iscsiadm with a
>    newroot command (using plymouth as an example), and used a dracut clenaup
>    hook to call "iscsiadm --newroot /sysroot".
> 
> 3) Related to #2, launching iscsid as a Type=simple service from the initrd
>    (I'm testing this with Fedora 18 beta, where dracut uses systemd in the
>    initrd) results in STDOUT/STDERR access after the switch_root failing with
>    EPIPE.  It seems that the connection to the journal process is dead once the
>    initrd instantiated systemd-journald is replaced with the runtime process.
> 
>    I can at least keep iscsid functioning if I run it as Type=forking, but I'm
>    not sure if I'm losing runtime logging or not.  I may be able to do
>    something with the StandardOutput and StandardError options in the service
>    file.
> 
> 4) None of this helps if the sessions are shutdown when we still need them.
>    Rather than the all-or-nothing _netdev mount option checks that have been
>    used in the past, I'm attempting to use the fact that iscsiadm will skip
>    over session that match a node with startup=onboot set when doing a
>    logoutall.  The iscsi_mark_root_nodes script is borrowed from the SUSE init
>    scripts in the open-iscsi repos written by Hannes Reinecke.  I've made minor
>    changes to export the list of sessions activated in the initramfs, and then
>    mark those as onboot when starting iscsi.service.
> 
> Things that still need looking into.
> 
> 1) Command line configured iSCSI parameters.  If iscsistart is to be fully
>    removed something needs to setup the node from the command line.  Or
>    iscsistart needs to be able to run alongside iscsid.
> 

The iscsi tools changes look ok to me. For 1), in this type of setup we
are always only doing

iscsiadm -m fw -l

(saw that in the iscsiroot.sh part of patch).

If so, then just modify to take params. I think you could just take
parse_param/apply_params from iscsistart and use them.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [systemd-devel] [RFC] iscsid / systemd / dracut integration effort
       [not found]         ` <20121211232646.GC5307-r8IHplWLGbA5tHQWs+pTeqPFFGjUI2lm2LY78lusg7I@public.gmane.org>
  2012-12-12  0:46           ` "Jóhann B. Guðmundsson"
  2012-12-12 20:45           ` Tomasz Torcz
@ 2013-09-23 17:33           ` The Lee-Man
       [not found]             ` <b993ef26-ea4e-4dbe-8d9a-d86ad50c9fbc-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2013-10-01  2:24             ` Lennart Poettering
  2 siblings, 2 replies; 16+ messages in thread
From: The Lee-Man @ 2013-09-23 17:33 UTC (permalink / raw)
  To: open-iscsi-/JYPxA39Uh5TLH3MbocFFw
  Cc: Jóhann B. Guðmundsson,
	systemd-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	initramfs-u79uwXL29TY76Z2rM5mHXA, agrover-H+wXaHxf7aLQT0dZR+AlfA,
	cleech-H+wXaHxf7aLQT0dZR+AlfA

[-- Attachment #1: Type: text/plain, Size: 2949 bytes --]


On Tuesday, December 11, 2012 3:26:46 PM UTC-8, Chris Leech wrote:
>
> ...
>
> Thanks, this got me going in the right direction.  These unit files 
> seems to be working much better for me, with the startup and shutdown 
> ordering between iscsi, iscsid, and remote-fs mounts sorted out.  I'm 
> not sure about the tgtd/targetcli stuff, not sure what the original need 
> there was. 
>
>
>
I just wanted to post a thank you for all of this work, as I was attempting 
to do some of it myself and making slow progress.

I am trying to get open-iscsi version 2.0-873-suse working on openSUSE.

In my case open-iscsi-based boot is not working and has not been working 
for a while. In addition, we have an initrd-based boot, and it looks like 
that will have to change before iscsid-based booting can work correctly. 
Because of that, I did not try to get iscsi-root volumes working. My goal 
was to get normal non-root open-iscsi working with systemd as well as it 
had with SysV-based init (or better).

Toward that end, I have 3 unit files that are working on openSUSE 12.3 that 
I thought I would share. I am not submitting these as patches, since the 
whole systemd-integration effort is still in flux.

Using the systemd configuration below, iscsid is not started until needed. 
NOTE: I think we need a new mode in iscsid that goes away when it's work is 
done, since it can now be socket-activated (i.e. it doesn't have to sit 
there and wait for work).


Submitted for your comments:


iscsid.socket:
==========
Unit]
Description=Open-iSCSI iscsid Socket
Documentation=man:iscsid(8) man:iscsiadm(8)

[Socket]
ListenStream=@ISCSIADM_ABSTRACT_NAMESPACE

[Install]
WantedBy=sockets.target



iscsid.service:
===========
[Unit]
Description=Open-iSCSI
Documentation=man:iscsid(8) man:iscsiadm(8)
After=network.target NetworkManager-wait-online.service tgtd.service 
targetcli.service

[Service]
Type=forking
PIDFile=/var/run/iscsid.pid
ExecStart=/sbin/iscsid

[Install]
WantedBy=multi-user.target



iscsi.service:
==========
[Unit]
Description=Login and scanning of iSCSI devices
Documentation=man:iscsiadm(8) man:iscsid(8)
After=network.target NetworkManager-wait-online.service iscsid.service
ConditionPathExists=/etc/iscsi/initiatorname.iscsi

[Service]
Type=oneshot
ExecStart=/sbin/iscsiadm -m node --loginall=automatic
ExecStop=/bin/sync
ExecStop=/sbin/iscsiadm -m session --logout
SuccessExitStatus=21
RemainAfterExit=true

[Install]
WantedBy=remote-fs.target

-- 
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
Visit this group at http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.

[-- Attachment #2: Type: text/html, Size: 3497 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [systemd-devel] [RFC] iscsid / systemd / dracut integration effort
       [not found]             ` <b993ef26-ea4e-4dbe-8d9a-d86ad50c9fbc-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2013-09-23 17:40               ` The Lee-Man
  0 siblings, 0 replies; 16+ messages in thread
From: The Lee-Man @ 2013-09-23 17:40 UTC (permalink / raw)
  To: open-iscsi-/JYPxA39Uh5TLH3MbocFFw
  Cc: Jóhann B. Guðmundsson,
	systemd-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	initramfs-u79uwXL29TY76Z2rM5mHXA, agrover-H+wXaHxf7aLQT0dZR+AlfA,
	cleech-H+wXaHxf7aLQT0dZR+AlfA

[-- Attachment #1: Type: text/plain, Size: 812 bytes --]

On Monday, September 23, 2013 10:33:36 AM UTC-7, The Lee-Man wrote:
>
> ...
> I just wanted to post a thank you for all of this work, as I was 
> attempting to do some of it myself and making slow progress.
>
> ...
>


Wanted to mention I also had to port back a couple of systemd-support 
patches for iscsid scoket use, as well.

-- 
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
Visit this group at http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.

[-- Attachment #2: Type: text/html, Size: 1187 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC] iscsid / systemd / dracut integration effort
  2013-09-23 17:33           ` The Lee-Man
       [not found]             ` <b993ef26-ea4e-4dbe-8d9a-d86ad50c9fbc-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2013-10-01  2:24             ` Lennart Poettering
  1 sibling, 0 replies; 16+ messages in thread
From: Lennart Poettering @ 2013-10-01  2:24 UTC (permalink / raw)
  To: The Lee-Man; +Cc: initramfs, agrover, open-iscsi, systemd-devel

On Mon, 23.09.13 10:33, The Lee-Man (leeman.duncan@gmail.com) wrote:

> After=network.target NetworkManager-wait-online.service tgtd.service 
> targetcli.service

Please use network-online.target here instead of
NetworkManager-wait-online.service.

Please see the discussion of this unit on:

http://www.freedesktop.org/software/systemd/man/systemd.special.html

That said, this service makes local block devices available over the
network, right, and it doesn't want to connect to anything on the
network, or does it? If so, I really don't see the need for pulling in
network-online.target/NetworkManager-wait-online.service here at all. 



> iscsi.service:
> ==========

> After=network.target NetworkManager-wait-online.service iscsid.service

This one on the other hand actually wants network connectivity around,
right, since it tries to connect to other hosts? For this one using
network-online.target sounds appropriate.

> ConditionPathExists=/etc/iscsi/initiatorname.iscsi
> 
> [Service]
> Type=oneshot
> ExecStart=/sbin/iscsiadm -m node --loginall=automatic
> ExecStop=/bin/sync

Wut?? Is this really necessary? If this is really necessary (which I
doubt, appears to be snake oil to me...), then why doesn't iscsiadm do
this internally?

Lennart

-- 
Lennart Poettering - Red Hat, Inc.

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2013-10-01  2:24 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-10 22:08 [RFC] iscsid / systemd / dracut integration effort Chris Leech
     [not found] ` <1355177316-25803-1-git-send-email-cleech-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-12-10 22:08   ` [RFC] iscsid: add --initrd option to set run from initrd hint for systemd Chris Leech
2012-12-10 22:08   ` [RFC] iscsiadm, iscsid: newroot command to survive switch_root Chris Leech
2012-12-10 22:08   ` [RFC] iscsi unit files and helper script Chris Leech
     [not found]     ` <1355177316-25803-4-git-send-email-cleech-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-12-11 21:47       ` Mike Christie
     [not found]         ` <50C7A9D7.8080900-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>
2012-12-11 22:43           ` Chris Leech
2012-12-10 22:08   ` [RFC] dracut iscsi module: early attempt to launch iscsid from the initramfs Chris Leech
2012-12-10 23:56   ` [systemd-devel] [RFC] iscsid / systemd / dracut integration effort "Jóhann B. Guðmundsson"
     [not found]     ` <50C67697.7020208-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-12-11 23:26       ` Chris Leech
     [not found]         ` <20121211232646.GC5307-r8IHplWLGbA5tHQWs+pTeqPFFGjUI2lm2LY78lusg7I@public.gmane.org>
2012-12-12  0:46           ` "Jóhann B. Guðmundsson"
2012-12-12 20:45           ` Tomasz Torcz
     [not found]             ` <20121212204545.GA23313-bmXekecGUa3k6X4NQihNpw@public.gmane.org>
2012-12-13  0:45               ` Andy Grover
2013-09-23 17:33           ` The Lee-Man
     [not found]             ` <b993ef26-ea4e-4dbe-8d9a-d86ad50c9fbc-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2013-09-23 17:40               ` The Lee-Man
2013-10-01  2:24             ` Lennart Poettering
2012-12-14 19:01   ` Mike Christie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.