Date: Fri, 08 Jun 2007 13:30:45 +0300 From: Danny Braniss <danny@cs.huji.ac.il> To: John Nielsen <lists@jnielsen.net> Cc: freebsd-current@freebsd.org, freebsd-stable@freebsd.org Subject: Re: iSCSI initiator tester wanted Message-ID: <E1Hwbjx-0001gJ-KV@cs1.cs.huji.ac.il> In-Reply-To: <20070606122953.mnndzgmvkcc0s8c8@newwebmail.jnielsen.net> References: <E1Hvx04-000HXt-Iv@cs1.cs.huji.ac.il> <20070606122953.mnndzgmvkcc0s8c8@newwebmail.jnielsen.net>
next in thread | previous in thread | raw e-mail | index | archive | help
> A couple comments just from reading through this, see below. > > > #!/bin/sh > > > > # PROVIDE: iscsi > > # REQUIRE: NETWORKING > > # BEFORE: DAEMON > > # KEYWORD: nojail shutdown > > > > # > > # Add the following lines to /etc/rc.conf to enable iscsi: > > # > > # iscsi_enable="YES" > > # iscsi_fstab="/etc/fstab.iscsi" > > The iscsi_exports knob should also be documented here. agreed > > > . /etc/rc.subr > > > > name=iscsi > > rcvar=`set_rcvar` > > > > command=/usr/local/sbin/iscontrol > > Assuming this gets commited this will want to be /sbin/iscontrol. > absolutely > > iscsi_enable=${iscsi_enable:-"NO"} > > iscsi_fstab=${iscsi_fstab:-"/etc/fstab.iscsi"} > > iscsi_exports=${iscsi_exports:-"/etc/exports.iscsi"} > > > > start_cmd="iscsi_start" > > faststop_cmp="iscsi_stop" > > stop_cmd="iscsi_stop" > > > > iscsi_wait() > > { > > dev=$1 > > trap "echo 'wait loop cancelled'; exit 1" 2 > > count=0 > > while true; do > > if [ -c $dev ]; then > > break; > > fi > > if [ $count -eq 0 ]; then > > echo -n Waiting for ${dev}': ' > > fi > > count=$((${count} + 1)) > > if [ $count -eq 6 ]; then > > echo ' Failed' > > return 0 > > break > > fi > > echo -n '.' > > sleep 5; > > done > > echo '.' > > return 1 > > } > > > > iscsi_start() > > { > > # > > # load needed modules > > for m in iscsi_initiator geom_label; do > > kldstat -qm $m || kldload $m > > done > > Good thinking making geom_label a pseudo-requirement. Examples and > documentation for fstab.iscsi should strongly recommend its use, since > device names will vary. > > > sysctl debug.iscsi=2 > > Maybe make this another rc variable that could be set in /etc/rc.conf. > You'll probably also want to change the module's default verbosity > level once it becomes more official. it will be zero by default, and no reason to clobber rc.conf. > > > # > > # start iscontrol for each target > > if [ -n "${iscsi_targets}" ]; then > > for target in ${iscsi_targets}; do > > ${command} ${rc_flags} -n ${target} > > done > > fi > > > > if [ -f "${iscsi_fstab}" ]; then > > while read spec file type opt t1 t2 > > do > > case ${spec} in > > \#*|'') > > ;; > > *) > > if iscsi_wait ${spec}; then > > break; > > fi > > echo type=$type spec=$spec file=$file > > fsck -p ${spec} && mount ${spec} ${file} > > ;; > > esac > > done < ${iscsi_fstab} > > fi > > > > if [ -f "${iscsi_exports}" ]; then > > cat ${iscsi_exports} >> /etc/exports > > #/etc/rc.d/mountd reload does not work, why? > > kill -1 `cat /var/run/mountd.pid` > > fi > > } > > Look at how Pawel handled this with ZFS (mostly in the zfs and mountd > rc.d scripts), and use the fact that mountd can take multiple exports > files on its command line to your advantage. i.e. appending to the > normal exports file is not really what you want to do. I like the idea of keeping things from spreading around, and maybe /etc/rc.d/mountd can be taught to use all exportfs.something files might be an idea, specially since sometimes one has to '/etc/rc.d/mountd reload' - i miss 'exportfs -a' :-) > > > iscsi_stop() > > { > > echo 'iscsi stopping' > > while read spec file type opt t1 t2 > > do > > case ${spec} in > > \#*|'') > > ;; > > *) > > echo iscsi: umount $spec > > umount -fv $spec > > # and remove from the exports ... > > See above; this could be a no-op. > > > ;; > > esac > > done < ${iscsi_fstab} > > } > > > > load_rc_config $name > > run_rc_command "$1" > > ------ > > problems with the above script: > > - no background fsck > > It would be nice not to re-invent the wheel here, and there are other > reasons it would be nice to just use /etc/fstab instead of adding a new > file -- a number of utilities use /etc/fstab to map between mountpoints > and device names even if the device isn't mounted. Did you try this > approach, and if so what obstacles did you encounter? I will play > around with this if I have time. The "late" fstab/mount option will > probably be useful here. it all boils down to my not-liking-to-spread-out syndrome, rc.conf should have all that is needed to configure a host, but alas, that is a too minimalistic approach, since there are also config files. well, some of the solutions take into concideration my local environment, most of the servers and workstations are 'dataless', they share many files, and via DHCP/rc.conf and some other magic, it all works. Except for 'small' changes in cofiguration files, ie: most of the hosts have serial console enabled, but a few problematic ones don't. [easy solution: a script that changes off/on accroding to some rc.conf tunable). most have a common fstab (cdrom, proc, linproc0, but different disks (da,ad,etc). so it would be nice to be able to keep the common stuff (DEFAULT) and the merge the diffs. and i don't want to go the XML road, nor any other heavy handed solution. ok, enough ramblings for a bussy morning. chears, danny PS: and sorry to polute/cross-post, and yes some of this should have gone to rc@freebsd, too late :-)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1Hwbjx-0001gJ-KV>