iscsid / systemd / dracut integration effort
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
A message that is not in the archive (sent off-list or not yet received): 1355177316-25803-1-git-send-email-cleech-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
RFC 1/1 iscsid: add --initrd option to set run from initrd hint for systemd
See http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons
--- usr/iscsid.c | 8 ++++++++ 1 file changed, 8 insertions(+)
usr/iscsid.c +8 -0
@@ -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 );
Signature · 1 line
1.7.11.7
RFC 1/1 iscsiadm, iscsid: newroot command to survive switch_root
In reply to a message not in the archiveWhen 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(-)
usr/iscsiadm.c +29 -1
@@ -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 (¶ms);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 );
usr/mgmt_ipc.c +11 -0
@@ -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)
usr/mgmt_ipc.h +5 -1
@@ -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;
Signature · 1 line
1.7.11.7
RFC 1/1 iscsi unit files and helper script
In reply to a message not in the archiveiSCSI service and socket files, and the iscsi_mark_root_nodes helper script to preserve sessions started in the initramfs.
iscsid.service +9 -0
@@ -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
iscsid.socket +9 -0
@@ -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
iscsi.service +18 -0
@@ -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
iscsiuio.service +11 -0
@@ -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
iscsiuio.socket +9 -0
@@ -0,0 +1,9 @@ +[Unit] +Description=Open-iSCSI iscsiuio +Documentation=man:iscsiuio(8) + +[Socket] +ListenStream=@ISCSID_UIP_ABSTRACT_NAMESPACE + +[Install] +WantedBy=sockets.target
usr/libexec/iscsi_mark_root_nodes +14 -0
@@ -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 +
A message that is not in the archive (sent off-list or not yet received): 1355177316-25803-4-git-send-email-cleech-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Re: [RFC] iscsi unit files and helper script
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.
Quoted 98 lines · Chris Leech
iSCSI service and socket files, and the
iscsi_mark_root_nodeshelper script to preserve sessions started in the initramfs.diff -Naur a/iscsid.service b/iscsid.service
iscsid.service +9
-0@@ -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 2diff -Naur a/iscsid.socket b/iscsid.socket
iscsid.socket +9
-0@@ -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.targetdiff -Naur a/iscsi.service b/iscsi.service
iscsi.service +18
-0@@ -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.targetdiff -Naur a/iscsiuio.service b/iscsiuio.service
iscsiuio.service +11
-0@@ -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 -fdiff -Naur a/iscsiuio.socket b/iscsiuio.socket
iscsiuio.socket +9
-0@@ -0,0 +1,9 @@ +[Unit] +Description=Open-iSCSI iscsiuio +Documentation=man:iscsiuio(8) + +[Socket] +ListenStream=@ISCSID_UIP_ABSTRACT_NAMESPACE + +[Install] +WantedBy=sockets.targetdiff -Naur a/usr/libexec/iscsi_mark_root_nodes b/usr/libexec/iscsi_mark_root_nodes
usr/libexec/iscsi_mark_root_nodes +14
-0@@ -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 +
Signature · 4 lines
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/[email protected] To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [RFC] iscsi unit files and helper script
Quoted 3 lines · Mike Christie
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
Quoted 100 lines · Chris Leech
Quoted 98 lines
iSCSI service and socket files, and the
iscsi_mark_root_nodeshelper script to preserve sessions started in the initramfs.diff -Naur a/iscsid.service b/iscsid.service
iscsid.service +9
-0@@ -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 2diff -Naur a/iscsid.socket b/iscsid.socket
iscsid.socket +9
-0@@ -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.targetdiff -Naur a/iscsi.service b/iscsi.service
iscsi.service +18
-0@@ -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.targetdiff -Naur a/iscsiuio.service b/iscsiuio.service
iscsiuio.service +11
-0@@ -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 -fdiff -Naur a/iscsiuio.socket b/iscsiuio.socket
iscsiuio.socket +9
-0@@ -0,0 +1,9 @@ +[Unit] +Description=Open-iSCSI iscsiuio +Documentation=man:iscsiuio(8) + +[Socket] +ListenStream=@ISCSID_UIP_ABSTRACT_NAMESPACE + +[Install] +WantedBy=sockets.targetdiff -Naur a/usr/libexec/iscsi_mark_root_nodes b/usr/libexec/iscsi_mark_root_nodes
usr/libexec/iscsi_mark_root_nodes +14
-0@@ -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 +
RFC 1/1 dracut iscsi module: early attempt to launch iscsid from the initramfs
In reply to a message not in the archiveNot 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
modules.d/95iscsi/cleanup-iscsi.sh +2 -1
@@ -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
modules.d/95iscsi/iscsid-initrd.service new file +10 -0
@@ -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
modules.d/95iscsi/iscsid-initrd.socket new file +9 -0
@@ -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
modules.d/95iscsi/iscsiroot.sh +14 -12
@@ -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
modules.d/95iscsi/iscsiuio-initrd.service new file +11 -0
@@ -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
modules.d/95iscsi/iscsiuio-initrd.socket new file +9 -0
@@ -0,0 +1,9 @@ +[Unit] +Description=Open-iSCSI iscsiuio +Documentation=man:iscsiuio(8) + +[Socket] +ListenStream=@ISCSID_UIP_ABSTRACT_NAMESPACE + +[Install] +WantedBy=sockets.target
modules.d/95iscsi/module-setup.sh +12 -2
@@ -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" }
Signature · 1 line
1.7.11.7
Quoted 32 lines · 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
_netdevmount 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 theswitch_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_rootfailing 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.
Quoted 4 lines
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
Quoted 12 lines
4) None of this helps if the sessions are shutdown when we still need them. Rather than the all-or-nothing
_netdevmount 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. Theiscsi_mark_root_nodesscript 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.
Quoted 8 lines
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
Signature · 4 lines
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/[email protected] To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Jóhann B. Guðmundsson
Quoted 5 lines · Chris Leech
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 ;)
Quoted 8 lines
[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
A message that is not in the archive (sent off-list or not yet received): 20121211232646.GC5307-r8IHplWLGbA5tHQWs+pTeqPFFGjUI2lm2LY78lusg7I@public.gmane.org
Quoted 16 lines · Chris Leech
Quoted 15 lines · Jóhann B. Gušmundsson
Quoted 4 lines · Chris Leech
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
Quoted 7 lines
Quoted 2 lines
[Install]
WantedBy=sysinit.targetThanks, 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
Quoted 4 lines
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 )
Quoted 2 lines
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
Quoted 46 lines
- 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)
Quoted 7 lines
[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
Signature · 4 lines
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/[email protected] To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.
Quoted 5 lines · Chris Leech
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.
Signature · 8 lines
Tomasz Torcz Morality must always be based on practicality. xmpp: zdzichubg-veJsmC5npURmR6Xm/[email protected] -- 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/[email protected] To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Tomasz Torcz
Quoted 5 lines · Chris Leech
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
Quoted 11 lines · Chris Leech
...
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
Signature · 5 lines
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/[email protected] To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/[email protected] Visit this group at http://groups.google.com/group/open-iscsi. For more options, visit https://groups.google.com/groups/opt_out.
A message that is not in the archive (sent off-list or not yet received): b993ef26-ea4e-4dbe-8d9a-d86ad50c9fbc-/[email protected]
Quoted 7 lines · The Lee-Man
...
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.
Signature · 5 lines
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/[email protected] To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/[email protected] Visit this group at http://groups.google.com/group/open-iscsi. For more options, visit https://groups.google.com/groups/opt_out.
Quoted 2 lines · The Lee-Man
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.
Quoted 4 lines
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.
Quoted 6 lines
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
Signature · 1 line
Lennart Poettering - Red Hat, Inc.
Quoted 46 lines · 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
_netdevmount 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 theswitch_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_rootfailing 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
_netdevmount 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. Theiscsi_mark_root_nodesscript 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.
Quoted 6 lines
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.