From owner-freebsd-current@FreeBSD.ORG Fri Jun 8 10:30:48 2007 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8E7A416A41F; Fri, 8 Jun 2007 10:30:48 +0000 (UTC) (envelope-from danny@cs.huji.ac.il) Received: from cs1.cs.huji.ac.il (cs1.cs.huji.ac.il [132.65.16.10]) by mx1.freebsd.org (Postfix) with ESMTP id 1B13213C458; Fri, 8 Jun 2007 10:30:47 +0000 (UTC) (envelope-from danny@cs.huji.ac.il) Received: from pampa.cs.huji.ac.il ([132.65.80.32]) by cs1.cs.huji.ac.il with esmtp id 1Hwbjx-0001gJ-KV; Fri, 08 Jun 2007 13:30:45 +0300 X-Mailer: exmh version 2.7.2 01/07/2005 with nmh-1.2 To: John Nielsen In-reply-to: <20070606122953.mnndzgmvkcc0s8c8@newwebmail.jnielsen.net> References: <20070606122953.mnndzgmvkcc0s8c8@newwebmail.jnielsen.net> Comments: In-reply-to John Nielsen message dated "Wed, 06 Jun 2007 12:29:53 -0400." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 08 Jun 2007 13:30:45 +0300 From: Danny Braniss Message-ID: Cc: freebsd-current@freebsd.org, freebsd-stable@freebsd.org Subject: Re: iSCSI initiator tester wanted X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jun 2007 10:30:48 -0000 > 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 :-)